From a4cf56c929ebce4589fd2551bd17d5f880ead208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Tue, 18 Jun 2024 12:24:16 +0200 Subject: [PATCH] Enforce the Dynaconf validaton (#15289) (cherry picked from commit 617286948df092182d64cf87513d8a0d2f447e41) --- .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 | 8 ++++---- 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, 25 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 276ff267e1..1e65633a28 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__IGNORE_VALIDATION_ERRORS: true jobs: codechecks: diff --git a/conf/certs.yaml.template b/conf/certs.yaml.template deleted file mode 100644 index e2b86d6d7b..0000000000 --- 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 710a09bb68..0000000000 --- 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 a24040aff0..0000000000 --- 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 061374b456..0000000000 --- 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 ca0629689e..adce62e41c 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 + IGNORE_VALIDATION_ERRORS: false diff --git a/robottelo/config/__init__.py b/robottelo/config/__init__.py index d761dd06e9..16af2133b3 100644 --- a/robottelo/config/__init__.py +++ b/robottelo/config/__init__.py @@ -40,10 +40,10 @@ 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('ignore_validation_errors'): + logger.warning(f'Dynaconf validation failed with\n{err}') + else: + raise err return settings diff --git a/robottelo/config/validators.py b/robottelo/config/validators.py index 09b33824f6..b4211dc7f0 100644 --- a/robottelo/config/validators.py +++ b/robottelo/config/validators.py @@ -84,16 +84,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'), @@ -115,17 +105,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', @@ -334,6 +313,9 @@ Validator('remotedb.ssl', default=True), Validator('remotedb.port', default=5432), ], + robottelo=[ + Validator('robottelo.settings.ignore_validation_errors', 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 800535b965..4fb0f73bb0 100644 --- a/tests/foreman/api/test_capsulecontent.py +++ b/tests/foreman/api/test_capsulecontent.py @@ -39,7 +39,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, @@ -100,7 +100,7 @@ def test_positive_uploaded_content_library_sync( assert caps_files[0] == constants.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 ): @@ -298,7 +298,7 @@ def test_positive_sync_updated_repo( assert len(caps_files) == 2 @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, @@ -443,7 +443,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_entitlement_manifest_org, module_target_sat ): @@ -510,7 +510,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, @@ -595,7 +595,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, @@ -697,7 +697,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 @@ -720,7 +720,7 @@ def test_positive_capsule_pub_url_accessible(self, module_capsule_configured): assert b'katello-server-ca.crt' in response.content @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_entitlement_manifest_org, distro @@ -815,7 +815,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 ae00ef3eee..2d3af7e639 100644 --- a/tests/foreman/cli/test_activationkey.py +++ b/tests/foreman/cli/test_activationkey.py @@ -589,7 +589,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): @@ -870,7 +869,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): @@ -911,7 +909,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): @@ -1600,7 +1597,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' @@ -1658,7 +1654,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 8492192a2f..8ed55887d0 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 7faef47e4e..663ce9d292 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) @@ -1408,7 +1408,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', @@ -1449,7 +1449,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', @@ -1493,7 +1493,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', @@ -1541,7 +1541,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', @@ -1582,7 +1582,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', @@ -1626,7 +1626,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 95af5c46b5..1e211adf4c 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')