Skip to content

Commit

Permalink
cu-case-katello-reimport-scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysawant committed Apr 3, 2024
1 parent bfa30ce commit d1ba479
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
3 changes: 3 additions & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,8 @@ class Colored(Box):
'option is not present in the /etc/dnf/dnf.conf'
)

EXPIRED_MANIFEST = 'expired-manifest.zip'

# Data File Paths
class DataFile(Box):
"""The boxed Data directory class with its attributes pointing to the Data directory files"""
Expand All @@ -2167,3 +2169,4 @@ class DataFile(Box):
PARTITION_SCRIPT_DATA_FILE = DATA_DIR.joinpath(PARTITION_SCRIPT_DATA_FILE)
OS_TEMPLATE_DATA_FILE = DATA_DIR.joinpath(OS_TEMPLATE_DATA_FILE)
FAKE_3_YUM_REPO_RPMS_ANT = DATA_DIR.joinpath(FAKE_3_YUM_REPO_RPMS[0])
EXPIRED_MANIFEST_FILE = DATA_DIR.joinpath(EXPIRED_MANIFEST)
44 changes: 43 additions & 1 deletion tests/foreman/cli/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
"""
from fauxfactory import gen_string
from manifester import Manifester
from nailgun import entities
import pytest

from robottelo.constants import PRDS, REPOS, REPOSET
from robottelo.config import settings
from robottelo.constants import EXPIRED_MANIFEST, PRDS, REPOS, REPOSET, DataFile
from robottelo.exceptions import CLIReturnCodeError

pytestmark = [pytest.mark.run_in_one_thread]
Expand Down Expand Up @@ -302,3 +304,43 @@ def test_positive_prepare_for_sca_only_hammer(function_org, target_sat):
'Simple Content Access will be required for all organizations in the next release'
in str(sca_results.stderr)
)

def test_negative_check_katello_reimport(target_sat, function_org):
"""Verify katello:reimport trace should not fail with an TypeError
:id: b7508a1c-7798-4649-83a3-cf94c7409c96
:steps:
1. Import expired manifest & refresh
2. Delete expired manifest
3. Re-import new valid manifest & refresh
:expectedresults: There should not be an error after reimport manifest
:customerscenario: true
:BZ: 2225534, 2253621
"""
remote_path = f'/tmp/{EXPIRED_MANIFEST}'
target_sat.put(DataFile.EXPIRED_MANIFEST_FILE, remote_path)
# Import expired manifest & refresh
target_sat.cli.Subscription.upload({'organization-id': function_org.id, 'file': remote_path})
with pytest.raises(CLIReturnCodeError):
target_sat.cli.Subscription.refresh_manifest({'organization-id': function_org.id})
exec_val = target_sat.execute(
'grep -i "Katello::HttpErrors::BadRequest: This Organization\'s subscription '
'manifest has expired. Please import a new manifest" /var/log/foreman/production.log'
)
assert exec_val.status
# Delete expired manifest
target_sat.cli.Subscription.delete_manifest({'organization-id': function_org.id})
# Re-import new manifest & refresh
manifester = Manifester(manifest_category=settings.manifest.golden_ticket)
manifest = manifester.get_manifest()
target_sat.upload_manifest(function_org.id, manifest.content)
ret_val = target_sat.cli.Subscription.refresh_manifest({'organization-id': function_org.id})
assert 'Candlepin job status: SUCCESS' in ret_val
# Additional check, katello:reimport trace should not fail with TypeError
trace_output = target_sat.execute("foreman-rake katello:reimport --trace")
assert 'TypeError: no implicit conversion of String into Integer' not in trace_output.stdout
assert trace_output.status == 0
Binary file added tests/foreman/data/expired-manifest.zip
Binary file not shown.

0 comments on commit d1ba479

Please sign in to comment.