diff --git a/tests/fixtures/config/remote-action-modules/git/org_project/playbooks/synchronize-bad-pull.yaml b/tests/fixtures/config/remote-action-modules/git/org_project/playbooks/synchronize-bad-pull.yaml new file mode 100644 index 0000000000..603a4da9d3 --- /dev/null +++ b/tests/fixtures/config/remote-action-modules/git/org_project/playbooks/synchronize-bad-pull.yaml @@ -0,0 +1,12 @@ +- hosts: all + tasks: + - name: Execute common-copy role + include_role: + name: common-copy + + - name: Test pull mode + synchronize: + dest: "/tmp" + mode: pull + src: "{{ destdir.path }}/" + verify_host: true diff --git a/tests/fixtures/config/remote-action-modules/git/org_project/playbooks/synchronize-bad-push.yaml b/tests/fixtures/config/remote-action-modules/git/org_project/playbooks/synchronize-bad-push.yaml new file mode 100644 index 0000000000..f9d9080a80 --- /dev/null +++ b/tests/fixtures/config/remote-action-modules/git/org_project/playbooks/synchronize-bad-push.yaml @@ -0,0 +1,12 @@ +- hosts: all + tasks: + - name: Execute common-copy role + include_role: + name: common-copy + + - name: Test push mode + synchronize: + dest: "{{ destdir.path }}/" + mode: push + src: "/tmp" + verify_host: true diff --git a/tests/fixtures/config/remote-action-modules/git/org_project/playbooks/synchronize-good.yaml b/tests/fixtures/config/remote-action-modules/git/org_project/playbooks/synchronize-good.yaml new file mode 100644 index 0000000000..fabf2dd231 --- /dev/null +++ b/tests/fixtures/config/remote-action-modules/git/org_project/playbooks/synchronize-good.yaml @@ -0,0 +1,53 @@ +- hosts: all + tasks: + - name: Execute common-copy role + include_role: + name: common-copy + + - name: Ensure executor push directory + file: + path: "{{ zuul.executor.log_root }}/push" + state: directory + delegate_to: localhost + + - name: Test pull mode + synchronize: + dest: "{{ zuul.executor.log_root }}/push" + mode: pull + src: "{{ destdir.path }}/" + verify_host: true + + - name: Validate push + stat: + path: "{{ zuul.executor.log_root }}/push/common-file" + register: _push + delegate_to: localhost + + - name: Assert push + assert: + that: + - _push.stat.exists + - _push.stat.isreg + + - name: Ensure controller pull directory + file: + path: "{{ destdir.path }}/pull" + state: directory + + - name: Test push mode + synchronize: + dest: "{{ destdir.path }}/pull/" + mode: push + src: "{{ zuul.executor.log_root }}/push" + verify_host: true + + - name: Validate pull + stat: + path: "{{ destdir.path }}/pull/push/common-file" + register: _pull + + - name: Assert pull + assert: + that: + - _pull.stat.exists + - _pull.stat.isreg diff --git a/tests/remote/test_remote_action_modules.py b/tests/remote/test_remote_action_modules.py index 0899e5d14a..26297ffd51 100644 --- a/tests/remote/test_remote_action_modules.py +++ b/tests/remote/test_remote_action_modules.py @@ -18,6 +18,8 @@ import textwrap from tests.base import AnsibleZuulTestCase, FIXTURE_DIR ERROR_ACCESS_OUTSIDE = "Accessing files from outside the working dir" +ERROR_SYNC_TO_OUTSIDE = "Syncing files to outside the working dir" +ERROR_SYNC_FROM_OUTSIDE = "Syncing files from outside the working dir" class TestActionModules(AnsibleZuulTestCase): @@ -154,6 +156,12 @@ class TestActionModules(AnsibleZuulTestCase): def test_shell_module(self): self._run_job('shell-good', 'SUCCESS') + def test_synchronize_module(self): + self._run_job('synchronize-good', 'SUCCESS') + self._run_job('synchronize-bad-pull', 'FAILURE', ERROR_SYNC_TO_OUTSIDE) + self._run_job( + 'synchronize-bad-push', 'FAILURE', ERROR_SYNC_FROM_OUTSIDE) + def test_template_module(self): self._run_job('template-good', 'SUCCESS')