Skip to content

Commit

Permalink
[class_parameter, bookmark, satellite_sync] - Upgrade scenario refact…
Browse files Browse the repository at this point in the history
…or (#10638)

* added the support for class parameter upgrade

* refactored and tested upgrade scenarios for bookmark
  • Loading branch information
omkarkhatavkar authored Mar 9, 2023
1 parent 37237fb commit 3a8ab01
Show file tree
Hide file tree
Showing 12 changed files with 262 additions and 201 deletions.
26 changes: 0 additions & 26 deletions pytest_fixtures/component/contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,3 @@ def module_cv_repo(module_org, module_repository, module_lce, module_target_sat)
content_view = content_view.read()
content_view.version[0].promote(data={'environment_ids': module_lce.id, 'force': False})
return content_view


@pytest.fixture
def set_importing_org(request, module_target_sat):
"""
Sets same CV, product and repository in importing organization as exporting organization
"""
product_name, repo_name, cv_name, mos = request.param
importing_org = module_target_sat.api.Organization().create()
importing_prod = module_target_sat.api.Product(
organization=importing_org, name=product_name
).create()

importing_repo = module_target_sat.api.Repository(
name=repo_name,
mirror_on_sync=mos,
download_policy='immediate',
product=importing_prod,
).create()

importing_cv = module_target_sat.api.ContentView(
name=cv_name, organization=importing_org
).create()
importing_cv.repository = [importing_repo]
importing_cv.update(['repository'])
yield [importing_cv, importing_org]
24 changes: 2 additions & 22 deletions pytest_fixtures/component/puppet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,11 @@
import pytest

from robottelo.config import settings
from robottelo.constants import COMMON_INSTALLER_OPTS as common_opts
from robottelo.constants import ENVIRONMENT
from robottelo.utils.installer import InstallerCommand


common_opts = {
'foreman-proxy-puppetca': 'true',
'foreman-proxy-puppet': 'true',
'puppet-server': 'true',
# Options for puppetbootstrap test
'foreman-proxy-templates': 'true',
'foreman-proxy-http': 'true',
}

enable_satellite_cmd = InstallerCommand(
installer_args=[
'enable-foreman-plugin-puppet',
'enable-foreman-cli-puppet',
'enable-puppet',
],
installer_opts=common_opts,
)

enable_capsule_cmd = InstallerCommand(
installer_args=[
'enable-puppet',
Expand All @@ -35,10 +18,7 @@
@pytest.fixture(scope='session')
def session_puppet_enabled_sat(session_satellite_host):
"""Satellite with enabled puppet plugin"""
result = session_satellite_host.execute(enable_satellite_cmd.get_command(), timeout='20m')
assert result.status == 0
session_satellite_host.execute('hammer -r') # workaround for BZ#2039696
yield session_satellite_host
yield session_satellite_host.enable_puppet()


@pytest.fixture(scope='module')
Expand Down
2 changes: 1 addition & 1 deletion pytest_fixtures/core/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@pytest.fixture(scope="function")
def dependent_scenario_name(request):
"""
This fixture is used to collect the depend test case name.
This fixture is used to collect the dependent test case name.
"""
depend_test_name = [
mark.kwargs['depend_on'].__name__
Expand Down
15 changes: 15 additions & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,21 @@ class Colored(Box):
}
CUSTOM_PUPPET_MODULE_REPOS_VERSION = '-0.2.0.tar.gz'

PULP_EXPORT_DIR = '/var/lib/pulp/exports/'
PULP_IMPORT_DIR = '/var/lib/pulp/imports/'
COMMON_INSTALLER_OPTS = {
'foreman-proxy-puppetca': 'true',
'foreman-proxy-content-puppet': 'true',
'foreman-proxy-puppet': 'true',
'puppet-server': 'true',
'puppet-server-foreman-ssl-ca': '/etc/pki/katello/puppet/puppet_client_ca.crt',
'puppet-server-foreman-ssl-cert': '/etc/pki/katello/puppet/puppet_client.crt',
'puppet-server-foreman-ssl-key': '/etc/pki/katello/puppet/puppet_client.key',
# Options for puppetbootstrap test
'foreman-proxy-templates': 'true',
'foreman-proxy-http': 'true',
}

KICKSTART_CONTENT = [
'treeinfo',
'images/pxeboot/initrd.img',
Expand Down
3 changes: 2 additions & 1 deletion robottelo/host_helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from robottelo.host_helpers.contenthost_mixins import SystemFacts
from robottelo.host_helpers.contenthost_mixins import VersionedContent
from robottelo.host_helpers.satellite_mixins import ContentInfo
from robottelo.host_helpers.satellite_mixins import EnablePlugins
from robottelo.host_helpers.satellite_mixins import Factories
from robottelo.host_helpers.satellite_mixins import SystemInfo

Expand All @@ -14,5 +15,5 @@ class CapsuleMixins(CapsuleInfo):
pass


class SatelliteMixins(ContentInfo, Factories, SystemInfo):
class SatelliteMixins(ContentInfo, Factories, SystemInfo, EnablePlugins):
pass
53 changes: 53 additions & 0 deletions robottelo/host_helpers/satellite_mixins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import contextlib
import io
import os
import random
import re

Expand All @@ -8,12 +9,34 @@
from robottelo.cli.base import CLIReturnCodeError
from robottelo.cli.proxy import CapsuleTunnelError
from robottelo.config import settings
from robottelo.constants import COMMON_INSTALLER_OPTS as common_opts
from robottelo.constants import PULP_EXPORT_DIR
from robottelo.constants import PULP_IMPORT_DIR
from robottelo.host_helpers.api_factory import APIFactory
from robottelo.host_helpers.cli_factory import CLIFactory
from robottelo.logging import logger
from robottelo.utils.installer import InstallerCommand
from robottelo.utils.manifest import clone


class EnablePlugins:
"""Miscellaneous settings helper methods"""

def enable_puppet(self):
enable_satellite_cmd = InstallerCommand(
installer_args=[
'enable-foreman-plugin-puppet',
'enable-foreman-cli-puppet',
'enable-puppet',
],
installer_opts=common_opts,
)
result = self.execute(enable_satellite_cmd.get_command(), timeout='20m')
assert result.status == 0
self.execute('hammer -r') # workaround for BZ#2039696
return self


class ContentInfo:
"""Miscellaneous content helper methods"""

Expand Down Expand Up @@ -168,6 +191,25 @@ def publish_content_view(self, org, repo_list):
content_view = content_view.read()
return content_view

def move_pulp_archive(self, org, export_message):
"""
Moves exported archive(s) and its metadata into import directory,
sets ownership, returns import path
"""
self.execute(
f'mv {PULP_EXPORT_DIR}/{org.name} {PULP_IMPORT_DIR} && '
f'chown -R pulp:pulp {PULP_IMPORT_DIR}'
)

# removes everything before export path,
# replaces EXPORT_PATH by IMPORT_PATH,
# removes metadata filename
import_path = os.path.dirname(
re.sub(rf'.*{PULP_EXPORT_DIR}', PULP_IMPORT_DIR, export_message)
)

return import_path


class SystemInfo:
"""Things that needs access to satellite shell for gaining satellite system configuration"""
Expand Down Expand Up @@ -258,6 +300,17 @@ def default_url_on_new_port(self, oldport, newport):
logger.debug(f'Killing ncat pid: {ncat_pid}')
self.execute(f'kill {ncat_pid.pop()}')

def validate_pulp_filepath(
self,
org,
dir_path,
file_names=['*.json', '*.tar.gz'],
):
"""Checks the existence of certain files in a pulp dir"""
extension_query = ' -o '.join([f'-name "{file}"' for file in file_names])
result = self.execute(fr'find {dir_path}{org.name} -type f \( {extension_query} \)')
return result.stdout


class Factories:
"""Mixin that provides attributes for each factory type"""
Expand Down
Loading

0 comments on commit 3a8ab01

Please sign in to comment.