305 lines
16 KiB
Plaintext
305 lines
16 KiB
Plaintext
*** Settings ***
|
||
Resource ElementPath.robot # DPM xpath路径
|
||
Library Selenium2Library
|
||
Library DatabaseLibrary
|
||
Resource ../RE0_Common/ElementPath.robot # 公共xpath
|
||
Resource ../RE0_Common/KeyWord.robot # 公共关键字
|
||
|
||
*** Keywords ***
|
||
SQLServer备份
|
||
[Arguments] ${Sqlserver_Agent} ${bk_type} ${mds_name} ${encryption_attr} ${compress_attr} ${dedup_attr} ${check_attr}
|
||
[Documentation] 功能:添加SQLserver备份策略,等待备份完成,产生备份集
|
||
...
|
||
... 使用方法:SQLserver备份
|
||
...
|
||
... 变量:${Sqlserver_Agent}代理名 | ${bk_type}备份类型 | ${mds_name}介质名 | ${encryption_attr}是否加密 | ${compress_attr}是否压缩 | ${dedup_attr}是否重删 | ${check_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()="${Sqlserver_Agent}"] 点击选择代理 定位sqlserver代理失败
|
||
元素点击 ${Add_Policy} 点击添加策略 定位添加策略按钮失败
|
||
元素点击 ${Sqlserver_Module} 点击选择Sqlserver模块 定位sqlserver模块失败
|
||
元素输入 ${Input_celuename} ${random_strategyName} 定位策略名输入框失败
|
||
元素点击 ${Sqlserver_Conn_NextStep} 点击下一步进入到实例选择页面 定位连接凭据下一步失败
|
||
Sleep 5s
|
||
元素点击 ${Sqlserver__NextStep} 点击下一步进入到目标数据库选择页面 定位实例选择下一步失败
|
||
元素点击 xpath=//span[contains(text(),'yy')]/../..//td[@width="20px"]/div[@class="dhx_bg_img_fix"] 点击勾选数据库 定位要备份的数据库失败
|
||
元素点击 ${SQLServer_mbdata next} 点击下一步进入任务周期 定位目标数据库下一步失败
|
||
元素点击 ${Add_taskcycle} 点击添加任务周期 定位添加任务周期按钮失败
|
||
Run Keyword If "${bk_type}"=="完全" 完全备份
|
||
... ELSE IF "${bk_type}"=="差量" 差量备份
|
||
... ELSE IF "${bk_type}"=="日志" 日志备份
|
||
... ELSE Fail 定位备份类型失败
|
||
元素点击 ${Cycle_Once} 设置任务仅执行一次 定位仅执行一次失败
|
||
元素点击 ${Cycle_Confirm} 确定任务周期设置完毕 定位任务周期设置失败
|
||
元素点击 ${Cycle_NextStep} 点击下一步进入备份集存储设置界面 定位下一步失败
|
||
元素点击 ${Manual_ChooseMDS} 点击勾选手动选择介质 定位选择介质失败
|
||
元素点击 ${Select_Sqlserver_MDS} 点击介质选择按钮 定位介质选择按钮失败
|
||
元素点击 xpath=//select[@id="dialogues_addCycleStorage_storagePath_selectMedia_selectedMdsIP_select"]/option[@label="${mds_name}"] 点击选择指定介质 定位指定介质失败
|
||
Run Keyword If ${dedup_attr}==1 重删
|
||
... ELSE log 不勾选重删
|
||
sleep 5s
|
||
元素点击 ${Storage_NextStep} 点击下一步进入到备份高级选项 定位下一步失败
|
||
Run Keyword If ${encryption_attr}==1 加密
|
||
... ELSE log 不加密
|
||
Run Keyword If ${compress_attr}==0 压缩
|
||
... ELSE IF ${compress_attr}==1 取消压缩
|
||
Run Keyword If ${check_attr}==1 校验
|
||
... ELSE log 不进行校验
|
||
元素点击 ${Senior_NextStep} 点击下一步进入到消息确认页面 定位备份高级选项下一步失败
|
||
元素点击 ${Success_Confirm} 点击确定按钮成功 点击确定按钮失败
|
||
sleep 6s
|
||
Comment 元素点击 ${Success_Confirm} 确定策略创建成功 策略创建失败
|
||
Comment 元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
|
||
Comment Sleep 60s
|
||
Comment Wait Until Page Contains Element Xpath=//td[4][text()="${random_strategyName}"]/..//td[text()="已完成"] 300s 备份未完成
|
||
Comment Log 备份完成
|
||
Comment Sleep 2s
|
||
元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
|
||
元素输入 ${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
|
||
|
||
SQLServer恢复
|
||
元素点击 ${BackupSet} 点击进入备份集恢复页面 定位备份集栏失败
|
||
Sleep 2s
|
||
元素点击 ${Click_recover} 点击恢复指定备份集 定位要恢复的备份集失败
|
||
Sleep 7s
|
||
元素点击 ${Recover_Target_NextStep_Sqlserver} 点击下一步进入到实例选择界面 定位恢复目标下一步失败
|
||
元素点击 ${Recover_Instance_NextStep} 点击下一步进入到高级选项界面 定位实例选择界面下一步失败
|
||
元素点击 ${Recover_Senior_NextStep} 点击下一步进入到确认恢复界面 定位高级选项下一步失败
|
||
元素点击 ${confirm_restore} 点击确定恢复确认按钮成功 点击确定恢复确认按钮失败
|
||
元素点击 ${Success_Confirm} 点击确认恢复成功 点击确认恢复失败
|
||
sleep 10s
|
||
元素点击 ${Policy_Work} 点击进入作业栏 定位作业栏失败
|
||
Sleep 60s
|
||
Wait Until Page Contains Element ${Recover_Success} 240s 恢复失败
|
||
sleep 2s
|
||
Log 恢复成功
|
||
|
||
创建SQLServer数据表
|
||
[Arguments] ${Sql_TableName1} ${Sql_IP_Remote} ${Sql_DB_User} ${Sql_DB_PWD} ${Sql_DB} #SQL表名#SQL代理IP#SQL数据库用户#SQL数据库密码#SQL数据库
|
||
[Documentation] 功能:连接SQLserver数据库,删除原有表、新建表后插入数据
|
||
...
|
||
... 使用方法:创建SQLserver数据表 表名
|
||
...
|
||
... 变量: ${DPM_MSSql_TableName1}表名
|
||
Connect To Database Using Custom Params pymssql host='${Sql_IP_Remote}',port='1433',user='${Sql_DB_User}',password='${Sql_DB_PWD}',database='${Sql_DB}',charset='CP936'
|
||
${row_count}= Row Count SELECT \ * FROM dbo.SysObjects WHERE ID = object_id(N'${Sql_TableName1}') AND OBJECTPROPERTY(ID, 'IsTable') = 1;
|
||
Run Keyword IF ${row_count}>0 Execute Sql String drop table ${Sql_TableName1};
|
||
log 执行sql建表
|
||
Execute Sql String create table ${Sql_TableName1}(id int,dt int)
|
||
log 插入数据
|
||
Execute Sql String insert into ${Sql_TableName1} values(1, 11111)
|
||
log 建表完成
|
||
${row_num}= Row Count select * from ${Sql_TableName1};
|
||
log ${row_num}
|
||
Disconnect From Database
|
||
|
||
删除SQLServer数据表
|
||
[Arguments] ${Sql_TableName1} ${Sql_IP_Remote} ${Sql_DB_User} ${Sql_DB_PWD} ${Sql_DB} #SQL表名#SQL代理IP#SQL数据库用户#SQL数据库密码#SQL数据库
|
||
Connect To Database Using Custom Params pymssql host='${Sql_IP_Remote}',user='${Sql_DB_User}',password='${Sql_DB_PWD}',database='${Sql_DB}'
|
||
${row_count} Row Count SELECT \ * FROM dbo.SysObjects WHERE ID = object_id(N'${Sql_TableName1}') AND OBJECTPROPERTY(ID, 'IsTable') = 1;
|
||
Run Keyword IF ${row_count}>0 Execute Sql String drop table ${Sql_TableName1};
|
||
Disconnect From Database
|
||
|
||
校验SQLServer数据表
|
||
[Arguments] ${Sql_TableName1} ${Sql_IP_Remote} ${Sql_DB_User} ${Sql_DB_PWD} ${Sql_DB} #SQL表名#SQL代理IP#SQL数据库用户#SQL数据库密码#SQL数据库
|
||
sleep 10s
|
||
Connect To Database Using Custom Params pymssql host='${Sql_IP_Remote}',user='${Sql_DB_User}',password='${Sql_DB_PWD}',database='${Sql_DB}'
|
||
log 查询表
|
||
${row_num} Row Count select * from ${Sql_TableName1};
|
||
log ${row_num}
|
||
Disconnect From Database
|
||
|
||
SQLServer差量备份
|
||
元素点击 ${dpm_Protection strategy} 选择定时保护策略 定位定时保护策略失败
|
||
元素点击 xpath=//td[text()="${random_strategyName}"]/..//span[text()="立即执行"] 点击立即执行 定位立即执行失败
|
||
元素点击 ${Select_BackType} 点击选择备份类型 定位选择备份类型失败
|
||
元素点击 ${Now Difference_Backup} 选择差量备份 定位差量备份失败
|
||
元素点击 ${Now Sure} 点击立即执行确定 定位立即执行确定失败
|
||
元素点击 ${Success_Confirm} 点击确定 定位确定失败
|
||
log 开始备份
|
||
Sleep 60s
|
||
元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
|
||
Sleep 60s
|
||
Wait Until Page Contains Element Xpath=//td[4][text()="${random_strategyName}"]/..//td[text()="SQLServer差量备份"]/..//td[text()="已完成"] 300s 备份未完成
|
||
Log 备份完成
|
||
Sleep 2s
|
||
|
||
SQLServer事务备份
|
||
元素点击 ${dpm_Protection strategy} 选择定时保护策略 定位定时保护策略失败
|
||
元素点击 xpath=//td[text()="${random_strategyName}"]/..//span[text()="立即执行"] 点击立即执行 定位立即执行失败
|
||
元素点击 ${Select_BackType} 点击选择备份类型 定位选择备份类型失败
|
||
元素点击 ${Now Difference_Backup} 选择差量备份 定位差量备份失败
|
||
元素点击 ${Now Sure} 点击立即执行确定 定位立即执行确定失败
|
||
元素点击 ${Success_Confirm} 点击确定 定位确定失败
|
||
log 开始备份
|
||
Sleep 60s
|
||
元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
|
||
Sleep 60s
|
||
Wait Until Page Contains Element Xpath=//td[4][text()="${random_strategyName}"]/..//td[text()="SQLServer差量备份"]/..//td[text()="已完成"] 300s 备份未完成
|
||
Log 备份完成
|
||
Sleep 2s
|
||
|
||
插入SQLServer数据
|
||
[Arguments] ${Sql_TableName1} ${Sql_IP_Remote} ${Sql_DB_User} ${Sql_DB_PWD} ${Sql_DB} #SQL表名#SQL代理IP#SQL数据库用户#SQL数据库密码#SQL数据库
|
||
log 连接数据库
|
||
Connect To Database Using Custom Params pymssql host='${Sql_IP_Remote}',user='${Sql_DB_User}',password='${Sql_DB_PWD}',database='${Sql_DB}',charset='CP936'
|
||
${row_count} Row Count SELECT \ * FROM dbo.SysObjects WHERE ID = object_id(N'${Sql_TableName1}') AND OBJECTPROPERTY(ID, 'IsTable') = 1;
|
||
Run Keyword IF ${row_count}>0 Execute Sql String insert into ${Sql_TableName1} values(2, 11111)
|
||
log 插入数据
|
||
Execute Sql String insert into ${Sql_TableName1} values(3, 11111)
|
||
log 数据插入完成
|
||
${row_num} Row Count select * from ${Sql_TableName1};
|
||
log ${row_num}
|
||
Disconnect From Database
|
||
|
||
完全备份
|
||
Sleep 2s
|
||
Click Element ${Full_Backup}
|
||
Log 勾选完全备份
|
||
|
||
差量备份
|
||
Sleep 2s
|
||
Click Element ${Difference_Backup}
|
||
Log 勾选差量备份
|
||
|
||
日志备份
|
||
Sleep 2s
|
||
Click Element ${SQLServer_sw}
|
||
Log 勾选日志备份
|
||
|
||
加密
|
||
元素点击 ${Sqlserver_Encryption} 点击勾选sqlserver加密 定位sqlserver加密选项失败
|
||
|
||
压缩
|
||
Log 点击压缩
|
||
|
||
重删
|
||
Sleep 2s
|
||
元素点击 ${Option_Dedup} 勾选重删 定位重删选项失败
|
||
Log 点击重删
|
||
Sleep 2s
|
||
|
||
校验
|
||
Set Focus To Element ${Option_Check}
|
||
Click Element ${Option_Check}
|
||
Log 勾选校验选项
|
||
Sleep 2s
|
||
|
||
SQLServer立即执行
|
||
[Arguments] ${bk_type} # 立即执行备份类型
|
||
元素点击 ${Timed_DataProtect} 点击进入定时数据保护页面 定位定时数据保护失败
|
||
元素点击 ${dpm_Protection strategy} 切换到定时保护策略栏 定位定时保护策略功能栏失败
|
||
Sleep 2s
|
||
元素点击 xpath=//td[text()="${random_strategyName}"]/..//span[text()="立即执行"] 点击策略立即执行 定位立即执行失败
|
||
元素点击 ${Select_BackType} 点击展开立即执行下拉框 定位立即执行备份类型失败
|
||
Run Keyword If "${bk_type}"=="1" 立即执行_完全
|
||
... ELSE IF "${bk_type}"=="2" 立即执行_差量
|
||
... ELSE IF "${bk_type}"=="3" 立即执行_事务日志
|
||
Sleep 2s
|
||
循环点击 ${ExecutePolicy_execute} ${Complie_confirm}
|
||
Sleep 5s
|
||
元素点击 ${Complie_confirm} 点击确定按钮 定位确定按钮失败
|
||
元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
|
||
Comment Sleep 60s
|
||
Comment Wait Until Page Contains Element xpath=//*[@id="backupSetTable"]//tr[2]/td[text()="已完成"] 300s 备份未完成
|
||
Comment Log 备份完成
|
||
Comment Sleep 5s
|
||
元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
|
||
元素输入 ${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
|
||
|
||
立即执行_完全
|
||
元素点击 ${Now Full_Bacup} 点击立即执行完全备份 定位完全备份选项失败
|
||
|
||
立即执行_差量
|
||
元素点击 ${Now Difference_Backup} 点击立即执行差量备份 定位差量备份选项失败
|
||
|
||
立即执行_事务日志
|
||
元素点击 ${Now SW_Backup} 点击立即执行事务日志备份 定位事务日志备份选项失败
|
||
|
||
取消压缩
|
||
Set Focus To Element ${Option_Compress}
|
||
Click Element ${Option_Compress}
|
||
Log 取消备份集压缩压缩
|
||
|
||
备份集属性校验
|
||
[Arguments] ${encryption} ${compress} ${deduped}
|
||
sleep 2s
|
||
元素点击 Xpath=//td[text()="${random_strategyName}"]/..//span[text()="详情"] 点击展开详情 定位详情失败
|
||
sleep 5s
|
||
Run Keyword If ${encryption}==1 加密属性校验_是
|
||
... ELSE 加密属性校验_否
|
||
Run Keyword If ${compress}==1 压缩属性校验_是
|
||
... ELSE 压缩属性校验_否
|
||
Run Keyword If ${deduped}==1 重删属性校验_是
|
||
... ELSE 重删属性校验_否
|
||
元素点击 ${Attr_Cancel} 点击取消关闭备份集详情弹窗 定位取消按钮失败
|
||
Log 备份集属性确认完毕
|
||
Sleep 2s
|
||
|
||
加密属性校验_是
|
||
sleep 3s
|
||
Element Should Contain ${Encryption_Attr} 是
|
||
Log 加密属性校验完毕
|
||
|
||
加密属性校验_否
|
||
sleep 3s
|
||
Element Should Contain ${Encryption_Attr} 否
|
||
Log 备份集未加密
|
||
|
||
压缩属性校验_是
|
||
sleep 3s
|
||
Element Should Contain ${Compress_Attr} 是
|
||
Log 压缩属性校验完毕
|
||
|
||
压缩属性校验_否
|
||
sleep 3s
|
||
Element Should Contain ${Compress_Attr} 否
|
||
Log 备份集未压缩
|
||
|
||
重删属性校验_是
|
||
sleep 3s
|
||
Element Should Contain ${SQLserver_Deduped_Attr} 是
|
||
Log 重删属性校验完毕
|
||
|
||
重删属性校验_否
|
||
sleep 3s
|
||
Element Should Contain ${SQLserver_Deduped_Attr} 否
|
||
Log 备份集未重删
|
||
|
||
缓存属性校验_是
|
||
Element Should Contain ${Cache_Attr} 是
|
||
Log 缓存属性校验完毕
|
||
|
||
缓存属性校验_否
|
||
Element Should Contain ${Cache_Attr} 否
|
||
Log 备份集未设置缓存
|