Github user nsoft commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/433#discussion_r213415931
--- Diff:
solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.java
---
@@ -322,6 +325,104 @@ 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,
+ sdoc("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);
+
+ // normal update, nothing special, no collection creation required.
+ List<String> cols = new
CollectionAdminRequest.ListAliases().process(solrClient).getAliasesAsLists().get(alias);
+ assertEquals(3,cols.size());
+
+ assertNumDocs("2017-10-23", 0);
+ assertNumDocs("2017-10-24", 0);
+ assertNumDocs("2017-10-25", 1);
+
+ // 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
--- End diff --
I think this comment is obsolete, carried over from earlier versions?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]