blob: 35955a24c3c1440c3b94625b84ba4b240c8244d9 [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
9
10
11Library SSHLibrary
12
causten147f5752016-08-11 16:24:45 -050013Force Tags chassisboot bmcreboot
Chris Austenb29d2e82016-06-07 12:25:35 -050014
15***test cases***
16
17Set the power restore policy Policy ExpectedSystemState NextSystemState
18
19 LEAVE_OFF HOST_POWERED_OFF HOST_POWERED_OFF
20 LEAVE_OFF HOST_POWERED_ON HOST_POWERED_OFF
21 ALWAYS_POWER_ON HOST_POWERED_OFF HOST_POWERED_ON
22 ALWAYS_POWER_ON HOST_POWERED_ON HOST_POWERED_ON
23 RESTORE_LAST_STATE HOST_POWERED_ON HOST_POWERED_ON
24 RESTORE_LAST_STATE HOST_POWERED_OFF HOST_POWERED_OFF
25
26 [Documentation] This test case sets the pilicy as given under the policy attribute.
27 ... ExpectedSystemState:-is the state where system should be before running the test case
28 ... NextSystemState:-is After Power cycle system should reach to this state
29 ... if the system is not at the Expected System State,This test case brings the system
30 ... in the Expected state then do the power cycle.
31
32 [Template] setRestorePolicy
Chris Austenb29d2e82016-06-07 12:25:35 -050033
34***keywords***
35setRestorePolicy
36 [arguments] ${policy} ${expectedSystemState} ${nextSystemState}
37 ${valueDict} = create dictionary data=${policy}
38 Write Attribute /org/openbmc/settings/host0 power_policy data=${valueDict}
39 ${currentPolicy}= Read Attribute /org/openbmc/settings/host0 power_policy
40 Should Be Equal ${currentPolicy} ${policy}
41 ${currentSystemState}= Read Attribute /org/openbmc/settings/host0 system_state
42 log Many "CurrentSystemState=" ${currentSystemState}
43 log Many "ExpectedSystemState=" ${expectedSystemState}
44 log Many "NextSystemState=" ${nextSystemState}
45 Run Keyword If '${currentSystemState}' != '${expectedSystemState}' and '${expectedSystemState}' == 'HOST_POWERED_ON' powerOnHost
46 Run Keyword If '${currentSystemState}' != '${expectedSystemState}' and '${expectedSystemState}' == 'HOST_POWERED_OFF' powerOffHost
47 log to console "Doing power cycle"
48 PDU Power Cycle
49 Wait For Host To Ping ${OPENBMC_HOST}
50 log to console "Host is pingable now"
51 Sleep 100sec
52 ${afterPduSystemState}= Read Attribute /org/openbmc/settings/host0 system_state
53 Should be equal ${afterPduSystemState} ${nextSystemState}
54
55powerOffHost
56 log to console "Powering off the host"
57 @{arglist}= Create List
58 ${args}= Create Dictionary data=@{arglist}
59 ${resp}= Call Method /org/openbmc/control/chassis0/ powerOff data=${args}
60 should be equal as strings ${resp.status_code} ${HTTP_OK}
61 ${json} = to json ${resp.content}
62 should be equal as strings ${json['status']} ok
63 sleep 30sec
64 ${currentSystemState}= Read Attribute /org/openbmc/settings/host0 system_state
65 Should be equal ${currentSystemState} HOST_POWERED_OFF
66
67powerOnHost
68 log to console "Powering on the host"
69 @{arglist}= Create List
70 ${args}= Create Dictionary data=@{arglist}
71 ${resp}= Call Method /org/openbmc/control/chassis0/ powerOn data=${args}
72 should be equal as strings ${resp.status_code} ${HTTP_OK}
73 ${json} = to json ${resp.content}
74 should be equal as strings ${json['status']} ok
75 sleep 30sec
76 ${currentSystemState}= Read Attribute /org/openbmc/settings/host0 system_state
77 Should be equal ${currentSystemState} HOST_POWERED_ON
78
79
80