Skip to content

Commit

Permalink
Fix flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoox committed May 23, 2024
1 parent 806556e commit 51caf2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.concurrent.atomic.AtomicInteger;

import org.hamcrest.Matchers;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;

import com.linecorp.armeria.common.HttpData;
Expand Down Expand Up @@ -152,6 +153,7 @@ void writeAfterClosed() {

@Test
void writeAfterStreamClosed() throws InterruptedException {
final CountDownLatch abortWait = new CountDownLatch(1);
final CountDownLatch wait = new CountDownLatch(1);
final CountDownLatch end = new CountDownLatch(1);
final ByteStreamMessage byteStreamMessage = StreamMessage.fromOutputStream(os -> {
Expand All @@ -160,6 +162,7 @@ void writeAfterStreamClosed() throws InterruptedException {
if (i < 2) {
os.write(i);
} else {
abortWait.countDown();
wait.await();
assertThatThrownBy(() -> os.write(0))
.isInstanceOf(IOException.class)
Expand All @@ -175,6 +178,13 @@ void writeAfterStreamClosed() throws InterruptedException {

StepVerifier.create(byteStreamMessage, 2)
.expectNext(httpData(0), httpData(1))
.then(() -> {
try {
abortWait.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
})
.then(byteStreamMessage::abort)
.then(() -> {
// Wait for the abortion to be completed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@

import com.linecorp.armeria.common.HttpResponse;
import com.linecorp.armeria.common.RequestTarget;
import com.linecorp.armeria.internal.testing.FlakyTest;
import com.linecorp.armeria.server.logging.LoggingService;
import com.linecorp.armeria.testing.junit5.server.ServerExtension;

@FlakyTest
class InvalidPathWithDataTest {

@RegisterExtension
Expand Down

0 comments on commit 51caf2a

Please sign in to comment.