robotframework-demo/Project/task4/Resource/RE3_DPM/KeyWord_MongoDB.robot

194 lines
9.5 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

*** Settings ***
Resource ElementPath.robot
Resource ../RE0_Common/KeyWord.robot
Library Selenium2Library
Library DatabaseLibrary
Library MongoDBLibrary
Resource ../RE0_Common/KeyWord.robot
*** Keywords ***
创建MongoDB数据表
[Arguments] ${Mongo_DB_User} ${Mongo_DB_PWD} ${Mongo_Host_IP} ${Mongo_Host_Port} ${DB_Name} ${DB_Collname}
Connect To Mongodb mongodb://${MongoDB_DB_User}:${MongoDB_DB_PWD}@${Mongo_Host_IP} ${MongoDB_port}
Drop MongoDB Collection ${DB_Name} ${DB_Collname}
${Results} Save MongoDB Records ${DB_Name} ${DB_Collname} {"name":"unaryAutoTest"}
log ${Results}
${allResults} Retrieve All MongoDB Records ${DB_Name} ${DB_Collname} Ture
Set Test Variable ${allResults}
Log ${allResults}
Disconnect From Mongodb
sleep 2s
删除MongoDB数据表
[Arguments] ${Mongo_DB_User} ${Mongo_DB_PWD} ${Mongo_Host_IP} ${Mongo_Host_Port} ${DB_Name} ${DB_Collname}
Connect To Mongodb mongodb://${Mongo_DB_User}:${Mongo_DB_PWD}@${Mongo_Host_IP} ${MongoDB_port}
Drop MongoDB Collection ${DB_Name} ${DB_Collname}
Disconnect From Mongodb
sleep 2s
校验MongoDB数据表
[Arguments] ${Mongo_DB_User} ${Mongo_DB_PWD} ${Mongo_Host_IP} ${Mongo_Host_Port} ${DB_Name} ${DB_Collname}
Connect To Mongodb mongodb://${Mongo_DB_User}:${Mongo_DB_PWD}@${Mongo_Host_IP} ${MongoDB_port}
${allReclResults} Retrieve All MongoDB Records ${DB_Name} ${DB_Collname} Ture
Log ${allReclResults}
Log ${allResults}
Run Keyword If "${allReclResults}"=="${allResults}" Log MongoDB恢复成功数据内容一致
... ELSE Fail MongoDB恢复失败数据内容不一致
Disconnect From Mongodb
sleep 2s
完全备份
[Arguments] ${agent_name} ${username} ${password} ${mds_name} ${encryption_attr} ${compress_attr} ${dedup_attr}
元素点击 ${Timed_DataProtect} 点击进入定时数据保护栏 定位定时数据保护栏失败
${date} Evaluate time.strftime('%Y%m%d%H%M%S',time.localtime()) time
${random_strategyName}= Catenate SEPARATOR=_ 完全 ${date}
${createpolicy} Catenate SEPARATOR= 新建了策略[ ${random_strategyName} ]
Set Suite Variable ${random_strategyName}
Set Suite Variable ${createpolicy}
Sleep 5s
元素点击 xpath=//span[text()="${agent_name}"] 点击选择代理 定位代理所在位置失败
元素点击 ${dpm_Protection strategy} 点击进入保护策略页面 定位保护策略按钮失败
元素点击 ${Add_Policy} 点击添加策略按钮 定位添加策略按钮失败
元素点击 ${MongoDB_Module} 点击选择MongoDB备份 定位MongoDB备份选项失败
元素输入 ${Set_PolicyName} ${random_strategyName} 定位策略名输入框失败
元素输入 ${Input_MongoDB_username} ${username} 定位用户名输入框失败
元素输入 ${Input_MongoDB_password} ${password} 定位密码输入框失败
元素点击 ${Connection credentials_Next} 点击下一步进入目标数据库页面 定位下一步按钮失败
Sleep 5s
元素点击 ${Select_MongoDB_dbname} 勾选需要备份数据库 定位需要备份数据库失败
元素点击 ${Target_database_Next_MongoDB} 点击下一步进入任务周期页面 定位下一步按钮失败
log 设置任务周期
元素点击 ${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
循环点击 ${MongoDB_Complete_CreatePolicy} ${Success_Confirm}
sleep 2s
元素点击 ${Success_Confirm} 确定策略创建成功 策略创建失败
sleep 2s
元素点击 ${BackupSet} 点击进入备份集一栏 定位备份集栏失败
Wait Until Page Contains Element xpath=//*[@id="backupSetTable"]//tr[2]/td[text()="已完成"] 180s 备份未完成
Log 备份完成
Sleep 2s
完全恢复
[Arguments] ${recover_username} ${recover_password} ${cache}
sleep 5s
循环点击 ${BackupSet} ${Click_recover}
元素点击 ${Click_recover} 点击恢复按钮 定位恢复按钮失败
元素输入 ${Input_Recover_MongoDB_username} ${recover_username} 定位用户名输入框失败
元素输入 ${Input_Recover_MongoDB_password} ${recover_password} 定位密码输入框失败
元素点击 ${Recover_Nextstep_Mongodb} 点击下一步进入恢复高级选项界面 定位下一步按钮失败
Sleep 5s
Run Keyword If ${cache}==1 恢复缓存 /opt
Sleep 2s
元素点击 ${MongoDB_Recover_run} 确定完成恢复策略创建 恢复执行定位失败
Sleep 2s
元素点击 ${confirm_restore} 点击确认恢复成功 点击确认恢复失败
元素点击 ${Success_Confirm} 恢复策略确定创建成功 恢复作业创建成功弹窗定位失败
元素点击 ${Policy_Work} 点击进入作业栏 定位作业栏失败
Wait Until Page Contains Element ${Recover_Success} 240s 恢复失败
sleep 2s
Log 恢复成功
加密
Sleep 2s
元素点击 ${MongoDB_Encrypt} 勾选加密 定位选项选项失败
Sleep 2s
取消压缩
Log 不勾选压缩
勾选压缩
Sleep 2s
Set Focus To Element ${MongoDB_Compress}
Click Element ${MongoDB_Compress}
Log 点击勾选压缩
Sleep 2s
重删
Sleep 2s
元素点击 ${MongoDB_Deduped} 勾选重删 定位重删选项失败
Log 点击重删
Sleep 2s
备份缓存
[Arguments] ${path}
元素点击 ${MongoDB_Change_Cache_Path} 点击更改缓存路径 定位更改缓存路径 选项失败
元素输入 ${MongoDB_Cache_Path} ${path} 定位缓存路径输入框失败
元素点击 ${MongoDB_Fin_CachePath} 缓存路径设置完毕 定位缓存路径设置确定按钮失败
恢复缓存
[Arguments] ${path}
元素点击 ${Recover_Cache} 勾选缓存 定位缓存选项失败
元素输入 ${Recover_CachePath} ${path} 定位缓存路径输入框失败
元素点击 ${Fin_Recover_CachePath} 缓存路径设置完毕 定位缓存路径设置确定按钮失败
Sleep 2s
取消备份缓存
Sleep 2s
Set Focus To Element ${Active_Cache}
Click Element ${Active_Cache}
Log 取消缓存
Sleep 2s
备份集属性校验
[Arguments] ${encryption} ${compress} ${deduped} ${cache}
sleep 2s
元素点击 Xpath=//td[text()="${random_strategyName}"]/..//span[text()="详情"] 点击展开详情 定位详情失败
Run Keyword If ${encryption}==1 加密属性校验_是
... ELSE 加密属性校验_否
Run Keyword If ${compress}==1 压缩属性校验_是
... ELSE 压缩属性校验_否
Run Keyword If ${deduped}==1 重删属性校验_是
... ELSE 重删属性校验_否
Run Keyword If ${cache}==1 缓存属性校验_是
... ELSE 缓存属性校验_否
元素点击 ${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 备份集未设置缓存