This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
dongxiaoyan-tsg-autotest/02-Keyword/tsg_mib/MibKeywords.robot

71 lines
2.4 KiB
Plaintext
Raw Normal View History

2020-04-13 19:29:32 +08:00
*** 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}