*** Settings *** Library Selenium2Library Library DatabaseLibrary Resource ../RE0_Common/KeyWord.robot Library SSHLibrary Resource ElementPath_XC.robot Library DateTime Library String *** Keywords *** Highgo备份 [Arguments] ${agent_name} ${highgo_user} ${highgo_pwd} ${mds_name} ${encryption_attr} ${compress_attr} ${dedup_attr} ${encryption} ${compress} ${deduped} [Documentation] Highgo数据库备份,备份的时候,勾选加密,压缩,重删, 默认没有缓存 元素点击 ${Timed_DataProtect} 点击进入定时数据保护页面 定位定时数据保护失败 ${date} Evaluate time.strftime('%Y%m%d%H%M%S',time.localtime()) time ${random_strategyName}= Catenate SEPARATOR=_ Highgo ${date} ${createpolicy} Catenate SEPARATOR= 新建了策略[ ${random_strategyName} ] Set Suite Variable ${random_strategyName} Set Suite Variable ${createpolicy} Sleep 5s 元素点击 xpath=//span[text()="${agent_name}"] 点击选择代理 定位代理所在位置失败 sleep 5s 元素点击 ${BackupSet} 点击进入备份集页面 定位备份集按钮失败 元素点击 ${dpm_Protection strategy} 点击进入保护策略页面 定位保护策略按钮失败 元素点击 ${Add_Policy} 点击添加策略按钮 定位添加策略按钮失败 元素点击 ${Highgo_source} 点击Highgo组件 定位Highgo组件失败 sleep 5s 元素输入 ${Input_celuename} ${random_strategyName} 定位策略名输入框失败 元素输入 ${Input_Highgo_user} ${highgo_user} 定位Highgo用户名输入框失败 元素输入 ${Input_Highgo_Pwd} ${highgo_pwd} 定位Highgo用户密码输入框失败 元素点击 ${Connection credentials_Next} 进入到目标数据库选择界面 定位下一步按钮失败 元素点击 ${NextStep_ButtonOn_TargetDatabase} 进入到任务周期页面 定位下一步按钮失败 元素点击 ${Add_TaskCycle} 点击添加任务周期 定位添加任务周期按钮失败 元素点击 ${Full_Backup} 勾选完全备份 定位完全备份元素失败 Sleep 2s 元素点击 ${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 重删 元素点击 ${Storage_NextStep} 点击下一步进入到备份高级选项 定位下一步失败 log 进入备份高级选项 Run Keyword If ${encryption_attr}==1 加密 Run Keyword If ${compress_attr}==1 压缩 ... ELSE IF ${compress_attr}==0 取消压缩 sleep 2s 循环点击 ${Complete_Policy_Create_No_Info} ${Success_Confirm} sleep 2s 元素点击 ${Success_Confirm} 确定策略创建成功 策略创建失败 元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败 Sleep 40s Wait Until Page Contains Element xpath=//*[@id="backupSetTable"]//tr[2]/td[text()="已完成"] 180s 备份未完成 Log 备份完成 sleep 5s 循环点击 ${BackupSet} ${View} sleep 2s 元素点击 ${View} 点击进入备份集详情 定位备份集详情失败 Sleep 10s 加密属性校验 ${encryption} 压缩属性校验 ${compress} 重删属性校验 ${deduped} 元素点击 ${Attr_Cancel} 点击取消关闭备份集详情弹窗 定位取消按钮失败 Log 备份集属性确认完毕 Sleep 2s Highgo恢复 [Arguments] ${db_user_name} ${db_passwd} #数据库用户名|密码 [Documentation] Highgo数据库恢复 sleep 5s 循环点击 ${BackupSet} ${Click_recover} sleep 5s 元素点击 ${Click_recover} 选择备份集进行恢复 定位恢复按钮失败 元素输入 ${Recover_Highgo_User_Input} ${db_user_name} 定位Highgo用户输入框失败 元素输入 ${Input_Ux_PwdR} ${db_passwd} 定位Highgo密码输入框失败 元素点击 ${Recover_Nextstep_Ux} 点击下一步进入到恢复高级选项 恢复目标下一步定位失败 sleep 2s 循环点击 ${Recover} ${Recovery_Comfirm_Button} 元素点击 ${Recovery_Comfirm_Button} 恢复策略确定创建成功 恢复作业创建成功弹窗定位失败 sleep 2s 元素点击 ${Comfirm_Add_Success_Button} 点击添加成功窗口确认按钮成功 点击添加成功窗口确认按钮失败 sleep 5s 元素点击 ${Policy_Work} 点击进入作业栏 定位作业栏失败 元素输入 xpath=//input[@ng-model="workPolicyName"] 恢复策略 定位所有策略输入框失败 元素点击 xpath=//span[@id="dpm_tab_work_workPolicyName_search_btn"] 点击查找筛选恢复策略 定位查找按钮失败 Sleep 60s Wait Until Page Contains Element ${Recover_Success} 180s 恢复失败 sleep 2s Log 恢复成功 加密 元素点击 ${Type_encrypt} 点击勾选加密选项 定位加密失败 压缩 元素点击 ${Type_compress} 点击勾选压缩选项 定位压缩失败 重删 [Documentation] 备份的时候勾选重删 元素点击 ${Type_dedup} 勾选重删 定位重删失败 取消压缩 [Documentation] 不勾选压缩 Log 默认不勾选压缩选项 Highgo立即执行 [Arguments] ${Highgo_BackupType} #瀚高备份的类型 [Documentation] 选择现有的第一个备份策略,点击立即执行--增量备份 元素点击 ${dpm_Protection strategy} 点击进入定时保护策略一栏 定位保护策略栏失败 元素点击 ${Complie_execute} 点击策略立即执行按钮 定位立即执行元素失败 循环点击 ${Select_Srctype_Ux} ${Complie_incre_Ux} Run Keyword If "${Highgo_BackupType}"=="增量" 增量备份 循环点击 ${ExecutePolicy_execute} ${Complie_confirm} 元素点击 ${Complie_confirm} 点击确定按钮 定位确定按钮失败 元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败 Sleep 60s Wait Until Page Contains Element Xpath=//*[@id="backupSetTable"]/div[2]/table/tbody/tr[2]/td[5][text()="HighGo${Highgo_BackupType}备份"] 100s 定位对应备份集失败 Log 备份集类型为${Highgo_BackupType} Sleep 5s Wait Until Page Contains Element xpath=//*[@id="backupSetTable"]//*[@class=" ev_dhx_web"]//td[text()="已完成"] 300s 备份未完成 Log 备份完成 增量备份 [Documentation] 选择现有的第一个备份策略,点击立即执行--增量备份 Sleep 2s 元素点击 ${Complie_incre_Ux} 点击增量备份 定位增量备份失败 Highgo建表 [Arguments] ${Highgo_IP} ${Highgo_User} ${Highgo_Passwd} [Documentation] 使用系统自动的shell命令实现Highgo数据的:删除,创建,插入,查询的命令 ... ... pg_delete_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'drop table autotest' ... ... pg_create_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'create table autotest(i int)' ... ... pg_insert_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(0)' ... ... pg_insert2_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(1)' ... ... pg_show_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'select * from autotest' Open Connection ${Highgo_IP} 22 log 用户登录远程测试机器 SSHLibrary.Login ${Highgo_User} ${Highgo_Passwd} Execute Command ./changedbtonormal.sh Execute Command ./pg_delete_db_table.sh log 删除旧的数据库表 ${out}= Execute Command ./pg_create_db_table.sh Should Contain ${out} CREATE TABLE Close Connection Highgo插入数据 [Arguments] ${Highgo_IP} ${Highgo_User} ${Highgo_Passwd} [Documentation] 使用系统自动的shell命令实现Highgo数据的:删除,创建,插入,查询的命令 ... ... pg_delete_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'drop table autotest' ... ... pg_create_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'create table autotest(i int)' ... ... pg_insert_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(0)' ... ... pg_insert2_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(1)' ... ... pg_show_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'select * from autotest' Open Connection ${Highgo_IP} 22 log 用户登录远程测试机器 SSHLibrary.Login ${Highgo_User} ${Highgo_Passwd} ${out}= Execute Command ./pg_insert_db_table.sh Should Contain ${out} INSERT 0 1 Close Connection Highgo查询表 [Arguments] ${Highgo_IP} ${Highgo_User} ${Highgo_Passwd} [Documentation] 使用系统自动的shell命令实现Highgo数据的:删除,创建,插入,查询的命令 ... ... pg_delete_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'drop table autotest' ... ... pg_create_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'create table autotest(i int)' ... ... pg_insert_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(0)' ... ... pg_insert2_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(1)' ... ... pg_show_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'select * from autotest' Open Connection ${Highgo_IP} 22 log 用户登录远程测试机器 SSHLibrary.Login ${Highgo_User} ${Highgo_Passwd} ${out}= Execute Command ./pg_show_db_table.sh Should Contain ${out} (1 Close Connection Highgo插入数据_增量 [Arguments] ${Highgo_IP} ${Highgo_User} ${Highgo_Passwd} [Documentation] 使用系统自动的shell命令实现Highgo数据的:删除,创建,插入,查询的命令 ... ... pg_delete_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'drop table autotest' ... ... pg_create_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'create table autotest(i int)' ... ... pg_insert_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(0)' ... ... pg_insert2_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(1)' ... ... pg_show_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'select * from autotest' Open Connection ${Highgo_IP} 22 log 用户登录远程测试机器 SSHLibrary.Login ${Highgo_User} ${Highgo_Passwd} ${out}= Execute Command ./pg_insert2_db_table.sh Should Contain ${out} INSERT 0 1 Close Connection Highgo删除表 [Arguments] ${Highgo_IP} ${Highgo_User} ${Highgo_Passwd} [Documentation] 使用系统自动的shell命令实现Highgo数据的:删除,创建,插入,查询的命令 ... ... pg_delete_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'drop table autotest' ... ... pg_create_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'create table autotest(i int)' ... ... pg_insert_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(0)' ... ... pg_insert2_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(1)' ... ... pg_show_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'select * from autotest' Open Connection ${Highgo_IP} 22 log 用户登录远程测试机器 SSHLibrary.Login ${Highgo_User} ${Highgo_Passwd} ${out}= Execute Command ./pg_delete_db_table.sh Should Contain ${out} DROP TABLE Close Connection Highgo查询表_增量 [Arguments] ${Highgo_IP} ${Highgo_User} ${Highgo_Passwd} [Documentation] 使用系统自动的shell命令实现Highgo数据的:删除,创建,插入,查询的命令 ... ... pg_delete_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'drop table autotest' ... ... pg_create_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'create table autotest(i int)' ... ... pg_insert_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(0)' ... ... pg_insert2_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(1)' ... ... pg_show_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'select * from autotest' Open Connection ${Highgo_IP} 22 log 用户登录远程测试机器 SSHLibrary.Login ${Highgo_User} ${Highgo_Passwd} ${out}= Execute Command ./pg_show_db_table.sh Should Contain ${out} (2 Close Connection 备份集属性校验 [Arguments] ${encryption} ${compress} ${deduped} ${cache} sleep 10s 循环点击 ${BackupSet} ${View} sleep 2s 元素点击 ${View} 点击进入备份集详情 定位备份集详情失败 Sleep 10s 加密属性校验 ${encryption} 压缩属性校验 ${compress} 重删属性校验 ${deduped} 缓存属性校验 ${cache} 元素点击 ${Attr_Cancel} 点击取消关闭备份集详情弹窗 定位取消按钮失败 Log 备份集属性确认完毕 Sleep 2s 压缩属性校验 [Arguments] ${encryption} Element Text Should Be ${Compress_Attr_BK_Path} ${encryption} Log 压缩属性校验完毕 加密属性校验 [Arguments] ${compress} Element Should Contain ${Encryption_Attr_BK_Path} ${compress} Log 加密属性校验完毕 重删属性校验 [Arguments] ${deduped} Element Should Contain ${Deduped_Attr_BK_Path} ${deduped} Log 重删属性校验完毕 缓存属性校验 [Arguments] ${bk_cache} Element Should Contain ${cache_BK_Path} ${bk_cache} Log 缓存属性校验完毕 插入时间戳秒级数据 [Arguments] ${Highgo_IP} ${Highgo_User} ${Highgo_Passwd} [Documentation] 使用系统自动的shell命令实现Highgo数据的:删除,创建,插入,查询的命令 ... ... pg_delete_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'drop table autotest' ... ... pg_create_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'create table autotest(i int)' ... ... pg_insert_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(0)' ... ... pg_insert2_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'insert into autotest(i) values(1)' ... ... pg_show_db_table.sh ... source .bash_profile ... PGPASSWORD=Unary@2022 psql -U sysdba -c 'select * from autotest' Open Connection ${Highgo_IP} 22 log 用户登录远程测试机器 SSHLibrary.Login ${Highgo_User} ${Highgo_Passwd} log 开始插入秒级数据 Execute Command ./start_insert.sh Close Connection 指定时间恢复 [Arguments] ${db_user_name} ${db_passwd} ${Highgo_IP} ${Highgo_User} ${Highgo_Passwd} Open Connection ${Highgo_IP} 22 log 用户登录远程测试机器 SSHLibrary.Login ${Highgo_User} ${Highgo_Passwd} log 停止秒级数据插入 Execute Command pkill time.sh log 删除表格为恢复做准备 Execute Command ./dropautotable.sh Close Connection Log 获取增量备份开始的时间 ${UXBFtime} Get text ${bk_time} ${RecoveryTime} Add Time to Date ${UXBFtime} -1 minute 循环点击 ${BackupSet} ${Click_recover} sleep 5s 元素点击 ${Click_recover} 选择备份集进行恢复 定位恢复按钮失败 元素输入 ${Recover_Highgo_User_Input} ${db_user_name} 定位Highgo用户输入框失败 元素输入 ${Input_Ux_PwdR} ${db_passwd} 定位Highgo密码输入框失败 元素点击 ${Recover_Nextstep_Ux} 点击下一步进入到恢复高级选项 恢复目标下一步定位失败 sleep 2s 元素点击 ${UXappointRecover} 点击指定时间点恢复 定位指定时间点恢复失败 元素点击 ${select_timeDi_UX} 点击指定时间点恢复 定位指定时间点恢复失败 元素输入 ${select_timeDi_UX} ${RecoveryTime} 指定恢复时间为粘贴失败 循环点击 ${Recover} ${Recovery_Comfirm_Button} sleep 2s 元素点击 ${Recovery_Comfirm_Button} 恢复策略确定创建成功 恢复作业创建成功弹窗定位失败 元素点击 ${Comfirm_Add_Success_Button} 点击添加成功窗口确认按钮成功 点击添加成功窗口确认按钮失败 sleep 5s 元素点击 ${Policy_Work} 点击进入作业栏 定位作业栏失败 元素输入 xpath=//input[@ng-model="workPolicyName"] 恢复策略 定位所有策略输入框失败 元素点击 xpath=//span[@id="dpm_tab_work_workPolicyName_search_btn"] 点击查找筛选恢复策略 定位查找按钮失败 Sleep 60s Wait Until Page Contains Element ${Recover_Success} 180s 恢复失败 Log 恢复成功 Log 登录机器查询数据库结果并验证 Open Connection ${Highgo_IP} 22 log 用户登录远程测试机器 SSHLibrary.Login ${Highgo_User} ${Highgo_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 验证结束,测试结束