From d07032fa5a9ceb49137af8b7ea90c41f4d53decd Mon Sep 17 00:00:00 2001 From: James Tanner Date: Fri, 21 Feb 2014 10:00:01 -0500 Subject: [PATCH] Add async test role --- test/integration/non_destructive.yml | 1 + .../roles/test_async/meta/main.yml | 3 ++ .../roles/test_async/tasks/main.yml | 45 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 test/integration/roles/test_async/meta/main.yml create mode 100644 test/integration/roles/test_async/tasks/main.yml diff --git a/test/integration/non_destructive.yml b/test/integration/non_destructive.yml index c0190d5d4e1..10d19a15a2c 100644 --- a/test/integration/non_destructive.yml +++ b/test/integration/non_destructive.yml @@ -28,4 +28,5 @@ - { role: test_filters, tags: test_filters } - { role: test_facts_d, tags: test_facts_d } - { role: test_conditionals, tags: test_conditionals } + - { role: test_async, tags: test_async } diff --git a/test/integration/roles/test_async/meta/main.yml b/test/integration/roles/test_async/meta/main.yml new file mode 100644 index 00000000000..1050c23ce30 --- /dev/null +++ b/test/integration/roles/test_async/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + diff --git a/test/integration/roles/test_async/tasks/main.yml b/test/integration/roles/test_async/tasks/main.yml new file mode 100644 index 00000000000..350d5ef4701 --- /dev/null +++ b/test/integration/roles/test_async/tasks/main.yml @@ -0,0 +1,45 @@ +# test code for the async keyword +# (c) 2014, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- name: run a 2 second loop + shell: for i in $(seq 1 2); do echo $i ; sleep 1; done; + async: 10 + poll: 1 + register: async_result + + +- debug: var=async_result + +- name: validate async returns + assert: + that: + - "'ansible_job_id' in async_result" + - "'changed' in async_result" + - "'cmd' in async_result" + - "'delta' in async_result" + - "'end' in async_result" + - "'finished' in async_result" + - "'invocation' in async_result" + - "'item' in async_result" + - "'rc' in async_result" + - "'start' in async_result" + - "'stderr' in async_result" + - "'stdout' in async_result" + - "'stdout_lines' in async_result" + - "async_result.rc == 0" +