psalagnac commented on code in PR #3036: URL: https://github.com/apache/solr/pull/3036#discussion_r1918216036
########## solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java: ########## @@ -207,6 +210,47 @@ protected static void waitForState( } } + /** + * Wait for a particular collection state to appear in the cluster client's state reader. + * + * <p>This is a convenience method using the {@link #DEFAULT_TIMEOUT}. + */ + protected static void waitForState( + String message, String collection, Predicate<DocCollection> predicate) { + waitForState(message, collection, predicate, DEFAULT_TIMEOUT, TimeUnit.SECONDS); + } + + /** + * Wait for a particular collection state to appear in the cluster client's state reader + * + * @param message a message to report on failure + * @param collection the collection to watch + * @param predicate a predicate to match against the collection state + */ + protected static void waitForState( + String message, + String collection, + Predicate<DocCollection> predicate, + int timeout, + TimeUnit timeUnit) { + log.info("waitForState ({}): {}", collection, message); + AtomicReference<DocCollection> state = new AtomicReference<>(); + try { + cluster + .getZkStateReader() + .waitForState( + collection, + timeout, + timeUnit, + c -> { + state.set(c); + return predicate.test(c); + }); + } catch (Exception e) { + fail(message + "\n" + e.getMessage() + "\nLast available state: " + state.get()); Review Comment: I wanted to do the same as existing variant of `waitForState()` (the one that watches both live nodes and the collection). I think the two methods should be aligned. I think it makes sense to raise a JUnit specific error. Most of the time, the caught exception has no interesting details, it's just a timeout. -- 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: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org