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

eol version check #13253

Merged
merged 1 commit into from
Jun 3, 2024
Merged

eol version check #13253

merged 1 commit into from
Jun 3, 2024

Conversation

pondrejk
Copy link
Contributor

@pondrejk pondrejk commented Dec 4, 2023

Problem Statement

This supplements tests for the EOL banner feature. The eol date for the version is defined in the satellite-lifecycle package (so that there is the same solution for connected and disconnected sats). This test aims to check the date in the package is correctly updated.

Solution

Comparing the date from the package with the date from the lifecycle api.

Keeping in draft state, as the EOL banner just got to 6.15, but not yet to older releases and the lifecycle api contains data only for released versions

Related Issues

satellite-jenkins MR 1185

@pondrejk pondrejk added 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 labels Dec 4, 2023
@pondrejk pondrejk self-assigned this Dec 4, 2023
@pondrejk pondrejk requested review from a team as code owners December 4, 2023 14:35
@pondrejk pondrejk marked this pull request as draft December 4, 2023 14:36
Copy link
Contributor

@lhellebr lhellebr left a comment

Choose a reason for hiding this comment

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

Conceptually LGTM

if result.status_code != 200:
raise requests.HTTPError(f'{settings.subscription.lifecycle_api_url} is not accessible')
versions = result.json()['data'][0]['versions']
version = [v for v in versions if v['name'] == current_version]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
version = [v for v in versions if v['name'] == current_version]
version = [v for v in versions if v['name'] == current_version][0]

version = [v for v in versions if v['name'] == current_version]
api_date = [
(p['date_format'], p['date'])
for p in version[0]['phases']
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for p in version[0]['phases']
for p in version['phases']

(p['date_format'], p['date'])
for p in version[0]['phases']
if p['name'] == 'Maintenance support'
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
]
][0]

for p in version[0]['phases']
if p['name'] == 'Maintenance support'
]
if api_date[0][0] == 'string':
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if api_date[0][0] == 'string':
if api_date[0] == 'string':

]
if api_date[0][0] == 'string':
assert eol_datetime.strftime("%B, %Y") in api_date[0][1]
if api_date[0][0] == 'date':
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if api_date[0][0] == 'date':
if api_date[0] == 'date':

"""
current_version = '.'.join(target_sat.version.split('.')[0:2])
output = yaml.load(target_sat.execute(rf'cat {LIFECYCLE_METADATA_FILE}').stdout, yaml.Loader)
eol_datetime = datetime.strptime(output['releases'][current_version]['end_of_life'], '%Y-%m-%y')
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
eol_datetime = datetime.strptime(output['releases'][current_version]['end_of_life'], '%Y-%m-%y')
eol_datetime = datetime.strptime(output['releases'][current_version]['end_of_life'], '%Y-%m-%d')

if p['name'] == 'Maintenance support'
]
if api_date[0][0] == 'string':
assert eol_datetime.strftime("%B, %Y") in api_date[0][1]
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Why is the comparison only accurate to a month?
  2. Can't we test for equality?

Copy link

This pull request has not been updated in the past 45 days.

@github-actions github-actions bot added the Stale Stale issue or Pull Request label Jan 19, 2024
@omkarkhatavkar
Copy link

@pondrejk can you please work on the review comments as the PR is getting stale status

@github-actions github-actions bot removed the Stale Stale issue or Pull Request label Jan 20, 2024
Copy link

github-actions bot commented Mar 5, 2024

This pull request has not been updated in the past 45 days.

@github-actions github-actions bot added the Stale Stale issue or Pull Request label Mar 5, 2024
@pondrejk pondrejk removed the Stale Stale issue or Pull Request label Mar 11, 2024
Copy link

This pull request has not been updated in the past 45 days.

@github-actions github-actions bot added the Stale Stale issue or Pull Request label Apr 26, 2024
Copy link

github-actions bot commented May 4, 2024

This pull request is now being closed after stale warnings.

@github-actions github-actions bot closed this May 4, 2024
@pondrejk pondrejk reopened this May 7, 2024
@pondrejk pondrejk removed the Stale Stale issue or Pull Request label May 7, 2024
@pondrejk pondrejk force-pushed the eol-version-check branch from c4aa858 to 2c08a8e Compare May 7, 2024 14:44
@pondrejk pondrejk removed 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 labels May 7, 2024
@pondrejk pondrejk force-pushed the eol-version-check branch from 2c08a8e to 4bc63f9 Compare May 9, 2024 13:38
@pondrejk pondrejk marked this pull request as ready for review May 9, 2024 13:38
@pondrejk pondrejk force-pushed the eol-version-check branch from 4bc63f9 to 06693a4 Compare May 9, 2024 13:39
@pondrejk pondrejk added CherryPick PR needs CherryPick to previous branches 6.14.z Introduced in or relating directly to Satellite 6.14 AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing labels May 9, 2024
@pondrejk
Copy link
Contributor Author

pondrejk commented May 9, 2024

@lhellebr & reviewers, thanks for the patience, I applied the feedback. This PR requires satelliteqe-jenkins mr !1335 to be in. I'm assuming that released sat versions will be present in the lifecycle api, which might be considered naive, but I didn't find a sure way to establish which versions are published just from our configs, hope this makes sense

@pondrejk pondrejk force-pushed the eol-version-check branch from 06693a4 to 7bb97a2 Compare May 9, 2024 15:52
@pondrejk
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_eol_banner.py

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6900
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_eol_banner.py --external-logging
Test Result : ================== 1 passed, 9 warnings in 623.95s (0:10:23) ===================

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label May 13, 2024
Copy link
Member

@rplevka rplevka left a comment

Choose a reason for hiding this comment

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

I believe there are some serious flaws in the assertion logic that might lead to false-negative test results in some scenarios.

Comment on lines 36 to 37
if result.status_code != 200:
raise requests.HTTPError(f'{settings.subscription.lifecycle_api_url} is not accessible')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if result.status_code != 200:
raise requests.HTTPError(f'{settings.subscription.lifecycle_api_url} is not accessible')
result.raise_for_status()

https://docs.python-requests.org/en/latest/api/#requests.Response.raise_for_status

tests/foreman/api/test_eol_banner.py Show resolved Hide resolved
tests/foreman/api/test_eol_banner.py Show resolved Hide resolved
@pondrejk pondrejk force-pushed the eol-version-check branch from 7bb97a2 to f0bb466 Compare May 20, 2024 11:56
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label May 20, 2024
@pondrejk
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_eol_banner.py

Copy link
Member

@rplevka rplevka left a comment

Choose a reason for hiding this comment

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

One more unhandled else

tests/foreman/api/test_eol_banner.py Outdated Show resolved Hide resolved
@pondrejk pondrejk force-pushed the eol-version-check branch from f0bb466 to f49f106 Compare May 27, 2024 09:59
@pondrejk
Copy link
Contributor Author

hello @rplevka @lhellebr mind revisiting?

Copy link
Contributor

@pnovotny pnovotny left a comment

Choose a reason for hiding this comment

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

LGTM

@pondrejk pondrejk merged commit e65bda0 into SatelliteQE:master Jun 3, 2024
8 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 3, 2024
(cherry picked from commit e65bda0)
github-actions bot pushed a commit that referenced this pull request Jun 3, 2024
(cherry picked from commit e65bda0)
jyejare pushed a commit to jyejare/robottelo that referenced this pull request Oct 19, 2024
pondrejk added a commit to pondrejk/robottelo that referenced this pull request Oct 22, 2024
Gauravtalreja1 pushed a commit that referenced this pull request Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing CherryPick PR needs CherryPick to previous branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants