|
|
@ -96,6 +96,8 @@ class TestPlaybook(unittest.TestCase):
|
|
|
|
os.unlink('/tmp/ansible_test_data_template.out')
|
|
|
|
os.unlink('/tmp/ansible_test_data_template.out')
|
|
|
|
if os.path.exists('/tmp/ansible_test_messages.out'):
|
|
|
|
if os.path.exists('/tmp/ansible_test_messages.out'):
|
|
|
|
os.unlink('/tmp/ansible_test_messages.out')
|
|
|
|
os.unlink('/tmp/ansible_test_messages.out')
|
|
|
|
|
|
|
|
if os.path.exists('/tmp/ansible_test_role_messages.out'):
|
|
|
|
|
|
|
|
os.unlink('/tmp/ansible_test_role_messages.out')
|
|
|
|
|
|
|
|
|
|
|
|
def _prepare_stage_dir(self):
|
|
|
|
def _prepare_stage_dir(self):
|
|
|
|
stage_path = os.path.join(self.test_dir, 'test_data')
|
|
|
|
stage_path = os.path.join(self.test_dir, 'test_data')
|
|
|
@ -304,20 +306,17 @@ class TestPlaybook(unittest.TestCase):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
playbook.run()
|
|
|
|
playbook.run()
|
|
|
|
|
|
|
|
|
|
|
|
with open('/tmp/ansible_test_messages.out') as f:
|
|
|
|
filename = '/tmp/ansible_test_messages.out'
|
|
|
|
actual = [l.strip() for l in f.readlines()]
|
|
|
|
expected_lines = [
|
|
|
|
|
|
|
|
|
|
|
|
print "**ACTUAL**"
|
|
|
|
|
|
|
|
print actual
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expected = [
|
|
|
|
|
|
|
|
"goodbye: Goodbye World!"
|
|
|
|
"goodbye: Goodbye World!"
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
self._compare_file_output(filename, expected_lines)
|
|
|
|
|
|
|
|
|
|
|
|
print "**EXPECTED**"
|
|
|
|
filename = '/tmp/ansible_test_role_messages.out'
|
|
|
|
print expected
|
|
|
|
expected_lines = [
|
|
|
|
|
|
|
|
"inside_a_role: Indeed!"
|
|
|
|
assert actual == expected
|
|
|
|
]
|
|
|
|
|
|
|
|
self._compare_file_output(filename, expected_lines)
|
|
|
|
|
|
|
|
|
|
|
|
# restore default hash behavior
|
|
|
|
# restore default hash behavior
|
|
|
|
C.DEFAULT_HASH_BEHAVIOUR = saved_hash_behavior
|
|
|
|
C.DEFAULT_HASH_BEHAVIOUR = saved_hash_behavior
|
|
|
@ -337,21 +336,34 @@ class TestPlaybook(unittest.TestCase):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
playbook.run()
|
|
|
|
playbook.run()
|
|
|
|
|
|
|
|
|
|
|
|
with open('/tmp/ansible_test_messages.out') as f:
|
|
|
|
filename = '/tmp/ansible_test_messages.out'
|
|
|
|
actual = [l.strip() for l in f.readlines()]
|
|
|
|
expected_lines = [
|
|
|
|
|
|
|
|
"goodbye: Goodbye World!",
|
|
|
|
print "**ACTUAL**"
|
|
|
|
"hello: Hello World!"
|
|
|
|
print actual
|
|
|
|
]
|
|
|
|
|
|
|
|
self._compare_file_output(filename, expected_lines)
|
|
|
|
|
|
|
|
|
|
|
|
expected = [
|
|
|
|
filename = '/tmp/ansible_test_role_messages.out'
|
|
|
|
|
|
|
|
expected_lines = [
|
|
|
|
|
|
|
|
"goodbye: Goodbye World!",
|
|
|
|
"hello: Hello World!",
|
|
|
|
"hello: Hello World!",
|
|
|
|
"goodbye: Goodbye World!"
|
|
|
|
"inside_a_role: Indeed!"
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
self._compare_file_output(filename, expected_lines)
|
|
|
|
print "**EXPECTED**"
|
|
|
|
|
|
|
|
print expected
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert actual == expected
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# restore default hash behavior
|
|
|
|
# restore default hash behavior
|
|
|
|
C.DEFAULT_HASH_BEHAVIOUR = saved_hash_behavior
|
|
|
|
C.DEFAULT_HASH_BEHAVIOUR = saved_hash_behavior
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _compare_file_output(self, filename, expected_lines):
|
|
|
|
|
|
|
|
actual_lines = []
|
|
|
|
|
|
|
|
with open(filename) as f:
|
|
|
|
|
|
|
|
actual_lines = [l.strip() for l in f.readlines()]
|
|
|
|
|
|
|
|
actual_lines = sorted(actual_lines)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print "**ACTUAL**"
|
|
|
|
|
|
|
|
print actual_lines
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print "**EXPECTED**"
|
|
|
|
|
|
|
|
print expected_lines
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert actual_lines == expected_lines
|
|
|
|