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

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

Merged
merged 2 commits into from
Apr 25, 2024
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
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
Copy link
Member

Choose a reason for hiding this comment

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

FYI, there is a discussion/PR in progress on how we retrieve the default OS.

We are to remove the need of search string especially for searching default os.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jyejare I don't see much progress on the discussion there. Do we want to hold off on this PR/fix? Is someone already assigned to work on it?

Copy link
Member

Choose a reason for hiding this comment

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

@jameerpathan111 @Gauravtalreja1 can either choose to fix discussion/PR comment in this PR or merge this as is if its urgent.

Which we would you like to go ?

Copy link
Collaborator Author

@Gauravtalreja1 Gauravtalreja1 Apr 25, 2024

Choose a reason for hiding this comment

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

@jyejare I'd prefer getting this merged as it is as its urgent for automation many tests are failing due to this, and we can discuss this in JPL call later to make this dynamically configurable later which can be handled in separate PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

a ping would have been nice

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jyejare I don't see much progress on the discussion there. Do we want to hold off on this PR/fix? Is someone already assigned to work on it?

2 weeks ago there were two approvals and no answer from @lpramuk requested changes

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