zigarn commented on code in PR #12434: URL: https://github.com/apache/kafka/pull/12434#discussion_r931889738
########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/rest/RestServerTest.java: ########## @@ -338,6 +341,41 @@ public void testDisableAdminEndpoint() throws IOException { Assert.assertEquals(404, response.getStatusLine().getStatusCode()); } + @Test + public void testRequestLogs() throws IOException, InterruptedException { + Map<String, String> configMap = new HashMap<>(baseWorkerProps()); + DistributedConfig workerConfig = new DistributedConfig(configMap); + + doReturn(KAFKA_CLUSTER_ID).when(herder).kafkaClusterId(); + doReturn(plugins).when(herder).plugins(); + doReturn(Collections.emptyList()).when(plugins).newPlugins(Collections.emptyList(), workerConfig, ConnectRestExtension.class); + + server = new RestServer(workerConfig); + server.initializeServer(); + server.initializeResources(herder); + URI advertisedUrl = server.advertisedUrl(); // Call before capturing logs as this creates a log + + try (LogCaptureAppender restServerAppender = LogCaptureAppender.createAndRegister(RestServer.class)) { + HttpRequest request = new HttpGet("/"); + CloseableHttpClient httpClient = HttpClients.createMinimal(); + HttpHost httpHost = new HttpHost(advertisedUrl.getHost(), advertisedUrl.getPort()); + CloseableHttpResponse response = httpClient.execute(httpHost, request); + + // Wait for server to handle request completion and create request log + int tries = 0; + while (restServerAppender.getMessages().size() < 1 && tries < 10) { + ++tries; + System.err.println("Wait for log message to arrive, retry " + tries); + Thread.sleep(1000); + } Review Comment: Yes it does as it's closing all the threads and joining them. Though about it but wasn't sure, fixed to do that. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org