# Verify 'async: <timeout>' functions as desired.

- name: integration/async/runner_with_polling_and_timeout.yml
  hosts: test-targets
  tasks:

  # Verify async-with-polling-and-timeout behaviour.

  - name: sleep for 7 seconds, but timeout after 1 second.
    ignore_errors: true
    shell: sleep 7
    async: 1
    poll: 1
    register: job1

  - assert:
      that:
        - job1.changed == False
        - job1.failed == True
        - |
          job1.msg == "async task did not complete within the requested time" or
          job1.msg == "async task did not complete within the requested time - 1s" or
          job1.msg == "Job reached maximum time limit of 1 seconds."
      fail_msg: |
        job1={{ job1 }}
  tags:
    - runner_with_polling_and_timeout
