blob: 66dc52267be0690fda2e31aec18586c122f69f80 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Documentation This suite will verifiy the power restore policy rest Interfaces
3... Details of valid interfaces can be found here...
4... https://github.com/openbmc/docs/blob/master/rest-api.md
5
6Resource ../lib/rest_client.robot
7Resource ../lib/pdu/pdu.robot
8Resource ../lib/utils.robot
George Keishingd55a4be2016-08-26 03:28:17 -05009Resource ../lib/openbmc_ffdc.robot
Chris Austenb29d2e82016-06-07 12:25:35 -050010
11
12Library SSHLibrary
13
George Keishingd55a4be2016-08-26 03:28:17 -050014Test Teardown Log FFDC
causten147f5752016-08-11 16:24:45 -050015Force Tags chassisboot bmcreboot
Chris Austenb29d2e82016-06-07 12:25:35 -050016
17***test cases***
18
19Set the power restore policy Policy ExpectedSystemState NextSystemState
George Keishingd277f832016-10-07 12:04:50 -050020
Chris Austenb29d2e82016-06-07 12:25:35 -050021 LEAVE_OFF HOST_POWERED_OFF HOST_POWERED_OFF
22 LEAVE_OFF HOST_POWERED_ON HOST_POWERED_OFF
23 ALWAYS_POWER_ON HOST_POWERED_OFF HOST_POWERED_ON
24 ALWAYS_POWER_ON HOST_POWERED_ON HOST_POWERED_ON
25 RESTORE_LAST_STATE HOST_POWERED_ON HOST_POWERED_ON
George Keishingd277f832016-10-07 12:04:50 -050026 RESTORE_LAST_STATE HOST_POWERED_OFF HOST_POWERED_OFF
27
Chris Austenb29d2e82016-06-07 12:25:35 -050028 [Documentation] This test case sets the pilicy as given under the policy attribute.
29 ... ExpectedSystemState:-is the state where system should be before running the test case
George Keishingd277f832016-10-07 12:04:50 -050030 ... NextSystemState:-is After Power cycle system should reach to this state
31 ... if the system is not at the Expected System State,This test case brings the system
Chris Austenb29d2e82016-06-07 12:25:35 -050032 ... in the Expected state then do the power cycle.
33
34 [Template] setRestorePolicy
Chris Austenb29d2e82016-06-07 12:25:35 -050035
36***keywords***
37setRestorePolicy
38 [arguments] ${policy} ${expectedSystemState} ${nextSystemState}
39 ${valueDict} = create dictionary data=${policy}
40 Write Attribute /org/openbmc/settings/host0 power_policy data=${valueDict}
41 ${currentPolicy}= Read Attribute /org/openbmc/settings/host0 power_policy
42 Should Be Equal ${currentPolicy} ${policy}
43 ${currentSystemState}= Read Attribute /org/openbmc/settings/host0 system_state
George Keishingd277f832016-10-07 12:04:50 -050044 log Many "CurrentSystemState=" ${currentSystemState}
45 log Many "ExpectedSystemState=" ${expectedSystemState}
Chris Austenb29d2e82016-06-07 12:25:35 -050046 log Many "NextSystemState=" ${nextSystemState}
47 Run Keyword If '${currentSystemState}' != '${expectedSystemState}' and '${expectedSystemState}' == 'HOST_POWERED_ON' powerOnHost
48 Run Keyword If '${currentSystemState}' != '${expectedSystemState}' and '${expectedSystemState}' == 'HOST_POWERED_OFF' powerOffHost
49 log to console "Doing power cycle"
50 PDU Power Cycle
George Keishingd277f832016-10-07 12:04:50 -050051 Check If BMC is Up 5 min 10 sec
Chris Austenb29d2e82016-06-07 12:25:35 -050052 log to console "Host is pingable now"
53 Sleep 100sec
54 ${afterPduSystemState}= Read Attribute /org/openbmc/settings/host0 system_state
55 Should be equal ${afterPduSystemState} ${nextSystemState}
56
57powerOffHost
58 log to console "Powering off the host"
George Keishingd277f832016-10-07 12:04:50 -050059 @{arglist}= Create List
Chris Austenb29d2e82016-06-07 12:25:35 -050060 ${args}= Create Dictionary data=@{arglist}
61 ${resp}= Call Method /org/openbmc/control/chassis0/ powerOff data=${args}
62 should be equal as strings ${resp.status_code} ${HTTP_OK}
63 ${json} = to json ${resp.content}
64 should be equal as strings ${json['status']} ok
65 sleep 30sec
66 ${currentSystemState}= Read Attribute /org/openbmc/settings/host0 system_state
67 Should be equal ${currentSystemState} HOST_POWERED_OFF
68
69powerOnHost
70 log to console "Powering on the host"
George Keishingd277f832016-10-07 12:04:50 -050071 @{arglist}= Create List
Chris Austenb29d2e82016-06-07 12:25:35 -050072 ${args}= Create Dictionary data=@{arglist}
73 ${resp}= Call Method /org/openbmc/control/chassis0/ powerOn data=${args}
74 should be equal as strings ${resp.status_code} ${HTTP_OK}
75 ${json} = to json ${resp.content}
76 should be equal as strings ${json['status']} ok
77 sleep 30sec
78 ${currentSystemState}= Read Attribute /org/openbmc/settings/host0 system_state
79 Should be equal ${currentSystemState} HOST_POWERED_ON
80
81
82