mirror of https://github.com/apache/kafka.git
MINOR: Use dynamic port in `RestServerTest` (#7079)
We have seen some failures recently in `RestServerTest`. It's the usual problem with reliance on static ports. ``` Caused by: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8083 at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:346) at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308) at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80) at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.server.Server.doStart(Server.java:396) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.apache.kafka.connect.runtime.rest.RestServer.initializeServer(RestServer.java:178) ... 56 more Caused by: java.net.BindException: Address already in use ``` This patch makes the chosen port dynamic. Reviewers: Ismael Juma <ismael@juma.me.uk>
This commit is contained in:
parent
d2328a1a0e
commit
1d873a9de9
|
|
@ -78,6 +78,7 @@ public class RestServerTest {
|
|||
workerProps.put(WorkerConfig.INTERNAL_KEY_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter");
|
||||
workerProps.put(WorkerConfig.INTERNAL_VALUE_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter");
|
||||
workerProps.put(DistributedConfig.OFFSET_STORAGE_TOPIC_CONFIG, "connect-offsets");
|
||||
workerProps.put(WorkerConfig.LISTENERS_CONFIG, "HTTP://localhost:0");
|
||||
|
||||
return workerProps;
|
||||
}
|
||||
|
|
@ -105,6 +106,7 @@ public class RestServerTest {
|
|||
|
||||
// Build listener from hostname and port
|
||||
configMap = new HashMap<>(baseWorkerProps());
|
||||
configMap.remove(WorkerConfig.LISTENERS_CONFIG);
|
||||
configMap.put(WorkerConfig.REST_HOST_NAME_CONFIG, "my-hostname");
|
||||
configMap.put(WorkerConfig.REST_PORT_CONFIG, "8080");
|
||||
config = new DistributedConfig(configMap);
|
||||
|
|
@ -115,7 +117,7 @@ public class RestServerTest {
|
|||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testAdvertisedUri() {
|
||||
// Advertised URI from listeenrs without protocol
|
||||
// Advertised URI from listeners without protocol
|
||||
Map<String, String> configMap = new HashMap<>(baseWorkerProps());
|
||||
configMap.put(WorkerConfig.LISTENERS_CONFIG, "http://localhost:8080,https://localhost:8443");
|
||||
DistributedConfig config = new DistributedConfig(configMap);
|
||||
|
|
@ -153,6 +155,7 @@ public class RestServerTest {
|
|||
|
||||
// listener from hostname and port
|
||||
configMap = new HashMap<>(baseWorkerProps());
|
||||
configMap.remove(WorkerConfig.LISTENERS_CONFIG);
|
||||
configMap.put(WorkerConfig.REST_HOST_NAME_CONFIG, "my-hostname");
|
||||
configMap.put(WorkerConfig.REST_PORT_CONFIG, "8080");
|
||||
config = new DistributedConfig(configMap);
|
||||
|
|
|
|||
Loading…
Reference in New Issue