FrankChen021 commented on code in PR #20319:
URL: https://github.com/apache/druid/pull/20319#discussion_r4053464009
##########
services/src/test/java/org/apache/druid/testing/embedded/EmbeddedClusterApis.java:
##########
@@ -332,6 +332,62 @@ public void waitForAllSegmentsToBeAvailable(String
dataSource, EmbeddedCoordinat
);
}
+ /**
+ * Waits for all non-tombstone used segments of the given datasource to be
+ * reported as available in {@code sys.segments} and for the datasource to be
+ * present in the Broker SQL schema, by polling the Broker.
+ * <p>
+ * Unlike {@link #waitForAllSegmentsToBeAvailable}, this method does not
depend
+ * on schema refresh metrics being emitted by the Broker and verifies the
state
+ * that SQL queries actually observe.
+ *
+ * @param timeoutMillis maximum time to wait
+ */
+ public void waitForAllSegmentsToBeQueryable(
+ String dataSource,
+ EmbeddedCoordinator coordinator,
+ long timeoutMillis
+ )
+ {
+ final int numSegments = (int) coordinator
+ .bindings()
+ .segmentsMetadataStorage()
+ .retrieveAllUsedSegments(dataSource, Segments.INCLUDING_OVERSHADOWED)
+ .stream()
+ .filter(segment -> !segment.isTombstone())
+ .count();
+
+ waitForResult(
+ () -> runSql(
+ "SELECT COUNT(*) FROM sys.segments WHERE datasource='%s' AND
is_available = 1",
Review Comment:
Fixed in d5a72cc41e. The helper now escapes the datasource once with
`StringUtils.escapeSql` and uses the escaped value in both SQL string literals.
Focused `services` test compilation passed.
--
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]