diff --git a/01-TestCase/tsg_mib/MibTestCase.robot b/01-TestCase/tsg_mib/MibTestCase.robot new file mode 100644 index 0000000..4484896 --- /dev/null +++ b/01-TestCase/tsg_mib/MibTestCase.robot @@ -0,0 +1,62 @@ +*** Settings *** +Test Setup OpenMibConnection +Test Teardown CloseMibConnection +Library json +Library String +Library Collections +Resource ../../03-Variable/BifangApiVariable.txt +Resource ../../02-Keyword/tsg_mib/MibKeywords.robot + +*** Test Cases *** +ScalarObjects_TestCase + # hwRRCTEMP + CheckMibByOid1 1.3.6.1.4.1.54450.1.2 int + # hwCMMTEMP + CheckMibByOid1 1.3.6.1.4.1.54450.1.3 int + # hwP1V + CheckMibByOid1 1.3.6.1.4.1.54450.1.4 float + # hwPVDDS + CheckMibByOid1 1.3.6.1.4.1.54450.1.5 float + # hwPVDDF + CheckMibByOid1 1.3.6.1.4.1.54450.1.6 float + # hwP3V3 + CheckMibByOid1 1.3.6.1.4.1.54450.1.7 float + # hwP5V + CheckMibByOid1 1.3.6.1.4.1.54450.1.8 float + # hwP12V + CheckMibByOid1 1.3.6.1.4.1.54450.1.9 float + # hwP1VRT + CheckMibByOid1 1.3.6.1.4.1.54450.1.10 float + # hwFan1 + CheckMibByOid1 1.3.6.1.4.1.54450.1.11 int + # hwFan2 + CheckMibByOid1 1.3.6.1.4.1.54450.1.12 int + # hwFan3 + CheckMibByOid1 1.3.6.1.4.1.54450.1.13 int + +TabularObjects_TestCase + # hwMCNTable + CheckMibByOid2 1.3.6.1.4.1.54450.1.100 21 + # cpuTable + CheckMibByOid2 1.3.6.1.4.1.54450.2.100 7 + # memTable + CheckMibByOid2 1.3.6.1.4.1.54450.3.100 6 + # dskTable + CheckMibByOid2 1.3.6.1.4.1.54450.4.100 6 + # netTable + CheckMibByOid2 1.3.6.1.4.1.54450.5.100 6 + # interfaceTable + CheckMibByOid2 1.3.6.1.4.1.54450.6.100 13 + # appTable + CheckMibByOid2 1.3.6.1.4.1.54450.7.100 9 + # protocolTable + CheckMibByOid2 1.3.6.1.4.1.54450.8.100 13 + # streamTable + CheckMibByOid2 1.3.6.1.4.1.54450.9.100 9 + +Notification_TestCase + # genTrap + CheckMibByOid3 1.3.6.1.4.1.54450.15.1 + # thresholdTrap + CheckMibByOid3 1.3.6.1.4.1.54450.15.2 + diff --git a/02-Keyword/tsg_bfapi/LoginLogout.robot b/02-Keyword/tsg_bfapi/LoginLogout.robot index 81662d1..46f8b18 100644 --- a/02-Keyword/tsg_bfapi/LoginLogout.robot +++ b/02-Keyword/tsg_bfapi/LoginLogout.robot @@ -84,5 +84,5 @@ CliLogin CliLogout [Tags] tsg_cli cli_logout Close Connection - Log Close connection - #exit \ No newline at end of file + Log Close CLI Connection + \ No newline at end of file diff --git a/02-Keyword/tsg_common/LoginAndLogoutTypeSwitch.robot b/02-Keyword/tsg_common/LoginAndLogoutTypeSwitch.robot index 212a015..87073a4 100644 --- a/02-Keyword/tsg_common/LoginAndLogoutTypeSwitch.robot +++ b/02-Keyword/tsg_common/LoginAndLogoutTypeSwitch.robot @@ -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 diff --git a/02-Keyword/tsg_mib/MibKeywords.robot b/02-Keyword/tsg_mib/MibKeywords.robot new file mode 100644 index 0000000..7553321 --- /dev/null +++ b/02-Keyword/tsg_mib/MibKeywords.robot @@ -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} diff --git a/03-Variable/BifangApiVariable.txt b/03-Variable/BifangApiVariable.txt index 5946f59..b009b8e 100644 --- a/03-Variable/BifangApiVariable.txt +++ b/03-Variable/BifangApiVariable.txt @@ -1,5 +1,5 @@ *** Variables *** -#ui登陆还是api登陆 +#登录类型:api | cli | ${None}(tsg mib) | 未指定,默认为ui ${loginType} api #执行环境是否Widonws ${systemType} Windows @@ -46,6 +46,13 @@ ${cliHost} 192.168.40.165 ${cliUsername} tsgadmin ${cliPassword} Cli2019 ${timeout} 600s -${retryInterval} 300s +${retryInterval} 300s +@{PolicyTypes} tsg_security pxy_manipulation @{ObjectTypes} ip url fqdn keywords subscriberid fqdn_category account http_signature # Cli自动化测试变量[end] +# SNMP服务测试变量[start] +${snmpHost} 192.168.40.165 +${snmpPort} 50161 +${snmpConnTimeout} 5 # 默认超时时间为6s,设置timeout值后超时时间为n*6s +${snmpCommunity} public +# SNMP服务测试变量[end]