feat(MIB):增加TSG MIB测试用例

This commit is contained in:
zhangwenqing
2020-04-13 19:29:32 +08:00
parent 3a50d9ad12
commit ab49f10b0e
5 changed files with 150 additions and 11 deletions

View File

@@ -84,5 +84,5 @@ CliLogin
CliLogout
[Tags] tsg_cli cli_logout
Close Connection
Log Close connection
#exit
Log Close CLI Connection

View File

@@ -13,13 +13,13 @@ LoginAndAddLocalIP
# 获取主机IP
#${ip} Get Host IP
#Run Keyword If '${ip}' != '${EMPTY}' Set Global Variable ${testClentIP} ${ip}
Run Keyword If '${loginType}' == 'api' ApiLoginAndAddLocalIP
... ELSE IF '${loginType}' == 'cli' CliLogin
... ELSE UiLoginAndAaddLocalIP
Run Keyword If '${loginType}' == 'api' ApiLoginAndAddLocalIP
... ELSE IF '${loginType}' == 'cli' CliLogin
... ELSE IF '${loginType}' != '${None}' UiLoginAndAaddLocalIP
LogoutAndDelLocalIP
[Tags] tsg_adc tsg_bf_api tsg_cli
Run Keyword If '${loginType}' == 'api' ApiLogoutAndDelLocalIP
... ELSE IF '${loginType}' == 'cli' CliLogout
... ELSE UiLogoutAndDelLocalIP
Run Keyword If '${loginType}' == 'api' ApiLogoutAndDelLocalIP
... ELSE IF '${loginType}' == 'cli' CliLogout
... ELSE IF '${loginType}' != '${None}' UiLoginAndAaddLocalIP

View File

@@ -0,0 +1,70 @@
*** Settings ***
Library json
Library String
Library SnmpLibrary
Library SSHLibrary
Library Collections
Resource ../../03-Variable/BifangApiVariable.txt
*** Keywords ***
OpenMibConnection
Open Snmp V2c Connection host=${snmpHost} community_string=${snmpCommunity} port=${snmpPort} timeout=${snmpConnTimeout}
# Open Snmp V3 Connection host=192.168.40.165 user=unsec port=50161
# Open Snmp V3 Connection host=192.168.40.165 user=SHA port=50161 timeout=3
# ... password=SHAAuthPP
# ... authentication_protocol=SHA
# Open Snmp V3 Connection host=192.168.40.165 user=SHADES port=50161 timeout=3
# ... password=SHADESAuthPP
# ... encryption_password=SHADESPrivPP
# ... authentication_protocol=SHA
# ... encryption_protocol=DES
CloseMibConnection
Close Snmp Connection
Log Close MIB Connection
CheckMibByOid1
[Documentation]
... 校验命令是否正常返回,且字段类型是否正确
[Arguments] ${oid} ${type}
${value} Walk .${oid}
# 断言返回值不能为空
Should Not Be Empty ${value}
${length} Get Length ${value}
Should Be True ${length} > 0
# 判断返回是否包含OID
${obj1} Set Variable ${value}[0]
Should Contain ${obj1}[0] ${oid}
# 判断返回值类型是否正确int/float/str
${flag} Evaluate type(${obj1}[1]) is ${type}
Should Be True ${flag}
CheckMibByOid2
[Documentation]
... 校验命令是否正常返回,且字段总数是否正确
[Arguments] ${oid} ${total}
${value} Walk .${oid}
# 断言返回值不能为空
Should Not Be Empty ${value}
${list} Convert To List ${value}
${length} Get Length ${list}
Should Be True ${length} > 0
# 判断是否返回所有的项
${index} Set Variable
FOR ${var} IN @{list}
Should Contain ${var}[0] ${oid}
Should Not Be Empty ${var}[1]
${nums} Evaluate re.split('[.]', '${var}[0]') re
${index} Evaluate ${nums[len(${nums})-2]}
END
Should Be True ${index} == ${total}
CheckMibByOid3
[Documentation]
... 校验命令是否正常返回
[Arguments] ${oid}
${value} Walk .${oid}
Log ${value}