Fixes #7209 - Flaky test GoAwayTest.testServerGoAwayWithStalledStreamServerConsumesDataOfInFlightStream()

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
(cherry picked from commit 0fb733f32a)
This commit is contained in:
Simone Bordet 2022-01-13 13:17:32 +01:00
parent 51123c7cd1
commit 0ac6718b35
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
1 changed files with 14 additions and 0 deletions

View File

@ -39,6 +39,7 @@ import org.eclipse.jetty.http2.frames.DataFrame;
import org.eclipse.jetty.http2.frames.GoAwayFrame; import org.eclipse.jetty.http2.frames.GoAwayFrame;
import org.eclipse.jetty.http2.frames.HeadersFrame; import org.eclipse.jetty.http2.frames.HeadersFrame;
import org.eclipse.jetty.http2.frames.ResetFrame; import org.eclipse.jetty.http2.frames.ResetFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.FuturePromise; import org.eclipse.jetty.util.FuturePromise;
@ -418,10 +419,17 @@ public class GoAwayTest extends AbstractTest
h2.setInitialStreamRecvWindow(flowControlWindow); h2.setInitialStreamRecvWindow(flowControlWindow);
}); });
CountDownLatch clientSettingsLatch = new CountDownLatch(1);
CountDownLatch clientGoAwayLatch = new CountDownLatch(1); CountDownLatch clientGoAwayLatch = new CountDownLatch(1);
CountDownLatch clientCloseLatch = new CountDownLatch(1); CountDownLatch clientCloseLatch = new CountDownLatch(1);
Session clientSession = newClient(new Session.Listener.Adapter() Session clientSession = newClient(new Session.Listener.Adapter()
{ {
@Override
public void onSettings(Session session, SettingsFrame frame)
{
clientSettingsLatch.countDown();
}
@Override @Override
public void onGoAway(Session session, GoAwayFrame frame) public void onGoAway(Session session, GoAwayFrame frame)
{ {
@ -434,6 +442,12 @@ public class GoAwayTest extends AbstractTest
clientCloseLatch.countDown(); clientCloseLatch.countDown();
} }
}); });
// Wait for the server settings to be received by the client.
// In particular, we want to wait for the initial stream flow
// control window setting before we create the first stream below.
Assertions.assertTrue(clientSettingsLatch.await(5, TimeUnit.SECONDS));
// This is necessary because the server session window is smaller than the // This is necessary because the server session window is smaller than the
// default and the server cannot send a WINDOW_UPDATE with a negative value. // default and the server cannot send a WINDOW_UPDATE with a negative value.
((ISession)clientSession).updateSendWindow(flowControlWindow - FlowControlStrategy.DEFAULT_WINDOW_SIZE); ((ISession)clientSession).updateSendWindow(flowControlWindow - FlowControlStrategy.DEFAULT_WINDOW_SIZE);