Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix QE script to not throw traceback #7777

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

ktsamis
Copy link
Contributor

@ktsamis ktsamis commented Oct 26, 2023

What does this PR change?

In the latest BV I had this failure:

15:04:10  Then the salt event log on server should contain no failures # features/step_definitions/salt_steps.rb:448
15:04:10        FAIL: python3 /tmp/salt_event_parser.py returned status code = 1.
15:04:10        Output:
15:04:10        Traceback (most recent call last):
15:04:10          File "/tmp/salt_event_parser.py", line 30, in <module>
15:04:10            if not j["return"][k]["result"]:
15:04:10        TypeError: string indices must be integers
15:04:10         (RuntimeError)
15:04:10        ./features/support/lavanda.rb:154:in `run'
15:04:10        ./features/step_definitions/salt_steps.rb:456:in `/^the salt event log on server should contain no failures$/'
15:04:10        features/build_validation/finishing/srv_debug.feature:13:in `the salt event log on server should contain no failures'

So I fixed it by refactoring the script to:

First check if j["return"] is a dictionary (isinstance(j["return"], dict)) to ensure it's iterable.

Then use a for loop to iterate over the keys and values in the j["return"] dictionary with for k, v in j["return"].items().

For each key-value pair, I check if v (the value) is a dictionary and if the "result" key within that dictionary is False. If these conditions are met, I increment the failure_count and print the failure information.

GUI diff

No difference.

  • DONE

Documentation

  • No documentation needed: only internal and user invisible changes

  • DONE

Test coverage

  • No tests: already covered

  • DONE

Links

Fixes no issue directly from testsuite review
Tracks https://github.com/SUSE/spacewalk/pull/22904

  • DONE

Changelogs

Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository

If you don't need a changelog check, please mark this checkbox:

  • No changelog needed

If you uncheck the checkbox after the PR is created, you will need to re-run changelog_test (see below)

Re-run a test

If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:

  • Re-run test "changelog_test"
  • Re-run test "backend_unittests_pgsql"
  • Re-run test "java_pgsql_tests"
  • Re-run test "schema_migration_test_pgsql"
  • Re-run test "susemanager_unittests"
  • Re-run test "javascript_lint"
  • Re-run test "spacecmd_unittests"

@ktsamis ktsamis requested a review from a team as a code owner October 26, 2023 13:18
Copy link
Member

@nodeg nodeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ktsamis
Copy link
Contributor Author

ktsamis commented Oct 27, 2023

I will wait until master is unblocked again, should be fine.

@deneb-alpha deneb-alpha merged commit 5dc28b1 into uyuni-project:master Nov 14, 2023
1 of 12 checks passed
@ktsamis ktsamis deleted the salt_event_parser branch November 14, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants