kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [kafka] branch trunk updated: MINOR: Use dynamic port in `RestServerTest` (#7079)
Date Fri, 12 Jul 2019 22:29:25 GMT
This is an automated email from the ASF dual-hosted git repository.

jgus pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 1d873a9  MINOR: Use dynamic port in `RestServerTest` (#7079)
1d873a9 is described below

commit 1d873a9de9ad98d9f3120fa2ff59c3372650775b
Author: Jason Gustafson <jason@confluent.io>
AuthorDate: Fri Jul 12 15:29:10 2019 -0700

    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>
---
 .../java/org/apache/kafka/connect/runtime/rest/RestServerTest.java   | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
index 3609fb3..a640b83 100644
--- a/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
+++ b/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java
@@ -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);


Mime
View raw message