Skip to content

Commit

Permalink
Migrate katello-agent tests to REX
Browse files Browse the repository at this point in the history
Katello agent was deprecated and is being removed from 6.15, the
functionality will be replaced by REX.
This PR moves testing of the functionality towards REX.
  • Loading branch information
vsedmik committed Sep 27, 2023
1 parent 23d49f5 commit 9a73c44
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 156 deletions.
1 change: 1 addition & 0 deletions robottelo/cli/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ def make_job_invocation_with_credentials(options=None, credentials=None):
'dynamic': None,
'effective-user': None,
'end-time': None,
'feature': None,
'input-files': None,
'inputs': None,
'job-template': None,
Expand Down
26 changes: 26 additions & 0 deletions robottelo/cli/rex_feature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Usage::
hammer remote-execution-feature [OPTIONS] SUBCOMMAND [ARG] ...
Parameters::
SUBCOMMAND Subcommand
[ARG] ... Subcommand arguments
Subcommands::
info Show remote execution feature
list List remote execution features
update Update a job template
"""
from robottelo.cli.base import Base


class RemoteExecutionFeature(Base):
"""
Handles Remote Execution Feature commands
"""

command_base = 'remote-execution-feature'
4 changes: 1 addition & 3 deletions tests/foreman/api/test_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
from robottelo import constants
from robottelo.cli.base import CLIReturnCodeError
from robottelo.config import settings
from robottelo.constants import DEFAULT_ARCHITECTURE
from robottelo.constants import MIRRORING_POLICIES
from robottelo.constants import REPOS
from robottelo.constants import DEFAULT_ARCHITECTURE, MIRRORING_POLICIES, REPOS
from robottelo.utils.datafactory import parametrized


Expand Down
154 changes: 150 additions & 4 deletions tests/foreman/cli/test_remoteexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
"""
from calendar import monthrange
from datetime import datetime, timedelta
import random
from time import sleep

from broker import Broker
from dateutil.relativedelta import FR, relativedelta
from fauxfactory import gen_string
import pytest

from robottelo import constants
from robottelo.cli.factory import (
make_filter,
make_job_invocation,
Expand All @@ -46,6 +48,21 @@
from robottelo.constants import PRDS, REPOS, REPOSET
from robottelo.hosts import ContentHost
from robottelo.utils import ohsnap
from robottelo.utils.datafactory import filtered_datapoint, parametrized


@filtered_datapoint
def valid_feature_names():
"""Returns a list of valid features and their descriptions"""
return [
{'label': 'katello_package_install', 'jt_name': 'Install Package - Katello Script Default'},
{'label': 'katello_package_update', 'jt_name': 'Update Package - Katello Script Default'},
{'label': 'katello_package_remove', 'jt_name': 'Remove Package - Katello Script Default'},
{'label': 'katello_group_install', 'jt_name': 'Install Group - Katello Script Default'},
{'label': 'katello_group_update', 'jt_name': 'Update Group - Katello Script Default'},
{'label': 'katello_group_remove', 'jt_name': 'Remove Group - Katello Script Default'},
{'label': 'katello_errata_install', 'jt_name': 'Install Errata - Katello Script Default'},
]


@pytest.fixture()
Expand Down Expand Up @@ -269,15 +286,15 @@ def test_positive_run_default_job_template_multiple_hosts_by_ip(
@pytest.mark.skipif(
(not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url'
)
def test_positive_install_multiple_packages_with_a_job_by_ip(
def test_positive_install_remove_multiple_packages_with_a_job(
self, rhel_contenthost, module_org, module_ak_with_cv, target_sat
):
"""Run job to install several packages on host by ip
"""Run job to install and remove several packages on host by ip
:id: 8b73033f-83c9-4024-83c3-5e442a79d320
:expectedresults: Verify the packages were successfully installed
on host
and removed on a host
:parametrized: yes
"""
Expand All @@ -290,16 +307,145 @@ def test_positive_install_multiple_packages_with_a_job_by_ip(
target_sat,
repo=settings.repos.yum_3.url,
)
# Install packages
invocation_command = make_job_invocation(
{
'job-template': 'Install Package - Katello Script Default',
'inputs': 'package={} {} {}'.format(*packages),
'inputs': f'package={" ".join(packages)}',
'search-query': f'name ~ {client.hostname}',
}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
result = client.run(f'rpm -q {" ".join(packages)}')
assert result.status == 0
# Update packages
pre_versions = result.stdout.splitlines()
result = client.run(f'dnf -y downgrade {" ".join(packages)}')
assert result.status == 0
invocation_command = make_job_invocation(
{
'job-template': 'Update Package - Katello Script Default',
'inputs': f'package={" ".join(packages)}',
'search-query': f'name ~ {client.hostname}',
}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
post_versions = client.run(f'rpm -q {" ".join(packages)}').stdout.splitlines()
assert set(pre_versions) == set(post_versions)
# Remove packages
invocation_command = make_job_invocation(
{
'job-template': 'Remove Package - Katello Script Default',
'inputs': f'package={" ".join(packages)}',
'search-query': f'name ~ {client.hostname}',
}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
result = client.run(f'rpm -q {" ".join(packages)}')
assert result.status == len(packages)

@pytest.mark.tier3
@pytest.mark.no_containers
@pytest.mark.rhel_ver_list([8])
@pytest.mark.skipif(
(not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url'
)
def test_positive_install_remove_packagegroup_with_a_job(
self, rhel_contenthost, module_org, module_ak_with_cv, target_sat
):
"""Run job to install and remove several package groups on host by ip
:id: 5be2a5c0-199a-4655-9784-e95c7ef151f5
:expectedresults: Verify the package groups were successfully installed
and removed on a host
:parametrized: yes
"""
client = rhel_contenthost
groups = ['birds', 'mammals']
client.register(
module_org,
None,
module_ak_with_cv.name,
target_sat,
repo=settings.repos.yum_1.url,
)
# Install the package groups
invocation_command = make_job_invocation(
{
'job-template': 'Install Group - Katello Script Default',
'inputs': f'package={" ".join(groups)}',
'search-query': f'name ~ {client.hostname}',
}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
result = client.run('dnf grouplist --installed')
assert all(item in result.stdout for item in groups)
# Remove one of the installed package groups
remove = random.choice(groups)
invocation_command = make_job_invocation(
{
'job-template': 'Remove Group - Katello Script Default',
'inputs': f'package={remove}',
'search-query': f'name ~ {client.hostname}',
}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
result = client.run('dnf grouplist --installed')
assert remove not in result.stdout

@pytest.mark.tier3
@pytest.mark.no_containers
@pytest.mark.rhel_ver_list([8])
@pytest.mark.skipif(
(not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url'
)
def test_positive_install_errata_with_a_job(
self, rhel_contenthost, module_org, module_ak_with_cv, target_sat
):
"""Run job to install errata on host by ip
:id: d906a884-9fd7-48dc-a91b-fa6e8c3311c1
:expectedresults: Verify the errata was successfully installed on a host
:parametrized: yes
"""
client = rhel_contenthost
client.register(
module_org,
None,
module_ak_with_cv.name,
target_sat,
repo=settings.repos.yum_1.url,
)
client.run(f'dnf install -y {constants.FAKE_1_CUSTOM_PACKAGE}')
# Install errata
invocation_command = make_job_invocation(
{
'job-template': 'Install Errata - Katello Script Default',
'inputs': f'errata={settings.repos.yum_0.errata[1]}',
'search-query': f'name ~ {client.hostname}',
}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
result = client.run(f'rpm -q {constants.FAKE_2_CUSTOM_PACKAGE}')
assert result.status == 0

@pytest.mark.tier3
@pytest.mark.parametrize('feature', **parametrized(valid_feature_names()))
def test_positive_match_feature_templates(self, target_sat, feature):
"""Verify the `feature` names match the correct templates
:id: a7cf23fe-4d3b-4bd2-b921-d31ad3e4d7e9
:expectedresults: All features exist and match the expected templates
:parametrized: yes
"""
result = target_sat.cli.RemoteExecutionFeature.info({'id': feature['label']})
assert result['job-template-name'] == feature['jt_name']

@pytest.mark.tier3
@pytest.mark.rhel_ver_list([8])
Expand Down
149 changes: 0 additions & 149 deletions tests/foreman/destructive/test_katello_agent.py

This file was deleted.

0 comments on commit 9a73c44

Please sign in to comment.