xref: /openbmc/openbmc-test-automation/xcat/test_xcat_group.robot (revision f133e8b61580620f1285d5a0413cbea7f078a05f)
1*** Settings ***
2Documentation   Module for testing BMC via XCAT.
3
4Resource        ../lib/xcat/resource.robot
5Resource        ../lib/xcat/xcat_utils.robot
6
7Library         OperatingSystem
8Library         String
9
10Suite Setup  Validate XCAT Setup
11Suite Teardown  Close All Connections
12
13*** Variables ***
14
15${POWERON_FLAG}             ON
16${POWEROFF_FLAG}            OFF
17${NUM_POWER_STATUS_CHECKS}  1000
18
19*** Test Cases ***
20
21Add BMC Nodes To XCAT
22    [Documentation]  Connect and add BMC nodes.
23    [Tags]  Add_BMC_Nodes_To_XCAT
24
25    # Add BMC nodes one by one and check whether it is successfully added.
26    FOR  ${bmc}  IN  @{BMC_LIST}
27      Add Nodes To XCAT  ${bmc}
28      Validate Added Node  ${bmc}
29    END
30
31Power On Via XCAT And Validate
32    [Documentation]  Power on via XCAT and validate.
33    [Tags]  Power_On_Via_XCAT_And_Validate
34
35    # Power on each BMC node and validate the power status.
36    FOR  ${bmc}  IN  @{BMC_LIST}
37      Power On Via XCAT  ${bmc}
38      Validate Power Status Via XCAT  ${bmc}  ${POWERON_FLAG}
39    END
40
41Power Off Via XCAT And Validate
42    [Documentation]  Power off via XCAT and validate.
43    [Tags]  Power_Off_Via_XCAT_And_Validate
44
45    # Power off each BMC node and validate the power status.
46    FOR  ${bmc}  IN  @{BMC_LIST}
47      Power Off Via XCAT  ${bmc}
48      Validate Power Status Via XCAT  ${bmc}  ${POWEROFF_FLAG}
49    END
50
51Add Nodes To Group List
52    [Documentation]  Add BMC nodes into group.
53    [Tags]  Add_Nodes_To_Group_List
54
55    # Add BMC nodes to group and validate.
56    FOR  ${bmc}  IN  @{BMC_LIST}
57      Add Nodes To Group  ${bmc}  ${GROUP}
58      Validate Node Added In Group  ${bmc}  ${GROUP}
59    END
60
61Power On Group And Validate
62    [Documentation]  Power on all BMCs in group and validate.
63    [Tags]  Power_On_Group_And_Validate
64
65    # Sample output of this keyword:
66    # XXX.XXX.XXX.XXX
67    # YYY.YYY.YYY.YYY
68    # ZZZ.ZZZ.ZZZ.ZZZ
69
70    ${nodes}=  Get List Of Nodes In Group  ${GROUP}
71    Should Not Be Empty  ${nodes}  msg=Group is empty.
72    Power On Via XCAT  ${GROUP}
73
74    # List the BMC nodes.
75
76    @{bmc_nodes}=  Split String  ${nodes}
77
78    # Validate power status on each BMC node one by one.
79    FOR  ${bmc_node}  IN  @{bmc_nodes}
80      Validate Power Status Via XCAT  ${bmc_node}  ${POWERON_FLAG}
81    END
82
83Power Off Group And Validate
84    [Documentation]  Power off all BMCs in group and validate.
85    [Tags]  Power_Off_Group_And_Validate
86
87    # Sample output of this keyword:
88    # XXX.XXX.XXX.XXX
89    # YYY.YYY.YYY.YYY
90    # ZZZ.ZZZ.ZZZ.ZZZ
91
92    ${nodes}=  Get List Of Nodes In Group  ${GROUP}
93    Should Not Be Empty  ${nodes}  msg=Group is empty.
94    Power Off Via XCAT  ${GROUP}
95
96    # List the BMC nodes.
97    @{bmc_nodes}=  Split String  ${nodes}
98
99    # Validate power status on each BMC node one by one.
100    FOR  ${bmc_node}  IN  @{bmc_nodes}
101      Validate Power Status Via XCAT  ${bmc_node}  ${POWEROFF_FLAG}
102    END
103
104Continuous Node Power Status
105    [Documentation]  Continuously get the power status.
106    # This keyword verifies the REST connectivity between XCAT and the BMC node.
107    [Tags]  Continuous_Node_Power_Status
108
109    # Performing this operation only on one BMC node.
110
111    Power On Via XCAT  ${BMC_LIST[1]}
112
113    # Get the power status of the node repeatedly.
114    # By default it gets power status 1000 times.
115    # It basically stress the BMC node and test REST implementation
116    # of the BMC node
117
118    FOR  ${index}  IN RANGE  1  ${NUM_POWER_STATUS_CHECKS}
119      Validate Power Status Via XCAT  ${BMC_LIST[1]}  ${POWERON_FLAG}
120    END
121
122Get Temperature Reading Via XCAT
123    [Documentation]  Get temperature reading via XCAT.
124    [Tags]  Get_Temperature_Reading_Via_XCAT
125
126    # Sample output of the keyword:
127    # node1: Ambient: 28.62 C
128    # node1: P0 Vcs Temp: 35 C
129    # node1: P0 Vdd Temp: 35 C
130    # node1: P0 Vddr Temp: 35 C
131    # node1: P0 Vdn Temp: 35 C
132    # node1: P1 Vcs Temp: 33 C
133    # node1: P1 Vdd Temp: 33 C
134    # node1: P1 Vddr Temp: 34 C
135    # node1: P1 Vdn Temp: 34 C
136
137    # Get temperature reading from each BMC node.
138
139    FOR  ${bmc}  IN  @{BMC_LIST}
140      ${temp_reading}=  Get Hardware Vitals Via XCAT  ${bmc}  temp
141      Should Match  ${temp_reading}  ${bmc}* C
142      Log  \n Temperature reading on $[bmc}\n ${temp_reading}
143    END
144
145Get Fanspeed Reading Via XCAT
146    [Documentation]  Get fanspeed via XCAT.
147    [Tags]  Get_Fanspeed_Reading_Via_XCAT
148
149    # Sample output of the keyword:
150    # node1: Fan0 0: 10714 RPMS
151    # node1: Fan1 0: 10216 RPMS
152    # node1: Fan2 0: 14124 RPMS
153    # node1: Fan3 0: 11114 RPMS
154
155    # Get fanspeed from each BMC node.
156
157    FOR  ${bmc}  IN  @{BMC_LIST}
158      ${fanspeed}=  Get Hardware Vitals Via XCAT  ${bmc}  fanspeed
159      Should Match  ${fanspeed}  ${bmc}* RPMS
160      Log  \n fanspeed on $[bmc}\n ${fanspeed}
161    END
162
163Get Voltage Reading Via XCAT
164    [Documentation]  Get voltage via XCAT.
165    [Tags]  Get_Voltage_Reading_Via_XCAT
166
167    # Sample output of the keyword:
168    # node1: No attributes returned from the BMC.
169    # BMC node is not returning anything, this will fail at present.
170
171    # Get voltage reading from each BMC node.
172
173    FOR  ${bmc}  IN  @{BMC_LIST}
174      ${voltage}=  Get Hardware Vitals Via XCAT  ${bmc}  voltage
175      Log  \n Voltage reading on $[bmc}\n ${voltage}
176    END
177
178Get Wattage Via XCAT
179    [Documentation]  Get wattage via XCAT.
180    [Tags]  Get_Wattage_Via_XCAT
181
182    # Sample output of the keyword:
183    # node1: No attributes returned from the BMC.
184    # BMC node is not returning anything, this will fail at present.
185
186    # Get wattage reading from each BMC node.
187
188    FOR  ${bmc}  IN  @{BMC_LIST}
189      ${wattage}=  Get Hardware Vitals Via XCAT  ${bmc}  wattage
190      Log  \n Wattage reading on $[bmc}\n ${wattage}
191    END
192
193*** Keywords ***
194
195Validate XCAT Setup
196    [Documentation]  Validate XCAT setup.
197
198    Open Connection And Login To XCAT
199
200    # Check if XCAT is installed.
201    ${cmd_output}=  Execute Command  ${XCAT_DIR_PATH}/lsxcatd -v
202    Should Not Be Empty  ${cmd_output}  msg=XCAT not installed.
203
204    Log  \n XCAT Version is: \n${cmd_output}
205
206    # Get all the BMC nodes from the config file.
207    ${nodes}=  Get List Of BMC Nodes
208    # Make a list of BMC nodes.
209    @{BMC_LIST}=  Split To Lines  ${nodes}
210    Log To Console  BMC nodes to be added:\n ${BMC_LIST}
211    Set Suite Variable  @{BMC_LIST}
212
213    # GROUP should not be empty.
214    Should Not Be EMPTY  ${GROUP}  msg=Group does not exist.
215
216Validate Power Status Via XCAT
217    [Documentation]  Validate power status.
218    [Arguments]  ${node}  ${flag}=ON
219
220    ${status}=  Get Power Status  ${node}
221    IF  '${flag}' == 'ON'
222        Should Contain  ${status}  on  msg=Host is off.
223    ELSE
224        Should Contain  ${status}  off  msg=Host is on.
225    END
226