Skip to content

Commit

Permalink
Add ISS Network Sync class and basic scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
vsedmik committed Dec 21, 2023
1 parent 80e6ba4 commit 479a86d
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 0 deletions.
7 changes: 7 additions & 0 deletions robottelo/cli/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
add-subnet Associate a resource
add-user Associate a resource
create Create an organization
configure-cdn Update the CDN configuration
delete Delete an organization
delete-parameter Delete parameter for an organization.
info Show an organization
Expand Down Expand Up @@ -166,3 +167,9 @@ def remove_user(cls, options=None):
"""Removes an user from an org"""
cls.command_sub = 'remove-user'
return cls.execute(cls._construct_command(options))

@classmethod
def configure_cdn(cls, options=None):
"""Update the CDN configuration"""
cls.command_sub = 'configure-cdn'
return cls.execute(cls._construct_command(options))
148 changes: 148 additions & 0 deletions tests/foreman/cli/test_satellitesync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2059,3 +2059,151 @@ def test_positive_install_package_from_imported_repos(self):
:CaseLevel: System
"""


@pytest.fixture(scope='module')
def module_downstream_sat(module_satellite_host):
"""Provides Downstream Satellite."""
module_satellite_host.cli.Settings.set(
{'name': 'subscription_connection_enabled', 'value': 'No'}
)
return module_satellite_host


@pytest.fixture
def function_downstream_org(module_downstream_sat, function_sca_manifest):
"""Provides organization with manifest on Downstream Satellite."""
org = module_downstream_sat.api.Organization().create()
module_downstream_sat.upload_manifest(org.id, function_sca_manifest.content)
return org


def _set_downstream_org(
dwn_sat,
up_sat,
dwn_org,
up_org='Default_Organization',
username=settings.server.admin_username,
password=settings.server.admin_password,
lce_label=None,
cv_label=None,
):
"""Configures Downstream organization to sync from particular Upstream organization.
:param dwn_sat: Downstream Satellite instance.
:param up_sat: Upstream Satellite instance.
:param dwn_org: Downstream organization to be configured.
:param up_org: Upstream organization to sync CDN content from, default: Default_Organization
:param username: Username for authentication, default: admin username from settings.
:param password: Password for authentication, default: admin password from settings.
:param lce_label: Upstream Lifecycle Environment, default: Library
:param cv_label: Upstream Content View Label, default: Default_Organization_View.
:return: True if succeeded.
"""
# Create Content Credentials with Upstream Satellite's katello-server-ca.crt.
crt_file = f'{up_sat.hostname}.crt'
dwn_sat.execute(f'curl -o {crt_file} http://{up_sat.hostname}/pub/katello-server-ca.crt')
cc = dwn_sat.cli.ContentCredential.create(
{
'name': up_sat.hostname,
'organization-id': dwn_org.id,
'path': crt_file,
'content-type': 'cert',
}
)
# Set the CDN configuration to Network Sync.
res = dwn_sat.cli.Org.configure_cdn(
{
'id': dwn_org.id,
'type': 'network_sync',
'url': f'https://{up_sat.hostname}/',
'username': username,
'password': password,
'upstream-organization-label': up_org.label,
'upstream-lifecycle-environment-label': lce_label,
'upstream-content-view-label': cv_label,
'ssl-ca-credential-id': cc['id'],
}
)
return 'Updated CDN configuration' in res


class TestNetworkSync:
"""Implements Network Sync scenarios."""

@pytest.mark.tier2
@pytest.mark.parametrize(
'function_synced_rhel_repo',
['rhae2'],
indirect=True,
)
def test_positive_network_sync_rh_repo(
self,
target_sat,
function_sca_manifest_org,
function_synced_rhel_repo,
module_downstream_sat,
function_downstream_org,
):
"""Sync a RH repo from Upstream to Downstream Satellite
:id: fdb58c18-0a64-418b-990d-2233381fee8f
:parametrized: yes
:setup:
1. Enabled and synced RH yum repository at Upstream Sat.
2. Organization with manifest at Downstream Sat.
:steps:
1. Set the Downstream org to sync from Upstream org.
2. Enable and sync the repository from Upstream to Downstream.
:expectedresults:
1. Repository can be enabled and synced.
:CaseLevel: System
:BZ: 2213128
:customerscenario: true
"""
assert _set_downstream_org(
module_downstream_sat,
target_sat,
function_downstream_org,
function_sca_manifest_org,
), 'Downstream org configuration failed'

# Enable and sync the repository.
reposet = module_downstream_sat.cli.RepositorySet.list(
{
'organization-id': function_downstream_org.id,
'search': f'content_label={function_synced_rhel_repo["content-label"]}',
}
)
assert (
len(reposet) == 1
), f'Expected just one reposet for "{function_synced_rhel_repo["content-label"]}"'
res = module_downstream_sat.cli.RepositorySet.enable(
{
'organization-id': function_downstream_org.id,
'id': reposet[0]['id'],
'basearch': DEFAULT_ARCHITECTURE,
}
)
assert 'Repository enabled' in str(res), 'Repository enable failed'

repos = module_downstream_sat.cli.Repository.list(
{'organization-id': function_downstream_org.id}
)
assert len(repos) == 1, 'Expected 1 repo enabled'
repo = repos[0]
module_downstream_sat.cli.Repository.synchronize({'id': repo['id']})

repo = module_downstream_sat.cli.Repository.info({'id': repo['id']})
assert 'Success' in repo['sync']['status'], 'Sync did not succeed'
assert (
repo['content-counts'] == function_synced_rhel_repo['content-counts']
), 'Content counts do not match'

0 comments on commit 479a86d

Please sign in to comment.