Skip to content

Commit ef465e2

Browse files
authored
Merge branch 'master' into fix_health_check_tests
2 parents 629fbd8 + 5021243 commit ef465e2

95 files changed

Lines changed: 2214 additions & 1330 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
# 5. To use secret from vault for any settings in conf/*.yaml, use the format: '@format {this._secret_name_in_vault_}'
77
# 6. jira.yaml Example:
88
# JIRA:
9-
# URL: https://issues.redhat.com
9+
# URL: https://redhat.atlassian.net
10+
# EMAIL: your_email@redhat.com
1011
# API_KEY: '@format {this.vault_jira_api_key}'
1112
# COMMENT_TYPE: group
1213
# COMMENT_VISIBILITY: "Red Hat Employee"

.github/workflows/auto_assignment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ jobs:
1515
if: "!contains(github.event.pull_request.labels.*.name, 'Auto_Cherry_Picked')"
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: kentaro-m/auto-assign-action@v2.0.1
18+
- uses: kentaro-m/auto-assign-action@v2.0.2
1919
with:
2020
configuration-path: ".github/auto_assign.yml"

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
env:
99
PYCURL_SSL_LIBRARY: openssl
1010
ROBOTTELO_JIRA__API_KEY: ${{ secrets.JIRA_KEY }}
11+
ROBOTTELO_JIRA__EMAIL: ${{ secrets.JIRA_EMAIL }}
1112

1213
jobs:
1314
codechecks:

.github/workflows/weekly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ jobs:
8383
id: cscheck
8484
env:
8585
ROBOTTELO_JIRA__API_KEY: ${{ secrets.JIRA_KEY }}
86+
ROBOTTELO_JIRA__EMAIL: ${{ secrets.JIRA_EMAIL }}
8687

8788
- name: Customer scenario status
8889
run: |

AGENTS.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
- Location: `tests/foreman/api/`
3838
- Example: `tests/foreman/api/test_activationkey.py`
3939

40-
**Upgrade Tests**: Uses`SharedResource` for single-test upgrade scenarios:
41-
- Location: 'tests/new_upgrades'
42-
- Example: 'tests'new_upgrades/test_activation_key.py'
40+
**Upgrade Tests**: Uses `SharedResource` for single-test upgrade scenarios:
41+
- Location: `tests/new_upgrades`
42+
- Example: `tests/new_upgrades/test_activation_key.py`
4343

4444
---
4545

@@ -78,7 +78,7 @@ The bottom layer containing helper classes, utilities, and base implementations.
7878
- **Location**: `robottelo/`
7979
- **Components**:
8080
- **API helpers**: `robottelo/api/` (Nailgun entities)
81-
- **Host classes**: `robottelo.hosts.py` (Base functionality for ContentHost, Capsule, Satellite interaction s)
81+
- **Host classes**: `robottelo.hosts.py` (Base functionality for ContentHost, Capsule, Satellite interactions)
8282
- **CLI helpers**: `robottelo/cli/` (Hammer command wrappers)
8383
- **Host helpers**: `robottelo/host_helpers/` (Satellite/ContentHost mixins)
8484
- **Utilities**: `robottelo/utils/` (decorators, data factories, etc.)
@@ -110,9 +110,9 @@ Pytest fixtures provide test dependencies and setup/teardown logic.
110110

111111
**Fixture Scopes**:
112112
- `function`: Per test function (default)
113+
- `class`: Per test class
113114
- `module`: Per test module
114115
- `session`: Per test session
115-
- `class`: Per test class
116116

117117
Example:
118118

@@ -175,7 +175,7 @@ ak = target_sat.api.ActivationKey(organization=org).create()
175175
# Using UI session
176176
with target_sat.ui_session() as session:
177177
session.organization.select('ORG_NAME')
178-
session.location.select('LOC_NAME')
178+
session.location.select('LOC_NAME')
179179
session.activationkey.create({'name': 'my-ak'})
180180

181181
# Using ContentHost methods
@@ -214,7 +214,6 @@ email = gen_email() # Random email
214214

215215
```python
216216
# Standard library
217-
from robottelo.logging import logger
218217
from datetime import datetime
219218

220219
# Third-party
@@ -225,6 +224,7 @@ from nailgun.entities import ActivationKey
225224
# Robottelo
226225
from robottelo.config import settings
227226
from robottelo.constants import DEFAULT_CV
227+
from robottelo.logging import logger
228228
from robottelo.utils.datafactory import gen_string
229229
```
230230

@@ -245,7 +245,7 @@ Test names follow a specific pattern to indicate expected behavior:
245245

246246
- `test_positive_*`: Test should succeed (happy path)
247247
- `test_negative_*`: Test should fail with expected error (error handling)
248-
- `test_upgrade_*`: Upgrade scenario test
248+
- `test_post_*`: Post-upgrade scenario test
249249

250250
Examples:
251251
- `test_positive_create_activation_key_with_cv()`
@@ -260,7 +260,7 @@ Use **reStructuredText** format with required fields, Reference `testimony.yaml`
260260
def test_positive_create_activation_key(module_org, module_target_sat):
261261
"""Create activation key with valid name
262262
263-
:id: 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d <uuid generated with 'uuidgen | tr "[:upper:]" "[:lower:]"'>
263+
:id: 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d <generated uuid>
264264
265265
:steps:
266266
1. Create organization
@@ -278,11 +278,11 @@ def test_positive_create_activation_key(module_org, module_target_sat):
278278
```
279279

280280
**Required Fields**:
281-
- `:id:` - Unique test UUID
281+
- `:id:` - Unique test UUID. Use `python -c 'import uuid; print(uuid.uuid4())'` to generate it
282282
- `:steps:` - Test execution steps
283283
- `:expectedresults:` - Expected outcome
284284

285-
**Optional fields**
285+
**Optional fields**:
286286
- `:Verifies:` - When the test verifies a Bug (Use as :Verifies: SAT-12345) (Formerly there was :BZ: tag, don't use that anymore)
287287
---
288288

@@ -309,7 +309,7 @@ def test_positive_create_ak_via_ui(module_org, module_target_sat):
309309
assert ak_values['details']['name'] == ak_name
310310
```
311311

312-
### Pattern 3: CLI Test
312+
### Pattern 2: CLI Test
313313

314314
```python
315315
def test_positive_create_ak_via_cli(module_org, module_target_sat):
@@ -333,7 +333,7 @@ def test_positive_create_ak_via_cli(module_org, module_target_sat):
333333
assert ak_info['name'] == ak_name
334334
```
335335

336-
### Pattern 4: Parametrized Test
336+
### Pattern 3: Parametrized Test
337337

338338
```python
339339
@pytest.mark.parametrize('name', [
@@ -362,7 +362,7 @@ def test_positive_create_with_different_names(name, module_org, module_target_sa
362362
indirect=True,
363363
)
364364
```
365-
### Pattern 5: End-to-End Test
365+
### Pattern 4: End-to-End Test
366366

367367
```python
368368
@pytest.mark.e2e
@@ -431,13 +431,18 @@ def module_satellite_iop(request, satellite_factory):
431431
**ContentHost Fixtures** (`pytest_fixtures/core/contenthosts.py`):
432432

433433
```python
434-
# RHEL ContentHost
434+
# RHEL ContentHost - parametrized for all supported RHEL versions defined in conf/supportability.yaml
435435
@pytest.fixture
436436
def rhel_contenthost(request):
437437
"""Provides a RHEL content host"""
438438
...
439439

440-
# If there is no need for multiple RHEL versions to be tested, but RHEL host is still needed for the sake of the test.
440+
# Parametrized for N latest RHEL versions only (N-0 = latest, N-1 = latest two, etc.)
441+
@pytest.mark.rhel_ver_match('N-1')
442+
def test_latest_two_rhels(rhel_contenthost):
443+
...
444+
445+
# If there is no need for multiple RHEL versions to be tested, use only RHEL host of the default version specified in settings.
441446
from robottelo.config import settings
442447
@pytest.mark.rhel_ver_match([settings.content_host.default_rhel_version])
443448
def test_with_default_rhel(rhel_contenthost):
@@ -511,18 +516,19 @@ def function_sca_manifest():
511516
```python
512517
@pytest.mark.e2e # End-to-end tests
513518
@pytest.mark.stubbed # Not yet implemented
514-
@pytest.mark.destructive # Modifies Satellite config and needs satellite teardown
519+
@pytest.mark.destructive # Forces deployment of a new Satellite instance for a particular test case (more expensive)
515520
@pytest.mark.skip_if_open() # Skip if BZ/issue open
516521
```
517522

518523
**Infrastructure Markers**:
524+
Content hosts are deployed in containers by default. If the host needs to run as a VM, use the `no_containers` marker.
519525
```python
520526
@pytest.mark.no_containers # Cannot run in containers
521527
```
522528

523529
### RHEL Version Markers
524530

525-
**`@pytest.mark.rhel_ver_match()`**: Match RHEL versions by regex
531+
**`@pytest.mark.rhel_ver_match()`**: Match RHEL versions based on versions defined in conf/supportability.yaml using regex, or by the N-x convention.
526532

527533
```python
528534
# Match RHEL 9 and 10 (exclude 7 and 8)
@@ -533,6 +539,9 @@ def function_sca_manifest():
533539

534540
# Match RHEL 9 including FIPS
535541
@pytest.mark.rhel_ver_match(r'^9') # Matches 9, 9_fips
542+
543+
# Using N-x convention
544+
@pytest.mark.rhel_ver_match('N-2') # Matches 3 latest RHEL versions
536545
```
537546

538547
**`@pytest.mark.rhel_ver_list()`**: Specify exact RHEL versions
@@ -838,7 +847,7 @@ repo_url = settings.repos.yum_3.url
838847
- Action: `create`, `update`, `delete`, `list`
839848

840849
* **Test Documentation:** Every test must have:
841-
- Unique `:id:` UUID generated with 'uuidgen | tr "[:upper:]" "[:lower:]"'
850+
- Unique `:id:` UUID (use `python -c 'import uuid; print(uuid.uuid4())'`)
842851
- Clear `:steps:`
843852
- Expected `:expectedresults:`
844853

conf/jira.yaml.template

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
JIRA:
2-
# url default value is set to 'https://issues.redhat.com' even if not provided.
3-
URL: https://issues.redhat.com
4-
# Provide api_key to access Jira REST API
2+
# url default value is set to 'https://redhat.atlassian.net' even if not provided.
3+
URL: https://redhat.atlassian.net
4+
# Provide email and api_key to access Jira REST API
5+
EMAIL: your_email@redhat.com
56
API_KEY: replace-with-jira-api-key
67
COMMENT_TYPE: group
78
COMMENT_VISIBILITY: "Red Hat Employee"

conf/rh_cloud.yaml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RH_CLOUD:
44
ORGANIZATION:
55
ACTIVATION_KEY: ak_name
66
CRC_ENV: prod
7-
IOP_ADVISOR_ENGINE:
7+
IOP:
88
IMAGE_PATH: # For 6.17 IoP
99
IMAGE_PATHS: # For 6.18+ IoP
1010
REGISTRY:

conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import pytest
44

5+
from robottelo.config import settings
6+
57
pytest_plugins = [
68
# Plugins
79
'pytest_plugins.auto_vault',
@@ -94,3 +96,14 @@ def pytest_runtest_makereport(item, call):
9496
# be "setup", "call", "teardown"
9597

9698
setattr(item, "report_" + report.when, report)
99+
100+
101+
@pytest.hookimpl(hookwrapper=True)
102+
def pytest_runtest_protocol(item, nextitem):
103+
"""Set version source to upstream for tests marked with foremanctl."""
104+
if item.get_closest_marker('foremanctl'):
105+
settings.set('server.version.source', 'upstream')
106+
yield
107+
settings.set('server.version.source', 'internal')
108+
else:
109+
yield

pytest_fixtures/component/hostgroup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ def module_hostgroup(module_target_sat):
1010
return module_target_sat.api.HostGroup().create()
1111

1212

13+
@pytest.fixture(scope='module')
14+
def module_hostgroup_with_org_loc(module_target_sat, module_org, module_location):
15+
return module_target_sat.api.HostGroup(
16+
organization=[module_org], location=[module_location]
17+
).create()
18+
19+
1320
@pytest.fixture(scope='class')
1421
def class_hostgroup(class_target_sat, class_org, class_location):
1522
"""Create a hostgroup linked to specific org and location created at the class scope"""

pytest_fixtures/component/maintain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def sat_maintain(request):
6363
yield infra_host
6464

6565
if host_type == 'satellite_iop':
66-
iop_settings = settings.rh_cloud.iop_advisor_engine
66+
iop_settings = settings.rh_cloud.iop
6767
if not infra_host.is_podman_logged_in(iop_settings.stage_registry):
6868
infra_host.podman_login(
6969
iop_settings.stage_username,

0 commit comments

Comments
 (0)