Skip to content

Commit

Permalink
[6.15.z] fixing the incorrect recording video url (SatelliteQE#13722)
Browse files Browse the repository at this point in the history
fixing the incorrect recording video url (SatelliteQE#13714)

fixing the recording video url

(cherry picked from commit de84bd3)

Co-authored-by: Omkar Khatavkar <[email protected]>
  • Loading branch information
Satellite-QE and omkarkhatavkar committed Jan 11, 2024
1 parent c6f27b4 commit 3139186
Show file tree
Hide file tree
Showing 20 changed files with 828 additions and 612 deletions.
29 changes: 29 additions & 0 deletions pytest_fixtures/core/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
from requests.exceptions import HTTPError

from robottelo.hosts import Satellite
from robottelo.logging import logger


Expand Down Expand Up @@ -70,3 +71,31 @@ def test_foo(autosession):
"""
with target_sat.ui_session(test_name, ui_user.login, ui_user.password) as started_session:
yield started_session


@pytest.fixture(autouse=True)
def ui_session_record_property(request, record_property):
"""
Autouse fixture to set the record_property attribute for Satellite instances in the test.
This fixture iterates over all fixtures in the current test node
(excluding the current fixture) and sets the record_property attribute
for instances of the Satellite class.
Args:
request: The pytest request object.
record_property: The value to set for the record_property attribute.
"""
test_directories = [
'tests/foreman/destructive',
'tests/foreman/ui',
'tests/foreman/sanity',
'tests/foreman/virtwho',
]
test_file_path = request.node.fspath.strpath
if any(directory in test_file_path for directory in test_directories):
for fixture in request.node.fixturenames:
if request.fixturename != fixture:
if isinstance(request.getfixturevalue(fixture), Satellite):
sat = request.getfixturevalue(fixture)
sat.record_property = record_property
2 changes: 1 addition & 1 deletion robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@ def get_caller():
raise
finally:
video_url = settings.ui.grid_url.replace(
':4444', f'/videos/{ui_session.ui_session_id}.mp4'
':4444', f'/videos/{ui_session.ui_session_id}/video.mp4'
)
if self.record_property is not None and settings.ui.record_video:
self.record_property('video_url', video_url)
Expand Down
140 changes: 74 additions & 66 deletions tests/foreman/ui/test_activationkey.py

Large diffs are not rendered by default.

28 changes: 17 additions & 11 deletions tests/foreman/ui/test_bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"""
from airgun.exceptions import NoSuchElementException
from airgun.session import Session
from fauxfactory import gen_string
from nailgun import entities
import pytest

from robottelo.config import user_nailgun_config
Expand Down Expand Up @@ -91,7 +89,9 @@ def test_positive_end_to_end(session, ui_entity):


@pytest.mark.tier2
def test_positive_create_bookmark_public(session, ui_entity, default_viewer_role, test_name):
def test_positive_create_bookmark_public(
session, ui_entity, default_viewer_role, test_name, module_target_sat
):
"""Create and check visibility of the (non)public bookmarks
:id: 93139529-7690-429b-83fe-3dcbac4f91dc
Expand Down Expand Up @@ -123,7 +123,9 @@ def test_positive_create_bookmark_public(session, ui_entity, default_viewer_role
{'name': name, 'query': gen_string('alphanumeric'), 'public': name == public_name}
)
assert any(d['Name'] == name for d in session.bookmark.search(name))
with Session(test_name, default_viewer_role.login, default_viewer_role.password) as session:
with module_target_sat.ui_session(
test_name, default_viewer_role.login, default_viewer_role.password
) as session:
assert any(d['Name'] == public_name for d in session.bookmark.search(public_name))
assert not session.bookmark.search(nonpublic_name)

Expand Down Expand Up @@ -182,15 +184,15 @@ def test_positive_update_bookmark_public(
controller=ui_entity['controller'],
public=name == public_name,
).create()
with Session(
with target_sat.ui_session(
test_name, default_viewer_role.login, default_viewer_role.password
) as non_admin_session:
assert any(d['Name'] == public_name for d in non_admin_session.bookmark.search(public_name))
assert not non_admin_session.bookmark.search(nonpublic_name)
with session:
session.bookmark.update(public_name, {'public': False})
session.bookmark.update(nonpublic_name, {'public': True})
with Session(
with target_sat.ui_session(
test_name, default_viewer_role.login, default_viewer_role.password
) as non_admin_session:
assert any(
Expand All @@ -200,7 +202,7 @@ def test_positive_update_bookmark_public(


@pytest.mark.tier2
def test_negative_delete_bookmark(ui_entity, default_viewer_role, test_name):
def test_negative_delete_bookmark(ui_entity, default_viewer_role, test_name, module_target_sat):
"""Simple removal of a bookmark query without permissions
:id: 1a94bf2b-bcc6-4663-b70d-e13244a0783b
Expand All @@ -219,8 +221,10 @@ def test_negative_delete_bookmark(ui_entity, default_viewer_role, test_name):
:expectedresults: The delete buttons are not displayed
"""
bookmark = entities.Bookmark(controller=ui_entity['controller'], public=True).create()
with Session(
bookmark = module_target_sat.api.Bookmark(
controller=ui_entity['controller'], public=True
).create()
with module_target_sat.ui_session(
test_name, default_viewer_role.login, default_viewer_role.password
) as non_admin_session:
assert non_admin_session.bookmark.search(bookmark.name)[0]['Name'] == bookmark.name
Expand All @@ -230,7 +234,7 @@ def test_negative_delete_bookmark(ui_entity, default_viewer_role, test_name):


@pytest.mark.tier2
def test_negative_create_with_duplicate_name(session, ui_entity):
def test_negative_create_with_duplicate_name(session, ui_entity, module_target_sat):
"""Create bookmark with duplicate name
:id: 18168c9c-bdd1-4839-a506-cf9b06c4ab44
Expand All @@ -248,7 +252,9 @@ def test_negative_create_with_duplicate_name(session, ui_entity):
:BZ: 1920566, 1992652
"""
query = gen_string('alphanumeric')
bookmark = entities.Bookmark(controller=ui_entity['controller'], public=True).create()
bookmark = module_target_sat.api.Bookmark(
controller=ui_entity['controller'], public=True
).create()
with session:
existing_bookmark = session.bookmark.search(bookmark.name)[0]
assert existing_bookmark['Name'] == bookmark.name
Expand Down
3 changes: 1 addition & 2 deletions tests/foreman/ui/test_branding.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
:CaseImportance: High
"""
from airgun.session import Session
import pytest


Expand All @@ -31,7 +30,7 @@ def test_verify_satellite_login_screen_info(target_sat):
:BZ: 1315849, 1367495, 1372436, 1502098, 1540710, 1582476, 1724738,
1959135, 2076979, 1687250, 1686540, 1742872, 1805642, 2105949
"""
with Session(login=False) as session:
with target_sat.ui_session(login=False) as session:
version = session.login.read_sat_version()
assert f'Version {target_sat.version}' == version['login_text']
assert 'Beta' not in version['login_text'], '"Beta" should not be there'
48 changes: 26 additions & 22 deletions tests/foreman/ui/test_contenthost.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
import re
from urllib.parse import urlparse

from airgun.session import Session
from fauxfactory import gen_integer, gen_string
from nailgun import entities
import pytest

from robottelo.config import setting_is_set, settings
Expand All @@ -44,8 +42,10 @@


@pytest.fixture(scope='module', autouse=True)
def host_ui_default():
settings_object = entities.Setting().search(query={'search': 'name=host_details_ui'})[0]
def host_ui_default(module_target_sat):
settings_object = module_target_sat.api.Setting().search(
query={'search': 'name=host_details_ui'}
)[0]
settings_object.value = 'No'
settings_object.update({'value'})
yield
Expand All @@ -54,10 +54,10 @@ def host_ui_default():


@pytest.fixture(scope='module')
def module_org():
org = entities.Organization(simple_content_access=False).create()
def module_org(module_target_sat):
org = module_target_sat.api.Organization(simple_content_access=False).create()
# adding remote_execution_connect_by_ip=Yes at org level
entities.Parameter(
module_target_sat.api.Parameter(
name='remote_execution_connect_by_ip',
value='Yes',
organization=org.id,
Expand All @@ -82,9 +82,9 @@ def vm_module_streams(module_repos_collection_with_manifest, rhel8_contenthost,
return rhel8_contenthost


def set_ignore_facts_for_os(value=False):
def set_ignore_facts_for_os(module_target_sat, value=False):
"""Helper to set 'ignore_facts_for_operatingsystem' setting"""
ignore_setting = entities.Setting().search(
ignore_setting = module_target_sat.api.Setting().search(
query={'search': 'name="ignore_facts_for_operatingsystem"'}
)[0]
ignore_setting.value = str(value)
Expand Down Expand Up @@ -659,7 +659,7 @@ def test_positive_remove_package_group(session, default_location, vm):
indirect=True,
)
def test_positive_search_errata_non_admin(
session, default_location, vm, test_name, default_viewer_role
default_location, vm, test_name, default_viewer_role, module_target_sat
):
"""Search for host's errata by non-admin user with enough permissions
Expand All @@ -675,7 +675,7 @@ def test_positive_search_errata_non_admin(
:parametrized: yes
"""
vm.run(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}')
with Session(
with module_target_sat.ui_session(
test_name, user=default_viewer_role.login, password=default_viewer_role.password
) as session:
session.location.select(default_location.name)
Expand Down Expand Up @@ -822,7 +822,9 @@ def test_positive_host_re_registration_with_host_rename(
],
indirect=True,
)
def test_positive_check_ignore_facts_os_setting(session, default_location, vm, module_org, request):
def test_positive_check_ignore_facts_os_setting(
session, default_location, vm, module_org, request, module_target_sat
):
"""Verify that 'Ignore facts for operating system' setting works
properly
Expand Down Expand Up @@ -855,9 +857,9 @@ def test_positive_check_ignore_facts_os_setting(session, default_location, vm, m
major = str(gen_integer(15, 99))
minor = str(gen_integer(1, 9))
expected_os = f'RedHat {major}.{minor}'
set_ignore_facts_for_os(False)
set_ignore_facts_for_os(module_target_sat, False)
host = (
entities.Host()
module_target_sat.api.Host()
.search(query={'search': f'name={vm.hostname} and organization_id={module_org.id}'})[0]
.read()
)
Expand All @@ -866,7 +868,7 @@ def test_positive_check_ignore_facts_os_setting(session, default_location, vm, m
# Get host current operating system value
os = session.contenthost.read(vm.hostname, widget_names='details')['details']['os']
# Change necessary setting to true
set_ignore_facts_for_os(True)
set_ignore_facts_for_os(module_target_sat, True)
# Add cleanup function to roll back setting to default value
request.addfinalizer(set_ignore_facts_for_os)
# Read all facts for corresponding host
Expand All @@ -883,7 +885,7 @@ def test_positive_check_ignore_facts_os_setting(session, default_location, vm, m
# Check that host OS was not changed due setting was set to true
assert os == updated_os
# Put it to false and re-run the process
set_ignore_facts_for_os(False)
set_ignore_facts_for_os(module_target_sat, False)
host.upload_facts(data={'name': vm.hostname, 'facts': facts})
session.contenthost.search('')
updated_os = session.contenthost.read(vm.hostname, widget_names='details')['details']['os']
Expand Down Expand Up @@ -920,8 +922,8 @@ def test_positive_virt_who_hypervisor_subscription_status(
:parametrized: yes
"""
org = entities.Organization().create()
lce = entities.LifecycleEnvironment(organization=org).create()
org = target_sat.api.Organization().create()
lce = target_sat.api.LifecycleEnvironment(organization=org).create()
# TODO move this to either hack around virt-who service or use an env-* compute resource
provisioning_server = settings.libvirt.libvirt_hostname
# Create a new virt-who config
Expand Down Expand Up @@ -992,7 +994,9 @@ def test_positive_virt_who_hypervisor_subscription_status(
],
indirect=True,
)
def test_module_stream_actions_on_content_host(session, default_location, vm_module_streams):
def test_module_stream_actions_on_content_host(
session, default_location, vm_module_streams, module_target_sat
):
"""Check remote execution for module streams actions e.g. install, remove, disable
works on content host. Verify that correct stream module stream
get installed/removed.
Expand All @@ -1005,7 +1009,7 @@ def test_module_stream_actions_on_content_host(session, default_location, vm_mod
"""
stream_version = '5.21'
run_remote_command_on_content_host('dnf -y upload-profile', vm_module_streams)
entities.Parameter(
module_target_sat.api.Parameter(
name='remote_execution_connect_by_ip',
value='Yes',
parameter_type='boolean',
Expand Down Expand Up @@ -1782,7 +1786,7 @@ def test_pagination_multiple_hosts_multiple_pages(session, module_host_template,


@pytest.mark.tier3
def test_search_for_virt_who_hypervisors(session, default_location):
def test_search_for_virt_who_hypervisors(session, default_location, module_target_sat):
"""
Search the virt_who hypervisors with hypervisor=True or hypervisor=False.
Expand All @@ -1796,7 +1800,7 @@ def test_search_for_virt_who_hypervisors(session, default_location):
:CaseImportance: Medium
"""
org = entities.Organization().create()
org = module_target_sat.api.Organization().create()
with session:
session.organization.select(org.name)
session.location.select(default_location.name)
Expand Down
Loading

0 comments on commit 3139186

Please sign in to comment.