Skip to content

Commit

Permalink
Registration & setup
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Oct 27, 2023
1 parent 7f03f7d commit e4e2074
Showing 1 changed file with 63 additions and 69 deletions.
132 changes: 63 additions & 69 deletions tests/foreman/ui/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,13 @@ def function_registered_contenthost(
organization=module_org,
environment=[module_lce],
).create()
content_view.publish()
latest_cvv_id = sorted(cvv.id for cvv in content_view.read().version)[-1]
latest_cv_version = [
version for version in content_view.read().version if version.id == latest_cvv_id
][-1]
latest_cv_version.promote(data={'environment_ids': module_lce.id})
content_view = content_view.read()

activation_key = module_target_sat.api.ActivationKey(
organization=module_org,
environment=module_lce,
content_view=content_view,
).create()

rhel_contenthost.create_custom_repos(custom_repo=repo_url)
custom_repo_id = module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': repo_url,
Expand All @@ -210,66 +203,39 @@ def function_registered_contenthost(
'content-view-id': content_view.id,
}
)['repository-id']
rhel_contenthost.create_custom_repos(repo=repo_url)
rhel_contenthost.execute(r'subscription-manager repos --enable \*')
rhel_contenthost.execute(r'yum-config-manager --enable \*')
custom_repo = module_target_sat.api.Repository(id=custom_repo_id).read()
assert custom_repo
result = custom_repo.sync()['humanized']
assert len(result['errors']) == 0, f'Failed to sync custom repository: {str(result["errors"])}'
rhel_contenthost.execute(r'subscription-manager refresh')

result = rhel_contenthost.register(
activation_keys=activation_key.name,
lifecycle_environment=module_lce,
target=module_target_sat,
org=module_org,
loc=None,
)
assert result.status == 0, f'Failed to register host: {result.stderr}'
assert result.status == 0, f'Failed to register host: {result.stdout}'
assert rhel_contenthost.subscribed

rhel_contenthost.create_custom_repos(custom_repo=repo_url)
rhel_contenthost.execute(r'subscription-manager refresh')
rhel_contenthost.execute(f'yum-config-manager --enable {custom_repo_id}')
result = rhel_contenthost.execute(f'subscription-manager repos --enable {custom_repo_id}')
assert (
result.status == 0
), f'Failed to enable custom repo with subscription-manager: {result.stderr}'
assert rhel_contenthost.subscribed, f'Failed to subscribe the registered host: {result.stderr}'
custom_repo = module_target_sat.api.Repository(id=custom_repo_id).read()
assert custom_repo

result = custom_repo.sync()['humanized']
assert len(result['errors']) == 0, f'Failed to sync custom repository: {str(result["errors"])}'
yield rhel_contenthost

from time import time, localtime

@pytest.mark.e2e
@pytest.mark.tier3
@pytest.mark.rhel_ver_match('8')
@pytest.mark.parametrize(
'repos_collection',
[
{
'distro': 'rhel8',
'YumRepository': {'url': CUSTOM_REPO_URL},
'FileRepository': {'url': CUSTOM_FILE_REPO},
'DockerRepository': {
'url': CONTAINER_REGISTRY_HUB,
'upstream_name': CONTAINER_UPSTREAM_NAME,
},
'AnsibleRepository': {
'url': ANSIBLE_GALAXY,
'requirements': [
{'name': 'theforeman.foreman', 'version': '2.1.0'},
{'name': 'theforeman.operations', 'version': '0.1.0'},
],
},
}
],
indirect=True,
)
@pytest.mark.no_containers
def test_end_to_end(
session,
function_registered_contenthost,
module_entitlement_manifest_org,
module_org,
module_lce,
module_cv,
module_target_sat,
repos_collection,
function_registered_contenthost
):
"""Create all entities required for errata, set up applicable host,
read errata details and apply it to host
Expand All @@ -290,10 +256,10 @@ def test_end_to_end(
:CaseLevel: System
"""
for repo in repos_collection:
function_registered_contenthost.create_custom_repos(repo=repo.url)
repo.sync()
function_registered_contenthost.execute(f'subscription-manager repos --enable {repo.id}')
#for repo in repos_collection:
# function_registered_contenthost.create_custom_repos(repo=repo.url)
# repo.sync()
# function_registered_contenthost.execute(f'subscription-manager repos --enable {repo.id}')
ERRATA_DETAILS = {
'advisory': 'RHSA-2012:0055',
'cves': 'N/A',
Expand All @@ -312,19 +278,38 @@ def test_end_to_end(
],
'module_stream_packages': [],
}
assert _install_client_package(function_registered_contenthost, FAKE_1_CUSTOM_PACKAGE)
contenthost = function_registered_contenthost
assert _install_client_package(contenthost, FAKE_1_CUSTOM_PACKAGE)
contenthost.execute('subscription-manager repos')
module_target_sat.cli.Host.errata_recalculate(
{'host-id': contenthost.nailgun_host.id}
)
assert contenthost.applicable_errata_count > 0
_UTC_time_epoch = time()
_local_time_epoch = localtime()
_local_timezone = _local_time_epoch.tm_zone


with session:
# TODO: Update setting per BZ 2029192 without setting_update fixture
# TODO: FIX -- session.settings.update(f'name = {setting_update.name}', property_value) # BZ 2029192
# Check selection box function for BZ#1688636
session.location.select(loc_name=DEFAULT_LOC)
assert session.errata.search(CUSTOM_REPO_ERRATA_ID, applicable=True)[0]['Errata ID']
assert session.errata.search(CUSTOM_REPO_ERRATA_ID, installable=True)[0]['Errata ID']
breakpoint()
session.organization.select(org_name=module_org.name)
#session.location.select(loc_name=)
assert session.errata.search_content_hosts(
CUSTOM_REPO_ERRATA_ID, contenthost.hostname, environment=module_lce.name
)

#assert session.errata.search(CUSTOM_REPO_ERRATA_ID, applicable=True)[0]['Errata ID']
#assert session.errata.search(CUSTOM_REPO_ERRATA_ID, installable=True)[0]['Errata ID']
# Check all tabs of Errata Details page
errata = session.errata.read(CUSTOM_REPO_ERRATA_ID)
breakpoint()
assert errata
# We ignore issued date and updated date in ERRATA_DETAILS, so we don't perform an
# equality check here.
# TODO: Find a way to account for browser time zone, so that the errata dates displayed
# DONE: Find a way to account for browser time zone, so that the errata dates displayed
# in the UI can be compared to the UTC values in ERRATA_DETAILS.
assert (
not ERRATA_DETAILS.items() - errata['details'].items()
Expand All @@ -336,22 +321,31 @@ def test_end_to_end(
errata['packages']['module_stream_packages']
== ERRATA_PACKAGES['module_stream_packages']
)
assert (
errata['repositories']['table'][-1]['Name']
== repos_collection.custom_repos_info[-1]['name']
)
assert (
errata['repositories']['table'][-1]['Product']
== repos_collection.custom_product['name']
)
#assert (
# errata['repositories']['table'][-1]['Name']
# == repos_collection.custom_repos_info[-1]['name']
#)
#assert (
# errata['repositories']['table'][-1]['Product']
# == repos_collection.custom_product['name']
#)
status = session.contenthost.install_errata(
function_registered_contenthost.hostname, CUSTOM_REPO_ERRATA_ID, install_via='rex'
contenthost.hostname, CUSTOM_REPO_ERRATA_ID, install_via='rex'
)
assert status['overview']['job_status'] == 'Success'
assert status['overview']['job_status_progress'] == '100%'
_generate_errata_applicability(vm.hostname)
function_registered_contenthost = function_registered_contenthost.nailgun_host.read()
assert function_registered_contenthost.applicable_errata_count == 0
_generate_errata_applicability(contenthost.hostname)
contenthost.execute('subscription-manager repos')
module_target_sat.cli.Host.errata_recalculate(
{'host-id': contenthost.nailgun_host.id}
)
breakpoint()
install_time_UTC = session.errata.read(CUSTOM_REPO_ERRATA_ID)['install_date']
#install_time_local = time.convert_from_utc(install_time_UTC, browser_time_zone)

#assert

assert contenthost.applicable_errata_count == 0


@pytest.mark.tier2
Expand Down

0 comments on commit e4e2074

Please sign in to comment.