blob: 15fff11f1a5f1f410f639608cacb33ffa19d5f33 [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
Chris Austenb29d2e82016-06-07 12:25:35 -050013
14***test cases***
15
16Set the power restore policy Policy ExpectedSystemState NextSystemState
17
18 LEAVE_OFF HOST_POWERED_OFF HOST_POWERED_OFF
19 LEAVE_OFF HOST_POWERED_ON HOST_POWERED_OFF
20 ALWAYS_POWER_ON HOST_POWERED_OFF HOST_POWERED_ON
21 ALWAYS_POWER_ON HOST_POWERED_ON HOST_POWERED_ON
22 RESTORE_LAST_STATE HOST_POWERED_ON HOST_POWERED_ON
23 RESTORE_LAST_STATE HOST_POWERED_OFF HOST_POWERED_OFF
24
25 [Documentation] This test case sets the pilicy as given under the policy attribute.
26 ... ExpectedSystemState:-is the state where system should be before running the test case
27 ... NextSystemState:-is After Power cycle system should reach to this state
28 ... if the system is not at the Expected System State,This test case brings the system
29 ... in the Expected state then do the power cycle.
30
31 [Template] setRestorePolicy
32 [Tags] reboot_tests
33
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