Test stream no encoding bug

Tests that if no encoding is defined on the output that JJB does not
accidentally trigger a recursion issue when iterating over a large
number of jobs and attempting to wrap the output stream.

Inspired by commit message from: https://review.openstack.org/283441

Change-Id: Ie69c3af0beb9fd7c589a436e8c6d2862210f8a4c
Co-Authored-By: Hao Liu <hliu@redhat.com>
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
Darragh Bailey 2016-05-03 19:22:21 +01:00 committed by Thanh Ha
parent 6190a2407b
commit a949a274e3
No known key found for this signature in database
GPG Key ID: B0CB27E00DA095AA
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,10 @@
- job-template:
name: '{name}-{a}-{b}-{c}'
- project:
name: project-name
a: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
b: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
c: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
jobs:
- '{name}-{a}-{b}-{c}'

View File

@ -73,6 +73,22 @@ class TestTests(CmdTestsBase):
'r', encoding='utf-8').read()
self.assertEqual(console_out.getvalue().decode('utf-8'), xml_content)
def test_stream_input_output_no_encoding_exceed_recursion(self):
"""
Test that we don't have issues processing large number of jobs and
outputting the result if the encoding is not set.
"""
console_out = io.BytesIO()
input_file = os.path.join(self.fixtures_path,
'large-number-of-jobs-001.yaml')
with io.open(input_file, 'r') as f:
with mock.patch('sys.stdout', console_out):
console_out.encoding = None
with mock.patch('sys.stdin', f):
args = ['test']
self.execute_jenkins_jobs_with_args(args)
def test_stream_input_output_utf8_encoding(self):
"""
Run test mode simulating using pipes for input and output using