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


##########
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:
   The old waiter run set `StillRunningAfter = self._ts` in every branch; with 
the flag, the FORCE_SWR/FORCE_SIE variants no longer check that ATS is still 
alive after the directive is flushed. Setting it unconditionally restores that 
and removes the asymmetry.
   ```suggestion
           def expect_log_entry(pattern: str, description: str) -> None:
               tr = Test.AddAwaitFileContainsTestRun(f"Await {description}", 
self._ts.Disk.stale_responses_log.AbsPath, pattern)
               tr.StillRunningBefore = self._ts
               tr.StillRunningAfter = self._ts
               self._ts.Disk.stale_responses_log.Content += 
Testers.ContainsExpression(pattern, f"Verify {description}")
   ```



##########
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:
   (goes with the helper change above)
   ```suggestion
               expect_log_entry(swr_log_pattern, "stale-while-revalidate 
directive is logged")
   ```



-- 
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