Run Redfish test framework parallel on all nodes
[validation.git] / tests / hardware / redfish / redfish.resource
1 ##############################################################################
2 # Copyright (c) 2019 AT&T Intellectual Property.                             #
3 # Copyright (c) 2019 Nokia.                                                  #
4 #                                                                            #
5 # Licensed under the Apache License, Version 2.0 (the "License");            #
6 # you maynot use this file except in compliance with the License.            #
7 #                                                                            #
8 # You may obtain a copy of the License at                                    #
9 #       http://www.apache.org/licenses/LICENSE-2.0                           #
10 #                                                                            #
11 # Unless required by applicable law or agreed to in writing, software        #
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
14 # See the License for the specific language governing permissions and        #
15 # limitations under the License.                                             #
16 ##############################################################################
17
18
19 *** Settings ***
20 Library             Collections
21 Library             JSONLibrary
22 Library             OperatingSystem
23 Library             Process
24
25
26 *** Variables ***
27 ${REPORTDIR}        ${LOG_PATH}/${SUITE_NAME.replace(' ','_')}
28 ${REDFISHDIR}       ${TEMPDIR}/Redfish
29
30
31 *** Keywords ***
32 Update Config File
33     [Arguments]     ${config_file}
34     ${conf}=        Load JSON From File  ${config_file}
35     ${conf}=        Update Value To Json  ${conf}  $.password  ${BMC_PASSWORD}
36     ${conf}=        Convert JSON To String  ${conf}
37     Create File     ${config_file}  ${conf}
38
39 Run Suite Against Target Node
40     [Arguments]     ${ip}
41     Start Process   python  test_framework.py
42     ...                 --directory  ${REDFISHDIR}/${ip}
43     ...                 --rhost  ${ip}
44     ...                 --user  ${BMC_USER}
45     ...                 --interpreter  python
46     ...                 --secure  Always
47     ...               cwd=${REDFISHDIR}/${ip}
48     ...               alias=${ip}
49     Process Should Be Running
50
51 Install Usecase Checkers Test Suite
52     @{BMC_IP}=      Remove Duplicates  ${BMC_IP}
53     Set Test Variable  @{BMC_IP}
54     FOR  ${ip}  IN  @{BMC_IP}
55         Copy Directory  /opt/akraino/Redfish-Test-Framework
56         ...             ${REDFISHDIR}/${ip}
57         Copy Directory  /opt/akraino/Redfish-Usecase-Checkers
58         ...             ${REDFISHDIR}/${ip}/Redfish-Usecase-Checkers
59         Create Directory  ${REDFISHDIR}/${ip}/reports
60         Update Config File  ${REDFISHDIR}/${ip}/framework_conf.json
61     END
62
63 Uninstall Test Suite
64     Remove Directory  ${REDFISHDIR}  recursive=True
65
66 Start Suite
67     @{ips}=         Create List
68     Set Test Variable  @{ips}
69     FOR  ${ip}  IN  @{BMC_IP}
70         Run Suite Against Target Node  ${ip}
71         Append To List  ${ips}  ${ip}
72     END
73
74 Suite Finished
75     @{tmp}=         Copy List  ${ips}
76     FOR  ${ip}  IN  @{tmp}
77         ${result}=  Wait For Process  ${ip}  timeout=1ms
78         Continue For Loop If  '${result}' == '${NONE}'
79         Remove Values From List  ${ips}  ${ip}
80         Copy Files  ${REDFISHDIR}/${ip}/reports/output-*/results*.json  ${REPORTDIR}/${ip}
81         Copy Files  ${REDFISHDIR}/${ip}/output-*/*.html  ${REPORTDIR}/${ip}
82     END
83     Should Be Empty  ${ips}
84
85 Wait Until Suite Finishes
86     Wait Until Keyword Succeeds  45m  15s  Suite Finished
87
88 Check Suite Results
89     FOR  ${ip}  IN  @{BMC_IP}
90         ${result}=  Get Process Result  ${ip}
91         Should Be Equal As Integers  ${result.rc}  0
92         Should Not Contain  ${result.stderr}  FAILED${\n} (Failures=
93     END