Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to recreate conditions in AAH-2609. #1831

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions galaxy_ng/tests/integration/api/test_artifact_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
wait_for_task,
)

from ..utils import build_collection as bc


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -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):
Expand Down
13 changes: 12 additions & 1 deletion galaxy_ng/tests/integration/utils/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading