This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 344692489f More robustness improvements to HTTP/2 8.1 tests
344692489f is described below

commit 344692489fb6bbaa69ba701cccf1c76f16e814e2
Author: Mark Thomas <[email protected]>
AuthorDate: Mon May 25 08:55:56 2026 +0100

    More robustness improvements to HTTP/2 8.1 tests
---
 test/org/apache/coyote/http2/Http2TestBase.java    |  24 +++++
 .../apache/coyote/http2/TestHttp2Section_8_1.java  | 104 ++++-----------------
 2 files changed, 44 insertions(+), 84 deletions(-)

diff --git a/test/org/apache/coyote/http2/Http2TestBase.java 
b/test/org/apache/coyote/http2/Http2TestBase.java
index 979ea511e2..e2a0eea8fd 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -1046,6 +1046,30 @@ public abstract class Http2TestBase extends 
TomcatBaseTest {
     }
 
 
+    void filterTrace(StringBuilder filteredTrace, int 
filteredFrameCountTarget, String... ignores) throws IOException,
+            Http2Exception {
+        output.clearTrace();
+        int filteredFrameCount = 0;
+
+        while (filteredFrameCount < filteredFrameCountTarget) {
+            parser.readFrame();
+            String singleFrameTrace = output.getTrace();
+            boolean keep = true;
+            for (String ignore : ignores) {
+                if (singleFrameTrace.contains(ignore)) {
+                    keep = false;
+                    break;
+                }
+            }
+            if (keep) {
+                filteredTrace.append(singleFrameTrace);
+                filteredFrameCount++;
+            }
+            output.clearTrace();
+        }
+    }
+
+
     static void setOneBytes(byte[] output, int firstByte, int value) {
         output[firstByte] = (byte) (value & 0xFF);
     }
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_8_1.java 
b/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
index 75d3d87328..6533e86c3b 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
@@ -615,51 +615,19 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
         writeFrame(trailerFrameHeader, trailerPayload);
 
         // Expect 2 window updates and a reset due to a protocol error. Order 
may vary.
-        boolean skip = true;
-        while (skip) {
-            parser.readFrame();
-            if (output.getTrace().contains("WindowSize")) {
-                // Ignore the window updates
-                output.clearTrace();
-            } else {
-                skip = false;
-            }
-        }
-        Assert.assertTrue(output.getTrace(), 
output.getTrace().contains("3-RST-[1]"));
-        output.clearTrace();
+        StringBuilder filteredTrace = new StringBuilder();
+        filterTrace(filteredTrace, 1, "WindowSize");
+        String actual = filteredTrace.toString();
+        Assert.assertTrue(actual, actual.toString().contains("3-RST-[1]"));
 
         // Ensure connection is still valid
         sendSimpleGetRequest(5);
-        // Read headers
-        // In async mode, may see multiple resets for Stream 3 and/or further 
window updates
-        skip = true;
-        while (skip) {
-            parser.readFrame();
-            if (output.getTrace().startsWith("3-RST")) {
-                // Ignore additional resets for stream 3
-                output.clearTrace();
-            } else if (output.getTrace().contains("WindowSize")) {
-                // Ignore the window updates
-                output.clearTrace();
-            } else {
-                skip = false;
-            }
-        }
-        // Read body
-        skip = true;
-        while (skip) {
-            parser.readFrame();
-            if (output.getTrace().startsWith("3-RST")) {
-                // Ignore additional resets for stream 3
-                output.clearTrace();
-            } else if (output.getTrace().contains("WindowSize")) {
-                // Ignore the window updates
-                output.clearTrace();
-            } else {
-                skip = false;
-            }
-        }
-        Assert.assertEquals(getSimpleResponseTrace(5), output.getTrace());
+        // Expect 2 frames: headers and body.
+        // In async mode, may see multiple resets for Stream 3 and/or 
remaining window updates.
+        filteredTrace = new StringBuilder();
+        filterTrace(filteredTrace, 2, "WindowSize", "3-RST");
+        actual = filteredTrace.toString();
+        Assert.assertEquals(actual, getSimpleResponseTrace(5), actual);
     }
 
 
@@ -720,50 +688,18 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
         writeFrame(dataFrameHeader, dataPayload);
 
         // Expect 2 window updates and a reset due to a protocol error. Order 
may vary.
-        boolean skip = true;
-        while (skip) {
-            parser.readFrame();
-            if (output.getTrace().contains("WindowSize")) {
-                // Ignore the window updates
-                output.clearTrace();
-            } else {
-                skip = false;
-            }
-        }
-        Assert.assertTrue(output.getTrace(), 
output.getTrace().contains("3-RST-[1]"));
-        output.clearTrace();
+        StringBuilder filteredTrace = new StringBuilder();
+        filterTrace(filteredTrace, 1, "WindowSize");
+        String actual = filteredTrace.toString();
+        Assert.assertTrue(actual, actual.toString().contains("3-RST-[1]"));
 
         // Ensure connection is still valid
         sendSimpleGetRequest(5);
-        // Read headers
-        // In async mode, may see multiple resets for Stream 3 and/or further 
window updates
-        skip = true;
-        while (skip) {
-            parser.readFrame();
-            if (output.getTrace().startsWith("3-RST")) {
-                // Ignore additional resets for stream 3
-                output.clearTrace();
-            } else if (output.getTrace().contains("WindowSize")) {
-                // Ignore the window updates
-                output.clearTrace();
-            } else {
-                skip = false;
-            }
-        }
-        // Read body
-        skip = true;
-        while (skip) {
-            parser.readFrame();
-            if (output.getTrace().startsWith("3-RST")) {
-                // Ignore additional resets for stream 3
-                output.clearTrace();
-            } else if (output.getTrace().contains("WindowSize")) {
-                // Ignore the window updates
-                output.clearTrace();
-            } else {
-                skip = false;
-            }
-        }
-        Assert.assertEquals(getSimpleResponseTrace(5), output.getTrace());
+        // Expect 2 frames: headers and body.
+        // In async mode, may see multiple resets for Stream 3 and/or 
remaining window updates.
+        filteredTrace = new StringBuilder();
+        filterTrace(filteredTrace, 2, "WindowSize", "3-RST");
+        actual = filteredTrace.toString();
+        Assert.assertEquals(actual, getSimpleResponseTrace(5), actual);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to