Skip to content

Commit

Permalink
Enforce the Dynaconf validaton
Browse files Browse the repository at this point in the history
  • Loading branch information
ogajduse committed Jun 17, 2024
1 parent 90ffb9b commit 5e660db
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 74 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
PYCURL_SSL_LIBRARY: openssl
ROBOTTELO_BUGZILLA__API_KEY: ${{ secrets.BUGZILLA_KEY }}
ROBOTTELO_JIRA__API_KEY: ${{ secrets.JIRA_KEY }}
ROBOTTELO_ROBOTTELO__SETTINGS__SKIP_VALIDATION: true

jobs:
codechecks:
Expand Down
6 changes: 0 additions & 6 deletions conf/certs.yaml.template

This file was deleted.

5 changes: 0 additions & 5 deletions conf/clients.yaml.template

This file was deleted.

3 changes: 0 additions & 3 deletions conf/discovery.yaml.template

This file was deleted.

6 changes: 0 additions & 6 deletions conf/distro.yaml.template

This file was deleted.

1 change: 1 addition & 0 deletions conf/robottelo.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ ROBOTTELO:
# Dynaconf and Dynaconf hooks related options
SETTINGS:
GET_FRESH: true
SKIP_VALIDATION: false
10 changes: 6 additions & 4 deletions robottelo/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ def get_settings():
try:
settings.validators.validate()
except ValidationError as err:
logger.warning(
f'Dynaconf validation failed, continuing for the sake of unit tests\n{err}'
)

if settings.robottelo.settings.get('skip_validation'):
logger.warning(
f'Dynaconf validation failed, continuing for the sake of unit tests\n{err}'
)
else:
raise err
return settings


Expand Down
24 changes: 3 additions & 21 deletions robottelo/config/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@
Validator('capsule.deploy_workflows.os', must_exist=True),
Validator('capsule.deploy_arguments', must_exist=True, is_type_of=dict, default={}),
],
certs=[
Validator(
'certs.cert_file',
'certs.key_file',
'certs.req_file',
'certs.ca_bundle_file',
must_exist=True,
)
],
clients=[Validator('clients.provisioning_server')],
libvirt=[
Validator('libvirt.libvirt_hostname', must_exist=True),
Validator('libvirt.libvirt_image_dir', default='/var/lib/libvirt/images'),
Expand All @@ -116,17 +106,6 @@
must_exist=True,
),
],
discovery=[Validator('discovery.discovery_iso', must_exist=True)],
distro=[
Validator(
'distro.image_el7',
'distro.image_el6',
'distro.image_el8',
'distro.image_sles11',
'distro.image_sles12',
must_exist=True,
)
],
docker=[
Validator(
'docker.external_registry_1',
Expand Down Expand Up @@ -335,6 +314,9 @@
Validator('remotedb.ssl', default=True),
Validator('remotedb.port', default=5432),
],
robottelo=[
Validator('robottelo.settings.skip_validation', is_type_of=bool, default=False),
],
shared_function=[
Validator('shared_function.storage', is_in=('file', 'redis'), default='file'),
Validator('shared_function.share_timeout', lte=86400, default=86400),
Expand Down
18 changes: 9 additions & 9 deletions tests/foreman/api/test_capsulecontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TestCapsuleContentManagement:
"""

@pytest.mark.tier4
@pytest.mark.skip_if_not_set('capsule', 'clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('capsule', 'fake_manifest')
def test_positive_uploaded_content_library_sync(
self,
module_capsule_configured,
Expand Down Expand Up @@ -136,7 +136,7 @@ def test_positive_uploaded_content_library_sync(
assert caps_files[0] == RPM_TO_UPLOAD

@pytest.mark.tier4
@pytest.mark.skip_if_not_set('capsule', 'clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('capsule', 'fake_manifest')
def test_positive_checksum_sync(
self, module_capsule_configured, function_org, function_product, function_lce, target_sat
):
Expand Down Expand Up @@ -338,7 +338,7 @@ def test_positive_sync_updated_repo(

@pytest.mark.e2e
@pytest.mark.tier4
@pytest.mark.skip_if_not_set('capsule', 'clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('capsule', 'fake_manifest')
def test_positive_capsule_sync(
self,
target_sat,
Expand Down Expand Up @@ -490,7 +490,7 @@ def test_positive_capsule_sync(
assert sat_files == caps_files

@pytest.mark.tier4
@pytest.mark.skip_if_not_set('capsule', 'clients')
@pytest.mark.skip_if_not_set('capsule')
def test_positive_iso_library_sync(
self, module_capsule_configured, module_sca_manifest_org, module_target_sat
):
Expand Down Expand Up @@ -557,7 +557,7 @@ def test_positive_iso_library_sync(
assert set(sat_isos) == set(caps_isos)

@pytest.mark.tier4
@pytest.mark.skip_if_not_set('capsule', 'clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('capsule', 'fake_manifest')
def test_positive_on_demand_sync(
self,
target_sat,
Expand Down Expand Up @@ -642,7 +642,7 @@ def test_positive_on_demand_sync(
assert package_md5 == published_package_md5

@pytest.mark.tier4
@pytest.mark.skip_if_not_set('capsule', 'clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('capsule', 'fake_manifest')
def test_positive_update_with_immediate_sync(
self,
target_sat,
Expand Down Expand Up @@ -744,7 +744,7 @@ def test_positive_update_with_immediate_sync(

@pytest.mark.skip_if_open("BZ:2122780")
@pytest.mark.tier4
@pytest.mark.skip_if_not_set('capsule', 'clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('capsule', 'fake_manifest')
def test_positive_capsule_pub_url_accessible(self, module_capsule_configured):
"""Ensure capsule pub url is accessible
Expand All @@ -768,7 +768,7 @@ def test_positive_capsule_pub_url_accessible(self, module_capsule_configured):

@pytest.mark.e2e
@pytest.mark.tier4
@pytest.mark.skip_if_not_set('capsule', 'clients')
@pytest.mark.skip_if_not_set('capsule')
@pytest.mark.parametrize('distro', ['rhel7', 'rhel8_bos', 'rhel9_bos'])
def test_positive_sync_kickstart_repo(
self, target_sat, module_capsule_configured, function_sca_manifest_org, distro
Expand Down Expand Up @@ -863,7 +863,7 @@ def test_positive_sync_kickstart_repo(

@pytest.mark.tier4
@pytest.mark.e2e
@pytest.mark.skip_if_not_set('capsule', 'clients')
@pytest.mark.skip_if_not_set('capsule')
def test_positive_sync_container_repo_end_to_end(
self,
target_sat,
Expand Down
5 changes: 0 additions & 5 deletions tests/foreman/cli/test_activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ def test_negative_update_usage_limit(module_org, module_target_sat):
assert 'Validation failed: Max hosts must be less than 2147483648' in raise_ctx.value.message


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
@pytest.mark.upgrade
def test_positive_usage_limit(module_org, module_location, target_sat):
Expand Down Expand Up @@ -871,7 +870,6 @@ def test_positive_delete_subscription(function_entitlement_manifest_org, module_
assert subscription_result[-1]['name'] not in ak_subs_info


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
@pytest.mark.upgrade
def test_positive_update_aks_to_chost(module_org, module_location, rhel7_contenthost, target_sat):
Expand Down Expand Up @@ -912,7 +910,6 @@ def test_positive_update_aks_to_chost(module_org, module_location, rhel7_content
assert rhel7_contenthost.subscribed


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.stubbed
@pytest.mark.tier3
def test_positive_update_aks_to_chost_in_one_command(module_org):
Expand Down Expand Up @@ -1601,7 +1598,6 @@ def test_positive_view_subscriptions_by_non_admin_user(
assert subscriptions[0]['id'] == subscription_id


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
def test_positive_subscription_quantity_attached(function_org, rhel7_contenthost, target_sat):
"""Check the Quantity and Attached fields of 'hammer activation-key subscriptions'
Expand Down Expand Up @@ -1659,7 +1655,6 @@ def test_positive_subscription_quantity_attached(function_org, rhel7_contenthost
assert regex.match(ak_sub['attached'])


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
def test_positive_ak_with_custom_product_on_rhel6(
module_org, module_location, rhel6_contenthost, target_sat
Expand Down
7 changes: 0 additions & 7 deletions tests/foreman/ui/test_activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,6 @@ def test_positive_add_docker_repo_ccv(session, module_org, module_target_sat):
assert ak['details']['lce'][lce.name][lce.name]


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
def test_positive_add_host(session, module_org, rhel_contenthost, target_sat):
"""Test that hosts can be associated to Activation Keys
Expand Down Expand Up @@ -851,7 +850,6 @@ def test_positive_add_host(session, module_org, rhel_contenthost, target_sat):
assert ak['content_hosts']['table'][0]['Name'] == rhel_contenthost.hostname


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
def test_positive_delete_with_system(session, rhel_contenthost, target_sat):
"""Delete an Activation key which has registered systems
Expand Down Expand Up @@ -891,7 +889,6 @@ def test_positive_delete_with_system(session, rhel_contenthost, target_sat):
assert session.activationkey.search(name)[0]['Name'] != name


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
def test_negative_usage_limit(session, module_org, target_sat):
"""Test that Usage limit actually limits usage
Expand Down Expand Up @@ -926,7 +923,6 @@ def test_negative_usage_limit(session, module_org, target_sat):
assert f'Max Hosts ({hosts_limit}) reached for activation key' in str(result.stderr)


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
@pytest.mark.upgrade
@pytest.mark.skipif((not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url')
Expand Down Expand Up @@ -984,7 +980,6 @@ def test_positive_add_multiple_aks_to_system(session, module_org, rhel_contentho
assert ak['content_hosts']['table'][0]['Name'] == rhel_contenthost.hostname


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
@pytest.mark.upgrade
@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url')
Expand Down Expand Up @@ -1031,7 +1026,6 @@ def test_positive_host_associations(session, target_sat):
assert ak2['content_hosts']['table'][0]['Name'] == vm2.hostname


@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
@pytest.mark.skipif((not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url')
def test_positive_service_level_subscription_with_custom_product(
Expand Down Expand Up @@ -1142,7 +1136,6 @@ def test_positive_delete_manifest(session, function_entitlement_manifest_org, ta


@pytest.mark.rhel_ver_list([6])
@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
@pytest.mark.skipif((not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url')
def test_positive_ak_with_custom_product_on_rhel6(rhel_contenthost, target_sat):
Expand Down
14 changes: 7 additions & 7 deletions tests/foreman/ui/test_contenthost.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from robottelo.exceptions import CLIFactoryError
from robottelo.utils.virtwho import create_fake_hypervisor_content

if not setting_is_set('clients') or not setting_is_set('fake_manifest'):
if not setting_is_set('fake_manifest'):
pytest.skip('skipping tests due to missing settings', allow_module_level=True)


Expand Down Expand Up @@ -1465,7 +1465,7 @@ def test_module_stream_update_from_satellite(session, default_location, vm_modul
)


@pytest.mark.skip_if_not_set('clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('fake_manifest')
@pytest.mark.tier3
@pytest.mark.parametrize(
'module_repos_collection_with_manifest',
Expand Down Expand Up @@ -1506,7 +1506,7 @@ def test_syspurpose_attributes_empty(session, default_location, vm_module_stream
assert details[spname] == ''


@pytest.mark.skip_if_not_set('clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('fake_manifest')
@pytest.mark.tier3
@pytest.mark.parametrize(
'module_repos_collection_with_manifest',
Expand Down Expand Up @@ -1550,7 +1550,7 @@ def test_set_syspurpose_attributes_cli(session, default_location, vm_module_stre
assert details[spname] == spdata[1]


@pytest.mark.skip_if_not_set('clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('fake_manifest')
@pytest.mark.tier3
@pytest.mark.parametrize(
'module_repos_collection_with_manifest',
Expand Down Expand Up @@ -1598,7 +1598,7 @@ def test_unset_syspurpose_attributes_cli(session, default_location, vm_module_st
assert details[spname] == ''


@pytest.mark.skip_if_not_set('clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('fake_manifest')
@pytest.mark.tier3
@pytest.mark.parametrize(
'module_repos_collection_with_manifest',
Expand Down Expand Up @@ -1639,7 +1639,7 @@ def test_syspurpose_matched(session, default_location, vm_module_streams):
assert details['system_purpose_status'] == 'Matched'


@pytest.mark.skip_if_not_set('clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('fake_manifest')
@pytest.mark.tier3
@pytest.mark.parametrize(
'module_repos_collection_with_manifest',
Expand Down Expand Up @@ -1683,7 +1683,7 @@ def test_syspurpose_bulk_action(session, default_location, vm):
assert val in result.stdout


@pytest.mark.skip_if_not_set('clients', 'fake_manifest')
@pytest.mark.skip_if_not_set('fake_manifest')
@pytest.mark.tier3
@pytest.mark.parametrize(
'module_repos_collection_with_manifest',
Expand Down
1 change: 0 additions & 1 deletion tests/foreman/ui/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ def test_positive_task_status(session, target_sat):
@pytest.mark.upgrade
@pytest.mark.no_containers
@pytest.mark.run_in_one_thread
@pytest.mark.skip_if_not_set('clients')
@pytest.mark.tier3
@pytest.mark.rhel_ver_match('8')
@pytest.mark.skipif((not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url')
Expand Down

0 comments on commit 5e660db

Please sign in to comment.