[tomcat] branch 8.5.x updated: Make test more robust

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[tomcat] branch 8.5.x updated: Make test more robust

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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 0ee5590  Make test more robust
0ee5590 is described below

commit 0ee5590535fbec7d8eece702978ceb3020994d72
Author: Mark Thomas <[hidden email]>
AuthorDate: Tue Sep 15 19:09:05 2020 +0100

    Make test more robust
---
 .../apache/coyote/http2/TestCancelledUpload.java   | 28 ++++++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/test/org/apache/coyote/http2/TestCancelledUpload.java b/test/org/apache/coyote/http2/TestCancelledUpload.java
index 2a5b762..9964aa4 100644
--- a/test/org/apache/coyote/http2/TestCancelledUpload.java
+++ b/test/org/apache/coyote/http2/TestCancelledUpload.java
@@ -74,7 +74,7 @@ public class TestCancelledUpload extends Http2TestBase {
         parser.readFrame(true);
 
         // If reset is first frame received end test here
-        if (output.getTrace().startsWith("3-RST-[3]\n")) {
+        if (checkReset()) {
             return;
         }
 
@@ -85,7 +85,7 @@ public class TestCancelledUpload extends Http2TestBase {
             int size = Integer.parseInt(trace.substring(14, trace.length() - 2));
             output.clearTrace();
             parser.readFrame(true);
-            if (output.getTrace().startsWith("3-RST-[3]\n")) {
+            if (checkReset()) {
                 return;
             }
             Assert.assertEquals("3-WindowSize-[" + size + "]\n", output.getTrace());
@@ -94,7 +94,7 @@ public class TestCancelledUpload extends Http2TestBase {
         }
 
         // Check for reset and exit if found
-        if (output.getTrace().startsWith("3-RST-[3]\n")) {
+        if (checkReset()) {
             return;
         }
 
@@ -109,7 +109,7 @@ public class TestCancelledUpload extends Http2TestBase {
 
         parser.readFrame(true);
         // Check for reset and exit if found
-        if (output.getTrace().startsWith("3-RST-[3]\n")) {
+        if (checkReset()) {
             return;
         }
 
@@ -129,7 +129,7 @@ public class TestCancelledUpload extends Http2TestBase {
             int size = Integer.parseInt(trace.substring(14, trace.length() - 2));
             output.clearTrace();
             parser.readFrame(true);
-            if (output.getTrace().startsWith("3-RST-[3]\n")) {
+            if (checkReset()) {
                 return;
             }
             Assert.assertEquals("3-WindowSize-[" + size + "]\n", output.getTrace());
@@ -138,12 +138,30 @@ public class TestCancelledUpload extends Http2TestBase {
         }
 
         // This should be the reset
+        checkReset();
         Assert.assertEquals("3-RST-[3]\n", output.getTrace());
 
         // If there are any more frames after this, ignore them
     }
 
 
+    /*
+     * Depending on timing, several resets may be sent.
+     */
+    private boolean checkReset() throws IOException, Http2Exception {
+        while (true) {
+            if (output.getTrace().startsWith("3-RST-[3]\n")) {
+                return true;
+            } else if (output.getTrace().startsWith("3-RST-[")) {
+                output.clearTrace();
+                parser.readFrame(true);
+            } else {
+                return false;
+            }
+        }
+    }
+
+
     @Override
     protected void configureAndStartWebApplication() throws LifecycleException {
         Tomcat tomcat = getTomcatInstance();


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