Skip to content

Fix python version module compatible (TEAM-11049)#311

Merged
aleksei-burlakov merged 1 commit intoClusterLabs:masterfrom
Dawei-Pang:fix_team_11049_python_version_module_compatible
Mar 24, 2026
Merged

Fix python version module compatible (TEAM-11049)#311
aleksei-burlakov merged 1 commit intoClusterLabs:masterfrom
Dawei-Pang:fix_team_11049_python_version_module_compatible

Conversation

@Dawei-Pang
Copy link
Copy Markdown
Contributor

@Dawei-Pang Dawei-Pang commented Mar 19, 2026

When running the head of master branch, we observed the followed problem, for example: https://openqa.suse.de/tests/21364964#step/hawk_gui/89

TEST: test_add_virtual_ip: Add virtual IP from the Wizard
Traceback (most recent call last):
  File "/hawk_test.py", line 181, in <module>
    sys.exit(main())
  File "/hawk_test.py", line 128, in main
    browser.test('test_add_virtual_ip', results, args.virtual_ip)
  File "/hawk_test_driver.py", line 337, in test
    if getattr(self, testname)(*extra):
  File "/hawk_test_driver.py", line 1042, in test_add_virtual_ip
    self.click_if_major_version("15", 'configuration')
  File "/hawk_test_driver.py", line 199, in click_if_major_version
    if Version(self.test_version) >= Version(version_to_check):
  File "/usr/lib/python3.6/site-packages/packaging/version.py", line 260, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
packaging.version.InvalidVersion: Invalid version: '15-SP7'

Filed a JIRA ticket https://jira.suse.com/browse/TEAM-11049

After some research, commit cbcd346 modified
from distutils.version import LooseVersion as Version to from packaging.version import Version
The new "Version" method cannot accept the string like "15-SP7" directly, so I would like to check VERSION_ID in /etc/os-release instead of VERSION for compatible.

VRs:
https://openqa.suse.de/tests/21450880 15-SP4
https://openqa.suse.de/tests/21450874 15-SP5
https://openqa.suse.de/tests/21451116 15-SP6
https://openqa.suse.de/tests/21450865 15-SP7
https://openqa.suse.de/tests/21426733 16.0 (pending)

@Dawei-Pang Dawei-Pang changed the title WIP: Fix python version module compatible (TEAM-11049) Fix python version module compatible (TEAM-11049) Mar 19, 2026
@Dawei-Pang Dawei-Pang force-pushed the fix_team_11049_python_version_module_compatible branch 3 times, most recently from 8608f82 to 1d6bfa6 Compare March 19, 2026 08:39
Comment thread e2e_test/hawk_test.py Outdated
Copy link
Copy Markdown

@mpagot mpagot left a comment

Choose a reason for hiding this comment

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

LGTM

@badboywj
Copy link
Copy Markdown
Contributor

LGTM, thanks

Comment thread e2e_test/hawk_test.py Outdated
# Get version from /etc/os-release
test_version = ssh.ssh.exec_command("grep VERSION= /etc/os-release")[1].read().decode().strip().split("=")[1].strip('"')
# Get VERSION_ID from /etc/os-release
_, out, err = ssh.ssh.exec_command('. /etc/os-release && echo $VERSION_ID')
Copy link
Copy Markdown
Contributor

@alvarocarvajald alvarocarvajald Mar 19, 2026

Choose a reason for hiding this comment

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

Elsewhere the test is doing: https://github.com/ClusterLabs/hawk/blob/master/e2e_test/hawk_test_results.py#L35-L37

Which is perhaps harder to read, but avoids running a shell.

Perhaps we can move those 3 lines here, then do:

test_version = osrel['VERSION_ID']

And then pass the PRETTY_NAME as an argument to results = ResultSet() (which is some lines above), like:

results = ResultSet(osrel['PRETTY_NAME'])
results.add_ssh_tests()

In any case, I'm approving. Changes LGTM.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, would you please help to review again?

Copy link
Copy Markdown
Contributor

@alvarocarvajald alvarocarvajald left a comment

Choose a reason for hiding this comment

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

LGTM

@Dawei-Pang Dawei-Pang force-pushed the fix_team_11049_python_version_module_compatible branch from 1d6bfa6 to 3bd5b85 Compare March 20, 2026 03:31
Comment thread e2e_test/hawk_test.py
Comment on lines +113 to +114
_, out, err = ssh.ssh.exec_command('cat /etc/os-release')
lines = out.read().decode('utf-8').splitlines()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not?

        with open('/etc/os-release', encoding="utf-8") as file:
            lines = file.read().splitlines()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From my understanding, the original codes fetch OS version from remote HA nodes, not local system running HAWK, so using ssh.ssh.exec_command('cat /etc/os-release')

Comment thread e2e_test/hawk_test.py
# Get version from /etc/os-release
test_version = ssh.ssh.exec_command("grep VERSION= /etc/os-release")[1].read().decode().strip().split("=")[1].strip('"')
# Get VERSION_ID from /etc/os-release
_, out, err = ssh.ssh.exec_command('cat /etc/os-release')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see you are changing VERSION in favor of VERSION_ID, which is indeed more preferable. But this change is also introduced in #310. If merge the PRs chronologically, there might be a conflict.

@aleksei-burlakov aleksei-burlakov merged commit 2873571 into ClusterLabs:master Mar 24, 2026
3 checks passed
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