From 12e7e9650e9bc7d780dfdfb051a2c8885e2e7d63 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Mon, 30 Jul 2018 10:41:49 +0200 Subject: [PATCH] Make use of Jinja tests 'finished' (#43233) And also used 'changed' and 'failed' tests while we are at it. --- test/integration/targets/async/tasks/main.yml | 2 +- .../targets/async_fail/tasks/main.yml | 3 ++- .../targets/aws_lambda/tasks/main.yml | 12 ++++----- .../integration/targets/aws_s3/tasks/main.yml | 2 +- .../targets/ec2_asg/tasks/main.yml | 4 +-- .../targets/win_async_wrapper/tasks/main.yml | 27 ++++++++++++------- 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/test/integration/targets/async/tasks/main.yml b/test/integration/targets/async/tasks/main.yml index 8f76d692778..38536109fbc 100644 --- a/test/integration/targets/async/tasks/main.yml +++ b/test/integration/targets/async/tasks/main.yml @@ -75,7 +75,7 @@ - name: assert task was successfully started assert: that: - - fnf_task.started + - fnf_task.started == 1 - "'ansible_job_id' in fnf_task" - name: 'check on task started as a "fire-and-forget"' diff --git a/test/integration/targets/async_fail/tasks/main.yml b/test/integration/targets/async_fail/tasks/main.yml index abf1bbc6727..40f72e105d3 100644 --- a/test/integration/targets/async_fail/tasks/main.yml +++ b/test/integration/targets/async_fail/tasks/main.yml @@ -30,6 +30,7 @@ that: - async_result.ansible_job_id is match('\d+\.\d+') - async_result.finished == 1 - - async_result.changed == true + - async_result is finished + - async_result is changed - async_result is successful - async_result.msg is search('succeeded') diff --git a/test/integration/targets/aws_lambda/tasks/main.yml b/test/integration/targets/aws_lambda/tasks/main.yml index cbaa27e99a6..767d6ada3b7 100644 --- a/test/integration/targets/aws_lambda/tasks/main.yml +++ b/test/integration/targets/aws_lambda/tasks/main.yml @@ -336,19 +336,19 @@ - name: wait for async job 1 async_status: jid={{ async_1.ansible_job_id }} register: job_result - until: job_result.finished + until: job_result is finished retries: 30 - name: wait for async job 2 async_status: jid={{ async_1.ansible_job_id }} register: job_result - until: job_result.finished + until: job_result is finished retries: 30 - name: wait for async job 3 async_status: jid={{ async_3.ansible_job_id }} register: job_result - until: job_result.finished + until: job_result is finished retries: 30 @@ -407,19 +407,19 @@ - name: wait for async job 1 async_status: jid={{ async_1.ansible_job_id }} register: job_result - until: job_result.finished + until: job_result is finished retries: 30 - name: wait for async job 2 async_status: jid={{ async_1.ansible_job_id }} register: job_result - until: job_result.finished + until: job_result is finished retries: 30 - name: wait for async job 3 async_status: jid={{ async_3.ansible_job_id }} register: job_result - until: job_result.finished + until: job_result is finished retries: 30 diff --git a/test/integration/targets/aws_s3/tasks/main.yml b/test/integration/targets/aws_s3/tasks/main.yml index 8e63b30712c..d72c4877355 100644 --- a/test/integration/targets/aws_s3/tasks/main.yml +++ b/test/integration/targets/aws_s3/tasks/main.yml @@ -93,7 +93,7 @@ async_status: jid: "{{ test_async.ansible_job_id }}" register: status - until: status.finished + until: status is finished retries: 10 - name: check that roles file lookups work as expected diff --git a/test/integration/targets/ec2_asg/tasks/main.yml b/test/integration/targets/ec2_asg/tasks/main.yml index a3f89e4edab..e51b2a81b0a 100644 --- a/test/integration/targets/ec2_asg/tasks/main.yml +++ b/test/integration/targets/ec2_asg/tasks/main.yml @@ -435,7 +435,7 @@ - name: Ensure ec2_asg task completes async_status: jid="{{ asg_job.ansible_job_id }}" register: status - until: status.finished + until: status is finished retries: 200 delay: 15 @@ -497,7 +497,7 @@ - name: Ensure ec2_asg task completes async_status: jid="{{ asg_job.ansible_job_id }}" register: status - until: status.finished + until: status is finished retries: 200 delay: 15 diff --git a/test/integration/targets/win_async_wrapper/tasks/main.yml b/test/integration/targets/win_async_wrapper/tasks/main.yml index 92d367a2fe3..1615f76c233 100644 --- a/test/integration/targets/win_async_wrapper/tasks/main.yml +++ b/test/integration/targets/win_async_wrapper/tasks/main.yml @@ -15,6 +15,7 @@ - asyncresult.ansible_job_id is match('\d+\.\d+') - asyncresult.started == 1 - asyncresult.finished == 0 + - asyncresult is not finished - asyncresult.results_file is search('\.ansible_async.+\d+\.\d+') # ensure that async is actually async- this test will fail if # hosts > forks or if the target host is VERY slow - (lookup('pipe', 'date +%s') | int) - (start_timestamp | int) < 8 @@ -31,7 +32,8 @@ that: - asyncresult.ansible_job_id is match('\d+\.\d+') - asyncresult.finished == 1 - - asyncresult.changed == true + - asyncresult is finished + - asyncresult is changed - asyncresult.ansible_async_watchdog_pid is number # - asyncresult.module_tempdir is search('ansible-tmp-') - asyncresult.module_pid is number @@ -68,7 +70,8 @@ that: - asyncresult.ansible_job_id is match('\d+\.\d+') - asyncresult.finished == 1 - - asyncresult.changed == true + - asyncresult is finished + - asyncresult is changed # - asyncresult.module_tempdir is search('ansible-tmp-') - asyncresult.module_pid is number @@ -105,8 +108,9 @@ that: - asyncresult.ansible_job_id is match('\d+\.\d+') - asyncresult.finished == 1 - - asyncresult.changed == false - - asyncresult is failed == true + - asyncresult is finished + - asyncresult is not changed + - asyncresult is failed - asyncresult.msg is search('timed out') - name: async poll graceful module failure @@ -122,8 +126,9 @@ that: - asyncresult.ansible_job_id is match('\d+\.\d+') - asyncresult.finished == 1 - - asyncresult.changed == true - - asyncresult is failed == true + - asyncresult is finished + - asyncresult is changed + - asyncresult is failed - asyncresult.msg == 'failed gracefully' - name: async poll exception module failure @@ -139,8 +144,9 @@ that: - asyncresult.ansible_job_id is match('\d+\.\d+') - asyncresult.finished == 1 - - asyncresult.changed == false - - asyncresult is failed == true + - asyncresult is finished + - asyncresult is not changed + - asyncresult is failed # TODO: re-enable after catastrophic failure behavior is cleaned up # - asyncresult.msg is search('failing via exception') @@ -184,7 +190,7 @@ # async_status: # jid: "{{ item }}" # register: asyncout -# until: asyncout.finished == 1 +# until: asyncout is finished # retries: 10 # delay: 1 # with_items: "{{ async_many.results | map(attribute='ansible_job_id') | list }}" @@ -193,8 +199,9 @@ # assert: # that: # - item.finished == 1 +# - item is finished # - item.slept_sec == 3 -# - item.changed == true +# - item is changed # - item.ansible_job_id is match('\d+\.\d+') # with_items: "{{ asyncout.results }}"