Github user dsmiley commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/422#discussion_r204819121 --- Diff: solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.java --- @@ -322,6 +327,59 @@ public void testSliceRouting() throws Exception { } } + @Test + public void testPreemptiveCreation() throws Exception { + String configName = TimeRoutedAliasUpdateProcessorTest.configName + getTestName(); + createConfigSet(configName); + + final int numShards = 1 ; + final int numReplicas = 1 ; + CollectionAdminRequest.createTimeRoutedAlias(alias, "2017-10-23T00:00:00Z", "+1DAY", timeField, + CollectionAdminRequest.createCollection("_unused_", configName, numShards, numReplicas) + .setMaxShardsPerNode(numReplicas)).setPreemptiveCreateWindow("3HOUR") + .process(solrClient); + + // cause some collections to be created + assertUpdateResponse(solrClient.add(alias, new SolrInputDocument("id","1","timestamp_dt", "2017-10-25T00:00:00Z"))); + assertUpdateResponse(solrClient.commit(alias)); + + // wait for all the collections to exist... + waitCol("2017-10-23", numShards); + waitCol("2017-10-24", numShards); + waitCol("2017-10-25", numShards); + + // cause some collections to be created + + ModifiableSolrParams params = params(); + assertUpdateResponse(add(alias, Arrays.asList( + sdoc("id", "2", "timestamp_dt", "2017-10-24T00:00:00Z"), + sdoc("id", "3", "timestamp_dt", "2017-10-25T00:00:00Z"), + sdoc("id", "4", "timestamp_dt", "2017-10-23T00:00:00Z"), + sdoc("id", "5", "timestamp_dt", "2017-10-25T23:00:00Z")), // should cause preemptive creation + params)); + + // given the long sleep below (without which the alias isn't available and we fail, make a request in the meantime + // targeting the new collection to ensure things don't blow up if docs come in while creation is in progress. + assertUpdateResponse(add(alias, Arrays.asList( + sdoc("id", "6", "timestamp_dt", "2017-10-25T23:01:00Z")), // should cause preemptive creation + params)); + assertUpdateResponse(solrClient.commit(alias)); + + waitCol("2017-10-26", numShards); // this seems to only wait for the collection to exist, but + // not for the replicas to be created and the alias updated + + // yuck, but collection creation seems to take 3sec on my machine doubling for slow, test loaded machines. + Thread.sleep(6000); --- End diff -- We needn't wait the full pre-emption window; we could wait as long as 10 seconds which ought to be plenty.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org