xref: /openbmc/openbmc-test-automation/xcat/test_xcat_group.robot (revision 2c731644a2d031d250faf8b08cbfc6db90453156)
1*** Settings ***
2Documentation   Module for testing BMC via XCAT.
3
4Resource        ../lib/xcat/resource.txt
5Resource        ../lib/xcat/xcat_utils.robot
6
7Library         OperatingSystem
8Library         String
9
10Suite Setup  Validate XCAT Setup
11
12*** Variables ***
13
14${poweron_flag}   ON
15${poweroff_flag}  OFF
16
17*** Test Cases ***
18
19Add BMC Nodes To XCAT
20    [Documentation]  Connect and add BMC nodes.
21    [Tags]  Add_BMC_Nodes_To_XCAT
22
23    # Add BMC nodes one by one and check whether it is successfully added.
24    : FOR  ${bmc}  IN  @{BMC_LIST}
25    \  Add Nodes To XCAT  ${bmc}
26    \  Validate Added Node  ${bmc}
27
28Power On Via XCAT And Validate
29    [Documentation]  Power on via XCAT and validate.
30    [Tags]  Power_On_Via_XCAT_And_Validate
31
32    # Power on each BMC node and validate the power status.
33    : FOR  ${bmc}  IN  @{BMC_LIST}
34    \  Power On Via XCAT  ${bmc}
35    \  Validate Power Status Via XCAT  ${bmc}  ${poweron_flag}
36
37Power Off Via XCAT And Validate
38    [Documentation]  Power off via XCAT and validate.
39    [Tags]  Power_Off_Via_XCAT_And_Validate
40
41    # Power off each BMC node and validate the power status.
42    : FOR  ${bmc}  IN  @{BMC_LIST}
43    \  Power Off Via XCAT  ${bmc}
44    \  Validate Power Status Via XCAT  ${bmc}  ${poweroff_flag}
45
46Add Nodes To Group List
47    [Documentation]  Add BMC nodes into group.
48    [Tags]  Move_Added_Nodes_To_Group
49
50    # Add BMC nodes to group and validate.
51    : FOR  ${bmc}  IN  @{BMC_LIST}
52    \  Add Nodes To Group  ${bmc}  ${GROUP}
53    \  Validate Node Added In Group  ${bmc}  ${GROUP}
54
55Power On Group And Validate
56    [Documentation]  Power on all BMCs in group and validate.
57    [Tags]  Power_On_Group_And_Validate
58
59    # Sample output of this keyword:
60    # XXX.XXX.XXX.XXX
61    # YYY.YYY.YYY.YYY
62    # ZZZ.ZZZ.ZZZ.ZZZ
63
64    ${nodes}=  Get List Of Nodes In Group  ${GROUP}
65    Should Not Be Empty  ${nodes}  msg=Group is empty.
66    Power On Via XCAT  ${GROUP}
67
68    # List the BMC nodes.
69
70    @{bmc_nodes}=  Split String  ${nodes}
71
72    # Validate power status on each BMC node one by one.
73    : FOR  ${bmc_node}  IN  @{bmc_nodes}
74    \  Validate Power Status Via XCAT  ${bmc_node}  ${poweron_flag}
75
76Power Off Group And Validate
77    [Documentation]  Power off all BMCs in group and validate.
78    [Tags]  Power_Off_Group_And_Validate
79
80    # Sample output of this keyword:
81    # XXX.XXX.XXX.XXX
82    # YYY.YYY.YYY.YYY
83    # ZZZ.ZZZ.ZZZ.ZZZ
84
85    ${nodes}=  Get List Of Nodes In Group  ${GROUP}
86    Should Not Be Empty  ${nodes}  msg=Group is empty.
87    Power Off Via XCAT  ${GROUP}
88
89    # List the BMC nodes.
90    @{bmc_nodes}=  Split String  ${nodes}
91
92    # Validate power status on each BMC node one by one.
93    : FOR  ${bmc_node}  IN  @{bmc_nodes}
94    \  Validate Power Status Via XCAT  ${bmc_node}  ${poweroff_flag}
95
96*** Keywords ***
97
98Validate XCAT Setup
99    [Documentation]  Validate XCAT setup.
100
101    Open Connection And Login To XCAT
102
103    # Check if XCAT is installed.
104    ${cmd_output}=  Execute Command  ${XCAT_DIR_PATH}/lsxcatd -v
105    Should Not Be Empty  ${cmd_output}  msg=XCAT not installed.
106
107    Log  \n XCAT Version is: \n${cmd_output}
108
109    # Get all the BMC nodes from the config file.
110    ${nodes}=  Get List Of BMC Nodes
111    # Make a list of BMC nodes.
112    @{BMC_LIST}=  Split To Lines  ${nodes}
113    Log To Console  BMC nodes to be added:\n ${BMC_LIST}
114    Set Suite Variable  @{BMC_LIST}
115
116    # GROUP should not be empty.
117    Should Not Be EMPTY  ${GROUP}  msg=Group does not exist.
118
119Validate Power Status Via XCAT
120    [Documentation]  Validate power status.
121    [Arguments]  ${node}  ${flag}=ON
122
123    ${status}=  Get Power Status  ${node}
124    Run Keyword If  '${flag}' == 'ON'
125    ...  Should Contain  ${status}  on  msg=Host is off.
126    ...  ELSE  Should Contain  ${status}  off  msg=Host is on.
127