xref: /openbmc/openbmc-test-automation/network/test_cable_pull_recover.robot (revision 173afd0f937b78f12199647fbfbb2f1821b7f69f)
1*173afd0fSDaniel Gonzalez*** Settings ***
2*173afd0fSDaniel GonzalezDocumentation  Verify the port recovery by simulating its disconnection.
3*173afd0fSDaniel Gonzalez
4*173afd0fSDaniel Gonzalez# Test Parameters:
5*173afd0fSDaniel Gonzalez
6*173afd0fSDaniel Gonzalez# OS_HOST             The OS host name or IP Address.
7*173afd0fSDaniel Gonzalez# OS_USERNAME         The OS login userid (usually root).
8*173afd0fSDaniel Gonzalez# OS_PASSWORD         The OS login password.
9*173afd0fSDaniel Gonzalez# DEVICE_HOST         The network device hostname or IP where the ports will
10*173afd0fSDaniel Gonzalez#                     be shutdown.
11*173afd0fSDaniel Gonzalez# DEVICE_USERNAME     The network device username.
12*173afd0fSDaniel Gonzalez# DEVICE_PASSWORD     The network device password.
13*173afd0fSDaniel Gonzalez# PORT_NUMBER         The switch port where the server is connected (e.g.
14*173afd0fSDaniel Gonzalez#                     "1", "2", etc).
15*173afd0fSDaniel Gonzalez# NET_INTERFACE       The network interface name that will be tested (e.g.
16*173afd0fSDaniel Gonzalez#                     "enP5s1f0", "eth0").
17*173afd0fSDaniel Gonzalez
18*173afd0fSDaniel GonzalezLibrary         ../lib/bmc_ssh_utils.py
19*173afd0fSDaniel GonzalezResource        ../lib/resource.txt
20*173afd0fSDaniel GonzalezResource        ../syslib/utils_os.robot
21*173afd0fSDaniel Gonzalez
22*173afd0fSDaniel GonzalezSuite Setup     Test Setup Execution
23*173afd0fSDaniel Gonzalez
24*173afd0fSDaniel Gonzalez*** Variables ***
25*173afd0fSDaniel Gonzalez
26*173afd0fSDaniel Gonzalez${PORT_NUMBER}  ${EMPTY}
27*173afd0fSDaniel Gonzalez
28*173afd0fSDaniel Gonzalez*** Test Cases ***
29*173afd0fSDaniel Gonzalez
30*173afd0fSDaniel GonzalezVerify Network Interface Recovery
31*173afd0fSDaniel Gonzalez    [Documentation]  Test the recovery of the network interface that has been
32*173afd0fSDaniel Gonzalez    ...  shutdown from the switch port.
33*173afd0fSDaniel Gonzalez    [Tags]  Verify_Network_Interface_Recovery
34*173afd0fSDaniel Gonzalez
35*173afd0fSDaniel Gonzalez    Rprintn
36*173afd0fSDaniel Gonzalez    Set Switch Port State  DOWN
37*173afd0fSDaniel Gonzalez    Set Switch Port State  UP
38*173afd0fSDaniel Gonzalez
39*173afd0fSDaniel Gonzalez*** Keywords ***
40*173afd0fSDaniel Gonzalez
41*173afd0fSDaniel GonzalezSet Switch Port State
42*173afd0fSDaniel Gonzalez    [Documentation]  Disable the port connected to the server.
43*173afd0fSDaniel Gonzalez    [Arguments]  ${port_number}=${PORT_NUMBER}  ${state}=${EMPTY}
44*173afd0fSDaniel Gonzalez
45*173afd0fSDaniel Gonzalez    # Description of argument(s):
46*173afd0fSDaniel Gonzalez    # port_number     The switch port where the server is connected (e.g.
47*173afd0fSDaniel Gonzalez    #                 "1", "2", etc).
48*173afd0fSDaniel Gonzalez    # state           The state to be set in the network interface ("UP" or
49*173afd0fSDaniel Gonzalez    #                 "DOWN").
50*173afd0fSDaniel Gonzalez
51*173afd0fSDaniel Gonzalez    Device Write  enable
52*173afd0fSDaniel Gonzalez    Device Write  configure terminal
53*173afd0fSDaniel Gonzalez    Device Write  interface port ${PORT_NUMBER}
54*173afd0fSDaniel Gonzalez    Run Keyword If  '${state}' == 'DOWN'
55*173afd0fSDaniel Gonzalez    ...    Device Write  shutdown
56*173afd0fSDaniel Gonzalez    ...  ELSE
57*173afd0fSDaniel Gonzalez    ...    Device Write  no shutdown
58*173afd0fSDaniel Gonzalez    Wait Until Keyword Succeeds  30 sec  5 sec
59*173afd0fSDaniel Gonzalez    ...  Check Network Interface State  ${state}
60*173afd0fSDaniel Gonzalez
61*173afd0fSDaniel GonzalezCheck Network Interface State
62*173afd0fSDaniel Gonzalez    [Documentation]  Check the status of the network interface.
63*173afd0fSDaniel Gonzalez    [Arguments]  ${NET_INTERFACE}=${NET_INTERFACE}  ${state}=${EMPTY}
64*173afd0fSDaniel Gonzalez
65*173afd0fSDaniel Gonzalez    # Description of argument(s):
66*173afd0fSDaniel Gonzalez    # NET_INTERFACE   The network interface name that will be tested (e.g.
67*173afd0fSDaniel Gonzalez    #                 "enP5s1f0", "eth0").
68*173afd0fSDaniel Gonzalez    # state           The network interface expected state ("UP" or "DOWN").
69*173afd0fSDaniel Gonzalez
70*173afd0fSDaniel Gonzalez    ${stdout}  ${stderr}  ${rc}=  OS Execute Command
71*173afd0fSDaniel Gonzalez    ...  ip link | grep "${NET_INTERFACE}" | cut -d " " -f9
72*173afd0fSDaniel Gonzalez    Should Contain  ${stdout}  ${state}  msg=State not found as expected.
73*173afd0fSDaniel Gonzalez
74*173afd0fSDaniel GonzalezTest Setup Execution
75*173afd0fSDaniel Gonzalez    [Documentation]  Do suite setup tasks.
76*173afd0fSDaniel Gonzalez
77*173afd0fSDaniel Gonzalez    Should Not Be Empty  ${PORT_NUMBER}
78*173afd0fSDaniel Gonzalez    Should Not Be Empty  ${NET_INTERFACE}
79