blob: b2632fecc906740942d795df6ec90484f0d4d9e9 [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
20
21 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
26 RESTORE_LAST_STATE HOST_POWERED_OFF HOST_POWERED_OFF
27
28 [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
30 ... 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
32 ... 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
44 log Many "CurrentSystemState=" ${currentSystemState}
45 log Many "ExpectedSystemState=" ${expectedSystemState}
46 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
51 Wait For Host To Ping ${OPENBMC_HOST}
52 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"
59 @{arglist}= Create List
60 ${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"
71 @{arglist}= Create List
72 ${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