Skip to content

Commit

Permalink
Merge branch 'master' into codecoverage_2173870
Browse files Browse the repository at this point in the history
  • Loading branch information
yanpliu authored Mar 12, 2024
2 parents db6cade + 98f375d commit 8d035be
Show file tree
Hide file tree
Showing 176 changed files with 1,023 additions and 870 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/prt_labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Remove the PRT label, for the new commit

on:
pull_request:
types: ["synchronize"]

jobs:
prt_labels_remover:
name: remove the PRT label when amendments or new commits added to PR
runs-on: ubuntu-latest
if: "(contains(github.event.pull_request.labels.*.name, 'PRT-Passed') || contains(github.event.pull_request.labels.*.name, 'PRT-Failed'))"
steps:
- name: Avoid the race condition as PRT result will be cleaned
run: |
echo "Avoiding the race condition if prt result will be cleaned" && sleep 60
- name: Fetch the PRT status
id: prt
uses: omkarkhatavkar/wait-for-status-checks@main
with:
ref: ${{ github.head_ref }}
context: 'Robottelo-Runner'
wait-interval: 2
count: 5

- name: remove the PRT Passed/Failed label, for new commit
if: always() && ${{steps.prt.outputs.result}} == 'not_found'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CHERRYPICK_PAT }}
script: |
const prNumber = '${{ github.event.number }}';
const issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const labelsToRemove = ['PRT-Failed', 'PRT-Passed'];
const labelsToRemoveFiltered = labelsToRemove.filter(label => issue.data.labels.some(({ name }) => name === label));
if (labelsToRemoveFiltered.length > 0) {
await Promise.all(labelsToRemoveFiltered.map(async label => {
await github.rest.issues.removeLabel({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
name: label
});
}));
}
2 changes: 2 additions & 0 deletions conf/capsule.yaml.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
CAPSULE:
# Capsule hostname for N-minus testing
HOSTNAME:
VERSION:
# The full release version (6.9.2)
RELEASE: # populate with capsule version
Expand Down
9 changes: 4 additions & 5 deletions conf/dynaconf_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def get_ohsnap_repos(settings):
settings,
repo='capsule',
product='capsule',
release=settings.server.version.release,
os_release=settings.server.version.rhel_version,
snap=settings.server.version.snap,
release=settings.capsule.version.release,
os_release=settings.capsule.version.rhel_version,
snap=settings.capsule.version.snap,
)

data['SATELLITE_REPO'] = get_ohsnap_repo_url(
Expand Down Expand Up @@ -157,12 +157,11 @@ def get_dogfood_satclient_repos(settings):


def get_ohsnap_repo_url(settings, repo, product=None, release=None, os_release=None, snap=''):
repourl = dogfood_repository(
return dogfood_repository(
settings.ohsnap,
repo=repo,
product=product,
release=release,
os_release=os_release,
snap=snap,
).baseurl
return repourl
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'pytest_plugins.requirements.update_requirements',
'pytest_plugins.sanity_plugin',
'pytest_plugins.video_cleanup',
'pytest_plugins.capsule_n-minus',
# Fixtures
'pytest_fixtures.core.broker',
'pytest_fixtures.core.sat_cap_factory',
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ select = [
"I", # isort
# "Q", # flake8-quotes
"PT", # flake8-pytest
"RET", # flake8-return
"SIM", # flake8-simplify
"UP", # pyupgrade
"W", # pycodestyle
]
Expand Down
15 changes: 5 additions & 10 deletions pytest_fixtures/component/activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,37 @@
@pytest.fixture(scope='module')
def module_activation_key(module_sca_manifest_org, module_target_sat):
"""Create activation key using default CV and library environment."""
activation_key = module_target_sat.api.ActivationKey(
return module_target_sat.api.ActivationKey(
content_view=module_sca_manifest_org.default_content_view.id,
environment=module_sca_manifest_org.library.id,
organization=module_sca_manifest_org,
).create()
return activation_key


@pytest.fixture(scope='module')
def module_ak(module_lce, module_org, module_target_sat):
ak = module_target_sat.api.ActivationKey(
return module_target_sat.api.ActivationKey(
environment=module_lce,
organization=module_org,
).create()
return ak


@pytest.fixture(scope='module')
def module_ak_with_cv(module_lce, module_org, module_promoted_cv, module_target_sat):
ak = module_target_sat.api.ActivationKey(
return module_target_sat.api.ActivationKey(
content_view=module_promoted_cv,
environment=module_lce,
organization=module_org,
).create()
return ak


@pytest.fixture(scope='module')
def module_ak_with_cv_repo(module_lce, module_org, module_cv_repo, module_target_sat):
ak = module_target_sat.api.ActivationKey(
return module_target_sat.api.ActivationKey(
content_view=module_cv_repo,
environment=module_lce,
organization=module_org,
).create()
return ak


@pytest.fixture(scope='module')
Expand All @@ -55,12 +51,11 @@ def module_ak_with_synced_repo(module_org, module_target_sat):
{'product-id': new_product['id'], 'content-type': 'yum'}
)
Repository.synchronize({'id': new_repo['id']})
ak = module_target_sat.cli_factory.make_activation_key(
return module_target_sat.cli_factory.make_activation_key(
{
'lifecycle-environment': 'Library',
'content-view': 'Default Organization View',
'organization-id': module_org.id,
'auto-attach': False,
}
)
return ak
6 changes: 2 additions & 4 deletions pytest_fixtures/component/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@

@pytest.fixture(scope='session')
def default_architecture(session_target_sat):
arch = (
return (
session_target_sat.api.Architecture()
.search(query={'search': f'name="{DEFAULT_ARCHITECTURE}"'})[0]
.read()
)
return arch


@pytest.fixture(scope='session')
def session_puppet_default_architecture(session_puppet_enabled_sat):
arch = (
return (
session_puppet_enabled_sat.api.Architecture()
.search(query={'search': f'name="{DEFAULT_ARCHITECTURE}"'})[0]
.read()
)
return arch


@pytest.fixture(scope='module')
Expand Down
3 changes: 1 addition & 2 deletions pytest_fixtures/component/contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ def module_ak_cv_lce(module_org, module_lce, module_published_cv, module_target_
content_view_version = module_published_cv.version[0]
content_view_version.promote(data={'environment_ids': module_lce.id})
module_published_cv = module_published_cv.read()
module_ak_with_cv_lce = module_target_sat.api.ActivationKey(
return module_target_sat.api.ActivationKey(
content_view=module_published_cv,
environment=module_lce,
organization=module_org,
).create()
return module_ak_with_cv_lce


@pytest.fixture(scope='module')
Expand Down
1 change: 0 additions & 1 deletion pytest_fixtures/component/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def module_model():
return entities.Model().create()


@pytest.mark.skip_if_not_set('clients', 'fake_manifest')
@pytest.fixture(scope="module")
def setup_rhst_repo(module_target_sat):
"""Prepare Satellite tools repository for usage in specified organization"""
Expand Down
3 changes: 1 addition & 2 deletions pytest_fixtures/component/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def default_os(
os.ptable.append(default_partitiontable)
os.provisioning_template.append(default_pxetemplate)
os.update(['architecture', 'ptable', 'provisioning_template'])
os = entities.OperatingSystem(id=os.id).read()
return os
return entities.OperatingSystem(id=os.id).read()


@pytest.fixture(scope='module')
Expand Down
24 changes: 8 additions & 16 deletions pytest_fixtures/component/provision_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,23 @@ def sat_azure_default_os(sat_azure):

@pytest.fixture(scope='module')
def sat_azure_default_architecture(sat_azure):
arch = (
return (
sat_azure.api.Architecture()
.search(query={'search': f'name="{DEFAULT_ARCHITECTURE}"'})[0]
.read()
)
return arch


@pytest.fixture(scope='session')
def azurerm_settings():
deps = {
return {
'tenant': settings.azurerm.tenant_id,
'app_ident': settings.azurerm.client_id,
'sub_id': settings.azurerm.subscription_id,
'resource_group': settings.azurerm.resource_group,
'secret': settings.azurerm.client_secret,
'region': settings.azurerm.azure_region.lower().replace(' ', ''),
}
return deps


@pytest.fixture(scope='session')
Expand All @@ -86,7 +84,7 @@ def azurermclient(azurerm_settings):
@pytest.fixture(scope='module')
def module_azurerm_cr(azurerm_settings, sat_azure_org, sat_azure_loc, sat_azure):
"""Create AzureRM Compute Resource"""
azure_cr = sat_azure.api.AzureRMComputeResource(
return sat_azure.api.AzureRMComputeResource(
name=gen_string('alpha'),
provider='AzureRm',
tenant=azurerm_settings['tenant'],
Expand All @@ -97,7 +95,6 @@ def module_azurerm_cr(azurerm_settings, sat_azure_org, sat_azure_loc, sat_azure)
organization=[sat_azure_org],
location=[sat_azure_loc],
).create()
return azure_cr


@pytest.fixture(scope='module')
Expand All @@ -108,15 +105,14 @@ def module_azurerm_finishimg(
module_azurerm_cr,
):
"""Creates Finish Template image on AzureRM Compute Resource"""
finish_image = sat_azure.api.Image(
return sat_azure.api.Image(
architecture=sat_azure_default_architecture,
compute_resource=module_azurerm_cr,
name=gen_string('alpha'),
operatingsystem=sat_azure_default_os,
username=settings.azurerm.username,
uuid=AZURERM_RHEL7_FT_IMG_URN,
).create()
return finish_image


@pytest.fixture(scope='module')
Expand All @@ -127,15 +123,14 @@ def module_azurerm_byos_finishimg(
sat_azure,
):
"""Creates BYOS Finish Template image on AzureRM Compute Resource"""
finish_image = sat_azure.api.Image(
return sat_azure.api.Image(
architecture=sat_azure_default_architecture,
compute_resource=module_azurerm_cr,
name=gen_string('alpha'),
operatingsystem=sat_azure_default_os,
username=settings.azurerm.username,
uuid=AZURERM_RHEL7_FT_BYOS_IMG_URN,
).create()
return finish_image


@pytest.fixture(scope='module')
Expand All @@ -146,7 +141,7 @@ def module_azurerm_cloudimg(
module_azurerm_cr,
):
"""Creates cloudinit image on AzureRM Compute Resource"""
finish_image = sat_azure.api.Image(
return sat_azure.api.Image(
architecture=sat_azure_default_architecture,
compute_resource=module_azurerm_cr,
name=gen_string('alpha'),
Expand All @@ -155,7 +150,6 @@ def module_azurerm_cloudimg(
uuid=AZURERM_RHEL7_UD_IMG_URN,
user_data=True,
).create()
return finish_image


@pytest.fixture(scope='module')
Expand All @@ -166,15 +160,14 @@ def module_azurerm_gallery_finishimg(
module_azurerm_cr,
):
"""Creates Shared Gallery Finish Template image on AzureRM Compute Resource"""
finish_image = sat_azure.api.Image(
return sat_azure.api.Image(
architecture=sat_azure_default_architecture,
compute_resource=module_azurerm_cr,
name=gen_string('alpha'),
operatingsystem=sat_azure_default_os,
username=settings.azurerm.username,
uuid=AZURERM_RHEL7_FT_GALLERY_IMG_URN,
).create()
return finish_image


@pytest.fixture(scope='module')
Expand All @@ -185,12 +178,11 @@ def module_azurerm_custom_finishimg(
module_azurerm_cr,
):
"""Creates Custom Finish Template image on AzureRM Compute Resource"""
finish_image = sat_azure.api.Image(
return sat_azure.api.Image(
architecture=sat_azure_default_architecture,
compute_resource=module_azurerm_cr,
name=gen_string('alpha'),
operatingsystem=sat_azure_default_os,
username=settings.azurerm.username,
uuid=AZURERM_RHEL7_FT_CUSTOM_IMG_URN,
).create()
return finish_image
2 changes: 1 addition & 1 deletion pytest_fixtures/component/provision_capsule_pxe.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def capsule_provisioning_rhel_content(
releasever=constants.REPOS['kickstart'][name]['version'],
)
# do not sync content repos for discovery based provisioning.
if not capsule_provisioning_sat.provisioning_type == 'discovery':
if capsule_provisioning_sat.provisioning_type != 'discovery':
rh_repo_id = sat.api_factory.enable_rhrepo_and_fetchid(
basearch=constants.DEFAULT_ARCHITECTURE,
org_id=module_sca_manifest_org.id,
Expand Down
Loading

0 comments on commit 8d035be

Please sign in to comment.