|
@@ -98,7 +98,7 @@ def test_log_outputs_kills_other_processes_when_one_errors():
|
|
process, 2, 'borg'
|
|
process, 2, 'borg'
|
|
).and_return(True)
|
|
).and_return(True)
|
|
other_process = subprocess.Popen(
|
|
other_process = subprocess.Popen(
|
|
- ['watch', 'true'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
|
|
|
|
|
+ ['sleep', '2'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
|
)
|
|
)
|
|
flexmock(module).should_receive('exit_code_indicates_error').with_args(
|
|
flexmock(module).should_receive('exit_code_indicates_error').with_args(
|
|
other_process, None, 'borg'
|
|
other_process, None, 'borg'
|
|
@@ -123,6 +123,38 @@ def test_log_outputs_kills_other_processes_when_one_errors():
|
|
assert error.value.output
|
|
assert error.value.output
|
|
|
|
|
|
|
|
|
|
|
|
+def test_log_outputs_vents_other_processes_when_one_exits():
|
|
|
|
+ '''
|
|
|
|
+ Execute a command to generate a longish random string and pipe it into another command that
|
|
|
|
+ exits quickly. The test is basically to ensure we don't hang forever waiting for the exited
|
|
|
|
+ process to read the pipe, and that the string-generating process eventually gets vented and
|
|
|
|
+ exits.
|
|
|
|
+ '''
|
|
|
|
+ flexmock(module.logger).should_receive('log')
|
|
|
|
+ flexmock(module).should_receive('command_for_process').and_return('grep')
|
|
|
|
+
|
|
|
|
+ process = subprocess.Popen(
|
|
|
|
+ ['shuf', '-zer', '-n10000', '{A..Z}'], stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
|
|
|
+ )
|
|
|
|
+ other_process = subprocess.Popen(
|
|
|
|
+ ['true'], stdin=process.stdout, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
|
|
|
+ )
|
|
|
|
+ flexmock(module).should_receive('output_buffer_for_process').with_args(
|
|
|
|
+ process, (process.stdout,)
|
|
|
|
+ ).and_return(process.stderr)
|
|
|
|
+ flexmock(module).should_receive('output_buffer_for_process').with_args(
|
|
|
|
+ other_process, (process.stdout,)
|
|
|
|
+ ).and_return(other_process.stdout)
|
|
|
|
+ flexmock(process.stdout).should_call('readline').once()
|
|
|
|
+
|
|
|
|
+ module.log_outputs(
|
|
|
|
+ (process, other_process),
|
|
|
|
+ exclude_stdouts=(process.stdout,),
|
|
|
|
+ output_log_level=logging.INFO,
|
|
|
|
+ borg_local_path='borg',
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+
|
|
def test_log_outputs_truncates_long_error_output():
|
|
def test_log_outputs_truncates_long_error_output():
|
|
flexmock(module).ERROR_OUTPUT_MAX_LINE_COUNT = 0
|
|
flexmock(module).ERROR_OUTPUT_MAX_LINE_COUNT = 0
|
|
flexmock(module.logger).should_receive('log')
|
|
flexmock(module.logger).should_receive('log')
|