Skip to content

Commit

Permalink
Session fixed, navigation error @apply_erratas()
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Oct 31, 2023
1 parent 37fb921 commit 8b82989
Showing 1 changed file with 52 additions and 29 deletions.
81 changes: 52 additions & 29 deletions tests/foreman/ui/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,20 @@ def _install_client_package(client, package, errata_applicability=False):
:param errata_applicability: If True, force host to generate errata applicability.
:returns: True if package installed successfully, False otherwise.
"""
result = client.run(f'yum install -y {package}')
result = client.execute(f'yum install -y {package}')
if errata_applicability:
_generate_errata_applicability(client.hostname)
return result.status == 0

def _remove_client_package(client, package, errata_applicability=False):
"""Delete a package in virtual machine client.
:param client: The Virtual machine client.
:param package: the package (general name, or version) to remove from virtual machine client.
:param errata_applicability: If True, force host to generate errata applicability.
:returns: True if a package was removed successfully, False otherwise.
"""
result = client.execute(f'yum delete -y {package}')
if errata_applicability:
_generate_errata_applicability(client.hostname)
return result.status == 0
Expand Down Expand Up @@ -170,7 +183,7 @@ def vm(module_repos_collection_with_setup, rhel7_contenthost, target_sat):


@pytest.fixture(scope='function')
def function_registered_contenthost(
def registered_contenthost(
rhel_contenthost,
module_org,
module_lce,
Expand Down Expand Up @@ -235,7 +248,7 @@ def test_end_to_end(
module_lce,
module_cv,
module_target_sat,
function_registered_contenthost,
registered_contenthost,
):
"""Create all entities required for errata, set up applicable host,
read errata details and apply it to host
Expand Down Expand Up @@ -278,35 +291,41 @@ def test_end_to_end(
],
'module_stream_packages': [],
}
contenthost = function_registered_contenthost
assert _install_client_package(contenthost, FAKE_1_CUSTOM_PACKAGE)
contenthost.execute('subscription-manager repos')
registered_contenthost
#_uninstall_client_package(contenthost, FAKE_1_CUSTOM_PACKAGE_NAME)
assert _install_client_package(registered_contenthost, FAKE_1_CUSTOM_PACKAGE)
module_target_sat.cli.Host.errata_recalculate(
{'host-id': contenthost.nailgun_host.id}
{'host-id': registered_contenthost.nailgun_host.id}
)
assert contenthost.applicable_errata_count > 0
assert registered_contenthost.applicable_errata_count > 0



_UTC_time_epoch = time()
_local_time_epoch = localtime()
_local_timezone = _local_time_epoch.tm_zone

assert len(product_list := module_target_sat.api.Product(organization=module_org).search()) == 1
module_product = product_list[0]
assert len(repo_list := module_target_sat.api.Repository(organization=module_org).search()) == 1
module_repo = repo_list[0]

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
breakpoint()
#session.organization.select(org_name=module_org.name)
session.location.select(loc_name=DEFAULT_LOC)
session.organization.select(org_name=module_org.name)
assert session.errata.search_content_hosts(
CUSTOM_REPO_ERRATA_ID, contenthost.hostname, environment=module_lce.name
CUSTOM_REPO_ERRATA_ID, registered_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
assert (errata := session.errata.read(CUSTOM_REPO_ERRATA_ID))

# We ignore issued date and updated date in ERRATA_DETAILS, so we don't perform an
# equality check here.
# DONE: Find a way to account for browser time zone, so that the errata dates displayed
Expand All @@ -321,31 +340,35 @@ 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']
#)
status = session.contenthost.install_errata(
contenthost.hostname, CUSTOM_REPO_ERRATA_ID, install_via='rex'
assert errata['repositories']['table'][-1]['Name'] == module_repo.name
assert errata['repositories']['table'][-1]['Product'] == module_product.name

session.host_new.apply_erratas(
client = registered_contenthost.hostname,
search = f"errata_id == {CUSTOM_REPO_ERRATA_ID}")
result = module_target_sat.wait_for_tasks(
search_query=(
f'"Install errata errata_id == {CUSTOM_REPO_ERRATA_ID.lower()} '
f'and type=security on {registered_contenthost.hostname}"'
),
search_rate=2,
max_tries=60,
)
assert status['overview']['job_status'] == 'Success'
assert status['overview']['job_status_progress'] == '100%'
_generate_errata_applicability(contenthost.hostname)
contenthost.execute('subscription-manager repos')
task_status = module_target_sat.api.ForemanTask(id=result[0].id).poll()
assert task_status['result'] == 'success'
breakpoint()
_generate_errata_applicability(registered_contenthost.hostname)
registered_contenthost.execute('subscription-manager repos')
module_target_sat.cli.Host.errata_recalculate(
{'host-id': contenthost.nailgun_host.id}
{'host-id': registered_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
assert registered_contenthost.applicable_errata_count == 0


@pytest.mark.tier2
Expand Down

0 comments on commit 8b82989

Please sign in to comment.