|
@@ -238,6 +238,7 @@ def test_run_configuration_retries_hard_error():
|
|
|
'foo: Error running actions for repository',
|
|
|
OSError,
|
|
|
levelno=logging.WARNING,
|
|
|
+ log_command_error_output=True,
|
|
|
).and_return([flexmock()])
|
|
|
error_logs = [flexmock()]
|
|
|
flexmock(module).should_receive('log_error_records').with_args(
|
|
@@ -277,11 +278,13 @@ def test_run_configuration_retries_round_robin():
|
|
|
'foo: Error running actions for repository',
|
|
|
OSError,
|
|
|
levelno=logging.WARNING,
|
|
|
+ log_command_error_output=True,
|
|
|
).and_return([flexmock()]).ordered()
|
|
|
flexmock(module).should_receive('log_error_records').with_args(
|
|
|
'bar: Error running actions for repository',
|
|
|
OSError,
|
|
|
levelno=logging.WARNING,
|
|
|
+ log_command_error_output=True,
|
|
|
).and_return([flexmock()]).ordered()
|
|
|
foo_error_logs = [flexmock()]
|
|
|
flexmock(module).should_receive('log_error_records').with_args(
|
|
@@ -311,11 +314,13 @@ def test_run_configuration_retries_one_passes():
|
|
|
'foo: Error running actions for repository',
|
|
|
OSError,
|
|
|
levelno=logging.WARNING,
|
|
|
+ log_command_error_output=True,
|
|
|
).and_return([flexmock()]).ordered()
|
|
|
flexmock(module).should_receive('log_error_records').with_args(
|
|
|
'bar: Error running actions for repository',
|
|
|
OSError,
|
|
|
levelno=logging.WARNING,
|
|
|
+ log_command_error_output=True,
|
|
|
).and_return(flexmock()).ordered()
|
|
|
error_logs = [flexmock()]
|
|
|
flexmock(module).should_receive('log_error_records').with_args(
|
|
@@ -339,6 +344,7 @@ def test_run_configuration_retry_wait():
|
|
|
'foo: Error running actions for repository',
|
|
|
OSError,
|
|
|
levelno=logging.WARNING,
|
|
|
+ log_command_error_output=True,
|
|
|
).and_return([flexmock()]).ordered()
|
|
|
|
|
|
flexmock(time).should_receive('sleep').with_args(10).and_return().ordered()
|
|
@@ -346,6 +352,7 @@ def test_run_configuration_retry_wait():
|
|
|
'foo: Error running actions for repository',
|
|
|
OSError,
|
|
|
levelno=logging.WARNING,
|
|
|
+ log_command_error_output=True,
|
|
|
).and_return([flexmock()]).ordered()
|
|
|
|
|
|
flexmock(time).should_receive('sleep').with_args(20).and_return().ordered()
|
|
@@ -353,6 +360,7 @@ def test_run_configuration_retry_wait():
|
|
|
'foo: Error running actions for repository',
|
|
|
OSError,
|
|
|
levelno=logging.WARNING,
|
|
|
+ log_command_error_output=True,
|
|
|
).and_return([flexmock()]).ordered()
|
|
|
|
|
|
flexmock(time).should_receive('sleep').with_args(30).and_return().ordered()
|
|
@@ -381,11 +389,13 @@ def test_run_configuration_retries_timeout_multiple_repos():
|
|
|
'foo: Error running actions for repository',
|
|
|
OSError,
|
|
|
levelno=logging.WARNING,
|
|
|
+ log_command_error_output=True,
|
|
|
).and_return([flexmock()]).ordered()
|
|
|
flexmock(module).should_receive('log_error_records').with_args(
|
|
|
'bar: Error running actions for repository',
|
|
|
OSError,
|
|
|
levelno=logging.WARNING,
|
|
|
+ log_command_error_output=True,
|
|
|
).and_return([flexmock()]).ordered()
|
|
|
|
|
|
# Sleep before retrying foo (and passing)
|
|
@@ -816,6 +826,10 @@ def test_log_record_does_not_raise():
|
|
|
module.log_record(levelno=1, foo='bar', baz='quux')
|
|
|
|
|
|
|
|
|
+def test_log_record_with_suppress_does_not_raise():
|
|
|
+ module.log_record(levelno=1, foo='bar', baz='quux', suppress_log=True)
|
|
|
+
|
|
|
+
|
|
|
def test_log_error_records_generates_output_logs_for_message_only():
|
|
|
flexmock(module).should_receive('log_record').replace_with(dict)
|
|
|
|
|
@@ -824,7 +838,7 @@ def test_log_error_records_generates_output_logs_for_message_only():
|
|
|
assert {log['levelno'] for log in logs} == {logging.CRITICAL}
|
|
|
|
|
|
|
|
|
-def test_log_error_records_generates_output_logs_for_called_process_error():
|
|
|
+def test_log_error_records_generates_output_logs_for_called_process_error_with_bytes_ouput():
|
|
|
flexmock(module).should_receive('log_record').replace_with(dict)
|
|
|
flexmock(module.logger).should_receive('getEffectiveLevel').and_return(logging.WARNING)
|
|
|
|
|
@@ -836,6 +850,18 @@ def test_log_error_records_generates_output_logs_for_called_process_error():
|
|
|
assert any(log for log in logs if 'error output' in str(log))
|
|
|
|
|
|
|
|
|
+def test_log_error_records_generates_output_logs_for_called_process_error_with_string_ouput():
|
|
|
+ flexmock(module).should_receive('log_record').replace_with(dict)
|
|
|
+ flexmock(module.logger).should_receive('getEffectiveLevel').and_return(logging.WARNING)
|
|
|
+
|
|
|
+ logs = tuple(
|
|
|
+ module.log_error_records('Error', subprocess.CalledProcessError(1, 'ls', 'error output'))
|
|
|
+ )
|
|
|
+
|
|
|
+ assert {log['levelno'] for log in logs} == {logging.CRITICAL}
|
|
|
+ assert any(log for log in logs if 'error output' in str(log))
|
|
|
+
|
|
|
+
|
|
|
def test_log_error_records_generates_logs_for_value_error():
|
|
|
flexmock(module).should_receive('log_record').replace_with(dict)
|
|
|
|