FrankChen021 commented on code in PR #20319:
URL: https://github.com/apache/druid/pull/20319#discussion_r4053464937
##########
services/src/test/java/org/apache/druid/testing/embedded/EmbeddedClusterApis.java:
##########
@@ -332,6 +332,48 @@ 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",
+ dataSource
+ ),
+ result -> Integer.parseInt(result.trim()) >= numSegments
+ ).withTimeoutMillis(timeoutMillis).go();
+
+ waitForResult(
+ () -> runSql(
+ "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA
= 'druid' AND TABLE_NAME = '%s'",
+ dataSource
+ ),
+ result -> "1".equals(result.trim())
+ ).withTimeoutMillis(timeoutMillis).go();
Review Comment:
Both points are now addressed. Commit e8afcf9ecd changed count parsing to
`long` with retry-on-non-numeric behavior, and d5a72cc41e escapes the
datasource before both SQL interpolations. 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]