Skip to content

Commit

Permalink
Update tests for satellite-maintain update command (#14883)
Browse files Browse the repository at this point in the history
  • Loading branch information
Griffin-Sullivan authored May 14, 2024
1 parent 5651769 commit 00ce6d0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 35 deletions.
36 changes: 36 additions & 0 deletions robottelo/cli/sm_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Usage:
satellite-maintain update [OPTIONS] SUBCOMMAND [ARG] ...
Parameters:
SUBCOMMAND subcommand
[ARG] ... subcommand arguments
Subcommands:
check Run pre-update checks before updating
run Run an update
Options:
-h, --help print help
"""
from robottelo.cli.base import Base


class Update(Base):
"""Manipulates Satellite-maintain's update command"""

command_base = 'update'

@classmethod
def check(cls, options=None, env_var=None):
"""Build satellite-maintain update check"""
cls.command_sub = 'check'
options = options or {}
return cls.sm_execute(cls._construct_command(options), env_var=env_var)

@classmethod
def run(cls, options=None, env_var=None):
"""Build satellite-maintain update run"""
cls.command_sub = 'run'
options = options or {}
return cls.sm_execute(cls._construct_command(options), env_var=env_var)
50 changes: 15 additions & 35 deletions tests/foreman/maintain/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import pytest

from robottelo.config import settings
from robottelo.constants import INSTALLER_CONFIG_FILE, SATELLITE_VERSION
from robottelo.constants import INSTALLER_CONFIG_FILE


def last_y_stream_version(release):
Expand Down Expand Up @@ -80,12 +80,11 @@ def test_positive_repositories_validate(sat_maintain):
:BZ: 1632111
"""
xy_version = '.'.join(sat_maintain.version.split('.')[:2])
skip_message = 'Your system is subscribed using custom activation key'
result = sat_maintain.cli.Upgrade.check(
result = sat_maintain.cli.Update.check(
options={
'assumeyes': True,
'target-version': f'{xy_version}.z',
'disable-self-update': True,
'whitelist': 'check-non-redhat-repository',
},
env_var='EXTERNAL_SAT_ORG=Sat6-CI EXTERNAL_SAT_ACTIVATION_KEY=Ext_AK',
Expand All @@ -111,37 +110,25 @@ def test_positive_repositories_validate(sat_maintain):
ids=['default', 'medium'],
indirect=True,
)
def test_negative_pre_upgrade_tuning_profile_check(request, custom_host):
def test_negative_pre_update_tuning_profile_check(request, custom_host):
"""Negative test that verifies a satellite with less than
tuning profile hardware requirements fails on pre-upgrade check.
tuning profile hardware requirements fails on pre-update check.
:id: 240bb97e-7353-4397-8d0e-228c3593c8cc
:steps:
1. Check out a RHEL instance with less than tuning requirements
2. Install Satellite
3. Run pre-upgrade check
3. Run pre-update check
:expectedresults: Pre-upgrade check fails.
:expectedresults: Pre-update check fails.
"""
profile = request.node.callspec.id
rhel_major = custom_host.os_version.major
sat_version = ".".join(settings.server.version.release.split('.')[0:2])
# Register to CDN for RHEL repos, download and enable last y stream's ohsnap repos,
# Register to CDN for RHEL repos, download and enable ohsnap repos,
# and enable the satellite module and install it on the host
custom_host.register_to_cdn()
last_y_stream = last_y_stream_version(
SATELLITE_VERSION if sat_version == 'stream' else sat_version
)
# Updated test to do a z-stream upgrade, as Satellite on RHEL9 is supported from 6.16 onwards.
# Remove this condition once 6.16 is GA
target_version = (
'6.16.z' if (SATELLITE_VERSION == '6.16' and rhel_major == 9) else SATELLITE_VERSION
)
if target_version == '6.16.z':
custom_host.download_repofile(product='satellite', release=sat_version)
else:
custom_host.download_repofile(product='satellite', release=last_y_stream)
custom_host.download_repofile(product='satellite', release=sat_version)
custom_host.install_satellite_or_capsule_package()
# Install with development tuning profile to get around installer checks
custom_host.execute(
Expand All @@ -153,19 +140,12 @@ def test_negative_pre_upgrade_tuning_profile_check(request, custom_host):
f'sed -i "s/tuning: development/tuning: {profile}/g" {INSTALLER_CONFIG_FILE};'
f'satellite-installer'
)
# Get current Satellite version's repofile
custom_host.download_repofile(
product='satellite', release=sat_version, snap=settings.server.version.snap
)
# Run satellite-maintain to have it self update to the newest version,
# however, this will not actually execute the command after updating
custom_host.execute('satellite-maintain upgrade list-versions')
# Check that we can upgrade to the new Y stream version
result = custom_host.execute('satellite-maintain upgrade list-versions')
assert target_version in result.stdout
# Check that the upgrade check fails due to system requirements
result = custom_host.execute(
f'satellite-maintain upgrade check --target-version {target_version}', timeout='5m'
# Check that the update check fails due to system requirements
result = custom_host.cli.Update.check(
options={
'assumeyes': True,
'disable-self-update': True,
}
)
assert (
f'ERROR: The installer is configured to use the {profile} tuning '
Expand Down

0 comments on commit 00ce6d0

Please sign in to comment.