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

[6.15.z] Fix AK tests assertion errors (#16220) #16273

Merged
merged 1 commit into from
Sep 10, 2024
Merged
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
41 changes: 24 additions & 17 deletions tests/foreman/cli/test_activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
from random import choice
import re

from broker import Broker
from fauxfactory import gen_alphanumeric, gen_string
import pytest

from robottelo.cli.defaults import Defaults
from robottelo.config import settings
from robottelo.constants import PRDS, REPOS, REPOSET
from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError
from robottelo.hosts import ContentHost
from robottelo.utils.datafactory import (
invalid_values_list,
parametrized,
Expand Down Expand Up @@ -204,9 +202,13 @@ def test_positive_create_content_and_check_enabled(module_org, module_target_sat
{'url': settings.repos.yum_0.url, 'organization-id': module_org.id}
)
content = module_target_sat.cli.ActivationKey.product_content(
{'id': result['activationkey-id'], 'organization-id': module_org.id}
{
'id': result['activationkey-id'],
'organization-id': module_org.id,
'content-access-mode-all': 1,
}
)
assert content[0]['default-enabled?'] == 'true'
assert content[0]['default-enabled?'] == 'false'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



@pytest.mark.tier2
Expand Down Expand Up @@ -592,7 +594,8 @@ def test_negative_update_usage_limit(module_org, module_target_sat):

@pytest.mark.tier3
@pytest.mark.upgrade
def test_positive_usage_limit(module_org, module_location, target_sat):
@pytest.mark.rhel_ver_list([settings.content_host.default_rhel_version])
def test_positive_usage_limit(module_org, module_location, target_sat, content_hosts):
"""Test that Usage limit actually limits usage

:id: 00ded856-e939-4140-ac84-91b6a8643623
Expand All @@ -610,6 +613,7 @@ def test_positive_usage_limit(module_org, module_location, target_sat):

:CaseImportance: Critical
"""
max_hosts = 1
env = target_sat.cli_factory.make_lifecycle_environment({'organization-id': module_org.id})
new_cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id})
target_sat.cli.ContentView.publish({'id': new_cv['id']})
Expand All @@ -622,17 +626,16 @@ def test_positive_usage_limit(module_org, module_location, target_sat):
'lifecycle-environment-id': env['id'],
'content-view': new_cv['name'],
'organization-id': module_org.id,
'max-hosts': '1',
'max-hosts': max_hosts,
}
)
with Broker(nick='rhel7', host_class=ContentHost, _count=2) as clients:
vm1, vm2 = clients
vm1.register(module_org, module_location, new_ak['name'], target_sat)
assert vm1.subscribed
result = vm2.register(module_org, module_location, new_ak['name'], target_sat)
assert not vm2.subscribed
assert result.status == 70
assert len(result.stderr) > 0
vm1, vm2 = content_hosts
vm1.register(module_org, module_location, new_ak['name'], target_sat)
assert vm1.subscribed
result = vm2.register(module_org, module_location, new_ak['name'], target_sat)
assert not vm2.subscribed
assert result.status, 'Second registration was expected to fail'
assert f"Max Hosts ({max_hosts}) reached for activation key '{new_ak.name}'" in result.stderr


@pytest.mark.tier2
Expand Down Expand Up @@ -728,7 +731,7 @@ def test_positive_add_redhat_product(function_entitlement_manifest_org, target_s

@pytest.mark.tier3
@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url')
def test_positive_add_custom_product(module_org, module_target_sat):
def test_positive_add_custom_product(function_org, module_target_sat):
"""Test that custom product can be associated to Activation Keys

:id: 96ace967-e165-4069-8ff7-f54c4c822de0
Expand All @@ -739,11 +742,15 @@ def test_positive_add_custom_product(module_org, module_target_sat):
:BZ: 1426386
"""
result = module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{'url': settings.repos.yum_0.url, 'organization-id': module_org.id}
{'url': settings.repos.yum_0.url, 'organization-id': function_org.id}
)
repo = module_target_sat.cli.Repository.info({'id': result['repository-id']})
content = module_target_sat.cli.ActivationKey.product_content(
{'id': result['activationkey-id'], 'organization-id': module_org.id}
{
'id': result['activationkey-id'],
'organization-id': function_org.id,
'content-access-mode-all': 1,
}
)
assert content[0]['name'] == repo['name']

Expand Down