From 0956539edf93736ef23169610b08959a69ec0d92 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Thu, 2 May 2019 12:24:19 -0600 Subject: [PATCH] Reset the stored logs at each notification test steps This is an atempt to solve a new appearance of bug 1813147 where the long test_instance_action notification sample test case logs too much. This patch drops the logs of each successful test step to try to avoid the overload of the logging system. Change-Id: I0e5db9b2f423ab92ff93b6b3aada7d6b79a7abf6 Related-Bug: #1813147 (cherry picked from commit 93027713ab614b59ebb66f0617f85d43c956427c) --- nova/tests/fixtures.py | 6 ++++++ .../functional/notification_sample_tests/test_instance.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index f16ab3422d7b..b61415a7102b 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -182,6 +182,12 @@ class StandardLogging(fixtures.Fixture): self.useFixture( fixtures.MonkeyPatch('oslo_log.log.setup', fake_logging_setup)) + def delete_stored_logs(self): + # NOTE(gibi): this depends on the internals of the fixtures.FakeLogger. + # This could be enhanced once the PR + # https://github.com/testing-cabal/fixtures/pull/42 merges + self.logger._output.truncate(0) + class OutputStreamCapture(fixtures.Fixture): """Capture output streams during tests. diff --git a/nova/tests/functional/notification_sample_tests/test_instance.py b/nova/tests/functional/notification_sample_tests/test_instance.py index a62bc1f92472..e31f5c2fa038 100644 --- a/nova/tests/functional/notification_sample_tests/test_instance.py +++ b/nova/tests/functional/notification_sample_tests/test_instance.py @@ -407,6 +407,11 @@ class TestInstanceNotificationSample( # Ensure that instance is in active state after an action self._wait_for_state_change(self.admin_api, server, 'ACTIVE') + # if the test step did not raised then we consider the step as + # succeeded. We drop the logs to avoid causing subunit parser + # errors due to logging too much at the end of the test case. + self.stdlog.delete_stored_logs() + def test_create_delete_server(self): fake_trusted_certs = ['cert-id-1', 'cert-id-2'] server = self._boot_a_server(