Fixes #9009 - Flaky test StreamCloseTest.testRequestDataClosedResponseDataClosedClosesStream.

Regression introduced by #8678.
Now using awaitility to wait for the stream count to go to zero.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2022-12-06 15:48:36 +01:00
parent 390abcccf2
commit 7c757689a2
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
1 changed files with 4 additions and 1 deletions

View File

@ -14,6 +14,7 @@
package org.eclipse.jetty.http2.client; package org.eclipse.jetty.http2.client;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
@ -38,6 +39,8 @@ import org.eclipse.jetty.util.FuturePromise;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ -179,7 +182,7 @@ public class StreamCloseTest extends AbstractTest
assertTrue(serverDataLatch.await(5, TimeUnit.SECONDS)); assertTrue(serverDataLatch.await(5, TimeUnit.SECONDS));
assertTrue(completeLatch.await(5, TimeUnit.SECONDS)); assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
assertTrue(stream.isClosed()); assertTrue(stream.isClosed());
assertEquals(0, stream.getSession().getStreams().size()); await().atMost(Duration.ofSeconds(5)).until(() -> stream.getSession().getStreams().size(), equalTo(0));
} }
@Test @Test