From 406cc545870db2835c3ac3158c607ed5dc785daf Mon Sep 17 00:00:00 2001 From: James Tanner Date: Tue, 8 Aug 2023 08:56:48 -0400 Subject: [PATCH] Add test. No-Issue Signed-off-by: James Tanner --- .../integration/api/test_artifact_upload.py | 53 +++++++++++++++++++ .../tests/integration/utils/collections.py | 13 ++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/galaxy_ng/tests/integration/api/test_artifact_upload.py b/galaxy_ng/tests/integration/api/test_artifact_upload.py index 5a53383373..2ffa426c73 100644 --- a/galaxy_ng/tests/integration/api/test_artifact_upload.py +++ b/galaxy_ng/tests/integration/api/test_artifact_upload.py @@ -18,6 +18,9 @@ wait_for_task, ) +from ..utils import build_collection as bc + + logger = logging.getLogger(__name__) @@ -425,6 +428,56 @@ def test_ansible_lint_exception(ansible_config, upload_artifact, hub_version): assert len(stderr_msg) == 0 # this stderr message not in log +@pytest.mark.stage_health +@pytest.mark.importer +@pytest.mark.all +def test_ansible_lint_exception_AAH_2606(ansible_config, upload_artifact, hub_version): + """ + https://issues.redhat.com/browse/AAH-2609 + - ansible-lint output is missing. + """ + config = ansible_config("basic_user") + api_client = get_client(config) + + IGNORE_CONTENT = \ + "plugins/modules/lm_otel_collector.py validate-modules:use-run-command-not-popen\n" + + expected = [ + ( + "meta/runtime.yml:1: meta-runtime[unsupported-version]:" + + " requires_ansible key must be set to a supported version." + ), + ( + "meta/runtime.yml:1: yaml[new-line-at-end-of-file]:" + + " No new line character at the end of file" + ), + ( + "tests/sanity/ignore-2.10.txt:1: sanity[cannot-ignore]:" + + " Ignore file contains validate-modules:use-run-command-not-popen at line 1," + + " which is not a permitted ignore." + ) + ] + + artifact = bc( + "skeleton", + config={ + "namespace": USERNAME_PUBLISHER, + "tags": ["database"], + }, + extra_files={ + "meta/runtime.yml": "requires_ansible: \">=2.10\"", + "tests/sanity/ignore-2.10.txt": IGNORE_CONTENT, + }, + ) + + resp = upload_artifact(config, api_client, artifact) + resp = wait_for_task(api_client, resp) + log_messages = [item["message"] for item in resp["messages"]] + log_messages = "\n".join(log_messages) + for line in expected: + assert line in log_messages, log_messages + + @pytest.mark.importer @pytest.mark.all def test_api_publish_log_missing_ee_deps(ansible_config, upload_artifact): diff --git a/galaxy_ng/tests/integration/utils/collections.py b/galaxy_ng/tests/integration/utils/collections.py index f2b2d7d9b9..97bfeeaa8b 100644 --- a/galaxy_ng/tests/integration/utils/collections.py +++ b/galaxy_ng/tests/integration/utils/collections.py @@ -188,7 +188,18 @@ def build_collection( f.write('') if extra_files: - raise Exception('extra_files not yet implemented') + for ename, econtent in extra_files.items(): + fpath = os.path.join(basedir, ename) + fdir = os.path.dirname(fpath) + if not os.path.exists(fdir): + os.makedirs(fdir) + with open(fpath, 'w') as f: + if isinstance(econtent, dict) and econtent.get('mimetype') == 'yaml': + yaml.dump(econtent['content'], f) + elif isinstance(econtent, dict): + f.write(econtent['content']) + else: + f.write(econtent) if pre_build: raise Exception('pre_build not yet implemented')