Skip to content

Commit

Permalink
Fix flaky MultipartEncoderTckTest.required_spec101... (#5136)
Browse files Browse the repository at this point in the history
Motivation:

`MultipartEncoderTckTest.required_spec101_XXX` fails quite often.

https://ge.armeria.dev/scans/tests?search.timeZoneId=Asia/Seoul&tests.container=com.linecorp.armeria.common.multipart.MultipartEncoderTckTest&tests.test=required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements
```java
java.lang.AssertionError: Publisher com.linecorp.armeria.common.multipart.MultipartEncoder@3eec8583 produced no element after first `request` within 200 ms
at org.testng.Assert.fail(Assert.java:98)
at org.reactivestreams.tck.TestEnvironment.flopAndFail(TestEnvironment.java:285)
at org.reactivestreams.tck.TestEnvironment$Receptacle.next(TestEnvironment.java:1047)
at org.reactivestreams.tck.TestEnvironment$ManualSubscriber.nextElement(TestEnvironment.java:514)
at org.reactivestreams.tck.TestEnvironment$ManualSubscriber.nextElement(TestEnvironment.java:510)
at org.reactivestreams.tck.PublisherVerification$3.run(PublisherVerification.java:212)
at org.reactivestreams.tck.PublisherVerification.activePublisherTest(PublisherVerification.java:1135)
at
org.reactivestreams.tck.PublisherVerification.required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements(PublisherVerification.java:204)
```

The failure couldn't be reproduced locally. I checked the log on the
Gradle scan and it shows that the classes are initialized when the test
starts.

I guess JVM lazy class initialization and the Netty worker group
initialization could affect the failure.

Modifications:

- Early initialize Netty worker group before starting the tests
- Increase timeout

Result:

- Closes #4554

---------

Co-authored-by: Trustin Lee <[email protected]>
  • Loading branch information
ikhoon and trustin authored Aug 23, 2023
1 parent 4e459df commit 59baf81
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.reactivestreams.tck.TestEnvironment;
import org.testng.annotations.Test;

import com.linecorp.armeria.common.CommonPools;
import com.linecorp.armeria.common.HttpData;
import com.linecorp.armeria.common.stream.StreamMessage;

Expand All @@ -48,8 +49,13 @@ public class MultipartEncoderTckTest extends PublisherVerification<HttpData> {

// Forked from https://github.com/oracle/helidon/blob/9d209a1a55f927e60e15b061700384e438ab5a01/media/multipart/src/test/java/io/helidon/media/multipart/MultiPartEncoderTckTest.java

static {
// Make sure the worker group is initialized.
CommonPools.workerGroup().next().submit(() -> {});
}

public MultipartEncoderTckTest() {
super(new TestEnvironment(200));
super(new TestEnvironment(500));
}

@Override
Expand Down

0 comments on commit 59baf81

Please sign in to comment.