From 5e660db65a4fd0513f1dc246034e71943b782afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Mon, 3 Jun 2024 19:00:27 +0200 Subject: [PATCH] Enforce the Dynaconf validaton --- .github/workflows/pull_request.yml | 1 + conf/certs.yaml.template | 6 ------ conf/clients.yaml.template | 5 ----- conf/discovery.yaml.template | 3 --- conf/distro.yaml.template | 6 ------ conf/robottelo.yaml.template | 1 + robottelo/config/__init__.py | 10 ++++++---- robottelo/config/validators.py | 24 +++--------------------- tests/foreman/api/test_capsulecontent.py | 18 +++++++++--------- tests/foreman/cli/test_activationkey.py | 5 ----- tests/foreman/ui/test_activationkey.py | 7 ------- tests/foreman/ui/test_contenthost.py | 14 +++++++------- tests/foreman/ui/test_dashboard.py | 1 - 13 files changed, 27 insertions(+), 74 deletions(-) delete mode 100644 conf/certs.yaml.template delete mode 100644 conf/clients.yaml.template delete mode 100644 conf/discovery.yaml.template delete mode 100644 conf/distro.yaml.template diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 276ff267e1a..44307be22cf 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -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: diff --git a/conf/certs.yaml.template b/conf/certs.yaml.template deleted file mode 100644 index e2b86d6d7bd..00000000000 --- a/conf/certs.yaml.template +++ /dev/null @@ -1,6 +0,0 @@ -CERTS: - CERT_FILE: "~/certs/server.crt" - KEY_FILE: "~/certs/server.key" - REQ_FILE: "~/certs/server.csr" - # CA cert (a.k.a cacert.crt or rootCA.pem) can be used as bundle file. - CA_BUNDLE_FILE: "~/certs/rootCA.pem" diff --git a/conf/clients.yaml.template b/conf/clients.yaml.template deleted file mode 100644 index 710a09bb68d..00000000000 --- a/conf/clients.yaml.template +++ /dev/null @@ -1,5 +0,0 @@ -CLIENTS: - # Provisioning server hostname where the clients will be created - PROVISIONING_SERVER: - # Path on the provisioning server where the virtual images will be stored, default "/var/lib/libvirt/images/" - IMAGE_DIR: diff --git a/conf/discovery.yaml.template b/conf/discovery.yaml.template deleted file mode 100644 index a24040aff06..00000000000 --- a/conf/discovery.yaml.template +++ /dev/null @@ -1,3 +0,0 @@ -DISCOVERY: - SATELLITE_VERSION_SHORT: "@jinja {{this.robottelo.satellite_version | replace('.', '')}}" - DISCOVERY_ISO: "discovery_image_sat{this[discovery].satellite_version_short}.iso" diff --git a/conf/distro.yaml.template b/conf/distro.yaml.template deleted file mode 100644 index 061374b4565..00000000000 --- a/conf/distro.yaml.template +++ /dev/null @@ -1,6 +0,0 @@ -DISTRO: - IMAGE_EL6: rhel610 - IMAGE_EL7: rhel79-20200908.1 - IMAGE_EL8: rhel820-20200423.0 - IMAGE_SLES11: sles-11-4 - IMAGE_SLES12: sles-12-3 diff --git a/conf/robottelo.yaml.template b/conf/robottelo.yaml.template index 7bf111cdc65..689c1f34fff 100644 --- a/conf/robottelo.yaml.template +++ b/conf/robottelo.yaml.template @@ -21,3 +21,4 @@ ROBOTTELO: # Dynaconf and Dynaconf hooks related options SETTINGS: GET_FRESH: true + SKIP_VALIDATION: false diff --git a/robottelo/config/__init__.py b/robottelo/config/__init__.py index d761dd06e91..8c18a4550b6 100644 --- a/robottelo/config/__init__.py +++ b/robottelo/config/__init__.py @@ -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 diff --git a/robottelo/config/validators.py b/robottelo/config/validators.py index 2ae4c42ac04..12200c3644d 100644 --- a/robottelo/config/validators.py +++ b/robottelo/config/validators.py @@ -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'), @@ -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', @@ -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), diff --git a/tests/foreman/api/test_capsulecontent.py b/tests/foreman/api/test_capsulecontent.py index 562105856c6..64ef2e2d614 100644 --- a/tests/foreman/api/test_capsulecontent.py +++ b/tests/foreman/api/test_capsulecontent.py @@ -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, @@ -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 ): @@ -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, @@ -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 ): @@ -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, @@ -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, @@ -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 @@ -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 @@ -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, diff --git a/tests/foreman/cli/test_activationkey.py b/tests/foreman/cli/test_activationkey.py index 92708960bc5..46743b1a33a 100644 --- a/tests/foreman/cli/test_activationkey.py +++ b/tests/foreman/cli/test_activationkey.py @@ -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): @@ -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): @@ -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): @@ -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' @@ -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 diff --git a/tests/foreman/ui/test_activationkey.py b/tests/foreman/ui/test_activationkey.py index 067921eda38..f3f87ae8e81 100644 --- a/tests/foreman/ui/test_activationkey.py +++ b/tests/foreman/ui/test_activationkey.py @@ -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 @@ -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 @@ -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 @@ -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') @@ -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') @@ -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( @@ -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): diff --git a/tests/foreman/ui/test_contenthost.py b/tests/foreman/ui/test_contenthost.py index a386cc18995..d1cd3c41a2c 100644 --- a/tests/foreman/ui/test_contenthost.py +++ b/tests/foreman/ui/test_contenthost.py @@ -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) @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', diff --git a/tests/foreman/ui/test_dashboard.py b/tests/foreman/ui/test_dashboard.py index 071e44cc4d7..d3f3439981f 100644 --- a/tests/foreman/ui/test_dashboard.py +++ b/tests/foreman/ui/test_dashboard.py @@ -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')