1*** Settings ***
2Documentation   Power cycle loop. This is to test where network service
3...             becomes unavailable during AC-Cycle stress test.
4
5Resource        ../lib/rest_client.robot
6Resource        ../lib/pdu/pdu.robot
7Resource        ../lib/utils.robot
8Resource        ../lib/openbmc_ffdc.robot
9Resource        ../lib/state_manager.robot
10Resource        ../lib/boot_utils.robot
11Resource        ../lib/code_update_utils.robot
12Library         ../lib/bmc_ssh_utils.py
13
14Test Teardown   Test Teardown Execution
15Suite Setup     Suite Setup Execution
16
17*** Variables ***
18${LOOP_COUNT}    ${50}
19
20*** Test Cases ***
21
22Run Multiple Power Cycle
23    [Documentation]  Execute multiple power cycles.
24    [Setup]  Validate Parameters
25    [Tags]  Run_Multiple_Power_Cycle
26
27    # By default run test for 50 loops, else user input iteration.
28    # Fails immediately if any of the execution rounds fail and
29    # check if BMC is still pinging and FFDC is collected.
30    Repeat Keyword  ${LOOP_COUNT} times  Power Cycle System Via PDU
31
32
33Run Multiple BMC Reset Via REST
34    [Documentation]  Execute multiple reboots via REST.
35    [Tags]  Run_Multiple_BMC_Reset_Via_REST
36
37    # By default run test for 50 loops, else user input iteration.
38    # Fails immediately if any of the execution rounds fail and
39    # check if BMC is still pinging and FFDC is collected.
40    Repeat Keyword  ${LOOP_COUNT} times  BMC REST Reset Cycle
41
42
43Run Multiple BMC Reset Via Reboot
44    [Documentation]  Execute multiple reboots via "reboot" command.
45    [Tags]  Run_Multiple_BMC_Reset_Via_Reboot
46
47    # By default run test for 50 loops, else user input iteration.
48    # Fails immediately if any of the execution rounds fail and
49    # check if BMC is still pinging and FFDC is collected.
50    Repeat Keyword  ${LOOP_COUNT} times  BMC Reboot Cycle
51
52
53*** Keywords ***
54
55Power Cycle System Via PDU
56    [Documentation]  Power cycle system and wait for BMC to reach Ready state.
57    Log  "Doing power cycle"
58    PDU Power Cycle
59    Check If BMC Is Up  5 min  10 sec
60
61    Wait Until Keyword Succeeds  10 min  10 sec  Is BMC Ready
62    Verify BMC RTC And UTC Time Drift
63    Field Mode Should Be Enabled
64
65
66BMC REST Reset Cycle
67    [Documentation]  Reset BMC via REST and wait for ready state.
68    Log  "Doing Reboot cycle"
69    ${bmc_version_before}=  Get BMC Version
70    Initiate BMC Reboot
71    Wait Until Keyword Succeeds  10 min  10 sec  Is BMC Ready
72    ${bmc_version_after}=  Get BMC Version
73    Should Be Equal  ${bmc_version_before}  ${bmc_version_after}
74    Verify BMC RTC And UTC Time Drift
75    Field Mode Should Be Enabled
76
77
78BMC Reboot Cycle
79    [Documentation]  Reboot BMC and wait for ready state.
80    Log  "Doing Reboot cycle"
81    ${bmc_version_before}=  Get BMC Version
82    OBMC Reboot (off)  stack_mode=normal
83    ${bmc_version_after}=  Get BMC Version
84    Should Be Equal  ${bmc_version_before}  ${bmc_version_after}
85    Verify BMC RTC And UTC Time Drift
86    Field Mode Should Be Enabled
87
88
89Test Teardown Execution
90    [Documentation]  Do test case tear-down.
91    Ping Host  ${OPENBMC_HOST}
92    FFDC On Test Case Fail
93
94    # Example of the u-boot-env o/p:
95    # root@witherspoon:~# grep fieldmode /dev/mtd/u-boot-env
96    # fieldmode=true
97    # fieldmode=true
98    ${field_mode}=
99    ...  BMC Execute Command  grep fieldmode /dev/mtd/u-boot-env
100    Should Contain  "${field_mode[0]}"  fieldmode=true
101    ...  msg=u-boot-env shows "fieldmode" is not set to true.
102
103
104Validate Parameters
105    [Documentation]  Validate PDU parameters.
106    Should Not Be Empty   ${PDU_IP}
107    Should Not Be Empty   ${PDU_TYPE}
108    Should Not Be Empty   ${PDU_SLOT_NO}
109    Should Not Be Empty   ${PDU_USERNAME}
110    Should Not Be Empty   ${PDU_PASSWORD}
111
112
113Suite Setup Execution
114    [Documentation]  Enable field mode.
115    Enable Field Mode And Verify Unmount
116    Field Mode Should Be Enabled
117