openbmc / openbmc-test-automation

Apache License 2.0
106 stars 92 forks source link

[Redfish]SNMP test ValueError: The HTTP status code was not valid. #2216

Open allen810118 opened 1 year ago

allen810118 commented 1 year ago

I am testing SNMP via Redfish, And the following error is displayed in the results of multiple test cases: image

I wonder if there are any additional requirements for testing SNMP via Redfish?

gkeishin commented 1 year ago

@prkatti1 @meghagn12345 Can u respond ?

meghagn5 commented 1 year ago

If you are trying to add SNMP manager which is already present, then it will show this error.

meghagn5 commented 1 year ago

curl -k -H "X-Auth-Token:${bmc_token}" -X GET https://${bmc}/redfish/v1/EventService/Subscriptions/snmp1 { "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp1", "@odata.type": "#EventDestination.v1_8_0.EventDestination", "Context": "", "Destination": "snmp://xx.xx.xx.xx:162", "EventFormatType": "Event", "Id": "snmp1", "Name": "Event Destination snmp1", "Protocol": "SNMPv2c", "SubscriptionType": "SNMPTrap" }bash-4.2$ curl -k -H "X-Auth-Token $bmc_token" -X POST https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination": "snmp://xx.xx.xx.xx:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMPv2c"}' { "Destination@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type EventDestination.v1_8_0.EventDestination with the property Destination with the value 'snmp://xx.xx.xx.xx:162' already exists.", "MessageArgs": [ "EventDestination.v1_8_0.EventDestination", "Destination", "snmp://xx.xx.xx.xx:162" ], "MessageId": "Base.1.13.0.ResourceAlreadyExists", "MessageSeverity": "Critical", "Resolution": "Do not repeat the create operation as the resource has already been created." } ] }

bash-4.2$ curl -k -H "X-Auth-Token: $bmc_token" -X POST https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination": "snmp://xx.xx.xx.xx:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMP2c"}' -vv

< HTTP/1.1 400 Bad Request

gkeishin commented 1 year ago

@allen810118 does the above information help ?

allen810118 commented 1 year ago

@meghagn5 I have not yet any subscriptions.

allen@allen:~$ curl -k -H "X-Auth-Token:${bmc_token}" -X GET https://${bmc}/redfish/v1/EventService/Subscriptions/ { "@odata.id": "/redfish/v1/EventService/Subscriptions", "@odata.type": "#EventDestinationCollection.EventDestinationCollection", "Members": [], "Members@odata.count": 0, "Name": "Event Destination Collections" }

and I tried to create a subscription based on your curl command, but it seems that it was not successful.

allen@allen:~$ curl -k -H "X-Auth-Token:${bmc_token}" -X POST https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination": "snmp://10.6.6.6:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMPv2c"}' { "Destination@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The value 'snmp://10.6.6.6:162' for the property Destination is of a different format than the property can accept.", "MessageArgs": [ "snmp://10.6.6.6:162", "Destination" ], "MessageId": "Base.1.11.0.PropertyValueFormatError", "MessageSeverity": "Warning", "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed." } ] }

I'm not sure if this is due to the same error as what happened with the robot file?

meghagn5 commented 1 year ago

@allen810118 as error says it is property value error, means the IP or port number which you are passing is not valid as per this error.

allen810118 commented 1 year ago

@allen810118 as error says it is property value error, means the IP or port number which you are passing is not valid as per this error.

But this set of IP and Port is obtained from reference to the "test_bmc_snmp_trap.robot" . I directly used it without making any modifications to the original code, but it seems to be invalid. And as far as I know, ports 161 and 162 should be used by SNMP Manager, there shouldn't be any errors.

Do you have any suggestions for this?

meghagn5 commented 1 year ago

Tried with same command, it is working fine.

curl -k -H "X-Auth-Token:${bmc_token}" -X POST https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination": "snmp://10.6.6.6:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMPv2c"}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The resource has been created successfully.", "MessageArgs": [], "MessageId": "Base.1.13.0.Created", "MessageSeverity": "OK", "Resolution": "None." } ] }

allen810118 commented 1 year ago

Tried with same command, it is working fine.

curl -k -H "X-Auth-Token:${bmc_token}" -X POST https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination": "snmp://10.6.6.6:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMPv2c"}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The resource has been created successfully.", "MessageArgs": [], "MessageId": "Base.1.13.0.Created", "MessageSeverity": "OK", "Resolution": "None." } ] }

May I ask what versions of openbmc and automation test you used when testing with this command? Last week during testing, I found that different versions yield different results. This may be the reason why I am unable to execute the command.

meghagn5 commented 1 year ago

@allen810118 can you please share me the version where you were hitting this issue.

allen810118 commented 1 year ago

@meghagn5 The openbmc versions we use are all following version 2.12.0.

gkeishin commented 1 year ago

@meghagn5 @prkatti1 any update?

meghagn5 commented 1 year ago

@allen810118 this code is working fine for us and we are not facing an issue , we also tested it manually & it is working fine consistently.

If you are facing the issue manually also means, please open a defect against SNMP.

Julia-Delta commented 6 months ago

Hi all, I have a simulate issue Test "Configure SNMP Manager On BMC And Verify" on version v4.0_stable, test result was failed. But this test item result on version 3.0_stable was passed. I checked the log, and found the error reason is "No JSON object could be decoded". Then I noticed that POST request content was "body=data=10.6.6.6&data=162". This was not json object. And test on version 3.0_stable, POST request was correct that content was "body={"data": ["10.6.6.6", 162]} ".

Those different contents ware created by python or utility robot files? On v4.0_stable test environment, used "Python 3.8.10". How do I check the test environment is correct for testing? image