DMTF / Redfish-Service-Validator

The Redfish Service Validator is a Python3 tool for checking conformance of any "device" with a Redfish service interface against Redfish CSDL schema
Other
40 stars 34 forks source link

Simplify URI checking for Ids #536

Closed tomasg2012 closed 1 year ago

tomasg2012 commented 1 year ago

Fixes #531 Fixes #533

Logic now only checks the last Id in the chain if it matches the current Resource.

mraineri commented 1 year ago

Using this payload to test, and I'm not seeing an error logged; Id doesn't match the last segment of the URI.

The URI is /redfish/v1/EventService/Subscriptions/4 and the Id property is Fred.

{
    "@odata.type": "#EventDestination.v1_12_0.EventDestination",
    "Id": "Fred",
    "Name": "EventSubscription for Remote syslog",
    "Destination": "syslog://123.45.10:514",
    "Context": "Syslog-Mockup",
    "Protocol": "SyslogTCP",
    "SyslogFilters": [
        {
            "LogFacilities": [
                "Kern",
                "User"
            ],
            "LowestSeverity": "Warning"
        }
    ],
    "@odata.id": "/redfish/v1/EventService/Subscriptions/4",
    "@Redfish.Copyright": "Copyright 2014-2022 DMTF. For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
}
tomasg2012 commented 1 year ago

Strange, can you send me a log file? I gave it a go and it returned this:

INFO - Redfish Service Validator, version 2.2.4
INFO - 
INFO - Writing config file to log directory
INFO - Target URI: http://127.0.0.1:8000
INFO - authtype: Basic
debugging: False
forceauth: False
ip: http://127.0.0.1:8000
logdir: ./logs
oemcheck: True
payload: ['SingleFile', 'id-payload.json']
schema_directory: ./SchemaFiles/metadata
uricheck: False
verbose: 0
INFO - Start time: 02/10/23 - 18:11:08
INFO - 
INFO - Setting up service...
INFO - Attempt 1 of /redfish/v1/
INFO - Response Time for GET to /redfish/v1/: 0.011017844999997806 seconds.
INFO - Attempt 1 of /redfish/v1/SessionService/Sessions
INFO - Response Time for GET to /redfish/v1/SessionService/Sessions: 0.011348849000000882 seconds.
INFO - Attempt 1 of /redfish/v1/$metadata
INFO - Response Time for GET to /redfish/v1/$metadata: 0.014616674000009766 seconds.
INFO - Constructing metadata...
INFO - Attempt 1 of /redfish/v1
INFO - Response Time for GET to /redfish/v1: 0.00978365800000347 seconds.
INFO - Redfish Version of Service: 1.6.0
INFO - Description of service: My Target System Root Service, version 1.6.0, 85775665-c110-4b85-8989-e6162170b3ec
INFO - 
*** id-payload.json
WARNING - id-payload.json @odata.id: Expected @odata.id to match URI link /redfish/v1/EventService/Subscriptions/4
ERROR - URI /redfish/v1/EventService/Subscriptions/4 does not match object ID of resource
INFO -   Type (EventDestination.v1_12_0.EventDestination), GET SUCCESS (time: 0)
ERROR - SubscriptionType: Mandatory prop does not exist
ERROR - @Redfish.Copyright is only allowed for mockups, and should not be allowed in official implementations
INFO -    FAIL...
INFO - Metadata: Namespaces missing from $metadata: set()
INFO - 
Elapsed time: 0:00:04
ERROR - 1 err.EventDestination.v1_3_0.SubscriptionType errors in id-payload.json
ERROR - 1 failMandatoryExist errors in id-payload.json
ERROR - 1 failRedfishUriStrict errors in id-payload.json
INFO - err.EventDestination.v1_3_0.SubscriptionType: 1   
failMandatoryExist: 1   
failRedfishUriStrict: 1   
metadataNamespaces: 58   
pass: 9   
passGet: 1   
passRedfishUri: 1   
skipOptional: 25   
warningPresent: 1   
ERROR - Validation has failed: 2 problems found

I used this when I was testing on my own as well.

{
    "@odata.type": "#Processor.v1_12_0.Processor",
    "Name": "Processor",
    "ProcessorType": "CPU",
    "ProcessorArchitecture": "x86",
    "InstructionSet": "x86-64",
    "Manufacturer": "Intel(R) Corporation",
    "Model": "Multi-Core Intel(R) Xeon(R) processor E5-1603",
    "MaxSpeedMHz": 2800,
    "TotalCores": 4,
    "TotalThreads": 8,
    "Id": "CXU",
    "Status": {
        "State": "Enabled",
        "Health": "OK"
    },
    "@odata.id": "/redfish/v1/Systems/529QB9453R6/Processors/CPU",
    "@Redfish.Copyright": "Copyright 2014-2021 DMTF. For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
}
mraineri commented 1 year ago

This may be my fault; the mockup I'm using doesn't have a RedfishVersion in ServiceRoot.

Update: Definitely my fault. Seeing the right error now; will keep poking at it (and merge in a bit when it all looks good).

mraineri commented 1 year ago

@tomasg2012 I'm seeing mixed results when I test against the public-rackmount1 mockup found in this bundle: https://www.dmtf.org/sites/default/files/standards/documents/DSP2043_2022.3.zip

Some of the failures are real and need to be fixed in the mockup, but these resources look correct to me (but the test report shows a "failRedfishUriStrict" error). Please take a look at the report for these URIs:

ConformanceLog_02_10_2023_203011.txt

ConformanceHtmlLog_02_10_2023_203011.html.txt

edtanous commented 1 year ago

Just tried this patch out, and it does fix the issues I was seeing with LDAP. Can we get it on master (even if it might not solve all issues) or get the old patch reverted?

mraineri commented 1 year ago

@edtanous does it flag false errors for other URIs? Maybe there's something specific with the mockup we need to look at further, but it's not obvious to me based on the URIs in the mockup compared with the URI patterns in the schema files.

edtanous commented 1 year ago

For the systems I have, there were only two false-positives (we've fixed the true positives), both that I mention in #533, LDAP and HTTPS are the two that were failing on mine. It seems like those are the only two cases of an embedded object that isn't a NavigationReference, and that's what this is failing on.

I looked through that report, and there's a lot more seemingly false-positives than I saw on my system. For example: /redfish/v1/Managers/BMC

OpenBMC has an identical URI, just a lower case "bmc", and it passed just fine.

mraineri commented 1 year ago

Thanks; I'll merge this now and file a new issue since this is an improvement.

plmanik commented 1 year ago

@mraineri I'm getting same error for below two URI's in below latest version as mentioned in this issue Tool Version: 2.2.5 Tue Feb 14 15:40:18 2023 (Run time: 0:09:22)

RROR - URI /redfish/v1/Systems/Capabilities does not match object ID of resource { "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem", "@odata.etag": "\"1525957699\"", "@odata.id": "/redfish/v1/Systems/Capabilities", "@odata.type": "#ComputerSystem.v1_16_0.ComputerSystem", "Boot": { "BootSourceOverrideEnabled@Redfish.AllowableValues": [ "Disabled", "Once", "Continuous" ], "BootSourceOverrideEnabled@Redfish.OptionalOnCreate": true, "BootSourceOverrideEnabled@Redfish.UpdatableAfterCreate": false, "BootSourceOverrideTarget@Redfish.AllowableValues": [ "None", "Pxe", "Floppy", "Cd", "Usb", "Hdd", "BiosSetup", "Utilities", "Diags", "UefiShell", "UefiTarget", "SDCard", "UefiHttp", "RemoteDrive", "UefiBootNext" ], "BootSourceOverrideTarget@Redfish.OptionalOnCreate": true, "BootSourceOverrideTarget@Redfish.UpdatableAfterCreate": false }, "Boot@Redfish.OptionalOnCreate": true, "Description": "Zone Capabilities", "Description@Redfish.OptionalOnCreate": true, "Description@Redfish.SetOnlyOnCreate": true, "HostName@Redfish.OptionalOnCreate": true, "HostName@Redfish.UpdatableAfterCreate": false, "Id": "Capabilities", "Links": { "ResourceBlocks@Redfish.RequiredOnCreate": true, "ResourceBlocks@Redfish.UpdatableAfterCreate": true }, "Links@Redfish.RequiredOnCreate": true, "Name": "Capabilities for the Zone", "Name@Redfish.RequiredOnCreate": true, "Name@Redfish.SetOnlyOnCreate": true }

ERROR - URI /redfish/v1/Systems/Self/Processors/DevType1_CPU0/AccelerationFunctions/Compression does not match object ID of resource { "@odata.context": "/redfish/v1/$metadata#AccelerationFunction.AccelerationFunction", "@odata.etag": "\"1676287999\"", "@odata.id": "/redfish/v1/Systems/Self/Processors/DevType1_CPU0/AccelerationFunctions/Compression", "@odata.type": "#AccelerationFunction.v1_0_2.AccelerationFunction", "FpgaReconfigurationSlots": [ "AFU0" ], "Id": "Compression", "Links": { "Endpoints@odata.count": 0, "PCIeFunctions@odata.count": 0 }, "Name": "Compression Accelerator", "PowerWatts": 15, "Status": { "Health": "OK", "State": "Enabled" }, "UUID": "38947555-7742-3448-3784-823347823834", "Version": "Green Compression Type 1 v.1.00.86" }

Seems Id and URI also matching, but getting same error. Please let us know if any issues in response

Thanks, Mani