zigarn commented on code in PR #12434:
URL: https://github.com/apache/kafka/pull/12434#discussion_r931894269
##########
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);
+ }
+
+ List<String> logMessages = restServerAppender.getMessages();
+ System.err.println(logMessages);
+ String requestlog = logMessages.get(0);
Review Comment:
Thought about it at the beginning and then focused on other parts and forgot.
Changed to find at least one log that match.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]