XYZ Network: Base test automation
This change includes:
1. Validating IP address.
2. Validating Prefix length value.
3. Validating route details.
4. Validating MAC address.
This resolves openbmc/openbmc-test-automation#684
Change-Id: Idec61d70c42d796c825985e13fa0814c4a95f2c2
Signed-off-by: Prashanth Katti <prkatti1@in.ibm.com>
diff --git a/data/variables.py b/data/variables.py
index 759bc6c..feed8bc 100644
--- a/data/variables.py
+++ b/data/variables.py
@@ -16,6 +16,7 @@
USER_MANAGER_URI = OPENBMC_BASE_URI + 'UserManager/'
NETWORK_MANAGER_URI = OPENBMC_BASE_URI + 'NetworkManager/'
TIME_MANAGER_URI = OPENBMC_BASE_URI + 'TimeManager/'
+XYZ_NETWORK_MANAGER = '/xyz/openbmc_project/network/'
# State Manager base variables.
BMC_REBOOT_TRANS = 'xyz.openbmc_project.State.BMC.Transition.Reboot'
@@ -43,9 +44,6 @@
# Software manager version
SOFTWARE_VERSION_URI = '/xyz/openbmc_project/software/'
ACTIVE = 'xyz.openbmc_project.Software.Activation.Activations.Active'
-READY = 'xyz.openbmc_project.Software.Activation.Activations.Ready'
-INVALID = 'xyz.openbmc_project.Software.Activation.Activations.Invalid'
-ACTIVATING = 'xyz.openbmc_project.Software.Activation.Activations.Activating'
# Inventory URI
HOST_INVENTORY_URI = '/xyz/openbmc_project/inventory/'
diff --git a/lib/bmc_network_utils.robot b/lib/bmc_network_utils.robot
index 3ea269f..231fbff 100644
--- a/lib/bmc_network_utils.robot
+++ b/lib/bmc_network_utils.robot
@@ -41,3 +41,58 @@
Should Be Equal ${bmc_mac_addr} ${mac_address} ignore_case=True
###############################################################################
+
+Get BMC IP Info
+ [Documentation] Get system IP address and prefix length.
+
+ Open Connection And Login
+
+ # Get system IP address and prefix length details using "ip addr"
+ # Sample Output of "ip addr":
+ # 1: eth0: <BROADCAST,MULTIAST> mtu 1500 qdisc mq state UP qlen 1000
+ # link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
+ # inet xx.xx.xx.xx/24 brd xx.xx.xx.xx scope global eth0
+
+ ${cmd_output}= Execute Command On BMC /sbin/ip addr | grep eth0
+
+ # Get line having IP address details.
+ ${lines}= Get Lines Containing String ${cmd_output} inet
+
+ # List IP address details.
+ @{ip_components}= Split To Lines ${lines}
+
+ @{ip_data}= Create List
+
+ # Get all IP addresses and prefix lengths on system.
+ :FOR ${ip_component} IN @{ip_components}
+ \ @{if_info}= Split String ${ip_component}
+ \ ${ip_n_prefix}= Get From List ${if_info} 1
+ \ Append To List ${ip_data} ${ip_n_prefix}
+
+ [Return] ${ip_data}
+
+Get BMC Route Info
+ [Documentation] Get system route info.
+
+ Open Connection And Login
+
+ # Sample output of "ip route":
+ # default via xx.xx.xx.x dev eth0
+ # xx.xx.xx.0/23 dev eth0 src xx.xx.xx.xx
+ # xx.xx.xx.0/24 dev eth0 src xx.xx.xx.xx
+
+ ${cmd_output}= Execute Command On BMC /sbin/ip route
+
+ [Return] ${cmd_output}
+
+Get BMC MAC Address
+ [Documentation] Get system MAC address.
+
+ Open Connection And Login
+
+ # Sample output of "ip addr | grep ether":
+ # link/ether xx.xx.xx.xx.xx.xx brd ff:ff:ff:ff:ff:ff
+
+ ${cmd_output}= Execute Command On BMC /sbin/ip addr | grep ether
+
+ [Return] ${cmd_output}
diff --git a/test_lists/skip_test_barreleye b/test_lists/skip_test_barreleye
index 8699afc..50bfbcf 100644
--- a/test_lists/skip_test_barreleye
+++ b/test_lists/skip_test_barreleye
@@ -42,3 +42,6 @@
-e Test_Power_LED_And_Verify_Via_REST
-e Test_Fault_LED_And_Verify_Via_REST
-e Verify_Enclosure_Fault_LED_On_Assertion
+# Network tests for xyz interface.
+# https://github.com/openbmc/openbmc-test-automation/issues/729
+-e Network_Test
diff --git a/test_lists/skip_test_palmetto b/test_lists/skip_test_palmetto
index f5fccb2..84392d4 100644
--- a/test_lists/skip_test_palmetto
+++ b/test_lists/skip_test_palmetto
@@ -49,3 +49,6 @@
-e Test_Beep_LED_And_Verify_Via_REST
-e Test_Fault_LED_And_Verify_Via_REST
-e Verify_Enclosure_Fault_LED_On_Assertion
+# Network tests for xyz interface.
+# https://github.com/openbmc/openbmc-test-automation/issues/729
+-e Network_Test
diff --git a/test_lists/skip_test_witherspoon b/test_lists/skip_test_witherspoon
index 347ebe7..cd2173a 100644
--- a/test_lists/skip_test_witherspoon
+++ b/test_lists/skip_test_witherspoon
@@ -55,3 +55,6 @@
-e Test_Heartbeat_LED_And_Verify_Via_REST
-e Test_Beep_LED_And_Verify_Via_REST
-e Test_Identify_LED_And_Verify_Via_REST
+# Network tests for xyz interface.
+# https://github.com/openbmc/openbmc-test-automation/issues/729
+-e Network_Test
diff --git a/tests/test_network.robot b/tests/test_network.robot
new file mode 100644
index 0000000..246ef22
--- /dev/null
+++ b/tests/test_network.robot
@@ -0,0 +1,120 @@
+*** Settings ***
+Documentation Network interface and functionalities test module.
+
+Resource ../lib/rest_client.robot
+Resource ../lib/utils.robot
+Resource ../lib/bmc_network_utils.robot
+
+Force Tags Network_Test
+
+Library String
+Library SSHLibrary
+
+Test Setup Test Init Setup
+
+*** Test Cases ***
+
+Get BMC IPv4 Address And Verify
+ [Documentation] Get BMC IPv4 address and verify.
+ [Tags] Get_BMC_IPv4_Address_And_Verify
+
+ :FOR ${ipv4_uri} IN @{IPv4_URI_List}
+ \ ${ipv4_addr}= Read Attribute ${ipv4_uri} Address
+ \ Validate IP on BMC ${ipv4_addr}
+
+Verify IPv4 Prefix Length
+ [Documentation] Get prefix length and verify.
+ [Tags] Verify_IPv4_Prefix_Length
+
+ :FOR ${ipv4_uri} IN @{IPv4_URI_List}
+ \ ${prefix_length}= Read Attribute ${ipv4_uri} PrefixLength
+ \ Validate Prefix Length On BMC ${prefix_length}
+
+Verify Gateway Address
+ [Documentation] Get gateway address and verify.
+ [Tags] Verify_Gateway_Address
+
+ :FOR ${ipv4_uri} IN @{IPv4_URI_List}
+ \ ${gw_ip}= Read Attribute ${ipv4_uri} Gateway
+ \ Validate Route On BMC ${gw_ip}
+
+Verify MAC Address
+ [Documentation] Get MAC address and verify.
+ [Tags] Verify_MAC_Address
+ ${macaddr}= Read Attribute ${XYZ_NETWORK_MANAGER}/eth0 MACAddress
+ Validate MAC On BMC ${macaddr}
+
+*** Keywords ***
+
+Test Init Setup
+ [Documentation] Network setup.
+ Open Connection And Login
+
+ @{IPv4_URI_List}= Get IPv4 URI List
+ Set Test Variable @{IPv4_URI_List}
+
+ # Get BMC IP address and prefix length.
+ ${ip_data}= Get BMC IP Info
+ Set Test Variable ${ip_data}
+
+Get IPv4 URI List
+ [Documentation] Get all IPv4 URIs.
+
+ # Sample output:
+ # "data": [
+ # "/xyz/openbmc_project/network/eth0/ipv4/e9767624",
+ # "/xyz/openbmc_project/network/eth0/ipv4/31f4ce8b"
+ # ],
+
+ @{ipv4_uri_list}= Read Properties ${XYZ_NETWORK_MANAGER}/eth0/ipv4/
+ Should Not Be Empty ${ipv4_uri_list} msg=IPv4 URI list is empty.
+
+ [Return] @{ipv4_uri_list}
+
+Validate IP on BMC
+ [Documentation] Validate IP on BMC.
+ [Arguments] ${ip_address}
+
+ # Description of the argument(s):
+ # ip_address IP address of the system.
+ # ip_data Suite variable which has list of IP address
+ # and prefix length values.
+
+ Should Contain Match ${ip_data} ${ip_address}*
+ ... msg=IP address does not exist.
+
+Validate Prefix Length On BMC
+ [Documentation] Validate prefix length on BMC.
+ [Arguments] ${prefix_length}
+
+ # Description of the argument(s):
+ # prefix_length It indicates netmask, netmask value 255.255.255.0
+ # is equal to prefix length 24.
+ # ip_data Suite variable which has list of IP address and
+ # prefix length values.
+
+ Should Contain Match ${ip_data} */${prefix_length}
+ ... msg=Prefix length does not exist.
+
+Validate Route On BMC
+ [Documentation] Validate route.
+ [Arguments] ${gw_ip}
+
+ # Description of the argument(s):
+ # gw_ip Gateway IP address.
+
+ ${route_info}= Get BMC Route Info
+ Should Contain ${route_info} ${gw_ip}
+ ... msg=Gateway IP address not matching.
+
+Validate MAC on BMC
+ [Documentation] Validate MAC on BMC.
+ [Arguments] ${macaddr}
+
+ # Description of the argument(s):
+ # macaddr MAC address of the BMC.
+
+ ${system_mac}= Get BMC MAC Address
+
+ Should Contain ${system_mac} ${macaddr}
+ ... ignore_case=True msg=MAC address does not exist.