Add test for large output; fix indentation.
parent
fba2bdcf0c
commit
83b9a43e60
|
@ -99,35 +99,32 @@ class TestRunner(unittest.TestCase):
|
||||||
|
|
||||||
def test_copy(self):
|
def test_copy(self):
|
||||||
# test copy module, change trigger, etc
|
# test copy module, change trigger, etc
|
||||||
pass
|
input_ = self._get_test_file('sample.j2')
|
||||||
|
|
||||||
def test_copy(self):
|
|
||||||
input = self._get_test_file('sample.j2')
|
|
||||||
output = self._get_stage_file('sample.out')
|
output = self._get_stage_file('sample.out')
|
||||||
assert not os.path.exists(output)
|
assert not os.path.exists(output)
|
||||||
result = self._run('copy', [
|
result = self._run('copy', [
|
||||||
"src=%s" % input,
|
"src=%s" % input_,
|
||||||
"dest=%s" % output,
|
"dest=%s" % output,
|
||||||
])
|
])
|
||||||
assert os.path.exists(output)
|
assert os.path.exists(output)
|
||||||
data_in = file(input).read()
|
data_in = file(input_).read()
|
||||||
data_out = file(output).read()
|
data_out = file(output).read()
|
||||||
assert data_in == data_out
|
assert data_in == data_out
|
||||||
assert 'failed' not in result
|
assert 'failed' not in result
|
||||||
assert result['changed'] == True
|
assert result['changed'] == True
|
||||||
assert 'md5sum' in result
|
assert 'md5sum' in result
|
||||||
result = self._run('copy', [
|
result = self._run('copy', [
|
||||||
"src=%s" % input,
|
"src=%s" % input_,
|
||||||
"dest=%s" % output,
|
"dest=%s" % output,
|
||||||
])
|
])
|
||||||
assert result['changed'] == False
|
assert result['changed'] == False
|
||||||
|
|
||||||
def test_template(self):
|
def test_template(self):
|
||||||
input = self._get_test_file('sample.j2')
|
input_ = self._get_test_file('sample.j2')
|
||||||
metadata = self._get_test_file('metadata.json')
|
metadata = self._get_test_file('metadata.json')
|
||||||
output = self._get_stage_file('sample.out')
|
output = self._get_stage_file('sample.out')
|
||||||
result = self._run('template', [
|
result = self._run('template', [
|
||||||
"src=%s" % input,
|
"src=%s" % input_,
|
||||||
"dest=%s" % output,
|
"dest=%s" % output,
|
||||||
"metadata=%s" % metadata
|
"metadata=%s" % metadata
|
||||||
])
|
])
|
||||||
|
@ -138,14 +135,13 @@ class TestRunner(unittest.TestCase):
|
||||||
assert 'md5sum' in result
|
assert 'md5sum' in result
|
||||||
assert 'failed' not in result
|
assert 'failed' not in result
|
||||||
result = self._run('template', [
|
result = self._run('template', [
|
||||||
"src=%s" % input,
|
"src=%s" % input_,
|
||||||
"dest=%s" % output,
|
"dest=%s" % output,
|
||||||
"metadata=%s" % metadata
|
"metadata=%s" % metadata
|
||||||
])
|
])
|
||||||
assert result['changed'] == False
|
assert result['changed'] == False
|
||||||
|
|
||||||
def test_command(self):
|
def test_command(self):
|
||||||
|
|
||||||
# test command module, change trigger, etc
|
# test command module, change trigger, etc
|
||||||
result = self._run('command', [ "/bin/echo", "hi" ])
|
result = self._run('command', [ "/bin/echo", "hi" ])
|
||||||
assert "failed" not in result
|
assert "failed" not in result
|
||||||
|
@ -167,6 +163,14 @@ class TestRunner(unittest.TestCase):
|
||||||
assert 'failed' not in result
|
assert 'failed' not in result
|
||||||
assert result['rc'] == 0
|
assert result['rc'] == 0
|
||||||
|
|
||||||
|
def test_large_output(self):
|
||||||
|
# Ensure reading a large amount of output from a command doesn't hang.
|
||||||
|
result = self._run('command', [ "/bin/cat", "/usr/share/dict/words" ])
|
||||||
|
assert "failed" not in result
|
||||||
|
assert "msg" not in result
|
||||||
|
assert result['rc'] == 0
|
||||||
|
assert len(result['stdout']) > 100000
|
||||||
|
assert result['stderr'] == ''
|
||||||
|
|
||||||
def test_setup(self):
|
def test_setup(self):
|
||||||
output = self._get_stage_file('output.json')
|
output = self._get_stage_file('output.json')
|
||||||
|
@ -203,11 +207,11 @@ class TestRunner(unittest.TestCase):
|
||||||
assert result['ansible_job_id'] == jid
|
assert result['ansible_job_id'] == jid
|
||||||
|
|
||||||
def test_fetch(self):
|
def test_fetch(self):
|
||||||
input = self._get_test_file('sample.j2')
|
input_ = self._get_test_file('sample.j2')
|
||||||
output = os.path.join(self.stage_dir, '127.0.0.2', input)
|
output = os.path.join(self.stage_dir, '127.0.0.2', input_)
|
||||||
result = self._run('fetch', [ "src=%s" % input, "dest=%s" % self.stage_dir ])
|
result = self._run('fetch', [ "src=%s" % input_, "dest=%s" % self.stage_dir ])
|
||||||
assert os.path.exists(output)
|
assert os.path.exists(output)
|
||||||
assert open(input).read() == open(output).read()
|
assert open(input_).read() == open(output).read()
|
||||||
|
|
||||||
def test_yum(self):
|
def test_yum(self):
|
||||||
if not get_binary("yum"):
|
if not get_binary("yum"):
|
||||||
|
|
Loading…
Reference in New Issue