This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new a31e8ce014 More robustness improvements to HTTP/2 8.1 tests
a31e8ce014 is described below
commit a31e8ce014aac54ebe1f70e47e5ec01afa620388
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 6a560bd8fc..ce5c1d1a5a 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -1043,6 +1043,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 21a7a29cb0..fbd7bbc0b9 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
@@ -614,51 +614,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);
}
@@ -719,50 +687,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]