From 5d11eaaa61ee0da2377c68e0f0a054a370d42421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ba=C5=A1ti?= Date: Wed, 29 Jan 2020 22:28:32 +0100 Subject: [PATCH 1/2] Test csv_annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test if csv_annotations are properly added to CSV metadata (including package name with suffix) Signed-off-by: Martin Bašti --- example.test.env.yaml | 2 ++ .../alter_package_names_test.py | 20 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/example.test.env.yaml b/example.test.env.yaml index b01eebd..e775a02 100644 --- a/example.test.env.yaml +++ b/example.test.env.yaml @@ -54,6 +54,8 @@ alter_package_name: suffix: "-test-suffix" # name of the package used for testing package: int-test + csv_annotations: + test: "package.{package_name}" # Config of the instance tested to check if Greenwave policies are met for the # NVR greenwave: diff --git a/tests/integration/alter_package_names/alter_package_names_test.py b/tests/integration/alter_package_names/alter_package_names_test.py index 98627a8..12f8200 100644 --- a/tests/integration/alter_package_names/alter_package_names_test.py +++ b/tests/integration/alter_package_names/alter_package_names_test.py @@ -11,6 +11,23 @@ from tests.integration.utils import test_env, make_bundle, is_yaml_file +def _test_csv_annotations(quay_bundle, config): + """ + Test if bundle contains configured annotations. + Package name must contain suffix. + """ + + package_name = config["package"] + config["suffix"] + + substitutions = { + 'package_name': package_name, + } + + for name, value in config['csv_annotations'].items(): + assert name in quay_bundle['metadata']['annotations'] + assert quay_bundle['metadata']['annotations'][name] == value.format(**substitutions) + + def has(suffix, manifest_path): """ Tell if 'suffix' can be found in YAML files under 'manifest_path'. @@ -66,6 +83,7 @@ def test_alter_package_name_during_nvr_push(suffix_omps, suffix_quay, koji, tmp_ ) assert quay_bundle["packageName"] == config["package"] + config["suffix"] + _test_csv_annotations(quay_bundle, config) @pytest.mark.skipif( @@ -103,5 +121,5 @@ def test_alter_package_name_during_archive_push(suffix_omps, suffix_quay, tmp_pa ) ) ) - assert quay_bundle["packageName"] == config["package"] + config["suffix"] + _test_csv_annotations(quay_bundle, config) From 79b20d813d5b811926a0143237255f05502b8f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ba=C5=A1ti?= Date: Wed, 29 Jan 2020 22:34:25 +0100 Subject: [PATCH 2/2] Override oauth token for different namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Different namespace must use different oath token Signed-off-by: Martin Bašti --- example.test.env.yaml | 4 +++- tests/integration/conftest.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/example.test.env.yaml b/example.test.env.yaml index e775a02..0a5ea63 100644 --- a/example.test.env.yaml +++ b/example.test.env.yaml @@ -46,7 +46,9 @@ replace_registry: # Config of the instance tested to alter package names. alter_package_name: # namespace in which package names should be altered - namespace: integration-tests + namespace: integration-tests-with-suffix + # oauth token for integration-tests-with-suffix namespace + quay_oauth_token: # robot account credentials with access to the namespace user: password: diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 23709a0..413c837 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -80,7 +80,7 @@ def suffix_quay(): if config: quay = QuayAppRegistry(test_env["quay_app_registry_api"], test_env["quay_api"], - test_env["quay_oauth_token"]) + config["quay_oauth_token"]) quay.login_to_cnr(config["user"], config["password"])