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