ScaleComputing / HyperCoreAnsibleCollection

Official Ansible collection for Scale Computing SC//HyperCore (HC3) v1 API
GNU General Public License v3.0
12 stars 8 forks source link

Fix API module return list of key instead of list of dict. #241

Closed anazobec closed 1 year ago

anazobec commented 1 year ago

API module with action get would sometimes return a list of with only a key present instead of dict. This minor bug could be seen in the records output on calling the api module with action get on endpoint /ping which returned:

record: [
  "status"
]

This PR fixes this bug to by making a minor change in the filter_resultsfunction in module_utils/utils.py. The return should now look like this:

record: [
  {
    "status": "Active"
  }
]
anazobec commented 1 year ago

Yes, I've mentioned that some integration tests fail. Before the latest commit, 12 tests failed. 9 with error Connection Refused and others with just an assertion failure.

Integ tests with Connection Refused

Integ tests with Assertion failure

The results of these integration tests, can be seen from here: https://github.com/ScaleComputing/HyperCoreAnsibleCollection/actions/runs/5043144438/jobs/9044620677

anazobec commented 1 year ago

With the latest commit (at this point d1e799e), API module should now on /ping endpoint, with data { status: "Active" } return something like this:

record: {
  "status": "Active"
}

If data on the endpoint is not a single dictionary, then a list of dictionaries will be returned.

anazobec commented 1 year ago

Here are the newly run integration tests as of commit d1e799e: https://github.com/ScaleComputing/HyperCoreAnsibleCollection/actions/runs/5045862848

11 tests fail: 2 are assertion errors, 1 of them is an error caused by changing the get_records function in the api module. The rest of the tests fail with a Connection Refused error, Unexpected response, EOF.

Assertion failure:

  1. version_update_info (.200)
  2. utils_login (.50) => is caused by fixing api module

Connection Refused failure:

  1. version_update__shutdown_restart_vms (.200)
  2. email_alert (.200)
  3. git_issue_15 (.201)
  4. git_issue_11 (.201)
  5. api (.201)
  6. virtual_disk (.201)

Other failures:

  1. certificate (.200, .201) => EOF in violation of protocol (_ssl.c: 997)
  2. git_issue_41 (.200) => Unexpected response - 500

These tests were rerun 3 times, first time ending with about 20 failures.