Skip to content

Commit

Permalink
close-loop bz2209968
Browse files Browse the repository at this point in the history
  • Loading branch information
lhellebr committed Mar 1, 2024
1 parent 0be99dd commit 809a95c
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
18 changes: 18 additions & 0 deletions robottelo/utils/datafactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,24 @@ def valid_hostgroups_list():
]


@filtered_datapoint
def valid_hostgroups_list_short():
"""Generates a list of valid host group names. Shorter so they can be nested.
:return: Returns the valid host group names list
"""
return [
gen_string('alphanumeric', random.randint(1, 15)),
gen_string('alpha', random.randint(1, 15)),
gen_string('cjk', random.randint(1, 15)),
gen_string('latin1', random.randint(1, 15)),
gen_string('numeric', random.randint(1, 15)),
gen_string('utf8', random.randint(1, 15)),
gen_string('html', random.randint(1, 15)),
gen_string('alphanumeric', random.randint(1, 15)),
]


@filtered_datapoint
def valid_labels_list():
"""Generates a list of valid labels."""
Expand Down
78 changes: 77 additions & 1 deletion tests/foreman/ui/test_jobinvocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
:CaseImportance: High
"""
from collections import OrderedDict

from inflection import camelize
import pytest

from robottelo.utils.datafactory import gen_string
from robottelo.utils.datafactory import (
gen_string,
valid_hostgroups_list_short,
)


@pytest.fixture
Expand All @@ -27,6 +32,77 @@ def module_rhel_client_by_ip(module_org, smart_proxy_location, rhel7_contenthost
return rhel7_contenthost


@pytest.mark.no_containers
@pytest.mark.tier4
def test_positive_bz2209968(
session,
module_org,
smart_proxy_location,
target_sat,
):
"""Check that full host group names are displayed when invoking a job
:id: 2301cd1d-ed82-4168-9f9b-d1661ac8fc5b
:steps:
1. Go to Monitor -> Jobs -> Run job
2. In "Target hosts and inputs" step, choose "Host groups" targeting
:expectedresults: Verify that in the dropdown, full hostgroup names are present, e.g. Parent/Child/Grandchild
:parametrized: yes
:customerscenario: true
:BZ: 2209968
"""
names = valid_hostgroups_list_short()
tree = OrderedDict(
{
'parent1': {'name': names[0], 'parent': None},
'parent2': {'name': names[1], 'parent': None},
'child1a': {'name': names[2], 'parent': 'parent1'},
'child1b': {'name': names[3], 'parent': 'parent1'},
'child2': {'name': names[4], 'parent': 'parent2'},
'grandchild1a1': {'name': names[5], 'parent': 'child1a'},
'grandchild1a2': {'name': names[6], 'parent': 'child1a'},
'grandchild1b': {'name': names[7], 'parent': 'child1b'},
}
)
expected_names = []
for identifier, data in tree.items():
name = data['name']
parent_name = None if data['parent'] is None else tree[data['parent']]['name']
target_sat.cli_factory.hostgroup(
{
'name': name,
'parent': parent_name,
'organization-ids': module_org.id,
'location-ids': smart_proxy_location.id,
}
)
expected_name = ''
current = identifier
while current:
expected_name = (
f"{tree[current]['name']}/{expected_name}"
if expected_name
else tree[current]['name']
)
current = tree[current]['parent']
# we should have something like "parent1/child1a"
expected_names.append(expected_name)

with session:
session.organization.select(module_org.name)
session.location.select(smart_proxy_location.name)
hostgroups = session.jobinvocation.read_hostgroups()

for name in expected_names:
assert name in hostgroups


@pytest.mark.tier4
def test_positive_run_default_job_template_by_ip(
session, module_org, smart_proxy_location, module_rhel_client_by_ip
Expand Down

0 comments on commit 809a95c

Please sign in to comment.