From 9d337b4c9d80efd1799543a80a3d2522775d7e62 Mon Sep 17 00:00:00 2001 From: James Falcon Date: Wed, 1 Dec 2021 22:31:53 -0600 Subject: [PATCH 1/2] testing: Remove date from final_message test --- tests/integration_tests/modules/test_combined.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/integration_tests/modules/test_combined.py b/tests/integration_tests/modules/test_combined.py index bc19c2a285f..01796d5cdd3 100644 --- a/tests/integration_tests/modules/test_combined.py +++ b/tests/integration_tests/modules/test_combined.py @@ -74,23 +74,16 @@ def test_final_message(self, class_client: IntegrationInstance): """Test that final_message module works as expected. Also tests LP 1511485: final_message is silent. - - It's possible that if this test is run within a minute or so of - midnight that we'll see a failure because the day in the logs - is different from the day specified in the test definition. """ client = class_client log = client.read_from_file('/var/log/cloud-init.log') - # Get date on host rather than locally as our host could be in a - # wildly different timezone (or more likely recording UTC) - today = client.execute('date "+%a, %d %b %Y"') expected = ( 'This is my final message!\n' r'\d+\.\d+.*\n' - '{}.*\n' + '.*\n' # Checking date is too error prone due to timezone 'DataSource.*\n' r'\d+\.\d+' - ).format(today) + ) assert re.search(expected, log) From 6ae54e304954dda1e1db50b93d131f2d518487c9 Mon Sep 17 00:00:00 2001 From: James Falcon Date: Thu, 2 Dec 2021 17:28:36 -0600 Subject: [PATCH 2/2] Use regex instead --- tests/integration_tests/modules/test_combined.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration_tests/modules/test_combined.py b/tests/integration_tests/modules/test_combined.py index 01796d5cdd3..b45f6f17ed7 100644 --- a/tests/integration_tests/modules/test_combined.py +++ b/tests/integration_tests/modules/test_combined.py @@ -78,11 +78,11 @@ def test_final_message(self, class_client: IntegrationInstance): client = class_client log = client.read_from_file('/var/log/cloud-init.log') expected = ( - 'This is my final message!\n' - r'\d+\.\d+.*\n' - '.*\n' # Checking date is too error prone due to timezone - 'DataSource.*\n' - r'\d+\.\d+' + "This is my final message!\n" + r"\d+\.\d+.*\n" + r"\w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} \+\d{4}\n" # Datetime + "DataSource.*\n" + r"\d+\.\d+" ) assert re.search(expected, log)