335 lines
17 KiB
Plaintext
335 lines
17 KiB
Plaintext
*** Settings ***
|
||
Resource ElementPath.robot
|
||
Library Selenium2Library
|
||
Library DatabaseLibrary
|
||
Resource ../RE0_Common/KeyWord.robot
|
||
Resource ../RE0_Common/ElementPath.robot
|
||
|
||
*** Keywords ***
|
||
删除OracleRAC数据表
|
||
[Arguments] ${OracleRAC_TableName1} ${DBRACInstance_lin}
|
||
[Documentation] 功能:连接Oracle数据库,删除原有表
|
||
...
|
||
... 使用方法:删除Oracle数据表 表名 实例名
|
||
...
|
||
... 变量: ${Oracle_TableName1}表名 | ${DBInstance_lin} 实例名
|
||
log 连接数据库
|
||
Connect To Database Using Custom Params cx_Oracle '${DBRACUser}','${DBRACPwd}','${DBRACInstance_lin}'
|
||
${rowcount} Row Count select * from user_tables where table_name=upper('${OracleRAC_TableName1}')
|
||
Run Keyword If ${rowcount} >= 1 Execute Sql String drop table ${OracleRAC_TableName1}
|
||
Disconnect From Database
|
||
|
||
创建OracleRAC数据表
|
||
[Arguments] ${OracleRAC_TableName1} ${DBRACInstance_lin}
|
||
log 删除表
|
||
删除OracleRAC数据表 ${OracleRAC_TableName1} ${DBRACInstance_lin}
|
||
log 连接数据库
|
||
Connect To Database Using Custom Params cx_Oracle '${DBRACUser}','${DBRACPwd}','${DBRACInstance_lin}'
|
||
log 获取行数
|
||
${rowcount} Row Count select * from user_tables where table_name=upper('${OracleRAC_TableName1}')
|
||
Run Keyword If ${rowcount} <=0 Execute Sql String create table ${OracleRAC_TableName1}(id char(50),name varchar(200))
|
||
Execute Sql String insert into ${OracleRAC_TableName1}(id,name)values('1','yuyang')
|
||
Execute Sql String insert into ${OracleRAC_TableName1}(id,name)values('2','yuyang2')
|
||
Execute Sql String commit
|
||
${rownum} Row Count select * from ${OracleRAC_TableName1}
|
||
Set Suite Variable ${rownum}
|
||
Log ${rownum}
|
||
Disconnect From Database
|
||
|
||
OracleRAC备份
|
||
[Arguments] ${Oracle_BackType} ${agent_name} ${mds_name} ${encryption_attr} ${compress_attr} ${dedup_attr} ${cache}
|
||
log 选择定时数据保护
|
||
元素点击 ${Timed_DataProtect} 点击进入定时数据保护页面 定位定时数据保护失败
|
||
${date} Evaluate time.strftime('%Y%m%d%H%M%S',time.localtime()) time
|
||
${random_strategyName}= Catenate SEPARATOR=_ ${Oracle_BackType} ${date}
|
||
${createpolicy} Catenate SEPARATOR= 新建了策略[ ${random_strategyName} ]
|
||
Set Suite Variable ${random_strategyName}
|
||
Set Suite Variable ${createpolicy}
|
||
Sleep 15s
|
||
元素点击 xpath=//span[text()="${agent_name}"] 点击选择代理 定位代理所在位置失败
|
||
Comment 元素点击 ${BackupSet} 点击进入备份集页面 定位备份集按钮失败
|
||
元素点击 ${dpm_Protection strategy} 点击进入保护策略页面 定位保护策略按钮失败
|
||
元素点击 ${Add_OracleRACPolicy} 点击添加策略按钮 定位添加策略按钮失败
|
||
元素点击 ${Select_Backup source} 点击Oracle组件按钮 定位Oracle组件按钮失败
|
||
元素输入 ${Input_PolicyName_Oracle} ${random_strategyName} 定位策略名输入框失败
|
||
元素点击 ${Select_Backup_source1} 点击浏览备份源下拉框成功 点击浏览备份源下拉框失败
|
||
元素点击 ${Select_Node} 选择racnode1-p节点成功 选择racnode1-p节点失败
|
||
元素点击 ${Click_Next} 点击下发策略下一步按钮成功 点击下发策略下一步按钮失败
|
||
元素点击 ${Add_Instance} 点击添加实例成功 点击添加实例失败
|
||
元素点击 ${Select_Node1} 成功 失败
|
||
元素点击 ${Select_TNS} 成功 失败
|
||
元素输入 ${Input_OracleTNS} ${OracleRAC1_Instance} 定位TNS输入框失败
|
||
元素输入 ${InputRAC1_User_Name} ${OracleRACUser} 定位用户名输入框失败
|
||
元素输入 ${InputRAC1_Password} ${DBRACPwd} 定位密码输入框失败
|
||
元素点击 ${Click_Sure} 定位确定按钮成功 定位确定按钮失败
|
||
元素点击 ${Add_Instance} 点击添加实例成功 点击添加实例失败
|
||
元素点击 ${Select_Node2} 成功 失败
|
||
元素输入 ${Input_OracleTNS} ${OracleRAC2_Instance} 定位TNS输入框失败
|
||
元素输入 xpath=//input[@id="colony_orcusername"and@name="colony_orcusername"] ${OracleRACUser} 定位用户名输入框失败
|
||
元素输入 ${InputRAC2_Password} ${DBRACPwd} 定位密码输入框失败
|
||
元素点击 ${Click_Sure} 定位确定按钮成功 定位确定按钮失败
|
||
sleep 5s
|
||
元素点击 ${Click_Next1} 点击连接凭据页面下一步按钮 点击连接凭据页面下一步按钮失败
|
||
sleep 5s
|
||
元素点击 ${Select_Target database} 点击勾选数据库 定位数据库勾选框失败
|
||
元素点击 ${Click_Next2} 点击目标数据库页面下一步按钮 定位目标数据库页面下一步按钮失败
|
||
元素点击 ${Oracle_Parameter_Next} 点击Oracle选项页面下一步按钮 定位Oracle选项页面下一步按钮失败
|
||
元素点击 ${Add_taskcycle} 点击添加任务周期按钮 定位添加任务周期按钮失败
|
||
Run Keyword If "${Oracle_BackType}"=="完全" 完全备份
|
||
... ELSE IF "${Oracle_BackType}"=="差量" 差量备份
|
||
... ELSE IF "${Oracle_BackType}"=="增量" 增量备份
|
||
... ELSE IF "${Oracle_BackType}"=="归档日志" 归档日志备份
|
||
... ELSE Fail 定位备份类型失败
|
||
元素点击 ${Cycle_Once} 设置任务仅执行一次 定位仅执行一次失败
|
||
元素点击 ${Cycle_Confirm} 确定任务周期设置完毕 定位任务周期设置失败
|
||
元素点击 ${Cycle_NextStep} 点击下一步进入备份集存储设置界面 定位下一步失败
|
||
元素点击 ${Manual_ChooseMDS} 点击勾选手动选择介质 定位选择介质失败
|
||
元素点击 ${Select_MDS} 点击介质选择按钮 定位介质选择按钮失败
|
||
元素点击 xpath=//option[@label="${mds_name}"] 点击选择指定介质 定位指定介质失败
|
||
Run Keyword If ${dedup_attr}==1 重删
|
||
元素点击 ${Storage_NextStep} 点击下一步进入到备份高级选项 定位下一步失败
|
||
Run Keyword If ${encryption_attr}==1 加密
|
||
Run Keyword If ${compress_attr}==1 压缩
|
||
Comment Run Keyword If ${check_attr}==1 校验
|
||
Run Keyword If ${cache}==1 备份缓存 /opt
|
||
循环点击 ${Backuphigh_OK} ${Cl_addOK}
|
||
sleep 2s
|
||
元素点击 ${Cl_addOK} 确定策略创建成功 策略创建失败
|
||
元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
|
||
sleep 5s
|
||
元素输入 ${Input_Policy_Name} ${random_strategyName} 定位策略搜索框失败
|
||
Log 输入策略名进行搜索
|
||
Sleep 15s
|
||
FOR ${n} IN RANGE 20
|
||
Click Element ${Button_Searchbk}
|
||
${bk_status} Run Keyword And Return Status Wait Until Element Is Visible xpath=//*[@id="backupSetTable"]//tr[2]/td[text()="已完成"]
|
||
Run Keyword If "${bk_status}"=="True" Exit For Loop
|
||
... ELSE Log 备份未完成
|
||
Sleep 30s
|
||
END
|
||
Run Keyword If ${bk_status}==False Fail
|
||
... ELSE Log 备份成功
|
||
Sleep 15s
|
||
|
||
完全备份
|
||
Sleep 2s
|
||
Click Element ${Full_Backup}
|
||
Log 勾选完全备份
|
||
|
||
增量备份
|
||
Sleep 2s
|
||
Click Element ${Incre_Backup}
|
||
Log 勾选增量备份
|
||
|
||
差量备份
|
||
Sleep 2s
|
||
Click Element ${Difference_Backup}
|
||
Log 勾选差量备份
|
||
|
||
归档日志备份
|
||
Sleep 2s
|
||
Click Element ${GD_Backup}
|
||
Log 勾选归档日志备份
|
||
|
||
加密
|
||
Sleep 2s
|
||
Click Element ${OracleRAC_Option_Encryption}
|
||
Log 点击加密
|
||
Sleep 2s
|
||
|
||
压缩
|
||
Sleep 2s
|
||
Click Element ${Option_Compress}
|
||
Log 点击压缩
|
||
Sleep 2s
|
||
|
||
重删
|
||
Sleep 2s
|
||
Click Element ${Option_Dedup}
|
||
Log 点击重删
|
||
Sleep 2s
|
||
|
||
备份缓存
|
||
[Arguments] ${path}
|
||
元素点击 ${Oracle_Cache_Pach} 点击启动本地备份缓存 定位本地备份缓存失败
|
||
元素输入 ${Cache_Path} ${path} 定位缓存路径输入框失败
|
||
元素点击 ${Oracle_backup_CachePath} 缓存路径设置完毕 定位缓存路径设置确定按钮失败
|
||
|
||
备份集属性校验
|
||
[Arguments] ${encryption} ${compress} ${deduped} ${cache}
|
||
sleep 2s
|
||
元素点击 Xpath=//td[text()="${random_strategyName}"]/..//span[text()="详情"] 点击展开详情 定位详情失败
|
||
sleep 2s
|
||
Run Keyword If ${encryption}==1 加密属性校验_是
|
||
... ELSE 加密属性校验_否
|
||
sleep 2s
|
||
Run Keyword If ${compress}==1 压缩属性校验_是
|
||
... ELSE 压缩属性校验_否
|
||
sleep 2s
|
||
Run Keyword If ${deduped}==1 重删属性校验_是
|
||
... ELSE 重删属性校验_否
|
||
sleep 2s
|
||
Run Keyword If ${cache}==1 缓存属性校验_是
|
||
... ELSE 缓存属性校验_否
|
||
sleep 2s
|
||
元素点击 ${Attr_Cancel} 点击取消关闭备份集详情弹窗 定位取消按钮失败
|
||
Log 备份集属性确认完毕
|
||
Sleep 2s
|
||
|
||
加密属性校验_是
|
||
Element Should Contain ${Encryption_Attr} 是
|
||
Log 加密属性校验完毕
|
||
|
||
加密属性校验_否
|
||
Element Should Contain ${Encryption_Attr} 否
|
||
Log 备份集未加密
|
||
|
||
压缩属性校验_是
|
||
Element Should Contain ${Compress_Attr} 是
|
||
Log 压缩属性校验完毕
|
||
|
||
压缩属性校验_否
|
||
Element Should Contain ${Compress_Attr} 否
|
||
Log 备份集未压缩
|
||
|
||
重删属性校验_是
|
||
Element Should Contain ${Mysql_Deduped_Attr} 是
|
||
Log 重删属性校验完毕
|
||
|
||
重删属性校验_否
|
||
Element Should Contain ${Mysql_Deduped_Attr} 否
|
||
Log 备份集未重删
|
||
|
||
缓存属性校验_是
|
||
Element Should Contain ${Cache_Attr} 是
|
||
Log 缓存属性校验完毕
|
||
|
||
缓存属性校验_否
|
||
Element Should Contain ${Cache_Attr} 否
|
||
Log 备份集未设置缓存
|
||
|
||
OracleRAC恢复
|
||
[Arguments] ${DBInstance}
|
||
元素点击 ${dpm_Protection strategy} 点击进入保护策略页面 定位保护策略按钮失败
|
||
元素点击 ${BackupSet} 点击进入备份集页面 定位备份集按钮失败
|
||
sleep 5s
|
||
元素点击 ${Click_recover} 点击恢复按钮 定位恢复按钮失败
|
||
sleep 5s
|
||
元素点击 ${Oracle_Recover_Next1} 点击备份内容页面下一步按钮 定位备份内容页面下一步按钮失败
|
||
元素点击 ${Select_recovery_host} 点击选择主机成功 点击选择主机失败
|
||
元素点击 ${Select_recovery_RAC1} 点击选择节点1成功 点击选择节点1失败
|
||
元素点击 ${Recover_RACinstancename} 点击添加实例按钮成功 点击添加实例按钮失败
|
||
元素点击 ${Recover_Select_Node1} 选择节点1成功 选择节点1失败
|
||
元素输入 ${Recover_RAC1InstanceName} ${OracleRAC1_Instance} 输入实例名失败
|
||
元素输入 ${Recover_RAC1_User_Name} ${OracleRACUser} 输入用户名失败
|
||
元素输入 ${Recover_RAC1_Password} ${DBRACPwd} 输入密码失败
|
||
元素点击 ${Click_Sure} 点击确定按钮成功 点击确定按钮失败
|
||
元素点击 ${Recover_RACinstancename} 点击添加实例按钮成功 点击添加实例按钮失败
|
||
元素点击 ${Recover_Select_Node2} 选择节点2成功 选择节点2失败
|
||
元素输入 ${Recover_RAC2InstanceName} ${OracleRAC2_Instance} 输入实例名失败
|
||
元素输入 ${Recover_RAC2_User_Name} ${OracleRACUser} 输入用户名失败
|
||
元素输入 ${Recover_RAC2_Password} ${DBRACPwd} 输入密码失败
|
||
元素点击 ${Click_Sure} 点击确定按钮成功 点击确定按钮失败
|
||
元素点击 ${Oracle_Recover_Next2} 点击恢复目标下一步成功 点击恢复目标下一步失败
|
||
元素点击 ${Oracle_Recover_Next3} 点击Oracle选项下一步成功 点击Oracle选项下一步失败
|
||
元素点击 ${Oracle_Recover_Next4} 点击恢复选项下一步成功 点击恢复选项下一步失败
|
||
元素点击 ${Oracle_Recover_Finish} 点击高级选择完成 点击高级选择完成失败
|
||
元素点击 ${recover_confirm} 点击恢复确认按钮成功 点击恢复确认按钮失败
|
||
sleep 5s
|
||
元素点击 ${recover_sucessOK} 点击恢复策略确定按钮 定位恢复确定按钮失败
|
||
元素输入 ${Host_Search} ${OracleRAC1_Name} 输入主机名成功
|
||
元素点击 xpath=//span[@class="standartTreeRow"and text()="${OracleRAC1_Name}"] 选择节点1成功 选择节点2失败
|
||
元素点击 ${Task} 点击作业栏按钮 定位作业栏失败
|
||
sleep 15s
|
||
FOR ${n} IN RANGE 20
|
||
${work_status} Run Keyword And Return Status Wait Until Element Is Visible Xpath=//table[@lay-size="sm"]//tr[1]//div[text()="本次恢复成功 "]
|
||
Run Keyword If ${work_status}==False Log 恢复未完成
|
||
... ELSE Exit For Loop
|
||
Sleep 60s
|
||
END
|
||
${work_status} Run Keyword And Return Status Wait Until Element Is Visible Xpath=//table[@lay-size="sm"]//tr[1]//div[text()="本次恢复成功 "]
|
||
Run Keyword If ${work_status}==False Fail
|
||
... ELSE Log 恢复成功
|
||
Sleep 15s
|
||
|
||
校验OracleRAC数据表
|
||
[Arguments] ${OracleRAC_TableName1} ${DBRACInstance_lin}
|
||
log 连接数据库
|
||
Connect To Database Using Custom Params cx_Oracle '${DBRACUser}','${DBRACPwd}','${DBRACInstance_lin}'
|
||
log 获取行数
|
||
${result} Row Count select * from ${OracleRAC_TableName1}
|
||
Execute Sql String select * from ${OracleRAC_TableName1}
|
||
Disconnect From Database
|
||
Run Keyword If "${result}"=="${rownum}" log 数据校验一致,恢复成功
|
||
... ELSE Fail 数据校验不一致,恢复失败
|
||
|
||
立即执行_OracleRAC
|
||
[Arguments] ${bk_type}
|
||
元素点击 ${Timed_DataProtect} 点击进入定时数据保护页面 定位定时数据保护失败
|
||
元素点击 ${dpm_Protection strategy} 切换到定时保护策略栏 定位定时保护策略功能栏失败
|
||
Sleep 2s
|
||
元素点击 xpath=//td[text()="${random_strategyName}"]/..//span[text()="立即执行"] 点击策略立即执行 定位立即执行失败
|
||
元素点击 ${Exe_Oracle_Bk} 点击展开立即执行下拉框 定位立即执行备份类型失败
|
||
Run Keyword If "${bk_type}"=="完全" 立即执行_完全备份
|
||
... ELSE IF "${bk_type}"=="差量" 立即执行_差量备份
|
||
... ELSE IF "${bk_type}"=="增量" 立即执行_增量备份
|
||
... ELSE IF "${bk_type}"=="日志" 立即执行_归档日志备份
|
||
Sleep 2s
|
||
元素点击 ${ExecutePolicy_execute} 点击立即执行确定按钮成功 点击立即执行确定按钮失败
|
||
Sleep 5s
|
||
元素点击 ${Complie_confirm} 点击确定按钮 定位确定按钮失败
|
||
元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
|
||
元素输入 ${Input_Policy_Name} ${random_strategyName} 输入策略名
|
||
FOR ${n} IN RANGE 10
|
||
Click Element ${Button_Searchbk}
|
||
${bk_status} Run Keyword And Return Status Wait Until Element Is Visible Xpath=//td[text()="${random_strategyName}"]/../td[contains(text(),"${bk_type}")]/../td[text()="已完成"]
|
||
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
|
||
|
||
立即执行_完全备份
|
||
Sleep 2s
|
||
Click Element ${Now Full_Bacup}
|
||
Log 勾选完全备份
|
||
|
||
立即执行_差量备份
|
||
Sleep 2s
|
||
Click Element ${Now Difference_Backup}
|
||
Log 勾选差量备份
|
||
|
||
立即执行_增量备份
|
||
Sleep 2s
|
||
Click Element ${Now Add_Backup}
|
||
Log 勾选增量备份
|
||
|
||
立即执行_归档日志备份
|
||
Sleep 2s
|
||
Click Element ${Now GD_Backup}
|
||
Log 勾选归档日志备份
|
||
|
||
插入OracleRAC数据
|
||
[Arguments] ${OracleRAC_TableName1} ${DBRACInstance_lin}
|
||
log 连接数据库
|
||
Connect To Database Using Custom Params cx_Oracle '${DBRACUser}','${DBRACPwd}','${DBRACInstance_lin}'
|
||
log 获取行数
|
||
${rowcount} Row Count select * from user_tables where table_name=upper('${OracleRAC_TableName1}')
|
||
Run Keyword If ${rowcount} >=1 Execute Sql String insert into ${OracleRAC_TableName1} select * from ${OracleRAC_TableName1}
|
||
${rownum} Row Count select * from ${OracleRAC_TableName1}
|
||
Set Suite Variable ${rownum}
|
||
Log ${rownum}
|
||
Disconnect From Database
|
||
|
||
关闭OracleRAC实例
|
||
[Arguments] ${ip} ${user} ${pwd}
|
||
Open Connection ${ip} 22
|
||
SSHLibrary.Login ${user} ${pwd}
|
||
Log 进入服务器
|
||
sleep 5s
|
||
Write srvctl stop database -d orcl
|
||
Sleep 60s
|
||
Close Connection
|