From 035b3a767f205d53e77428cb980c44303188754d Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Thu, 12 Aug 2021 12:13:10 -0400 Subject: [PATCH 1/4] Add custom integration python job --- .zuul.d/jobs.yaml | 10 ++++++++++ .zuul.d/project.yaml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.zuul.d/jobs.yaml b/.zuul.d/jobs.yaml index 53ae10637..2e2793e75 100644 --- a/.zuul.d/jobs.yaml +++ b/.zuul.d/jobs.yaml @@ -194,3 +194,13 @@ - job: name: ansible-runner-upload-container-image-stable-2.9 parent: ansible-runner-container-image-base + +- job: + name: ansible-runner-integration + parent: ansible-buildset-registry-consumer + requires: + - ansible-runner-container-image + +- job: + name: ansible-runner-integration + parent: ansible-tox-py38 diff --git a/.zuul.d/project.yaml b/.zuul.d/project.yaml index 0665774a1..e9188a976 100644 --- a/.zuul.d/project.yaml +++ b/.zuul.d/project.yaml @@ -7,7 +7,7 @@ - ansible-runner-build-container-image-stable-2.9 - ansible-runner-build-container-image-stable-2.10 - ansible-runner-build-container-image-stable-2.11 - - ansible-tox-py38 + - ansible-runner-integration - ansible-tox-docs: vars: sphinx_build_dir: docs/build From 4c0d1dfa20b71d473c7b859eca4364755fa3cefc Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Mon, 16 Aug 2021 16:11:17 -0400 Subject: [PATCH 2/4] Add container_command to new job --- .zuul.d/jobs.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.zuul.d/jobs.yaml b/.zuul.d/jobs.yaml index 2e2793e75..7902d0526 100644 --- a/.zuul.d/jobs.yaml +++ b/.zuul.d/jobs.yaml @@ -200,6 +200,9 @@ parent: ansible-buildset-registry-consumer requires: - ansible-runner-container-image + vars: + container_command: podman + nodeset: centos-8-stream - job: name: ansible-runner-integration From c2937434e8f705bb5926fcaa71d9cb2fc1c764a5 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Wed, 18 Aug 2021 12:57:42 -0400 Subject: [PATCH 3/4] Remove adhoc and playbook tests --- .zuul.d/jobs.yaml | 5 ++- .../containerized/test_cli_containerized.py | 42 ------------------- 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/.zuul.d/jobs.yaml b/.zuul.d/jobs.yaml index 7902d0526..ab09dddfe 100644 --- a/.zuul.d/jobs.yaml +++ b/.zuul.d/jobs.yaml @@ -200,9 +200,10 @@ parent: ansible-buildset-registry-consumer requires: - ansible-runner-container-image + dependencies: + - ansible-buildset-registry vars: - container_command: podman - nodeset: centos-8-stream + container_command: docker - job: name: ansible-runner-integration diff --git a/test/integration/containerized/test_cli_containerized.py b/test/integration/containerized/test_cli_containerized.py index 56b159931..fc0a55df8 100644 --- a/test/integration/containerized/test_cli_containerized.py +++ b/test/integration/containerized/test_cli_containerized.py @@ -29,45 +29,3 @@ def test_playbook_run(cli, skip_if_no_podman): def test_provide_env_var(cli, skip_if_no_podman, test_data_dir): r = cli(['run', os.path.join(test_data_dir, 'job_env'), '-p', 'printenv.yml']) assert 'gifmyvqok2' in r.stdout, r.stdout - - -@pytest.mark.serial -def test_adhoc_localhost_setup(cli, skip_if_no_podman, container_runtime_installed): - r = cli( - [ - 'adhoc', - '--private-data-dir', os.path.join(HERE, 'priv_data'), - '--container-runtime', container_runtime_installed, - 'localhost', '-m', 'setup' - ] - ) - # TODO: look for some fact that indicates we are in container? - assert '"ansible_facts": {' in r.stdout - - -@pytest.mark.serial -def test_playbook_with_private_data_dir(cli, skip_if_no_podman, container_runtime_installed): - # tests using a private_data_dir in conjunction with an absolute path - r = cli( - [ - 'playbook', - '--private-data-dir', os.path.join(HERE, 'priv_data'), - '--container-runtime', container_runtime_installed, - os.path.join(HERE, 'priv_data/project/test-container.yml') - ] - ) - assert 'PLAY RECAP *******' in r.stdout - assert 'failed=0' in r.stdout - - -@pytest.mark.serial -def test_playbook_with_relative_path(cli, skip_if_no_podman, container_runtime_installed): - r = cli( - [ - 'playbook', - '--container-runtime', container_runtime_installed, - 'test/integration/containerized/priv_data/project/test-container.yml' - ] - ) - assert 'PLAY RECAP *******' in r.stdout - assert 'failed=0' in r.stdout From 3ad53963c036498f336e39da5ddcb6269a9774bf Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Thu, 19 Aug 2021 11:54:54 -0400 Subject: [PATCH 4/4] add iterate_timeout() for test usage --- test/integration/test_main.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/test/integration/test_main.py b/test/integration/test_main.py index 34cd96439..0ad33ef1b 100644 --- a/test/integration/test_main.py +++ b/test/integration/test_main.py @@ -18,6 +18,16 @@ HERE = os.path.abspath(os.path.dirname(__file__)) +def iterate_timeout(max_seconds, purpose, interval=2): + start = time.time() + count = 0 + while (time.time() < start + max_seconds): + count += 1 + yield count + time.sleep(interval) + raise Exception("Timeout waiting for %s" % purpose) + + def ensure_directory(directory): if not os.path.exists(directory): os.makedirs(directory) @@ -304,21 +314,22 @@ def test_playbook_start(skipif_pre_ansible28): temp_dir]]) p.start() - time.sleep(5) - - assert os.path.exists(os.path.join(temp_dir, 'pid')) + pid_path = os.path.join(temp_dir, 'pid') + for _ in iterate_timeout(30, "pid file creation"): + if os.path.exists(pid_path): + break rc = main(['is-alive', temp_dir]) assert rc == 0 rc = main(['stop', temp_dir]) assert rc == 0 - time.sleep(1) + for _ in iterate_timeout(30, "background process to stop"): + rc = main(['is-alive', temp_dir]) + if rc == 1: + break - rc = main(['is-alive', temp_dir]) - assert rc == 1 - - ensure_removed(os.path.join(temp_dir, 'pid')) + ensure_removed(pid_path) rc = main(['stop', temp_dir]) - assert rc == 1 + assert rc == 1