Commit 64673cc9 by John Kleint

Add test for large output; fix indentation.

parent 0956aa96
......@@ -78,13 +78,13 @@ class TestRunner(unittest.TestCase):
return results['contacted']['127.0.0.2']
def test_ping(self):
result = self._run('ping',[])
result = self._run('ping', [])
assert "ping" in result
def test_facter(self):
if not get_binary("facter"):
raise SkipTest
result = self._run('facter',[])
result = self._run('facter', [])
assert "hostname" in result
# temporarily disbabled since it occasionally hangs
......@@ -99,35 +99,32 @@ class TestRunner(unittest.TestCase):
def test_copy(self):
# test copy module, change trigger, etc
pass
def test_copy(self):
input = self._get_test_file('sample.j2')
input_ = self._get_test_file('sample.j2')
output = self._get_stage_file('sample.out')
assert not os.path.exists(output)
result = self._run('copy', [
"src=%s" % input,
"src=%s" % input_,
"dest=%s" % output,
])
assert os.path.exists(output)
data_in = file(input).read()
data_in = file(input_).read()
data_out = file(output).read()
assert data_in == data_out
assert 'failed' not in result
assert result['changed'] == True
assert 'md5sum' in result
result = self._run('copy', [
"src=%s" % input,
"src=%s" % input_,
"dest=%s" % output,
])
assert result['changed'] == False
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')
output = self._get_stage_file('sample.out')
result = self._run('template', [
"src=%s" % input,
"src=%s" % input_,
"dest=%s" % output,
"metadata=%s" % metadata
])
......@@ -138,14 +135,13 @@ class TestRunner(unittest.TestCase):
assert 'md5sum' in result
assert 'failed' not in result
result = self._run('template', [
"src=%s" % input,
"src=%s" % input_,
"dest=%s" % output,
"metadata=%s" % metadata
])
assert result['changed'] == False
def test_command(self):
# test command module, change trigger, etc
result = self._run('command', [ "/bin/echo", "hi" ])
assert "failed" not in result
......@@ -167,6 +163,14 @@ class TestRunner(unittest.TestCase):
assert 'failed' not in result
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):
output = self._get_stage_file('output.json')
......@@ -203,11 +207,11 @@ class TestRunner(unittest.TestCase):
assert result['ansible_job_id'] == jid
def test_fetch(self):
input = self._get_test_file('sample.j2')
output = os.path.join(self.stage_dir, '127.0.0.2', input)
result = self._run('fetch', [ "src=%s" % input, "dest=%s" % self.stage_dir ])
input_ = self._get_test_file('sample.j2')
output = os.path.join(self.stage_dir, '127.0.0.2', input_)
result = self._run('fetch', [ "src=%s" % input_, "dest=%s" % self.stage_dir ])
assert os.path.exists(output)
assert open(input).read() == open(output).read()
assert open(input_).read() == open(output).read()
def test_yum(self):
if not get_binary("yum"):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment