From 371e9ca1106dd1feb00b7dced2720329e067b3b4 Mon Sep 17 00:00:00 2001 From: Brian Neradt Date: Thu, 2 Feb 2023 19:03:13 +0000 Subject: [PATCH 1/3] fatal.test.py autest: make it more reliable The fatal.test.py test has been flaky because of a race condition between the process shutdown caused by TSFatal and the autest shutting down the process because the Default Process print statement finished. This patch adds a FileContaines ready condition for the TSFatal log message before ending the TestRun which makes it run correctly more reliably. --- tests/gold_tests/shutdown/fatal.test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/gold_tests/shutdown/fatal.test.py b/tests/gold_tests/shutdown/fatal.test.py index a15201e80e4..bb3ccccff0b 100644 --- a/tests/gold_tests/shutdown/fatal.test.py +++ b/tests/gold_tests/shutdown/fatal.test.py @@ -46,6 +46,7 @@ tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) ts.ReturnCode = 70 -ts.Ready = 0 # Need this to be 0 because we are testing shutdown, this is to make autest not think ats went away for a bad reason. +ts.Ready = When.FileContains(ts.Disk.traffic_out.Name, "testing fatal shutdown") +ts.Timeout = 5 ts.Disk.traffic_out.Content = Testers.ExcludesExpression('failed to shutdown', 'should NOT contain "failed to shutdown"') ts.Disk.diags_log.Content = Testers.IncludesExpression('testing fatal shutdown', 'should contain "testing fatal shutdown"') From 65e72bd836a12b11e2ce680e4834ccb59d238500 Mon Sep 17 00:00:00 2001 From: Brian Neradt Date: Thu, 2 Feb 2023 19:17:27 +0000 Subject: [PATCH 2/3] remap_load_empty_failure.test.py autest: make it more reliable The remap_load_empty_failure.test.py had a race condition between the autest run finishing due to the Default echo process finishing and the traffic server instance writing the "remap.config failed to load" message to the diags.log. This updates the Ready condition for the traffic server process to wait until that log is printed before running the echo and ending the test. --- tests/gold_tests/remap/remap_load_empty_failure.test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/gold_tests/remap/remap_load_empty_failure.test.py b/tests/gold_tests/remap/remap_load_empty_failure.test.py index 29dbfb9969a..199d65da778 100644 --- a/tests/gold_tests/remap/remap_load_empty_failure.test.py +++ b/tests/gold_tests/remap/remap_load_empty_failure.test.py @@ -24,7 +24,9 @@ ts.Disk.remap_config.AddLine(f"") # empty file ts.Disk.records_config.update({'proxy.config.url_remap.min_rules_required': 1}) ts.ReturnCode = 33 # expect to Emergency fail due to empty "remap.config". +ts.Ready = When.FileContains(ts.Disk.diags_log.Name, "remap.config failed to load") tr = Test.AddTestRun("test") -tr.Processes.Default.Command = "echo" -tr.Processes.Default.StartAfter(ts, ready=When.FileExists(ts.Disk.diags_log)) +tr.Processes.Default.Command = "echo howdy" +tr.TimeOut = 5 +tr.Processes.Default.StartBefore(ts) From 561567da76f9291e41a8b39004c372057f7e5949 Mon Sep 17 00:00:00 2001 From: Brian Neradt Date: Thu, 2 Feb 2023 19:46:30 +0000 Subject: [PATCH 3/3] emergency.test.py autest: make it more reliable The emergency.test.py test has been flaky because of a race condition between the process shutdown caused by TSEmergency and the autest shutting down the process because the Default Process print statement finished. This patch adds a FileContaines ready condition for the TSEmergency log message before ending the TestRun which makes it run correctly more reliably. --- tests/gold_tests/shutdown/emergency.test.py | 4 +++- tests/gold_tests/shutdown/fatal.test.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/gold_tests/shutdown/emergency.test.py b/tests/gold_tests/shutdown/emergency.test.py index c9518a7520f..74ca0f9791d 100644 --- a/tests/gold_tests/shutdown/emergency.test.py +++ b/tests/gold_tests/shutdown/emergency.test.py @@ -45,7 +45,9 @@ tr.Processes.Default.Command = 'printf "Emergency Shutdown Test"' tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) +tr.Timeout = 5 + ts.ReturnCode = 33 -ts.Ready = 0 # Need this to be 0 because we are testing shutdown, this is to make autest not think ats went away for a bad reason. +ts.Ready = When.FileContains(ts.Disk.traffic_out.Name, "testing emergency shutdown") ts.Disk.traffic_out.Content = Testers.ExcludesExpression('failed to shutdown', 'should NOT contain "failed to shutdown"') ts.Disk.diags_log.Content = Testers.IncludesExpression('testing emergency shutdown', 'should contain "testing emergency shutdown"') diff --git a/tests/gold_tests/shutdown/fatal.test.py b/tests/gold_tests/shutdown/fatal.test.py index bb3ccccff0b..da7999d8da0 100644 --- a/tests/gold_tests/shutdown/fatal.test.py +++ b/tests/gold_tests/shutdown/fatal.test.py @@ -45,8 +45,9 @@ tr.Processes.Default.Command = 'printf "Fatal Shutdown Test"' tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(ts) +tr.Timeout = 5 + ts.ReturnCode = 70 ts.Ready = When.FileContains(ts.Disk.traffic_out.Name, "testing fatal shutdown") -ts.Timeout = 5 ts.Disk.traffic_out.Content = Testers.ExcludesExpression('failed to shutdown', 'should NOT contain "failed to shutdown"') ts.Disk.diags_log.Content = Testers.IncludesExpression('testing fatal shutdown', 'should contain "testing fatal shutdown"')