Skip to content

Commit

Permalink
Extend search in *_default_os fixtures for EL9 as default OS (Satelli…
Browse files Browse the repository at this point in the history
…teQE#14851)

* Extend search in *_default_os fixtures for EL9 as default OS

Signed-off-by: Gaurav Talreja <[email protected]>

* Move default os search query to constants and delete unused session_default_os fixture

Signed-off-by: Gaurav Talreja <[email protected]>

---------

Signed-off-by: Gaurav Talreja <[email protected]>
  • Loading branch information
Gauravtalreja1 authored and jyejare committed Oct 19, 2024
1 parent 1d55ad2 commit b7c794c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 24 deletions.
4 changes: 3 additions & 1 deletion pytest_fixtures/component/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from nailgun import entities
import pytest

from robottelo import constants


@pytest.fixture(scope='session')
def default_os(
Expand All @@ -17,7 +19,7 @@ def default_os(
"""
os = getattr(request, 'param', None)
if os is None:
search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8")'
search_string = constants.DEFAULT_OS_SEARCH_QUERY
else:
version = os.split(' ')[1].split('.')
search_string = f'family="Redhat" AND major="{version[0]}" AND minor="{version[1]}"'
Expand Down
6 changes: 4 additions & 2 deletions pytest_fixtures/component/provision_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
AZURERM_RHEL7_FT_IMG_URN,
AZURERM_RHEL7_UD_IMG_URN,
DEFAULT_ARCHITECTURE,
DEFAULT_OS_SEARCH_QUERY,
)


Expand Down Expand Up @@ -38,8 +39,9 @@ def sat_azure_domain(sat_azure, sat_azure_loc, sat_azure_org):
@pytest.fixture(scope='module')
def sat_azure_default_os(sat_azure):
"""Default OS on the Satellite"""
search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8" OR major="9")'
return sat_azure.api.OperatingSystem().search(query={'search': search_string})[0].read()
return (
sat_azure.api.OperatingSystem().search(query={'search': DEFAULT_OS_SEARCH_QUERY})[0].read()
)


@pytest.fixture(scope='module')
Expand Down
13 changes: 2 additions & 11 deletions pytest_fixtures/component/provision_gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from robottelo.config import settings
from robottelo.constants import (
DEFAULT_ARCHITECTURE,
DEFAULT_OS_SEARCH_QUERY,
DEFAULT_PTABLE,
FOREMAN_PROVIDERS,
GCE_RHEL_CLOUD_PROJECTS,
Expand Down Expand Up @@ -41,8 +42,7 @@ def sat_gce_domain(sat_gce, sat_gce_loc, sat_gce_org):
@pytest.fixture(scope='module')
def sat_gce_default_os(sat_gce):
"""Default OS on the Satellite"""
search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8" OR major="9")'
return sat_gce.api.OperatingSystem().search(query={'search': search_string})[0].read()
return sat_gce.api.OperatingSystem().search(query={'search': DEFAULT_OS_SEARCH_QUERY})[0].read()


@pytest.fixture(scope='session')
Expand Down Expand Up @@ -103,15 +103,6 @@ def gce_custom_cloudinit_uuid(googleclient, gce_cert):
return googleclient.get_template('customcinit', project=gce_cert['project_id']).uuid


@pytest.fixture(scope='session')
def session_default_os(session_target_sat):
"""Default OS on the Satellite"""
search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8")'
return (
session_target_sat.api.OperatingSystem().search(query={'search': search_string})[0].read()
)


@pytest.fixture(scope='module')
def module_gce_compute(sat_gce, sat_gce_org, sat_gce_loc, gce_cert):
return sat_gce.api.GCEComputeResource(
Expand Down
13 changes: 7 additions & 6 deletions pytest_fixtures/component/puppet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Puppet Environment fixtures
import pytest

from robottelo.constants import ENVIRONMENT
from robottelo import constants


@pytest.fixture(scope='session')
Expand Down Expand Up @@ -119,10 +119,9 @@ def session_puppet_enabled_proxy(session_puppet_enabled_sat):
@pytest.fixture(scope='session')
def session_puppet_default_os(session_puppet_enabled_sat):
"""Default OS on the puppet-enabled Satellite"""
search_string = 'name="RedHat" AND (major="6" OR major="7" OR major="8")'
return (
session_puppet_enabled_sat.api.OperatingSystem()
.search(query={'search': search_string})[0]
.search(query={'search': constants.DEFAULT_OS_SEARCH_QUERY})[0]
.read()
)

Expand All @@ -141,9 +140,11 @@ def module_puppet_lce_library(session_puppet_enabled_sat, module_puppet_org):
"""Returns the Library lifecycle environment from chosen organization"""
return (
session_puppet_enabled_sat.api.LifecycleEnvironment()
.search(query={'search': f'name={ENVIRONMENT} and organization_id={module_puppet_org.id}'})[
0
]
.search(
query={
'search': f'name={constants.ENVIRONMENT} and organization_id={module_puppet_org.id}'
}
)[0]
.read()
)

Expand Down
1 change: 1 addition & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ class Colored(Box):
DEFAULT_ARCHITECTURE = 'x86_64'
DEFAULT_RELEASE_VERSION = '6Server'
DEFAULT_ROLE = 'Default role'
DEFAULT_OS_SEARCH_QUERY = 'name="RedHat" AND (major="6" OR major="7" OR major="8" OR major="9")'

VDC_SUBSCRIPTION_NAME = 'Red Hat Enterprise Linux for Virtual Datacenters, Premium'

Expand Down
3 changes: 2 additions & 1 deletion robottelo/host_helpers/api_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from robottelo.config import settings
from robottelo.constants import (
DEFAULT_ARCHITECTURE,
DEFAULT_OS_SEARCH_QUERY,
DEFAULT_PTABLE,
DEFAULT_PXE_TEMPLATE,
DEFAULT_TEMPLATE,
Expand Down Expand Up @@ -336,7 +337,7 @@ def configure_provisioning(self, org=None, loc=None, compute=False, os=None):
if os is None:
os = (
self._satellite.api.OperatingSystem()
.search(query={'search': 'name="RedHat" AND (major="6" OR major="7")'})[0]
.search(query={'search': DEFAULT_OS_SEARCH_QUERY})[0]
.read()
)
else:
Expand Down
5 changes: 2 additions & 3 deletions tests/foreman/ui/test_contentview_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
CONTAINER_UPSTREAM_NAME,
DEFAULT_ARCHITECTURE,
DEFAULT_CV,
DEFAULT_OS_SEARCH_QUERY,
DEFAULT_PTABLE,
ENVIRONMENT,
FAKE_0_CUSTOM_PACKAGE,
Expand Down Expand Up @@ -2675,9 +2676,7 @@ def test_positive_delete_with_kickstart_repo_and_host_group(
.read()
)
# Get the OS ID
os = target_sat.api.OperatingSystem().search(
query={'search': 'name="RedHat" AND (major="6" OR major="7")'}
)[0]
os = target_sat.api.OperatingSystem().search(query={'search': DEFAULT_OS_SEARCH_QUERY})[0]
# Update the OS to associate arch and ptable
os.architecture = [arch]
os.ptable = [ptable]
Expand Down

0 comments on commit b7c794c

Please sign in to comment.