rishi-rana commented on code in PR #20549:
URL: https://github.com/apache/druid/pull/20549#discussion_r4238742726
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/indexing/IngestionSmokeTest.java:
##########
@@ -429,22 +429,27 @@ public void test_streamLogs_ofCancelledTask() throws
Exception
.hasDimension(DruidMetrics.TASK_STATUS, "FAILED")
);
- final Optional<InputStream> streamOptional =
- cluster.callApi().waitForResult(
- () -> overlord.bindings()
- .getInstance(TaskLogStreamer.class)
- .streamTaskLog(taskId, 0),
- Optional::isPresent
- ).go();
-
- Assertions.assertTrue(streamOptional.isPresent());
-
- final String logs = IOUtils.toString(streamOptional.get(),
StandardCharsets.UTF_8);
-
final String expectedLogLine = StringUtils.format(
"Running task[%s] for [%d] millis",
taskId, runDurationMillis
);
+
+ // The Indexer serves this task's log over HTTP straight from its own
process log file
+ // (see HttpRemoteTaskRunner#streamTaskLog), so the stream can become
present before the
+ // expected line has actually been written to that file. Poll until the
expected line shows
+ // up, rather than just until the stream is present, to avoid racing
against that lag.
+ final String logs = cluster.callApi().waitForResult(
+ () -> {
+ final Optional<InputStream> streamOptional = overlord.bindings()
+
.getInstance(TaskLogStreamer.class)
+
.streamTaskLog(taskId, 0);
+ return streamOptional.isPresent()
+ ? IOUtils.toString(streamOptional.get(),
StandardCharsets.UTF_8)
Review Comment:
Fixed in 23b4f1cdda — wrapped the stream read in try-with-resources so every
attempt (matched or not) closes its InputStream.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]