1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Async tests complete. Fixed bug in async_wrapper

This commit is contained in:
Michael DeHaan 2012-04-04 11:30:14 -04:00
parent fae3a71899
commit c71afe35d6
2 changed files with 5 additions and 8 deletions

View file

@ -38,8 +38,6 @@ if len(sys.argv) < 3:
}) })
sys.exit(1) sys.exit(1)
print sys.argv
jid = sys.argv[1] jid = sys.argv[1]
time_limit = sys.argv[2] time_limit = sys.argv[2]
wrapped_module = sys.argv[3] wrapped_module = sys.argv[3]

View file

@ -57,6 +57,8 @@ class TestRunner(unittest.TestCase):
self.runner.module_args = module_args self.runner.module_args = module_args
self.runner.background = background self.runner.background = background
results = self.runner.run() results = self.runner.run()
# when using nosetests this will only show up on failure
# which is pretty useful
print "RESULTS=%s" % results print "RESULTS=%s" % results
assert "127.0.0.1" in results['contacted'] assert "127.0.0.1" in results['contacted']
return results['contacted']['127.0.0.1'] return results['contacted']['127.0.0.1']
@ -139,17 +141,14 @@ class TestRunner(unittest.TestCase):
def test_async(self): def test_async(self):
# test async launch and job status # test async launch and job status
# of any particular module # of any particular module
result = self._run('command', [ "/bin/sleep", "10" ], background=20) result = self._run('command', [ "/bin/sleep", "3" ], background=20)
print "RESULT1=%s" % result
assert 'ansible_job_id' in result assert 'ansible_job_id' in result
assert 'started' in result assert 'started' in result
jid = result['ansible_job_id'] jid = result['ansible_job_id']
# no real chance of this op taking a while, but whatever # no real chance of this op taking a while, but whatever
time.sleep(1) time.sleep(5)
# TODO: verify we are still running
time.sleep(12)
# CLI will abstract this, but this is how it works internally # CLI will abstract this, but this is how it works internally
result = self._run('async_status', [ "jid=%s" % ansible_job_id ]) result = self._run('async_status', [ "jid=%s" % jid ])
# TODO: would be nice to have tests for supervisory process # TODO: would be nice to have tests for supervisory process
# killing job after X seconds # killing job after X seconds
assert 'finished' in result assert 'finished' in result