From fdb1a5ce50397a727ded3ddf3d94367ea8b607b2 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Wed, 28 Nov 2018 13:05:32 -0800 Subject: [PATCH] Fix deletion of stale build dirs on startup This code had a bug -- it didn't build the full path. This code was not tested. These two things are related. Change-Id: I7881fb30017cedc12435e0fcbfda321bdf20d611 --- tests/base.py | 8 ++-- .../ansible/git/bare-role/tasks/main.yaml | 2 +- .../git/common-config/playbooks/post.yaml | 2 +- .../git/common-config/playbooks/pre.yaml | 2 +- .../git/common-config/playbooks/python27.yaml | 6 +-- .../ansible/git/common-config/zuul.yaml | 2 +- .../git/org_project/playbooks/faillocal.yaml | 4 +- .../git/common-config/playbooks/cleanup.yaml | 2 +- .../git/common-config/playbooks/post.yaml | 4 +- .../git/common-config/zuul.yaml | 2 +- .../git/common-config/playbooks/post.yaml | 4 +- .../post-playbook/git/common-config/zuul.yaml | 2 +- .../common-config/playbooks/post-fail.yaml | 2 +- .../git/common-config/playbooks/post.yaml | 2 +- .../git/common-config/playbooks/pre.yaml | 6 +-- .../git/common-config/playbooks/python27.yaml | 2 +- .../roles/git/bare-role/tasks/main.yaml | 2 +- .../streamer/git/common-config/zuul.yaml | 2 +- tests/remote/test_remote_action_modules.py | 2 +- tests/remote/test_remote_hostvars.py | 2 +- tests/remote/test_remote_zuul_json.py | 2 +- tests/remote/test_remote_zuul_stream.py | 2 +- tests/unit/test_executor.py | 12 +++++ tests/unit/test_v3.py | 46 +++++++++---------- zuul/executor/server.py | 1 + 25 files changed, 69 insertions(+), 54 deletions(-) diff --git a/tests/base.py b/tests/base.py index d92aae2a21..d0f751059f 100644 --- a/tests/base.py +++ b/tests/base.py @@ -3177,6 +3177,7 @@ class ZuulTestCase(BaseTestCase): self.state_root = os.path.join(self.test_root, "lib") self.merger_state_root = os.path.join(self.test_root, "merger-lib") self.executor_state_root = os.path.join(self.test_root, "executor-lib") + self.jobdir_root = os.path.join(self.test_root, "builds") if os.path.exists(self.test_root): shutil.rmtree(self.test_root) @@ -3185,6 +3186,7 @@ class ZuulTestCase(BaseTestCase): os.makedirs(self.state_root) os.makedirs(self.merger_state_root) os.makedirs(self.executor_state_root) + os.makedirs(self.jobdir_root) # Make per test copy of Configuration. self.setup_config() @@ -3272,7 +3274,7 @@ class ZuulTestCase(BaseTestCase): self.executor_server = RecordingExecutorServer( self.config, self.connections, - jobdir_root=self.test_root, + jobdir_root=self.jobdir_root, _run_ansible=self.run_ansible, _test_root=self.test_root, keep_jobdir=KEEP_TEMPDIRS, @@ -4408,11 +4410,11 @@ class AnsibleZuulTestCase(ZuulTestCase): try: yield except Exception: - path = os.path.join(self.test_root, build.uuid, + path = os.path.join(self.jobdir_root, build.uuid, 'work', 'logs', 'job-output.txt') with open(path) as f: self.log.debug(f.read()) - path = os.path.join(self.test_root, build.uuid, + path = os.path.join(self.jobdir_root, build.uuid, 'work', 'logs', 'job-output.json') with open(path) as f: self.log.debug(f.read()) diff --git a/tests/fixtures/config/ansible/git/bare-role/tasks/main.yaml b/tests/fixtures/config/ansible/git/bare-role/tasks/main.yaml index cd8917d1bf..7e7686896f 100644 --- a/tests/fixtures/config/ansible/git/bare-role/tasks/main.yaml +++ b/tests/fixtures/config/ansible/git/bare-role/tasks/main.yaml @@ -1,3 +1,3 @@ - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.bare-role.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.bare-role.flag" state: touch diff --git a/tests/fixtures/config/ansible/git/common-config/playbooks/post.yaml b/tests/fixtures/config/ansible/git/common-config/playbooks/post.yaml index 7fd8a2be56..393ac408ed 100644 --- a/tests/fixtures/config/ansible/git/common-config/playbooks/post.yaml +++ b/tests/fixtures/config/ansible/git/common-config/playbooks/post.yaml @@ -1,5 +1,5 @@ - hosts: all tasks: - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.post.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.post.flag" state: touch diff --git a/tests/fixtures/config/ansible/git/common-config/playbooks/pre.yaml b/tests/fixtures/config/ansible/git/common-config/playbooks/pre.yaml index 268cd6541b..b5b64f9c24 100644 --- a/tests/fixtures/config/ansible/git/common-config/playbooks/pre.yaml +++ b/tests/fixtures/config/ansible/git/common-config/playbooks/pre.yaml @@ -1,5 +1,5 @@ - hosts: all tasks: - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.pre.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.pre.flag" state: touch diff --git a/tests/fixtures/config/ansible/git/common-config/playbooks/python27.yaml b/tests/fixtures/config/ansible/git/common-config/playbooks/python27.yaml index 6669f23256..aa23aacfd9 100644 --- a/tests/fixtures/config/ansible/git/common-config/playbooks/python27.yaml +++ b/tests/fixtures/config/ansible/git/common-config/playbooks/python27.yaml @@ -4,10 +4,10 @@ path: "{{flagpath}}" state: touch - copy: - src: "{{zuul._test.test_root}}/{{zuul.build}}.flag" - dest: "{{zuul._test.test_root}}/{{zuul.build}}.copied" + src: "{{zuul._test.test_root}}/builds/{{zuul.build}}.flag" + dest: "{{zuul._test.test_root}}/builds/{{zuul.build}}.copied" - copy: content: "{{test_secret.username}} {{test_secret.password}}" - dest: "{{zuul._test.test_root}}/{{zuul.build}}.secrets" + dest: "{{zuul._test.test_root}}/builds/{{zuul.build}}.secrets" roles: - bare-role diff --git a/tests/fixtures/config/ansible/git/common-config/zuul.yaml b/tests/fixtures/config/ansible/git/common-config/zuul.yaml index 8be4f1b33d..6ece419239 100644 --- a/tests/fixtures/config/ansible/git/common-config/zuul.yaml +++ b/tests/fixtures/config/ansible/git/common-config/zuul.yaml @@ -98,7 +98,7 @@ pre-run: playbooks/pre.yaml post-run: playbooks/post.yaml vars: - flagpath: '{{zuul._test.test_root}}/{{zuul.build}}.flag' + flagpath: '{{zuul._test.test_root}}/builds/{{zuul.build}}.flag' roles: - zuul: bare-role secrets: diff --git a/tests/fixtures/config/ansible/git/org_project/playbooks/faillocal.yaml b/tests/fixtures/config/ansible/git/org_project/playbooks/faillocal.yaml index 5b0c18d6bc..69c1e37ca6 100644 --- a/tests/fixtures/config/ansible/git/org_project/playbooks/faillocal.yaml +++ b/tests/fixtures/config/ansible/git/org_project/playbooks/faillocal.yaml @@ -1,5 +1,5 @@ - hosts: all tasks: - copy: - src: "{{zuul._test.test_root}}/{{zuul.build}}.flag" - dest: "{{zuul._test.test_root}}/{{zuul.build}}.failed" + src: "{{zuul._test.test_root}}/builds/{{zuul.build}}.flag" + dest: "{{zuul._test.test_root}}/builds/{{zuul.build}}.failed" diff --git a/tests/fixtures/config/cleanup-playbook/git/common-config/playbooks/cleanup.yaml b/tests/fixtures/config/cleanup-playbook/git/common-config/playbooks/cleanup.yaml index 863b942e43..4ccf19b48b 100644 --- a/tests/fixtures/config/cleanup-playbook/git/common-config/playbooks/cleanup.yaml +++ b/tests/fixtures/config/cleanup-playbook/git/common-config/playbooks/cleanup.yaml @@ -2,4 +2,4 @@ tasks: - copy: content: "{{ zuul_success }}" - dest: "{{ zuul._test.test_root }}/{{ zuul.build }}.cleanup.flag" + dest: "{{ zuul._test.test_root }}/builds/{{ zuul.build }}.cleanup.flag" diff --git a/tests/fixtures/config/cleanup-playbook/git/common-config/playbooks/post.yaml b/tests/fixtures/config/cleanup-playbook/git/common-config/playbooks/post.yaml index 40b3ca7325..f8df2600c1 100644 --- a/tests/fixtures/config/cleanup-playbook/git/common-config/playbooks/post.yaml +++ b/tests/fixtures/config/cleanup-playbook/git/common-config/playbooks/post.yaml @@ -2,12 +2,12 @@ tasks: - debug: var=waitpath - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.post_start.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.post_start.flag" state: touch # Do not finish until test creates the flag file - wait_for: state: present path: "{{waitpath}}" - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.post_end.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.post_end.flag" state: touch diff --git a/tests/fixtures/config/cleanup-playbook/git/common-config/zuul.yaml b/tests/fixtures/config/cleanup-playbook/git/common-config/zuul.yaml index 42f83bb142..c6f6f188a4 100644 --- a/tests/fixtures/config/cleanup-playbook/git/common-config/zuul.yaml +++ b/tests/fixtures/config/cleanup-playbook/git/common-config/zuul.yaml @@ -26,7 +26,7 @@ post-run: playbooks/post.yaml cleanup-run: playbooks/cleanup.yaml vars: - waitpath: '{{zuul._test.test_root}}/{{zuul.build}}/test_wait' + waitpath: '{{zuul._test.test_root}}/builds/{{zuul.build}}/test_wait' run: playbooks/python27.yaml - job: diff --git a/tests/fixtures/config/post-playbook/git/common-config/playbooks/post.yaml b/tests/fixtures/config/post-playbook/git/common-config/playbooks/post.yaml index 40b3ca7325..f8df2600c1 100644 --- a/tests/fixtures/config/post-playbook/git/common-config/playbooks/post.yaml +++ b/tests/fixtures/config/post-playbook/git/common-config/playbooks/post.yaml @@ -2,12 +2,12 @@ tasks: - debug: var=waitpath - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.post_start.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.post_start.flag" state: touch # Do not finish until test creates the flag file - wait_for: state: present path: "{{waitpath}}" - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.post_end.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.post_end.flag" state: touch diff --git a/tests/fixtures/config/post-playbook/git/common-config/zuul.yaml b/tests/fixtures/config/post-playbook/git/common-config/zuul.yaml index a1f1ad7415..5c61adec5c 100644 --- a/tests/fixtures/config/post-playbook/git/common-config/zuul.yaml +++ b/tests/fixtures/config/post-playbook/git/common-config/zuul.yaml @@ -25,5 +25,5 @@ pre-run: playbooks/pre.yaml post-run: playbooks/post.yaml vars: - waitpath: '{{zuul._test.test_root}}/{{zuul.build}}/test_wait' + waitpath: '{{zuul._test.test_root}}/builds/{{zuul.build}}/test_wait' run: playbooks/python27.yaml diff --git a/tests/fixtures/config/pre-playbook/git/common-config/playbooks/post-fail.yaml b/tests/fixtures/config/pre-playbook/git/common-config/playbooks/post-fail.yaml index f58533f10a..baa3453924 100644 --- a/tests/fixtures/config/pre-playbook/git/common-config/playbooks/post-fail.yaml +++ b/tests/fixtures/config/pre-playbook/git/common-config/playbooks/post-fail.yaml @@ -1,5 +1,5 @@ - hosts: all tasks: - invalid-task: - path: "{{zuul._test.test_root}}/{{zuul.build}}.post.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.post.flag" state: touch diff --git a/tests/fixtures/config/pre-playbook/git/common-config/playbooks/post.yaml b/tests/fixtures/config/pre-playbook/git/common-config/playbooks/post.yaml index 7fd8a2be56..393ac408ed 100644 --- a/tests/fixtures/config/pre-playbook/git/common-config/playbooks/post.yaml +++ b/tests/fixtures/config/pre-playbook/git/common-config/playbooks/post.yaml @@ -1,5 +1,5 @@ - hosts: all tasks: - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.post.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.post.flag" state: touch diff --git a/tests/fixtures/config/pre-playbook/git/common-config/playbooks/pre.yaml b/tests/fixtures/config/pre-playbook/git/common-config/playbooks/pre.yaml index 4875ad4f47..d99146f87a 100644 --- a/tests/fixtures/config/pre-playbook/git/common-config/playbooks/pre.yaml +++ b/tests/fixtures/config/pre-playbook/git/common-config/playbooks/pre.yaml @@ -1,8 +1,8 @@ - hosts: all tasks: - copy: - src: "{{zuul._test.test_root}}/{{zuul.build}}.flag" - dest: "{{zuul._test.test_root}}/{{zuul.build}}.failed" + src: "{{zuul._test.test_root}}/builds/{{zuul.build}}.flag" + dest: "{{zuul._test.test_root}}/builds/{{zuul.build}}.failed" - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.pre.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.pre.flag" state: touch diff --git a/tests/fixtures/config/pre-playbook/git/common-config/playbooks/python27.yaml b/tests/fixtures/config/pre-playbook/git/common-config/playbooks/python27.yaml index 08c7bd3f9e..98786aec6d 100644 --- a/tests/fixtures/config/pre-playbook/git/common-config/playbooks/python27.yaml +++ b/tests/fixtures/config/pre-playbook/git/common-config/playbooks/python27.yaml @@ -1,5 +1,5 @@ - hosts: all tasks: - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.main.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.main.flag" state: touch diff --git a/tests/fixtures/config/roles/git/bare-role/tasks/main.yaml b/tests/fixtures/config/roles/git/bare-role/tasks/main.yaml index cd8917d1bf..7e7686896f 100644 --- a/tests/fixtures/config/roles/git/bare-role/tasks/main.yaml +++ b/tests/fixtures/config/roles/git/bare-role/tasks/main.yaml @@ -1,3 +1,3 @@ - file: - path: "{{zuul._test.test_root}}/{{zuul.build}}.bare-role.flag" + path: "{{zuul._test.test_root}}/builds/{{zuul.build}}.bare-role.flag" state: touch diff --git a/tests/fixtures/config/streamer/git/common-config/zuul.yaml b/tests/fixtures/config/streamer/git/common-config/zuul.yaml index 272b71febc..fd0159ac12 100644 --- a/tests/fixtures/config/streamer/git/common-config/zuul.yaml +++ b/tests/fixtures/config/streamer/git/common-config/zuul.yaml @@ -22,5 +22,5 @@ - job: name: python27 vars: - waitpath: '{{zuul._test.test_root}}/{{zuul.build}}/test_wait' + waitpath: '{{zuul._test.test_root}}/builds/{{zuul.build}}/test_wait' run: playbooks/python27.yaml diff --git a/tests/remote/test_remote_action_modules.py b/tests/remote/test_remote_action_modules.py index e2e97500bd..f05a06ec42 100644 --- a/tests/remote/test_remote_action_modules.py +++ b/tests/remote/test_remote_action_modules.py @@ -78,7 +78,7 @@ class TestActionModules25(AnsibleZuulTestCase): self.assertEqual(build.result, result) if expect_error: - path = os.path.join(self.test_root, build.uuid, + path = os.path.join(self.jobdir_root, build.uuid, 'work', 'logs', 'job-output.txt') with open(path, 'r') as f: self.assertIn(expect_error, f.read()) diff --git a/tests/remote/test_remote_hostvars.py b/tests/remote/test_remote_hostvars.py index 6a40f25cab..8cdc2ad36b 100644 --- a/tests/remote/test_remote_hostvars.py +++ b/tests/remote/test_remote_hostvars.py @@ -73,7 +73,7 @@ class TestZuulHostVars(AnsibleZuulTestCase): with self.jobLog(job): build = self.history[-1] inventory = yaml.safe_load(open(os.path.join( - self.test_root, build.uuid, 'ansible', 'inventory.yaml'))) + self.jobdir_root, build.uuid, 'ansible', 'inventory.yaml'))) self.assertEqual( "python2", inventory["all"]["hosts"]["controller"][ diff --git a/tests/remote/test_remote_zuul_json.py b/tests/remote/test_remote_zuul_json.py index c3e74623a8..c2451151c2 100644 --- a/tests/remote/test_remote_zuul_json.py +++ b/tests/remote/test_remote_zuul_json.py @@ -68,7 +68,7 @@ class TestZuulJSON25(AnsibleZuulTestCase): return job def _get_json_as_text(self, build): - path = os.path.join(self.test_root, build.uuid, + path = os.path.join(self.jobdir_root, build.uuid, 'work', 'logs', 'job-output.json') with open(path) as f: return f.read() diff --git a/tests/remote/test_remote_zuul_stream.py b/tests/remote/test_remote_zuul_stream.py index 43f89eb493..384fe75e63 100644 --- a/tests/remote/test_remote_zuul_stream.py +++ b/tests/remote/test_remote_zuul_stream.py @@ -75,7 +75,7 @@ class TestZuulStream25(AnsibleZuulTestCase): return job def _get_job_output(self, build): - path = os.path.join(self.test_root, build.uuid, + path = os.path.join(self.jobdir_root, build.uuid, 'work', 'logs', 'job-output.txt') with open(path) as f: return f.read() diff --git a/tests/unit/test_executor.py b/tests/unit/test_executor.py index 53da8cb039..e8bd600cf4 100644 --- a/tests/unit/test_executor.py +++ b/tests/unit/test_executor.py @@ -789,3 +789,15 @@ class TestExecutorFacts(AnsibleZuulTestCase): date_time = \ j[0]['plays'][0]['tasks'][0]['hosts']['localhost']['date_time'] self.assertEqual(18, len(date_time)) + + +class TestExecutorStart(ZuulTestCase): + tenant_config_file = 'config/single-tenant/main.yaml' + + def setup_config(self): + super(TestExecutorStart, self).setup_config() + self.junk_dir = os.path.join(self.jobdir_root, 'junk') + os.makedirs(self.junk_dir) + + def test_executor_start(self): + self.assertFalse(os.path.exists(self.junk_dir)) diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py index 1cc29d60cf..ed4dbb453d 100644 --- a/tests/unit/test_v3.py +++ b/tests/unit/test_v3.py @@ -2591,8 +2591,8 @@ class TestAnsible25(AnsibleZuulTestCase): self.waitUntilSettled() build_timeout = self.getJobFromHistory('timeout', result='TIMED_OUT') with self.jobLog(build_timeout): - post_flag_path = os.path.join(self.test_root, build_timeout.uuid + - '.post.flag') + post_flag_path = os.path.join( + self.jobdir_root, build_timeout.uuid + '.post.flag') self.assertTrue(os.path.exists(post_flag_path)) build_post_timeout = self.getJobFromHistory('post-timeout') with self.jobLog(build_post_timeout): @@ -2635,26 +2635,26 @@ class TestAnsible25(AnsibleZuulTestCase): build_python27 = self.getJobFromHistory('python27') with self.jobLog(build_python27): self.assertEqual(build_python27.result, 'SUCCESS') - flag_path = os.path.join(self.test_root, + flag_path = os.path.join(self.jobdir_root, build_python27.uuid + '.flag') self.assertTrue(os.path.exists(flag_path)) - copied_path = os.path.join(self.test_root, build_python27.uuid + + copied_path = os.path.join(self.jobdir_root, build_python27.uuid + '.copied') self.assertTrue(os.path.exists(copied_path)) - failed_path = os.path.join(self.test_root, build_python27.uuid + + failed_path = os.path.join(self.jobdir_root, build_python27.uuid + '.failed') self.assertFalse(os.path.exists(failed_path)) - pre_flag_path = os.path.join(self.test_root, build_python27.uuid + - '.pre.flag') + pre_flag_path = os.path.join( + self.jobdir_root, build_python27.uuid + '.pre.flag') self.assertTrue(os.path.exists(pre_flag_path)) - post_flag_path = os.path.join(self.test_root, build_python27.uuid + - '.post.flag') + post_flag_path = os.path.join( + self.jobdir_root, build_python27.uuid + '.post.flag') self.assertTrue(os.path.exists(post_flag_path)) - bare_role_flag_path = os.path.join(self.test_root, + bare_role_flag_path = os.path.join(self.jobdir_root, build_python27.uuid + '.bare-role.flag') self.assertTrue(os.path.exists(bare_role_flag_path)) - secrets_path = os.path.join(self.test_root, + secrets_path = os.path.join(self.jobdir_root, build_python27.uuid + '.secrets') with open(secrets_path) as f: self.assertEqual(f.read(), "test-username test-password") @@ -2796,8 +2796,8 @@ class TestPrePlaybooks(AnsibleZuulTestCase): pre_flag_path = os.path.join(self.test_root, build.uuid + '.pre.flag') self.assertFalse(os.path.exists(pre_flag_path)) - post_flag_path = os.path.join(self.test_root, build.uuid + - '.post.flag') + post_flag_path = os.path.join( + self.jobdir_root, build.uuid + '.post.flag') self.assertTrue(os.path.exists(post_flag_path), "The file %s should exist" % post_flag_path) @@ -2878,7 +2878,7 @@ class TestPostPlaybooks(AnsibleZuulTestCase): break build = self.builds[0] - post_start = os.path.join(self.test_root, build.uuid + + post_start = os.path.join(self.jobdir_root, build.uuid + '.post_start.flag') for _ in iterate_timeout(60, 'job post running'): if os.path.exists(post_start): @@ -2890,7 +2890,7 @@ class TestPostPlaybooks(AnsibleZuulTestCase): build = self.getJobFromHistory('python27') self.assertEqual('ABORTED', build.result) - post_end = os.path.join(self.test_root, build.uuid + + post_end = os.path.join(self.jobdir_root, build.uuid + '.post_end.flag') self.assertTrue(os.path.exists(post_start)) self.assertFalse(os.path.exists(post_end)) @@ -2910,19 +2910,19 @@ class TestCleanupPlaybooks(AnsibleZuulTestCase): break build = self.builds[0] - post_start = os.path.join(self.test_root, build.uuid + + post_start = os.path.join(self.jobdir_root, build.uuid + '.post_start.flag') for _ in iterate_timeout(60, 'job post running'): if os.path.exists(post_start): break - with open(os.path.join(self.test_root, build.uuid, 'test_wait'), + with open(os.path.join(self.jobdir_root, build.uuid, 'test_wait'), "w") as of: of.write("continue") self.waitUntilSettled() build = self.getJobFromHistory('python27') self.assertEqual('SUCCESS', build.result) - cleanup_flag = os.path.join(self.test_root, build.uuid + + cleanup_flag = os.path.join(self.jobdir_root, build.uuid + '.cleanup.flag') self.assertTrue(os.path.exists(cleanup_flag)) with open(cleanup_flag) as f: @@ -2949,7 +2949,7 @@ class TestCleanupPlaybooks(AnsibleZuulTestCase): build = self.getJobFromHistory('python27-failure') self.assertEqual('FAILURE', build.result) - cleanup_flag = os.path.join(self.test_root, build.uuid + + cleanup_flag = os.path.join(self.jobdir_root, build.uuid + '.cleanup.flag') self.assertTrue(os.path.exists(cleanup_flag)) with open(cleanup_flag) as f: @@ -2966,7 +2966,7 @@ class TestCleanupPlaybooks(AnsibleZuulTestCase): break build = self.builds[0] - post_start = os.path.join(self.test_root, build.uuid + + post_start = os.path.join(self.jobdir_root, build.uuid + '.post_start.flag') for _ in iterate_timeout(60, 'job post running'): if os.path.exists(post_start): @@ -2978,9 +2978,9 @@ class TestCleanupPlaybooks(AnsibleZuulTestCase): build = self.getJobFromHistory('python27') self.assertEqual('ABORTED', build.result) - post_end = os.path.join(self.test_root, build.uuid + + post_end = os.path.join(self.jobdir_root, build.uuid + '.post_end.flag') - cleanup_flag = os.path.join(self.test_root, build.uuid + + cleanup_flag = os.path.join(self.jobdir_root, build.uuid + '.cleanup.flag') self.assertTrue(os.path.exists(cleanup_flag)) self.assertTrue(os.path.exists(post_start)) @@ -3320,7 +3320,7 @@ class TestProjectKeys(ZuulTestCase): class RoleTestCase(ZuulTestCase): def _getRolesPaths(self, build, playbook): - path = os.path.join(self.test_root, build.uuid, + path = os.path.join(self.jobdir_root, build.uuid, 'ansible', playbook, 'ansible.cfg') roles_paths = [] with open(path) as f: diff --git a/zuul/executor/server.py b/zuul/executor/server.py index 83b87063bd..53b6c4e9e6 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -2390,6 +2390,7 @@ class ExecutorServer(object): # in case we were uncleanly shut down. if not self.keep_jobdir: for fn in os.listdir(self.jobdir_root): + fn = os.path.join(self.jobdir_root, fn) if not os.path.isdir(fn): continue self.log.info("Deleting stale jobdir %s", fn)