Skip to content

Commit

Permalink
Convert Discovery upgrade scenario to new format
Browse files Browse the repository at this point in the history
  • Loading branch information
synkd committed Nov 13, 2024
1 parent 41ec8b6 commit c155bf7
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/new_upgrades/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,14 @@ def content_upgrade_shared_satellite():
) as test_duration:
yield sat_instance
test_duration.ready()


@pytest.fixture
def fdi_upgrade_shared_satellite():
"""Mark tests using this fixture with pytest.mark.content_upgrades."""
sat_instance = shared_checkout("fdi_upgrade")
with SharedResource(
"fdi_upgrade_tests", shared_checkin, sat_instance=sat_instance
) as test_duration:
yield sat_instance
test_duration.ready()
70 changes: 70 additions & 0 deletions tests/new_upgrades/test_discovery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""Test Discovery Plugin related Upgrade Scenario's
:Requirement: UpgradedSatellite
:CaseAutomation: Automated
:CaseComponent: DiscoveryImage
:Team: Rocket
:CaseImportance: High
"""

import re

from box import Box
from packaging.version import Version
import pytest

from robottelo.utils.shared_resource import SharedResource


@pytest.fixture
def fdi_upgrade_setup(fdi_upgrade_shared_satellite, upgrade_action):
"""Perform setup for Foreman Discovery Image upgrade test.
:id: preupgrade-8c94841c-6791-4af0-aa9c-e54c8d8b9a92
:steps:
1. Check installed version of FDI
:expectedresults: Version should be saved and checked post-upgrade
"""
target_sat = fdi_upgrade_shared_satellite
with SharedResource(target_sat.hostname, upgrade_action, target_sat=target_sat) as sat_upgrade:
target_sat.register_to_cdn()
target_sat.execute('foreman-maintain packages install -y foreman-discovery-image')
fdi_package = target_sat.execute('rpm -qa *foreman-discovery-image*').stdout
# Note: The regular exp takes care of format digit.digit.digit or digit.digit.digit-digit in the output
pre_upgrade_version = Version(re.search(r'\d+\.\d+\.\d+(-\d+)?', fdi_package).group())
test_data = Box(
{
'target_sat': target_sat,
'pre_upgrade_version': str(pre_upgrade_version),
}
)
sat_upgrade.ready()
target_sat._session = None
yield test_data


@pytest.mark.discovery_upgrades
def test_post_upgrade_fdi_version(fdi_upgrade_setup):
"""Test FDI version post upgrade.
:id: postugrade-38bdecaa-2b50-434b-90b1-4aa2b600d04e
:steps:
1. Check installed version of FDI
:expectedresults: Version should be greater than or equal to pre_upgrade version
"""
pre_upgrade_version = fdi_upgrade_setup.pre_upgrade_version
target_sat = fdi_upgrade_setup.target_sat
fdi_package = target_sat.execute('rpm -qa *foreman-discovery-image*').stdout
# Note: The regular exp takes care of format digit.digit.digit or digit.digit.digit-digit in the output
post_upgrade_version = Version(re.search(r'\d+\.\d+\.\d+(-\d+)?', fdi_package).group())
assert post_upgrade_version >= Version(pre_upgrade_version)
target_sat.unregister()

0 comments on commit c155bf7

Please sign in to comment.