bneradt commented on code in PR #13323:
URL: https://github.com/apache/trafficserver/pull/13323#discussion_r3572255270


##########
tests/gold_tests/pluginTest/stale_response/stale_response.test.py:
##########
@@ -140,28 +140,23 @@ def setupClient(self, tr: 'TestRun') -> None:
 
     def verify_plugin_log(self) -> None:
         """Verify the contents of the stale_response plugin log."""
-        tr = Test.AddTestRun("Verify stale_response plugin log")
-        name = f'log_waiter_{TestStaleResponse._ts_counter}'
-        log_waiter = tr.Processes.Process(name)
-        log_waiter.Command = 'sleep 30'
+        swr_log_pattern = "stale-while-revalidate:.*stale.jpeg"
+        sie_log_pattern = "stale-if-error:.*error.jpeg"
+
+        def expect_log_entry(pattern: str, description: str, 
still_running_after: bool = False) -> None:
+            tr = Test.AddAwaitFileContainsTestRun(f"Await {description}", 
self._ts.Disk.stale_responses_log.AbsPath, pattern)
+            tr.StillRunningBefore = self._ts
+            if still_running_after:
+                tr.StillRunningAfter = self._ts
+            self._ts.Disk.stale_responses_log.Content += 
Testers.ContainsExpression(pattern, f"Verify {description}")

Review Comment:
   Applied. expect_log_entry() now sets StillRunningAfter = self._ts 
unconditionally, so every await run preserves the old waiter behavior and keeps 
ATS alive after the directive is observed.



##########
tests/gold_tests/pluginTest/stale_response/stale_response.test.py:
##########
@@ -140,28 +140,23 @@ def setupClient(self, tr: 'TestRun') -> None:
 
     def verify_plugin_log(self) -> None:
         """Verify the contents of the stale_response plugin log."""
-        tr = Test.AddTestRun("Verify stale_response plugin log")
-        name = f'log_waiter_{TestStaleResponse._ts_counter}'
-        log_waiter = tr.Processes.Process(name)
-        log_waiter.Command = 'sleep 30'
+        swr_log_pattern = "stale-while-revalidate:.*stale.jpeg"
+        sie_log_pattern = "stale-if-error:.*error.jpeg"
+
+        def expect_log_entry(pattern: str, description: str, 
still_running_after: bool = False) -> None:
+            tr = Test.AddAwaitFileContainsTestRun(f"Await {description}", 
self._ts.Disk.stale_responses_log.AbsPath, pattern)
+            tr.StillRunningBefore = self._ts
+            if still_running_after:
+                tr.StillRunningAfter = self._ts
+            self._ts.Disk.stale_responses_log.Content += 
Testers.ContainsExpression(pattern, f"Verify {description}")
+
         if self._option_type == OptionType.FORCE_SWR:
-            log_waiter.Ready = 
When.FileContains(self._ts.Disk.stale_responses_log.Name, 
"stale-while-revalidate:")
-            self._ts.Disk.stale_responses_log.Content += 
Testers.ContainsExpression(
-                "stale-while-revalidate:.*stale.jpeg", "Verify 
stale-while-revalidate directive is logged")
+            expect_log_entry(swr_log_pattern, "stale-while-revalidate 
directive is logged")
         elif self._option_type == OptionType.FORCE_SIE:
-            log_waiter.Ready = 
When.FileContains(self._ts.Disk.stale_responses_log.Name, "stale-if-error:")
-            self._ts.Disk.stale_responses_log.Content += 
Testers.ContainsExpression(
-                "stale-if-error:.*error.jpeg", "Verify stale-if-error 
directive is logged")
+            expect_log_entry(sie_log_pattern, "stale-if-error directive is 
logged")
         else:
-            log_waiter.Ready = 
When.FileContains(self._ts.Disk.stale_responses_log.Name, "stale-if-error:")
-            self._ts.Disk.stale_responses_log.Content += 
Testers.ContainsExpression(
-                "stale-while-revalidate:.*stale.jpeg", "Verify 
stale-while-revalidate directive is logged")
-            self._ts.Disk.stale_responses_log.Content += 
Testers.ContainsExpression(
-                "stale-if-error:.*error.jpeg", "Verify stale-if-error 
directive is logged")
-        p = tr.Processes.Default
-        p.Command = 'echo "Waiting upon the stale response log."'
-        p.StartBefore(log_waiter)
-        p.StillRunningAfter = self._ts
+            expect_log_entry(swr_log_pattern, "stale-while-revalidate 
directive is logged", still_running_after=True)

Review Comment:
   Applied with the helper change. The default case now calls 
expect_log_entry() without the still_running_after argument.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to