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

[6.15.z] eol version check #15267

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conf/subscription.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ SUBSCRIPTION:
RHN_PASSWORD:
# subscription pool id
RHN_POOLID:
# lifecycle API url
LIFECYCLE_API_URL:
1 change: 1 addition & 0 deletions robottelo/config/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
Validator('subscription.rhn_username', must_exist=True),
Validator('subscription.rhn_password', must_exist=True),
Validator('subscription.rhn_poolid', must_exist=True),
Validator('subscription.lifecycle_api_url', must_exist=True),
],
ansible_hub=[
Validator('ansible_hub.url', must_exist=True),
Expand Down
1 change: 1 addition & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,7 @@
"DELETE",
"PATCH",
]
LIFECYCLE_METADATA_FILE = '/usr/share/satellite/lifecycle-metadata.yml'

OPENSSH_RECOMMENDATION = 'Decreased security: OpenSSH config permissions'
DNF_RECOMMENDATION = (
Expand Down
57 changes: 57 additions & 0 deletions tests/foreman/api/test_eol_banner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""Test module for EOL tracking

:Requirement: Dashboard

:CaseAutomation: Automated

:CaseComponent: Dashboard

:Team: Endeavour

:CaseImportance: High
"""

from datetime import datetime

import pytest
import requests
import yaml

from robottelo.config import settings
from robottelo.constants import LIFECYCLE_METADATA_FILE
from robottelo.logging import logger


@pytest.mark.tier2
def test_positive_check_eol_date(target_sat):
"""Check if the EOL date for the satellite version

:id: 1c2f0d19-a357-4461-9ace-edb468f9ca5c

:BlockedBy: SAT-25522

:expectedresults: EOL date from satellite-lifecycle package is accurate
"""
current_version = '.'.join(target_sat.version.split('.')[0:2])
output = yaml.load(target_sat.execute(rf'cat {LIFECYCLE_METADATA_FILE}').stdout, yaml.Loader)
logger.debug(f'contents of {LIFECYCLE_METADATA_FILE} :{output}')
eol_datetime = datetime.strptime(output['releases'][current_version]['end_of_life'], '%Y-%m-%d')
result = requests.get(settings.subscription.lifecycle_api_url, verify=False)
if result.status_code != 200:
result.raise_for_status()
versions = result.json()['data'][0]['versions']
version = [v for v in versions if v['name'] == current_version]
if len(version) > 0:
api_date = [
(p['date_format'], p['date'])
for p in version[0]['phases']
if p['name'] == 'Maintenance support'
]
if api_date[0][0] == 'string':
assert eol_datetime.strftime("%B, %Y") in api_date[0][1]
elif api_date[0][0] == 'date':
assert eol_datetime.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + 'Z' == api_date[0][1]
else:
pytest.fail("Unexpcted date format returned")
else:
pytest.skip("The Satellite version is not GA yet")
Loading