openbmc / openbmc-test-automation

Apache License 2.0
100 stars 92 forks source link

many test cases in several suites have the Redfish path `/redfish/v1/Systems/system` hard-coded #2172

Closed generatz closed 2 years ago

generatz commented 2 years ago

Instead, the last element in the path should be determined from the OData entry. For example, looking at the DTMF mockup Systems resource the entry could look something like this:

{
"@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
"Name": "Computer System Collection",
"Members@odata.count": 1,
"Members": [
    {
        "@odata.id": "/redfish/v1/Systems/437XR1138R2"
    }
],
"@odata.id": "/redfish/v1/Systems"
}

and for those cases where that element actually is "systems" (as is true when these test cases are passing), it probably looks something like this:

{
"@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
"Name": "Computer System Collection",
"Members@odata.count": 1,
"Members": [
    {
        "@odata.id": "/redfish/v1/Systems/systems"
    }
],
"@odata.id": "/redfish/v1/Systems"
}

So the test case should obtain the path using the OData. For example, with ipmi/test_ipmi_general.robot instead of defining the keyword Verify Identify LED State Via Redfish as:

Verify Identify LED State Via Redfish
    [Documentation]  Verify that Redfish identify LED system with given state.
    [Arguments]  ${expected_state}
    # Description of argument(s):
    # expected_led_status  Expected value of Identify LED.

   ${led_value}=  Redfish.Get Attribute  /redfish/v1/Systems/system  IndicatorLED
   Should Be True  '${led_value}' == '${expected_state}'

it should be

Verify Identify LED State Via Redfish
    [Documentation]  Verify that Redfish identify LED system with given state.
    [Arguments]  ${expected_state}
    # Description of argument(s):
    # expected_led_status  Expected value of Identify LED.

    ${systems}=  Redfish_Utils.Get Member List  /redfish/v1/Systems
    FOR  ${system}  IN  @{systems}
        ${led_value}=  Redfish.Get Attribute  ${system}  IndicatorLED
        Should Be True  '${led_value}' == '${expected_state}'
    END

Here's the git diff for that change:

diff --git a/ipmi/test_ipmi_general.robot b/ipmi/test_ipmi_general.robot
index 73a0b99d..ec71f699 100644
--- a/ipmi/test_ipmi_general.robot
+++ b/ipmi/test_ipmi_general.robot
@@ -273,5 +273,9 @@ Verify Identify LED State Via Redfish
     # Description of argument(s):
     # expected_led_status  Expected value of Identify LED.

-    ${led_value}=  Redfish.Get Attribute  /redfish/v1/Systems/system  IndicatorLED
-    Should Be True  '${led_value}' == '${expected_state}'
+    ${systems}=  Redfish_Utils.Get Member List  /redfish/v1/Systems
+    FOR  ${system}  IN  @{systems}
+        ${led_value}=  Redfish.Get Attribute  ${system}  IndicatorLED
+        Should Be True  '${led_value}' == '${expected_state}'
+    END
+
gkeishin commented 2 years ago

I can further check on this

gkeishin commented 2 years ago

Up for review

https://gerrit.openbmc-project.xyz/c/openbmc/openbmc-test-automation/+/51907