From 59baf81b63d04ac807e93469b4c11cded16349c3 Mon Sep 17 00:00:00 2001 From: Ikhun Um Date: Wed, 23 Aug 2023 16:55:56 +0900 Subject: [PATCH] Fix flaky `MultipartEncoderTckTest.required_spec101...` (#5136) 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 --- .../armeria/common/multipart/MultipartEncoderTckTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/com/linecorp/armeria/common/multipart/MultipartEncoderTckTest.java b/core/src/test/java/com/linecorp/armeria/common/multipart/MultipartEncoderTckTest.java index bd252c35c8d..af2a4d920af 100644 --- a/core/src/test/java/com/linecorp/armeria/common/multipart/MultipartEncoderTckTest.java +++ b/core/src/test/java/com/linecorp/armeria/common/multipart/MultipartEncoderTckTest.java @@ -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; @@ -48,8 +49,13 @@ public class MultipartEncoderTckTest extends PublisherVerification { // 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