Skip to content

Flaky UT: JettyWithResponseFilterEnabledTest #13111

@paul-rogers

Description

@paul-rogers

The UT JettyWithResponseFilterEnabledTest.testExtensionAuthFilter failed in this build:

org.apache.druid.server.initialization.JettyWithResponseFilterEnabledTest
[ERROR] org.apache.druid.server.initialization.JettyWithResponseFilterEnabledTest.testExtensionAuthFilter  Time elapsed: 0.317 s  <<< ERROR!
java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:50684
	at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349)

The same test passes locally in an IDE. Conclusion: the test is flaky, likely due to networking issues, or an attempt to run tests in parallel using the same listen port on the host. Jetty allows listening on a random port: tests should use that feature if they don't already do so.

The test attempt to randomize ports:

    final int ephemeralPort = ThreadLocalRandom.current().nextInt(49152, 65535);

However, this is the wrong way to do so. Each run will produce the same sequence of random numbers, unless a random seed is provided. Also, Jetty does this the right way: it chooses a random port and ensures that the port is not in use.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions