1*** Settings ***
2Documentation    Verify that Redfish software inventory can be collected.
3
4Resource         ../../lib/resource.robot
5Resource         ../../lib/bmc_redfish_resource.robot
6Resource         ../../lib/openbmc_ffdc.robot
7Library          ../../lib/gen_robot_valid.py
8
9Test Setup       Test Setup Execution
10Test Teardown    Test Teardown Execution
11
12*** Test Cases ***
13
14Verify Redfish Update Service Enabled
15    [Documentation]  Verify "ServiceEnabled" is enabled.
16    [Tags]  Verify_Update_Service_Enabled
17
18    # Example:
19    # "HttpPushUri": "/redfish/v1/UpdateService",
20    # "Id": "UpdateService",
21    # "Name": "Update Service",
22    # "ServiceEnabled": true
23
24    ${resp}=  Redfish.Get  /redfish/v1/UpdateService
25    Should Be Equal As Strings  ${resp.dict["ServiceEnabled"]}  ${True}
26
27
28Verify Redfish Software Inventory Collection
29    [Documentation]  Verify software inventory collection member and object entries.
30    [Tags]  Verify_Redfish_Software_Inventory_Collection
31
32    # Example:
33    # {
34    #    "@odata.type": "#SoftwareInventoryCollection.SoftwareInventoryCollection",
35    #    "Members": [
36    #      {
37    #        "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/a3522998"
38    #      },
39    #      {
40    #        "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/a7c79f71"
41    #      },
42    #      {
43    #        "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/ace821ef"
44    #      }
45    #   ],
46    #   "Members@odata.count": 3,
47    #   "Name": "Software Inventory Collection"
48    # }
49
50    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
51
52    Should Be True  ${resp.dict["Members@odata.count"]} >= ${1}
53    Length Should Be  ${resp.dict["Members"]}  ${resp.dict["Members@odata.count"]}
54
55
56Redfish Software Inventory Status Check
57    [Documentation]  Get firmware inventory entries and do health check status.
58    [Tags]  Redfish_Software_Inventory_Status_Check
59
60    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
61
62    # Entries "Members@odata.count": 3,
63    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a3522998'}
64    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a7c79f71'}
65    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/ace821ef'}
66
67    :FOR  ${entry}  IN RANGE  0  ${resp.dict["Members@odata.count"]}
68    \  ${resp_resource}=  Redfish.Get  ${resp.dict["Members"][${entry}]["@odata.id"]}
69    # Example:
70    # "Status": {
71    #     "Health": "OK",
72    #     "HealthRollup": "OK",
73    #     "State": "Enabled"
74    # },
75    \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["Health"]}  OK
76    \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["HealthRollup"]}  OK
77    \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["State"]}  Enabled
78
79
80Verify BMC Version Matches With FirmwareInventory
81    [Documentation]  Verify BMC version from FirmwareInventory same as in manager.
82    [Tags]  Verify_BMC_Version_Matches_With_FirmwareInventory
83
84    ${bmc_manager}=  Redfish.Get  /redfish/v1/Managers/bmc
85    ${manager_bmc_version}=  Get BMC Version
86    # Check for manager version and cat /etc/os-release.
87    Should Be Equal As Strings
88    ...  ${bmc_manager.dict["FirmwareVersion"]}  ${manager_bmc_version.strip('"')}
89
90    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
91
92    # Entries "Members@odata.count": 3,
93    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a3522998'}
94    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a7c79f71'}
95    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/ace821ef'}
96
97    ${actual_count}=  Evaluate  ${resp.dict["Members@odata.count"]}-1
98    :FOR  ${entry}  IN RANGE  0  ${resp.dict["Members@odata.count"]}
99    \  ${resp_resource}=  Redfish.Get  ${resp.dict["Members"][${entry}]["@odata.id"]}
100    # 3rd comparison of BMC version and verify FirmwareInventory bmc version.
101    # Example:
102    # "Version": 2.7.0-dev-19-g9b44ea7
103    \  Exit For Loop If  '${resp_resource.dict["Version"]}' == '${manager_bmc_version.strip('"')}'
104    \  Run Keyword If  '${entry}' == '${actual_count}'  Fail
105    ...  BMC version not there in Firmware Inventory
106
107
108Verify UpdateService Supports TransferProtocol TFTP
109    [Documentation]  Verify update service supported values have TFTP protocol.
110    [Tags]  Verify_UpdateService_Supports_TransferProtocol_TFTP
111
112    # Example:
113    #   "Actions": {
114    #     "#UpdateService.SimpleUpdate": {
115    #       "TransferProtocol@Redfish.AllowableValues": [
116    #         "TFTP"
117    #       ],
118    #       "target": "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate"
119    #     }
120    #  },
121
122    ${allowable_values}=  Redfish.Get Attribute  /redfish/v1/UpdateService  Actions
123
124    Valid Value
125    ...  allowable_values["#UpdateService.SimpleUpdate"]["TransferProtocol@Redfish.AllowableValues"][0]
126    ...  valid_values=['TFTP']
127    Valid Value  allowable_values["#UpdateService.SimpleUpdate"]["target"]
128    ...  valid_values=['/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate']
129
130
131Verify Redfish BIOS Version
132    [Documentation]  Get host firmware version from system inventory.
133    [Tags]  Verify_Redfish_BIOS_Version
134
135    ${bios_version}=  Redfish.Get Attribute  /redfish/v1/Systems/system/  BiosVersion
136    ${pnor_version}=  Get PNOR Version
137    Should Be Equal  ${pnor_version}  ${bios_version}
138
139
140*** Keywords ***
141
142Test Setup Execution
143    [Documentation]  Do test case setup tasks.
144
145    Redfish.Login
146
147
148Test Teardown Execution
149    [Documentation]  Do the post test teardown.
150
151    FFDC On Test Case Fail
152    Redfish.Logout
153