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
7
8Test Setup       Test Setup Execution
9Test Teardown    Test Teardown Execution
10
11*** Test Cases ***
12
13Verify Redfish Update Service Enabled
14    [Documentation]  Verify "ServiceEnabled" is enabled.
15    [Tags]  Verify_Update_Service_Enabled
16
17    # Example:
18    # "HttpPushUri": "/redfish/v1/UpdateService",
19    # "Id": "UpdateService",
20    # "Name": "Update Service",
21    # "ServiceEnabled": true
22
23    ${resp}=  Redfish.Get  /redfish/v1/UpdateService
24    Should Be Equal As Strings  ${resp.dict["ServiceEnabled"]}  ${True}
25
26
27Verify Redfish Software Inventory Collection
28    [Documentation]  Verify software inventory collection member and object entries.
29    [Tags]  Verify_Redfish_Software_Inventory_Collection
30
31    # Example:
32    # {
33    #    "@odata.type": "#SoftwareInventoryCollection.SoftwareInventoryCollection",
34    #    "Members": [
35    #      {
36    #        "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/a3522998"
37    #      },
38    #      {
39    #        "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/a7c79f71"
40    #      },
41    #      {
42    #        "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/ace821ef"
43    #      }
44    #   ],
45    #   "Members@odata.count": 3,
46    #   "Name": "Software Inventory Collection"
47    # }
48
49    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
50
51    Should Be True  ${resp.dict["Members@odata.count"]} >= ${1}
52    Length Should Be  ${resp.dict["Members"]}  ${resp.dict["Members@odata.count"]}
53
54
55Redfish Software Inventory Status Check
56    [Documentation]  Get firmware inventory entries and do health check status.
57    [Tags]  Redfish_Software_Inventory_Status_Check
58
59    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
60
61    # Entries "Members@odata.count": 3,
62    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a3522998'}
63    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a7c79f71'}
64    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/ace821ef'}
65
66    :FOR  ${entry}  IN RANGE  0  ${resp.dict["Members@odata.count"]}
67    \  ${resp_resource}=  Redfish.Get  ${resp.dict["Members"][${entry}]["@odata.id"]}
68    # Example:
69    # "Status": {
70    #     "Health": "OK",
71    #     "HealthRollup": "OK",
72    #     "State": "Enabled"
73    # },
74    \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["Health"]}  OK
75    \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["HealthRollup"]}  OK
76    \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["State"]}  Enabled
77
78
79Verify BMC Version Matches With FirmwareInventory
80    [Documentation]  Verify BMC version from FirmwareInventory same as in manager.
81    [Tags]  Verify_BMC_Version_Matches_With_FirmwareInventory
82
83    ${bmc_manager}=  Redfish.Get  /redfish/v1/Managers/bmc
84    ${manager_bmc_version}=  Get BMC Version
85    # Check for manager version and cat /etc/os-release.
86    Should Be Equal As Strings
87    ...  ${bmc_manager.dict["FirmwareVersion"]}  ${manager_bmc_version.strip('"')}
88
89    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
90
91    # Entries "Members@odata.count": 3,
92    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a3522998'}
93    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a7c79f71'}
94    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/ace821ef'}
95
96    ${actual_count}=  Evaluate  ${resp.dict["Members@odata.count"]}-1
97    :FOR  ${entry}  IN RANGE  0  ${resp.dict["Members@odata.count"]}
98    \  ${resp_resource}=  Redfish.Get  ${resp.dict["Members"][${entry}]["@odata.id"]}
99    # 3rd comparison of BMC version and verify FirmwareInventory bmc version.
100    # Example:
101    # "Version": 2.7.0-dev-19-g9b44ea7
102    \  Exit For Loop If  '${resp_resource.dict["Version"]}' == '${manager_bmc_version.strip('"')}'
103    \  Run Keyword If  '${entry}' == '${actual_count}'  Fail
104    ...  BMC version not there in Firmware Inventory
105
106
107*** Keywords ***
108
109Test Setup Execution
110    [Documentation]  Do test case setup tasks.
111
112    Redfish.Login
113
114
115Test Teardown Execution
116    [Documentation]  Do the post test teardown.
117
118    FFDC On Test Case Fail
119    Redfish.Logout
120