Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cu-case-katello-reimport-scenario #14572

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,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 @@ -2168,3 +2170,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)
45 changes: 44 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 @@ -276,3 +278,44 @@ def test_positive_auto_attach_disabled_golden_ticket(
with pytest.raises(CLIReturnCodeError) as context:
target_sat.cli.Host.subscription_auto_attach({'host-id': host_id})
assert "This host's organization is in Simple Content Access mode" in str(context.value)


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
vijaysawant marked this conversation as resolved.
Show resolved Hide resolved
vijaysawant marked this conversation as resolved.
Show resolved Hide resolved
assert trace_output.status == 0
Binary file added tests/foreman/data/expired-manifest.zip
Binary file not shown.
Loading