Author: markt
Date: Fri Aug 17 20:45:42 2018
New Revision: 1838286

URL: http://svn.apache.org/viewvc?rev=1838286&view=rev
Log:
Expand Async + HTTP/2 tests to cover larger window sizes. Confirm previous fix 
fixes BZ 62628.

Modified:
    tomcat/trunk/test/org/apache/coyote/http2/TestAsync.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/test/org/apache/coyote/http2/TestAsync.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestAsync.java?rev=1838286&r1=1838285&r2=1838286&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestAsync.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestAsync.java Fri Aug 17 
20:45:42 2018
@@ -46,6 +46,7 @@ import org.apache.catalina.startup.Tomca
  * Based on
  * https://bz.apache.org/bugzilla/show_bug.cgi?id=62614
  * https://bz.apache.org/bugzilla/show_bug.cgi?id=62620
+ * https://bz.apache.org/bugzilla/show_bug.cgi?id=62628
  */
 @RunWith(Parameterized.class)
 public class TestAsync extends Http2TestBase {
@@ -53,7 +54,8 @@ public class TestAsync extends Http2Test
     private static final int BLOCK_SIZE = 0x8000;
 
     @Parameterized.Parameters(name = "{index}: expandConnectionFirst[{0}], " +
-            "connectionUnlimited[{1}], streamUnlimited[{2}], 
useNonContainerThreadForWrite[{3}]")
+            "connectionUnlimited[{1}], streamUnlimited[{2}], 
useNonContainerThreadForWrite[{3}]," +
+            "largeInitialWindow[{4}]")
     public static Collection<Object[]> parameters() {
         Boolean[] booleans = new Boolean[] { Boolean.FALSE, Boolean.TRUE };
         List<Object[]> parameterSets = new ArrayList<>();
@@ -62,10 +64,12 @@ public class TestAsync extends Http2Test
             for (Boolean connectionUnlimited : booleans) {
                 for (Boolean streamUnlimited : booleans) {
                     for (Boolean useNonContainerThreadForWrite : booleans) {
-                        parameterSets.add(new Object[] {
-                                expandConnectionFirst, connectionUnlimited, 
streamUnlimited,
-                                useNonContainerThreadForWrite
-                        });
+                        for (Boolean largeInitialWindow : booleans) {
+                            parameterSets.add(new Object[] {
+                                    expandConnectionFirst, 
connectionUnlimited, streamUnlimited,
+                                    useNonContainerThreadForWrite, 
largeInitialWindow
+                            });
+                        }
                     }
                 }
             }
@@ -78,20 +82,23 @@ public class TestAsync extends Http2Test
     private final boolean connectionUnlimited;
     private final boolean streamUnlimited;
     private final boolean useNonContainerThreadForWrite;
+    private final boolean largeInitialWindow;
 
 
     public TestAsync(boolean expandConnectionFirst, boolean 
connectionUnlimited,
-            boolean streamUnlimited, boolean useNonContainerThreadForWrite) {
+            boolean streamUnlimited, boolean useNonContainerThreadForWrite,
+            boolean largeInitialWindow) {
         this.expandConnectionFirst = expandConnectionFirst;
         this.connectionUnlimited = connectionUnlimited;
         this.streamUnlimited = streamUnlimited;
         this.useNonContainerThreadForWrite = useNonContainerThreadForWrite;
+        this.largeInitialWindow = largeInitialWindow;
     }
 
 
     @Test
     public void testEmptyWindow() throws Exception {
-        int blockCount = 4;
+        int blockCount = 8;
 
         enableHttp2();
 
@@ -106,19 +113,32 @@ public class TestAsync extends Http2Test
         ctxt.addServletMappingDecoded("/async", "async");
         tomcat.start();
 
+        int startingWindowSize;
+
         openClientConnection();
         doHttpUpgrade();
         sendClientPreface();
         validateHttp2InitialResponse();
 
+        // Reset connection window size after intial response
+        sendWindowUpdate(0, SimpleServlet.CONTENT_LENGTH);
+
+        if (largeInitialWindow) {
+            startingWindowSize = ((1 << 17) - 1);
+            SettingValue sv =
+                    new SettingValue(Setting.INITIAL_WINDOW_SIZE.getId(), 
startingWindowSize);
+            sendSettings(0, false, sv);
+            // Test code assumes connection window and stream window size are 
the same at the start
+            sendWindowUpdate(0, startingWindowSize - 
ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE);
+        } else {
+            startingWindowSize = 
ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE;
+        }
+
         byte[] frameHeader = new byte[9];
         ByteBuffer headersPayload = ByteBuffer.allocate(128);
         buildGetRequest(frameHeader, headersPayload, null, 3, "/async");
         writeFrame(frameHeader, headersPayload);
 
-        // Reset connection window size after intial response
-        sendWindowUpdate(0, SimpleServlet.CONTENT_LENGTH);
-
         if (connectionUnlimited) {
             // Effectively unlimited for this test
             sendWindowUpdate(0, blockCount * BLOCK_SIZE * 2);
@@ -133,7 +153,6 @@ public class TestAsync extends Http2Test
         // Body
 
         if (!connectionUnlimited || !streamUnlimited) {
-            int startingWindowSize = 
ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE;
 
             while (output.getBytesRead() < startingWindowSize) {
                 parser.readFrame(true);
@@ -224,7 +243,7 @@ public class TestAsync extends Http2Test
                                     throw new IllegalStateException(e);
                                 }
                             }
-                        }, 2, TimeUnit.SECONDS);
+                        }, 200, TimeUnit.MILLISECONDS);
                     } else {
                         write();
                     }

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1838286&r1=1838285&r2=1838286&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Aug 17 20:45:42 2018
@@ -56,8 +56,9 @@
         bodies using asynchronous processing over HTTP/2. (markt)
       </fix>
       <fix>
-        Additional fixes for output corruption of response bodies when writing
-        large bodies using asynchronous processing over HTTP/2. (markt)
+        <bug>62628</bug>: Additional fixes for output corruption of response
+        bodies when writing large bodies using asynchronous processing over
+        HTTP/2. (markt)
       </fix>
     </changelog>
   </subsection>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to