2020-04-01 12:42:05 +08:00
*** Settings ***
Library json
Library String
Library DateTime
Library SSHLibrary
Library Collections
Library RequestsLibrary
Library Selenium2Library
2020-06-11 09:26:43 +08:00
Resource ../../03-Variable/BifangApiVariable.txt
2020-04-01 12:42:05 +08:00
*** Variables ***
2020-04-02 14:19:25 +08:00
# 指令前缀
2020-04-01 12:42:05 +08:00
${Tsg_Policy} tsg_policy
${Tsg_Policy_Object} tsg_policy_object
${Tsg_Record} tsg_record
${Tsg_Show} tsg_show
${Tsg_Passwd} tsg_passwd
2020-04-02 14:19:25 +08:00
# tsg_help指令返回值对比文件路径
2020-04-01 12:42:05 +08:00
${Tsg_Help_file_Path} cli_files/tsg_help.txt
2020-04-02 14:19:25 +08:00
# tsg_show指令查询时附加sql条件
2020-04-28 17:03:28 +08:00
${Tsg_Show_Added_Sql} "order by time desc limit 1"
2020-04-24 11:17:09 +08:00
${Tsg_Show_Added_Sql_Query} --query
2020-04-02 14:19:25 +08:00
# tsg_show指令返回数据flowType和sled参数值
${Tsg_Show_FlowType_Values} inline|intercomm|mirror
${Tsg_Show_Sled_Values} mcn0|mcn1|mcn2|mcn3
2020-04-01 12:42:05 +08:00
*** Keywords ***
Get_Policy_Object1
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述: 获取SecurityPolicy数据
... 参数: type(策略类型)
... 返回:除默认策略外的任意单条策略
2020-04-01 12:42:05 +08:00
[Arguments] ${type}
${dict} Tsg_Policy_Query ${type} ${None} ${None} ${None} ${True}
Should Be True ${dict}[data][total] > 1
2020-04-14 15:42:54 +08:00
${list} Evaluate list(${dict}[data][list])[1:11]
[Return] ${list}
2020-04-01 12:42:05 +08:00
Get_Policy_Object2
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述: 获取ProxyManipulationPolicy数据
... 参数: type(策略类型)
... 返回:任意单条策略
2020-04-01 12:42:05 +08:00
[Arguments] ${type}
${dict} Tsg_Policy_Query ${type} ${None} ${None} ${None} ${True}
2020-04-21 19:07:05 +08:00
${list} Evaluate list(${dict}[data][list])[1:11]
2020-04-14 15:42:54 +08:00
[Return] ${list}
2020-04-01 12:42:05 +08:00
2020-04-02 14:19:25 +08:00
Get_Policy_Object3
[Documentation]
... 描述:用于执行'tsg_policy --enable/disable ...'指令前的数据获取
... 参数: type(策略类型)
... 返回: policyId(策略ID)、commandType1(enable/disable, 修改)、commandType2(enable/disable, 还原)
2020-04-01 12:42:05 +08:00
[Arguments] ${type}
2020-04-14 15:42:54 +08:00
#${obj} Get_Policy_Object1 ${type}
${dict} Tsg_Policy_Query ${type} ${None} ${None} ${None} ${True}
Should Be True ${dict}[data][total] > 1
${obj} Set Variable ${dict}[data][list][1]
2020-04-01 12:42:05 +08:00
${commandType1} Run Keyword If ${obj}[isValid]==0 Set Variable enable
... ELSE Set Variable disable
${commandType2} Run Keyword If ${obj}[isValid]==1 Set Variable enable
... ELSE Set Variable disable
Set To Dictionary ${obj} commandType1=${commandType1} commandType2=${commandType2}
[Return] ${obj}
Get_Policy_Object4
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述: 获取Object数据
... 参数: type(对象类型)
... 返回:任意单条对象
2020-04-01 12:42:05 +08:00
[Arguments] ${type}
${dict} Tsg_Policy_Object_Query ${type} ${None} ${True}
2020-04-14 15:42:54 +08:00
${list} Evaluate list(${dict}[data][list])[:10]
[Return] ${list}
2020-04-01 12:42:05 +08:00
Get_File_Name
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:拼接对象数据导出时的文件名
... 参数: ObjectType(对象类型) FileType(txt|csv)
... 返回:文件名称
2020-04-01 12:42:05 +08:00
[Arguments] ${ObjectType} ${FileType}
2020-04-02 14:19:25 +08:00
${date} Get Current Date
2020-04-01 12:42:05 +08:00
${date_stamp} Convert Date ${date} epoch
${time} Evaluate int(round(${date_stamp} * 1000))
${filename} Set Variable ${ObjectType}_export_${time}.${FileType}
[Return] ${filename}
Get_Import_Info
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:随机生成对象数据导入时的对象名称
... 参数: type(对象类型)
... 返回:对象名称
2020-04-01 12:42:05 +08:00
[Arguments] ${type}
${date} Get Current Date
${date_stamp} Convert Date ${date} epoch
${time} Evaluate int(round(${date_stamp} * 1000))
${name} Set Variable ${type}_import_${time}
[Return] ${name}
Tsg_Policy_Query
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_policy --query ...'指令
... 参数: type(策略类型) param(非必传,最大参数数量为四位,依次顺序为'policyId'、'policyName'、'policyDesc'和'allFlag',中间存在为空参数可用'None'占位)
... 返回:查询响应数据
2020-04-01 12:42:05 +08:00
[Arguments] ${type} @{params}
${str} Evaluate '${Tsg_Policy} --query --policyType %s ' % ('${type}')
${str} Run Keyword If '${params}[0]' != '${None}' Evaluate '${str}--policyId %s ' % ('${params}[0]')
... ELSE Set Variable ${str}
${str} Run Keyword If '${params}[1]' != '${None}' Evaluate '${str}--policyName "%s" ' % ('${params}[1]')
... ELSE Set Variable ${str}
${str} Run Keyword If '${params}[2]' != '${None}' Evaluate '${str}--policyDesc "%s" ' % ('${params}[2]')
... ELSE Set Variable ${str}
${str} Run Keyword If ${params}[3] == ${True} Evaluate '${str}--all '
... ELSE Set Variable ${str}
Log ${str}
${r} Run1 ${str}
[Return] ${r}
Tsg_Policy_EnDisable
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_policy --enable/disable ...'指令
... 参数: id(策略ID) type(策略类型) commandType(enable|disable)
... 返回:无
2020-04-01 12:42:05 +08:00
[Arguments] ${id} ${type} ${commandType}
${str} Evaluate '${Tsg_Policy} --%s --policyId %s --policyType %s' % ('${commandType}', '${id}', '${type}')
2020-04-02 14:19:25 +08:00
Run2 ${str}
# 数据更改后做查询验证
${r} Tsg_Policy_Query ${type} ${id} ${None} ${None} ${True}
${value} Run Keyword If '${commandType}'=='disable' Convert To Integer 0
... ELSE Convert To Integer 1
2020-04-07 16:57:57 +08:00
#Should Be Equal ${r}[data][list][0][isValid] ${value}
Run Keyword If '${cliUsername}'=='tsgadmin' Should Be Equal ${r}[data][list][0][isValid] ${value}
2020-04-01 12:42:05 +08:00
Tsg_Policy_Object_Query
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_policy_object --query ...'指令
... 参数: param(非必传,最大参数数量为三位,依次顺序为'objectName'、'objectType'和'allFlag',中间存在为空参数可用'None'占位)
... 返回:查询响应数据
2020-04-01 12:42:05 +08:00
[Arguments] @{params}
${str} Set Variable ${Tsg_Policy_Object} --query
${str} Run Keyword If '${params}[0]' != '${None}' Evaluate '${str} --objectType "%s" ' % ('${params}[0]')
... ELSE Set Variable ${str}
${str} Run Keyword If '${params}[1]' != '${None}' Evaluate '${str} --objectName "%s" ' % ('${params}[1]')
... ELSE Set Variable ${str}
${str} Run Keyword If ${params}[2] == ${True} Evaluate '${str} --all '
... ELSE Set Variable ${str}
${r} Run1 ${str}
[Return] ${r}
Tsg_Policy_Object_Import
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_policy_object --import ...'指令
... 参数: type(对象类型) file(导入文件名称) params(对象名称)
... 返回:无
2020-04-01 12:42:05 +08:00
[Arguments] ${type} ${file} @{params}
${newFile} Replace String ${file} export import
${command} Set Variable head -n 2 files/${file} > files/${newFile}
Run4 ${command}
${str} Evaluate '${Tsg_Policy_Object} --import --objectType %s --file files/%s ' % ('${type}','${newFile}')
${str} Run Keyword If '${params}[0]' != '${None}' Evaluate '${str}--objectName %s ' % ('${params}[0]')
... ELSE Set Variable ${str}
2020-04-02 14:19:25 +08:00
Run3 ${str}
# 数据导入后做查询验证
Tsg_Policy_Object_Query ${type} ${params}[0] ${True}
2020-04-01 12:42:05 +08:00
Tsg_Policy_Object_Export
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_policy_object --export ...'指令
... 参数: type(对象类型) file(导出文件名称) params(txt|csv)
... 返回:无
2020-04-01 12:42:05 +08:00
[Arguments] ${type} ${file} @{params}
${str} Evaluate '${Tsg_Policy_Object} --export --objectType %s --file files/%s ' % ('${type}','${file}')
${str} Run Keyword If '${params}[0]' != '${None}' Evaluate '${str}--exportFormat %s ' % ('${params}[0]')
... ELSE Set Variable ${str}
Run3 ${str}
Tsg_Record_UserList
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_record --userlist'指令
... 参数:无
... 返回:无
2020-04-01 12:42:05 +08:00
${str} Set Variable ${Tsg_Record} --userlist
Run6 ${str} ${cliUsername}
Tsg_Record_Query
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_record --username'指令
... 参数:无
... 返回:无
2020-04-01 12:42:05 +08:00
${str} Evaluate '${Tsg_Record} --username %s ' % ('${cliUsername}')
${param} Set Variable ${Tsg_Record} --userlist
Run6 ${str} ${param}
Clear_Test_Data
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:清除测试对象导出功能时的文件
... 参数:无
... 返回:无
2020-04-01 12:42:05 +08:00
${str} Set Variable rm -rf /home/${cliUsername}/files/*
Run4 ${str}
Tsg_Help_Keyword
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_help'指令,并验证返回值
... 参数:无
... 返回:无
${r} Run9 tsg_help
2020-04-15 16:10:00 +08:00
${data} Evaluate str(open(r"${path}/${Tsg_Help_file_Path}",'rb').read())
${data} Evaluate ${data.replace('\\n', '\\r\\n')}
Should Be Equal As Strings ${r} ${data}
2020-04-01 12:42:05 +08:00
Tsg_Diagnose_Keyword
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_diagnose'指令
... 参数:无
... 返回:无
# 执行'text'指令,在'timeout'时间内每隔'retry_interval'时间重试,直至返回值出现'expected'时或超时结束
Write Until Expected Output tsg_diagnose\n Success ${timeout} ${retryInterval}
2020-04-01 12:42:05 +08:00
2020-04-14 15:42:54 +08:00
Tsg_Command_Help
[Documentation]
... 描述:执行'* --help'指令,并验证返回值
... 参数:无
... 返回:无
[Arguments] ${cmd}
${str} Set Variable ${cmd} --help
${r} Run9 ${str}
2020-04-15 16:10:00 +08:00
${data} Evaluate str(open(r"${path}/cli_files/${cmd}_help.txt",'rb').read(), 'utf-8')
Should Be Equal As Strings ${r} ${data}
2020-04-14 15:42:54 +08:00
2020-04-01 12:42:05 +08:00
Tsg_Show_Chassis-ip
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_show --chassis-ip'指令,并验证返回值
... 参数:无
... 返回:无
2020-04-01 12:42:05 +08:00
${str} Set Variable ${Tsg_Show} --chassis-ip
2020-04-02 14:19:25 +08:00
${r} Run9 ${str}
Should Contain ${r} mxn
Should Contain ${r} mcn0
Should Contain ${r} mcn1
Should Contain ${r} mcn2
Should Contain ${r} mcn3
2020-04-01 12:42:05 +08:00
Tsg_Show_Chassis-port
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_show --chassis-port'指令,并验证返回值
... 参数:无
... 返回:无
2020-04-01 12:42:05 +08:00
${str} Set Variable ${Tsg_Show} --chassis-port
2020-04-02 14:19:25 +08:00
${r} Run9 ${str}
Should Contain Any ${r} physical backplane
Should Contain Any ${r} inline mirror business intercomm
Time_Check
[Documentation]
... 描述:验证时间是否正确
... 参数: str(时间列值) start(起始时间,用于验证) end(结束时间,用于验证)
... 返回:无
[Arguments] ${str} ${start} ${end}
# 处理'time'返回值, 例2020-03-31T09:19:05.445123Z
${str} Get Substring ${str} 0 -4
${date} Add Time To Date ${str} 08:00:00
${time} Evaluate int(time.mktime(time.strptime('${date}', '%Y-%m-%d %H:%M:%S.%f'))) time
# 处理时间范围
${start} Add Time To Date ${start} -00:10:00
${end} Add Time To Date ${end} 00:10:00
${minTime} Convert Date ${start} epoch
${maxTime} Convert Date ${end} epoch
Should Be True ${minTime} < ${time} < ${maxTime}
2020-04-01 12:42:05 +08:00
Tsg_Show_Interface
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_show --interface'指令,并验证返回值
... 参数:无
... 返回:无
2020-04-24 11:17:09 +08:00
${str} Set Variable ${Tsg_Show} --interface -- ${Tsg_Show_Added_Sql} ${Tsg_Show_Added_Sql_Query}
2020-04-02 14:19:25 +08:00
${stime} Get Time
@{list} Run5 ${str}
${etime} Get Time
FOR ${obj} IN @{list}
2020-04-28 19:51:12 +08:00
#Time_Check ${obj}[time] ${stime} ${etime}
2020-04-02 14:19:25 +08:00
Should Contain ${Tsg_Show_FlowType_Values} ${obj}[flow_type]
Should Contain ${Tsg_Show_Sled_Values} ${obj}[sled]
END
2020-04-01 12:42:05 +08:00
Tsg_Show_APP
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_show --app'指令,并验证返回值
... 参数:无
... 返回:无
2020-04-24 11:17:09 +08:00
${str} Set Variable ${Tsg_Show} --app -- ${Tsg_Show_Added_Sql} ${Tsg_Show_Added_Sql_Query}
2020-04-02 14:19:25 +08:00
${stime} Get Time
@{list} Run5 ${str}
${etime} Get Time
FOR ${obj} IN @{list}
2020-04-28 19:51:12 +08:00
#Time_Check ${obj}[time] ${stime} ${etime}
2020-04-02 14:19:25 +08:00
Should Contain ${Tsg_Show_FlowType_Values} ${obj}[flow_type]
Should Contain ${Tsg_Show_Sled_Values} ${obj}[sled]
END
2020-04-01 12:42:05 +08:00
Tsg_Show_Protocol
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_show --protocol'指令,并验证返回值
... 参数:无
... 返回:无
2020-04-24 11:17:09 +08:00
${str} Set Variable ${Tsg_Show} --protocol -- ${Tsg_Show_Added_Sql} ${Tsg_Show_Added_Sql_Query}
2020-04-02 14:19:25 +08:00
${stime} Get Time
@{list} Run5 ${str}
${etime} Get Time
FOR ${obj} IN @{list}
2020-04-28 19:51:12 +08:00
#Time_Check ${obj}[time] ${stime} ${etime}
2020-04-02 14:19:25 +08:00
Should Contain ${Tsg_Show_FlowType_Values} ${obj}[flow_type]
Should Contain ${Tsg_Show_Sled_Values} ${obj}[sled]
END
2020-04-01 12:42:05 +08:00
Tsg_Show_Stream
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_show --stream'指令,并验证返回值
... 参数:无
... 返回:无
2020-04-24 11:17:09 +08:00
${str} Set Variable ${Tsg_Show} --stream -- ${Tsg_Show_Added_Sql} ${Tsg_Show_Added_Sql_Query}
2020-04-02 14:19:25 +08:00
${stime} Get Time
@{list} Run5 ${str}
${etime} Get Time
FOR ${obj} IN @{list}
2020-04-28 19:51:12 +08:00
#Time_Check ${obj}[time] ${stime} ${etime}
2020-04-02 14:19:25 +08:00
Should Contain ${Tsg_Show_FlowType_Values} ${obj}[flow_type]
Should Contain ${Tsg_Show_Sled_Values} ${obj}[sled]
END
2020-04-01 12:42:05 +08:00
Tsg_Show_Intercept
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_show --intercept'指令,并验证返回值
... 参数:无
... 返回:无
2020-04-24 11:17:09 +08:00
${str} Set Variable ${Tsg_Show} --intercept -- ${Tsg_Show_Added_Sql} ${Tsg_Show_Added_Sql_Query}
2020-04-02 14:19:25 +08:00
${stime} Get Time
@{list} Run5 ${str}
${etime} Get Time
FOR ${obj} IN @{list}
2020-04-28 19:51:12 +08:00
#Time_Check ${obj}[time] ${stime} ${etime}
2020-04-02 14:19:25 +08:00
Should Contain ${Tsg_Show_Sled_Values} ${obj}[sled]
END
2020-04-01 12:42:05 +08:00
Tsg_Passwd_Keyword
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:执行'tsg_show --passwd'指令,更改密码并验证
... 参数:无
... 返回:无
# 修改密码
2020-04-01 12:42:05 +08:00
${str1} Evaluate '${Tsg_Passwd} --password %s' % ('${cliPassword}x')
Run7 ${str1}
${str2} Evaluate '${Tsg_Passwd} --password %s --username %s' % ('${cliPassword}y','${cliUsername}')
2020-04-02 14:19:25 +08:00
Run7 ${str2}
Close Connection
# 登录验证
Open Connection ${cliHost}
SSHLibrary.Login ${cliUsername} ${cliPassword}y
# 复原密码
2020-04-01 12:42:05 +08:00
${str3} Evaluate '${Tsg_Passwd} --password %s' % ('${cliPassword}')
2020-04-02 14:19:25 +08:00
Run8 ${str3}
2020-04-01 12:42:05 +08:00
Run1
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:运行指令,将返回值处理后返回
... 参数: command(具体指令内容)
... 返回:响应数据,字典
2020-04-01 12:42:05 +08:00
[Arguments] ${command}
Write ${command}
${r} Read delay=10s
${dict} Run Keyword If '${cliUsername}'!='tsgadmin' Run1_A ${r}
... ELSE Run1_B ${r}
[Return] ${dict}
Run1_A
[Arguments] ${r}
2020-04-07 16:57:57 +08:00
Should Contain ${r} command not found
2020-04-01 12:42:05 +08:00
${dict} To Json {"data":{"list":[{"policyDesc":"","policyId":0,"policyName":"","policyType":"","objectType":"","objectName":"","isValid":0},{"policyDesc":"","policyId":0,"policyName":"","policyType":"","isValid":0}],"total":2},"msg":"Success"}
[Return] ${dict}
Run1_B
[Arguments] ${r}
Should Contain ${r} Success
${str} Replace String ${r} ${\n} -
${str} Replace String ${str} ' \\'
2020-06-18 10:06:08 +08:00
#${index} Evaluate '${str}'.rindex('}') + 1
#${len} Convert To Integer ${index}
#${json} Evaluate '${str}'[0:${len}]
#${testStr} Catenate ''' ${str} '''
#${testIndex3} Evaluate ${testStr}.rindex('}')
#Log ${testIndex3}
#${len} Convert To Integer ${testIndex3}
#${json} Get Substring ${str} 0 ${len}
${testStr1} Catenate ''' ${str} '''
${testIndex3} Evaluate ${testStr1}.rindex('-') - 1
Log ${testIndex3}
${len} Convert To Integer ${testIndex3}
${json} Get Substring ${str} 0 ${len}
Log ${json}
2020-04-01 12:42:05 +08:00
${dict} json.Loads ${json}
Should Be True ${dict}[data][total] > 0
[Return] ${dict}
Run2
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:运行指令,并验证返回值
... 参数: command(具体指令内容)
... 返回:无
2020-04-01 12:42:05 +08:00
[Arguments] ${command}
Write ${command}
${r} Read delay=10s
2020-04-07 16:57:57 +08:00
Run Keyword If '${cliUsername}'!='tsgadmin' Should Contain ${r} command not found
2020-04-01 12:42:05 +08:00
... ELSE Should Contain ${r} Success
Run3
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:运行指令,并验证返回值
... 参数: command(具体指令内容)
... 返回:无
2020-04-01 12:42:05 +08:00
[Arguments] ${command}
2020-04-07 16:57:57 +08:00
${flag} Run Keyword If '${cliUsername}'!='tsgadmin' Set Variable command not found
2020-04-01 12:42:05 +08:00
... ELSE Set Variable Success
2020-04-02 14:19:25 +08:00
# 执行'text'指令,在'timeout'时间内每隔'retry_interval'时间重试,直至返回值出现'expected'时或超时结束
Write Until Expected Output ${command}\n ${flag} ${timeout} ${retryInterval}
Read delay=5s
2020-04-01 12:42:05 +08:00
Run4
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:运行指令,并验证返回值
... 参数: command(具体指令内容)
... 返回:无
2020-04-01 12:42:05 +08:00
[Arguments] ${command}
Write ${command}
${r} Read delay=10s
2020-04-07 16:57:57 +08:00
Run Keyword If '${cliUsername}'!='tsgadmin' Should Contain Any ${r} command not found -bash:
2020-04-01 12:42:05 +08:00
... ELSE Should Not Contain ${r} head:
Run5
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:运行指令,并验证返回值
... 参数: command(具体指令内容)
... 返回:响应数据,列表
2020-04-01 12:42:05 +08:00
[Arguments] ${command}
Write ${command}
${r} Read delay=10s
Should Not Be Empty ${r}
2020-05-08 13:55:18 +08:00
#用换行符作为命令结束
2020-05-08 13:51:03 +08:00
${str} Replace String ${r} ${\n} -
2020-06-18 10:06:08 +08:00
2020-05-08 13:51:03 +08:00
${index} Evaluate '${str}'.rindex('-')
2020-04-02 14:19:25 +08:00
${len} Convert To Integer ${index}
2020-05-08 13:51:03 +08:00
${json} Evaluate '${str}'[0:${len}]
2020-05-08 13:55:18 +08:00
#cli命令结果返回结束为换行使用下面截取
2020-05-08 13:51:03 +08:00
#${index} Evaluate '${r}'.rindex('tsgcli >')
#${len} Convert To Integer ${index}
#${json} Evaluate '${r}'[0:${len}]
2020-04-02 14:19:25 +08:00
${dict} json.Loads ${json}
${list} Convert To List ${dict}
[Return] ${list}
2020-04-01 12:42:05 +08:00
Run6
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:运行指令,并验证返回值
... 参数: command(具体指令内容) param(预期内容,用于验证)
... 返回:无
2020-04-01 12:42:05 +08:00
[Arguments] ${command} ${param}
Write ${command}
${r} Read delay=10s
Should Not Be Empty ${r}
2020-04-07 16:57:57 +08:00
Run Keyword If '${cliUsername}'!='tsgadmin' Should Contain ${r} command not found
2020-04-01 12:42:05 +08:00
... ELSE Should Contain ${r} ${param}
Run7
2020-04-02 14:19:25 +08:00
[Documentation]
... 描述:运行指令,并验证返回值
... 参数: command(具体指令内容)
... 返回:无
2020-04-01 12:42:05 +08:00
[Arguments] ${command}
Write ${command}
${r} Read delay=10s
Should Contain ${r} Success
2020-04-02 14:19:25 +08:00
Run8
[Documentation]
... 描述:运行指令,并验证返回值
... 参数: command(具体指令内容)
... 返回:无
[Arguments] ${command}
# 执行'text'指令,在'timeout'时间内每隔'retry_interval'时间重试,直至返回值出现'expected'时或超时结束
Write Until Expected Output ${command}\n Success ${timeout} ${retryInterval}
Read delay=5s
Run9
[Documentation]
... 描述:运行指令,并验证返回值
... 参数: command(具体指令内容)
... 返回:无
[Arguments] ${command}
Write ${command}
${r} Read delay=10s
Should Not Be Empty ${r}
[Return] ${r}
2020-04-14 15:42:54 +08:00
QueryObjectInnerForEach
# 循环嵌套
[Arguments] ${objectType}
${list} Get_Policy_Object4 ${objectType}
# 取最多10条策略对象数据, 分别做条件查询
FOR ${obj} IN @{list}
Tsg_Policy_Object_Query ${None} ${obj}[objectName] ${True}
Tsg_Policy_Object_Query ${obj}[objectType] ${None} ${True}
Tsg_Policy_Object_Query ${obj}[objectType] ${obj}[objectName] ${True}
END