353 lines
19 KiB
Plaintext
353 lines
19 KiB
Plaintext
*** Settings ***
|
|
Resource ElementPath.robot
|
|
Library SSHLibrary
|
|
Resource ../RE0_Common/KeyWord.robot
|
|
Library DatabaseLibrary
|
|
Library Selenium2Library
|
|
Library String
|
|
Library DateTime
|
|
|
|
*** Keywords ***
|
|
创建数据表
|
|
[Arguments] ${PostSql_DB} ${PostSql_DB_User} ${PostSql_DB_Pwd_lin} ${PostSql_DB_IP_lin} ${PostSql_DB_Port}
|
|
Connect to Database Using Custom params psycopg2 database="${PostSql_DB}",user="${PostSql_DB_User}",password="${PostSql_DB_Pwd_lin}",host="${PostSql_DB_IP_lin}",port="${PostSql_DB_Port}"
|
|
Sleep 2s
|
|
Execute Sql String drop table if exists autotest;
|
|
Execute Sql String create table autotest(id int);
|
|
Execute Sql String insert into autotest values(2021);
|
|
Execute Sql String insert into autotest values(2022);
|
|
Execute Sql String insert into autotest values(2023);
|
|
${query_result} Query Select * from autotest;
|
|
Log 建表成功,数据为${query_result}
|
|
Disconnect From Database
|
|
Set Suite Variable ${query_result}
|
|
|
|
删除数据表
|
|
[Arguments] ${PostSql_DB} ${PostSql_DB_User} ${PostSql_DB_Pwd_lin} ${PostSql_DB_IP_lin} ${PostSql_DB_Port}
|
|
Connect to Database Using Custom params psycopg2 database="${PostSql_DB}",user="${PostSql_DB_User}",password="${PostSql_DB_Pwd_lin}",host="${PostSql_DB_IP_lin}",port="${PostSql_DB_Port}"
|
|
Execute Sql String drop table autotest;
|
|
Disconnect From Database
|
|
Log 删除表成功
|
|
|
|
校验数据表
|
|
[Arguments] ${PostSql_DB} ${PostSql_DB_User} ${PostSql_DB_Pwd_lin} ${PostSql_DB_IP_lin} ${PostSql_DB_Port}
|
|
Connect to Database Using Custom params psycopg2 database="${PostSql_DB}",user="${PostSql_DB_User}",password="${PostSql_DB_Pwd_lin}",host="${PostSql_DB_IP_lin}",port="${PostSql_DB_Port}"
|
|
${query_result_check} Query Select id from autotest;
|
|
Should Contain "${query_result_check}" "${query_result}"
|
|
Log 数据库校验成功
|
|
Disconnect From Database
|
|
|
|
插入数据
|
|
[Arguments] ${PostSql_DB} ${PostSql_DB_User} ${PostSql_DB_Pwd_lin} ${PostSql_DB_IP_lin} ${PostSql_DB_Port}
|
|
Connect to Database Using Custom params psycopg2 database="${PostSql_DB}",user="${PostSql_DB_User}",password="${PostSql_DB_Pwd_lin}",host="${PostSql_DB_IP_lin}",port="${PostSql_DB_Port}"
|
|
Sleep 2s
|
|
Execute Sql String insert into autotest select * from autotest;
|
|
${query_result} Query Select * from autotest;
|
|
Log 表数据为${query_result}
|
|
Disconnect From Database
|
|
Set Suite Variable ${query_result}
|
|
|
|
Postgresql备份
|
|
[Arguments] ${Postgresql_Agent} ${Username} ${Password} ${DB_Name} ${Backup_Scheme} ${bk_type} ${mds_name} ${dedup_attr} ${encryption_attr} ${compress_attr} ${cache} #代理|#用户名|#密码|#数据库名称|#备份方案|#备份方式|#介质名称|#重删|#加密|#压缩|#缓存
|
|
元素点击 ${Timed_DataProtect} 点击进入定时数据保护页面 定位定时数据保护失败
|
|
${date} Evaluate time.strftime('%Y%m%d%H%M%S',time.localtime()) time
|
|
${random_strategyName}= Catenate SEPARATOR=_ ${bk_type} ${date}
|
|
${createpolicy} Catenate SEPARATOR= 新建了策略[ ${random_strategyName} ]
|
|
Set Suite Variable ${random_strategyName}
|
|
Set Suite Variable ${createpolicy}
|
|
Sleep 5s
|
|
元素点击 xpath=//span[text()="${Postgresql_Agent}"] 点击选择代理 定位代理所在位置失败
|
|
元素点击 ${BackupSet} 点击进入备份集页面 定位备份集按钮失败
|
|
元素点击 ${dpm_Protection strategy} 点击进入保护策略页面 定位保护策略按钮失败
|
|
元素点击 ${Add_Policy} 点击添加策略按钮 定位添加策略按钮失败
|
|
元素点击 ${Postgresql_Module} 点击选择Postgresql数据库 定位数据库模块失败
|
|
元素输入 ${Set_PolicyName} ${random_strategyName} 定位策略名输入框失败
|
|
Run Keyword IF ${Backup_Scheme}==1 物理备份
|
|
... ELSE IF ${Backup_Scheme}==0 逻辑备份
|
|
... ELSE 物理流式备份
|
|
元素输入 ${Postgresql_Username} ${Username} 定位数据库用户名输入框失败
|
|
元素输入 ${Postgresql_PWD} ${Password} 定位数据库密码输入框失败
|
|
元素点击 ${PG_Advanced_Setup} 点击切换到高级设置 定位高级设置失败
|
|
Run Keyword IF ${Backup_Scheme}==1 or ${Backup_Scheme}==2 高级设置_物理备份
|
|
... ELSE IF ${Backup_Scheme}==0 元素输入 ${PG_UpdatePath} /home/postgres/pgsql/bin 定位安装路径输入框失败
|
|
sleep 10s
|
|
元素点击 ${Connection credentials_Next} 点击下一步进入目标数据库选择页面 定位下一步按钮失败
|
|
元素点击 xpath=//div[@id="addPolicyPostgresqlTree"]//span[contains(text(),"${DB_Name}")]/../../td[2]/div 点击勾选需要备份数据库 定位需要备份的数据库失败
|
|
元素点击 ${Target_database_Next_Postgres} 点击下一步进入任务周期选项 定位任务周期选项失败
|
|
元素点击 ${Add_taskcycle} 添加任务周期 定位添加任务周期失败
|
|
Run Keyword IF "${bk_type}"=="完全" 完全备份
|
|
... ELSE IF "${bk_type}"=="增量" 增量备份
|
|
Comment 元素点击 ${Add_taskcycle} 点击添加任务周期 定位添加任务周期按钮失败
|
|
元素点击 ${Cycle_Once} 设置任务仅执行一次 定位仅执行一次失败
|
|
元素点击 ${Cycle_Confirm} 确定任务周期设置完毕 定位任务周期设置失败
|
|
元素点击 ${Cycle_NextStep} 点击下一步进入备份集存储设置界面 定位下一步失败
|
|
元素点击 ${Manual_ChooseMDS} 点击勾选手动选择介质 定位选择介质失败
|
|
元素点击 ${Select_MDS_DM} 点击介质选择按钮 定位介质选择按钮失败
|
|
元素点击 xpath=//select[@id="dialogues_addCycleStorage_storagePath_selectMedia_selectedMdsIP_select"]/option[@label="${mds_name}"] 点击选择指定介质 定位指定介质失败
|
|
Run Keyword If ${dedup_attr}==1 重删
|
|
... ELSE log 不勾选重删
|
|
元素点击 ${Storage_NextStep} 点击下一步进入到备份高级选项 定位下一步失败
|
|
log 进入备份高级选项
|
|
Run Keyword If ${encryption_attr}==1 加密
|
|
... ELSE log 不勾选加密
|
|
Run Keyword If ${compress_attr}==1 压缩
|
|
... ELSE log 不勾选压缩
|
|
Run Keyword If ${cache}==1 备份缓存 /opt
|
|
... ELSE IF ${cache}==0 取消缓存
|
|
元素点击 ${PG_Complete_CreatePolicy} 点击确定按钮完成策略创建 定位确定按钮失败
|
|
元素点击 ${Success_Confirm} 确定策略创建成功 策略创建失败
|
|
元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
|
|
Sleep 5s
|
|
元素输入 ${Input_Policy_Name} ${random_strategyName} 定位策略名搜索框失败
|
|
Sleep 60s
|
|
Wait Until Page Contains Element ${Backup_Completed} 180s 备份未完成
|
|
Log 备份完成
|
|
Sleep 2s
|
|
|
|
Postgresql恢复
|
|
[Arguments] ${Username} ${Password} ${cache} ${Backup_Scheme} # 用户名|密码|缓存|备份方案
|
|
sleep 5s
|
|
循环点击 ${BackupSet} ${Click_recover}
|
|
元素点击 ${Click_recover} 点击恢复按钮 定位恢复按钮失败
|
|
Sleep 5s
|
|
元素输入 ${Recover_Postgresql_Username} ${Username} 定位用户名输入框失败
|
|
Comment 元素输入 ${Recover_Postgresql_PWD} ${Password} 定位密码输入框失败
|
|
Run Keyword If ${Backup_Scheme}==0 元素输入 ${Recover_Postgresql_PWD} ${Password} 定位密码输入框失败
|
|
... ELSE Log 物理恢复不输入密码
|
|
元素点击 ${PG_Recover_Setup} 点击切换到高级设置 定位高级设置失败
|
|
Run Keyword IF ${Backup_Scheme}==1 or ${Backup_Scheme}==2 高级设置_物理恢复
|
|
... ELSE IF ${Backup_Scheme}==0 元素输入 ${PG_Recover_UpdatePath} /home/postgres/pgsql/bin 定位安装路径输入框失败
|
|
元素点击 ${Recover_Nextstep_Postgres} 点击下一步进入恢复高级选项 定位下一步按钮失败
|
|
Sleep 5s
|
|
Run Keyword If ${cache}==1 恢复缓存 /opt
|
|
... ELSE IF ${cache}==0 Log 不勾选缓存
|
|
... ELSE Log 流式恢复
|
|
Sleep 5s
|
|
循环点击 ${Recovery_run_kingbase} ${Confirm_Recovery}
|
|
循环点击 ${Confirm_Recovery} ${Success_Confirm}
|
|
元素点击 ${Recover_OK} 点击确定 定位确定失败
|
|
Sleep 5s
|
|
元素点击 ${Policy_Work} 点击进入作业栏 定位作业栏失败
|
|
元素点击 ${select_recover} 选择恢复类型 恢复类型选择失败
|
|
元素点击 ${Search_By_Policy} 点击查询 定位查询按钮失败
|
|
Sleep 300s
|
|
Wait Until Page Contains Element ${Recover_Success} 300s 恢复失败
|
|
sleep 5s
|
|
Log 恢复成功
|
|
|
|
加密
|
|
Sleep 2s
|
|
元素点击 ${Postgresql_Option_Encryption} 勾选加密 定位选项选项失败
|
|
Sleep 2s
|
|
|
|
压缩
|
|
sleep 2s
|
|
元素点击 ${Postgresql_Option_Compress} 点击压缩 定位压缩失败
|
|
Log 点击压缩
|
|
|
|
取消压缩
|
|
Sleep 2s
|
|
Set Focus To Element ${Postgresql_Option_Compress}
|
|
Click Element ${Postgresql_Option_Compress}
|
|
Log 取消压缩
|
|
Sleep 2s
|
|
|
|
重删
|
|
Sleep 2s
|
|
元素点击 ${Option_Dedup} 勾选重删 定位重删选项失败
|
|
Log 点击重删
|
|
Sleep 2s
|
|
|
|
备份缓存
|
|
[Arguments] ${path}
|
|
元素点击 ${Button_Change_Cachepath} 点击更改缓存路径 定位缓存路径更改失败
|
|
元素输入 ${Cache_Path} ${path} 定位缓存路径输入框失败
|
|
元素点击 ${Fin_CachePath} 缓存路径设置完毕 定位缓存路径设置确定按钮失败
|
|
|
|
取消缓存
|
|
元素点击 ${Active_Cache} 取消勾选缓存 定位缓存选项失败
|
|
|
|
恢复缓存
|
|
[Arguments] ${path}
|
|
元素点击 ${Recover_Cache} 勾选缓存 定位缓存选项失败
|
|
元素输入 ${Recover_CachePath} ${path} 定位缓存路径输入框失败
|
|
元素点击 ${Fin_Recover_CachePath} 缓存路径设置完毕 定位缓存路径设置确定按钮失败
|
|
Sleep 2s
|
|
|
|
物理备份
|
|
sleep 2s
|
|
元素点击 ${PG_addBackup_Scheme} 选择备份方案 定位备份方案下拉框失败
|
|
元素点击 ${PG_addBackup_Physics} 选择物理备份 定位物理备份失败
|
|
log 本次为postgresql物理普通方式备份
|
|
sleep 5s
|
|
|
|
逻辑备份
|
|
sleep 2s
|
|
元素点击 ${PG_addBackup_Scheme} 选择备份方案 定位备份方案下拉框失败
|
|
元素点击 ${PG_addBackup_Logic} 选择逻辑备份 定位逻辑备份失败
|
|
log 本次为逻辑备份
|
|
|
|
完全备份
|
|
Sleep 2s
|
|
Click Element ${Full_Backup}
|
|
Log 勾选完全备份
|
|
|
|
增量备份
|
|
Sleep 2s
|
|
Click Element ${Total_Backup}
|
|
Log 勾选增量备份
|
|
|
|
立即执行
|
|
[Arguments] ${bk_type} # 备份类型
|
|
元素点击 ${Timed_DataProtect} 点击进入定时数据保护页面 定位定时数据保护失败
|
|
元素点击 ${dpm_Protection strategy} 切换到定时保护策略栏 定位定时保护策略功能栏失败
|
|
Sleep 2s
|
|
元素点击 xpath=//td[text()="${random_strategyName}"]/..//span[text()="立即执行"] 点击策略立即执行 定位立即执行失败
|
|
元素点击 ${Select_Srctype_Gbase8t} 点击展开立即执行下拉框 定位立即执行备份类型失败
|
|
Run Keyword If "${bk_type}"=="完全" 立即执行_完全备份
|
|
... ELSE IF "${bk_type}"=="增量" 立即执行_增量备份
|
|
Sleep 2s
|
|
循环点击 ${ExecutePolicy_execute} ${Complie_confirm}
|
|
Sleep 5s
|
|
元素点击 ${Complie_confirm} 点击确定按钮 定位确定按钮失败
|
|
元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
|
|
FOR ${n} IN RANGE 10
|
|
Click Element ${Button_Searchbk}
|
|
${bk_status} Run Keyword And Return Status Wait Until Element Is Visible ${Backup_Completed}
|
|
Run Keyword If "${bk_status}"=="True" Exit For Loop
|
|
... ELSE Log 备份未完成
|
|
Sleep 60s
|
|
END
|
|
Run Keyword If ${bk_status}==False Fail
|
|
... ELSE Log 备份成功
|
|
Sleep 15s
|
|
|
|
立即执行_完全备份
|
|
元素点击 ${Now Full_Bacup} 点击立即执行完全备份 定位完全备份选项失败
|
|
|
|
立即执行_增量备份
|
|
元素点击 ${Now Add_Backup} 点击立即执行增量备份 定位增量备份选项失败
|
|
|
|
备份集属性校验
|
|
[Arguments] ${encryption} ${compress} ${deduped} ${cache} # 加密、压缩、重删、缓存
|
|
sleep 2s
|
|
循环点击 ${BackupSet} ${Detail}
|
|
元素点击 ${Detail} 点击进入备份集详情 定位备份集详情失败
|
|
Sleep 2s
|
|
Run Keyword If ${encryption}==1 加密属性校验
|
|
... ELSE Log 加密属性不校验
|
|
Run Keyword If ${compress}==1 压缩属性校验
|
|
... ELSE Log 压缩属性不校验
|
|
Run Keyword If ${deduped}==1 重删属性校验
|
|
... ELSE Log 重删属性不校验
|
|
Run Keyword If ${cache}==1 缓存属性校验
|
|
... ELSE Log 缓存属性不校验
|
|
元素点击 ${Attr_Cancel} 点击取消关闭备份集详情弹窗 定位取消按钮失败
|
|
Log 备份集属性确认完毕
|
|
Sleep 2s
|
|
Sleep 2s
|
|
|
|
加密属性校验
|
|
${get_attr}= Get Text ${Encryption_Attr}
|
|
Element Should Contain ${Encryption_Attr} 是
|
|
Log 加密属性校验完毕
|
|
|
|
压缩属性校验
|
|
${get_attr}= Get Text ${Compress_Attr}
|
|
Element Should Contain ${Compress_Attr} 是
|
|
Log 压缩属性校验完毕
|
|
|
|
重删属性校验
|
|
${get_attr}= Get Text ${Dedup_Confirm}
|
|
Element Should Contain ${Dedup_Confirm} 是
|
|
Log 重删属性校验完毕
|
|
|
|
缓存属性校验
|
|
${get_attr}= Get Text ${Cache_Attr}
|
|
Element Should Contain ${Cache_Attr} 是
|
|
Log 缓存属性校验完毕
|
|
|
|
高级设置_物理备份
|
|
元素输入 ${PG_UpdateUser} ${PostSql_DB_User} 定位系统用户名输入框失败
|
|
元素输入 ${PG_UpdatePath} ${PostSql_InstallPath} 定位安装路径输入框失败
|
|
元素输入 ${PG_UpdateArchivePath} ${PostSql_ArchivePath} 定位归档日志路径输入框失败
|
|
元素输入 ${PG_UpdateDataPath} ${PostSql_DataPath} 定位data目录输入框失败
|
|
|
|
高级设置_物理恢复
|
|
元素输入 ${PG_Recover_UpdateUser} ${PostSql_DB_User} 定位系统用户名输入框失败
|
|
元素输入 ${PG_Recover_UpdatePath} ${PostSql_InstallPath} 定位安装路径输入框失败
|
|
元素输入 ${PG_Recover_ArchivePath} ${PostSql_ArchivePath} 定位归档日志路径输入框失败
|
|
元素输入 ${PG_Recover_DataPath} ${PostSql_DataPath} 定位data目录输入框失败
|
|
|
|
插入秒级数据
|
|
[Arguments] ${PG_IP} ${PG_User} ${PG_Passwd}
|
|
Open Connection ${PG_IP} 22
|
|
log 用户登录远程测试机器
|
|
SSHLibrary.Login ${PG_User} ${PG_Passwd}
|
|
log 开始插入秒级数据
|
|
Execute Command ./start_insert.sh
|
|
Close Connection
|
|
|
|
物理流式备份
|
|
sleep 2s
|
|
元素点击 ${PG_addBackup_Scheme} 选择备份方案 定位备份方案下拉框失败
|
|
元素点击 ${PG_addBackup_Physics} 选择物理备份 定位物理备份失败
|
|
元素点击 ${PG_BackupMode_Scheme} 选择物理备份模式 定位物理备份模式下拉框失败
|
|
元素点击 ${PG_BackupMode} 选择流式备份 定位流式备份失败
|
|
log 本次为postgresql物理 流式备份
|
|
sleep 5s
|
|
|
|
指定时间点恢复
|
|
[Arguments] ${PG_IP} ${PG_User} ${PG_Passwd}
|
|
Open Connection ${PG_IP} 22
|
|
log 用户登录远程测试机器
|
|
SSHLibrary.Login ${PG_User} ${PG_Passwd}
|
|
log 停止秒级数据插入
|
|
Execute Command pkill time.sh
|
|
log 删除表格为恢复做准备
|
|
Execute Command ./dropautotable.sh
|
|
Close Connection
|
|
Log 获取增量备份开始的时间
|
|
${UXBFtime} Get text ${PG_bk_time}
|
|
${RecoveryTime} Add Time to Date ${UXBFtime} -1 minute
|
|
循环点击 ${BackupSet} ${Click_recover}
|
|
元素点击 ${Click_recover} 选择备份集进行恢复 定位恢复按钮失败
|
|
Sleep 5s
|
|
元素输入 ${Recover_Postgresql_Username} ${PG_User} 定位用户名输入框失败
|
|
元素点击 ${PG_Recover_Setup} 点击切换到高级设置 定位高级设置失败
|
|
高级设置_物理恢复
|
|
元素点击 ${Recover_Nextstep_Postgres} 点击下一步进入恢复高级选项 定位下一步按钮失败
|
|
Sleep 5s
|
|
元素点击 ${PG_appointRecover} 点击指定时间点恢复 定位指定时间点恢复失败
|
|
元素点击 ${PG_select_timeDi} 点击指定时间点恢复 定位指定时间点恢复失败
|
|
元素输入 ${PG_select_timeDi} ${RecoveryTime} 指定恢复时间为粘贴失败
|
|
Sleep 5s
|
|
循环点击 ${Recovery_run_kingbase} ${Confirm_Recovery}
|
|
循环点击 ${Confirm_Recovery} ${Success_Confirm}
|
|
元素点击 ${Recover_OK} 点击确定 定位确定失败
|
|
Sleep 5s
|
|
元素点击 ${Policy_Work} 点击进入作业栏 定位作业栏失败
|
|
元素点击 ${select_recover} 选择恢复类型 恢复类型选择失败
|
|
元素点击 ${Search_By_Policy} 点击查询 定位查询按钮失败
|
|
Sleep 300s
|
|
Wait Until Page Contains Element ${Recover_Success} 300s 恢复失败
|
|
sleep 5s
|
|
Log 恢复成功
|
|
Log 登录机器查询数据库结果并验证
|
|
Open Connection ${PG_IP} 22
|
|
log 用户登录远程测试机器
|
|
SSHLibrary.Login ${PG_User} ${PG_Passwd}
|
|
${out0}= Execute Command ./checkfinalresult.sh
|
|
Log 提取数据库的最后一行数据
|
|
${out} Get Substring ${out0} 35 49
|
|
Log 把数据库获取的数据改为时间格式
|
|
${RecoveryCheckOut} Convert Date ${out} exclude_millis=yes
|
|
Log 只获取分钟
|
|
${CompareDBMin} Get Substring ${out} 10 12
|
|
Log ${RecoveryCheckOut}
|
|
Should Contain ${RecoveryCheckOut} ${RecoveryCheckOut}
|
|
Should Contain ${RecoveryTime} ${CompareDBMin}
|
|
Execute Command ./changedbtonormal.sh
|
|
Close Connection
|
|
Log 验证结束,测试结束
|