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|FAILURE|Failed to start
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 Redfish
37    [Documentation]  Execute multiple reboots via REST.
38    [Tags]  Run_Multiple_BMC_Reset_Via_Redfish
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 Redfish 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
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
67
68BMC Redfish Reset Cycle
69    [Documentation]  Reset BMC via Redfish and verify required states.
70
71    Redfish OBMC Reboot (off)
72    ${bmc_version}=  Get BMC Version
73    Valid Value  bmc_version  ["${initial_bmc_version}"]
74    Check For Regex In Journald  ${ERROR_REGEX}  error_check=${0}  boot=-b
75    Verify BMC RTC And UTC Time Drift
76    ${boot_side}=  Get BMC Flash Chip Boot Side
77    Valid Value  boot_side  ['0']
78
79
80BMC Reboot Cycle
81    [Documentation]  Reboot BMC and wait for ready state.
82
83    OBMC Reboot (off)  stack_mode=normal
84    ${bmc_version}=  Get BMC Version
85    Valid Value  bmc_version  ["${initial_bmc_version}"]
86    Verify BMC RTC And UTC Time Drift
87    Check For Regex In Journald  ${ERROR_REGEX}  error_check=${0}  boot=-b
88    ${boot_side}=  Get BMC Flash Chip Boot Side
89    Valid Value  boot_side  ['0']
90
91
92Test Teardown Execution
93    [Documentation]  Do test case tear-down.
94    Ping Host  ${OPENBMC_HOST}
95    FFDC On Test Case Fail
96
97
98Validate Parameters
99    [Documentation]  Validate PDU parameters.
100    Should Not Be Empty   ${PDU_IP}
101    Should Not Be Empty   ${PDU_TYPE}
102    Should Not Be Empty   ${PDU_SLOT_NO}
103    Should Not Be Empty   ${PDU_USERNAME}
104    Should Not Be Empty   ${PDU_PASSWORD}
105
106
107Suite Setup Execution
108    [Documentation]  Do suite setup.
109
110    ${bmc_version}=  Get BMC Version
111    Set Suite Variable  ${initial_bmc_version}  ${bmc_version}
112