diff --git a/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java index 77ecb22da94..0965e3cea29 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java @@ -64,10 +64,14 @@ public class CategoryRoutedAliasUpdateProcessorTest extends RoutedAliasUpdatePro private int lastDocId = 0; private static CloudSolrClient solrClient; private int numDocsDeletedOrFailed = 0; + // uncomment to create pause for attaching profiler. +// static { +// JOptionPane.showMessageDialog(null,"Ready?"); +// } @Before public void doBefore() throws Exception { - configureCluster(4).configure(); + configureCluster(1).configure(); solrClient = getCloudSolrClient(cluster); //log this to help debug potential causes of problems log.info("SolrClient: {}", solrClient); @@ -85,6 +89,8 @@ public class CategoryRoutedAliasUpdateProcessorTest extends RoutedAliasUpdatePro IOUtils.close(solrClient); } + @Test + @Slow public void testNonEnglish() throws Exception { // test to document the expected behavior with non-english text for categories // the present expectation is that non-latin text and many accented latin characters @@ -128,7 +134,7 @@ public class CategoryRoutedAliasUpdateProcessorTest extends RoutedAliasUpdatePro CollectionAdminRequest.createCategoryRoutedAlias(getAlias(), categoryField, 20, CollectionAdminRequest.createCollection("_unused_", configName, 1, 1) - .setMaxShardsPerNode(2)) + .setMaxShardsPerNode(12)) .process(solrClient); addDocsAndCommit(true, newDoc(somethingInChinese), @@ -188,7 +194,6 @@ public class CategoryRoutedAliasUpdateProcessorTest extends RoutedAliasUpdatePro // now we index a document addDocsAndCommit(true, newDoc(SHIPS[0])); - //assertDocRoutedToCol(lastDocId, col23rd); String uninitialized = getAlias() + "__CRA__" + CategoryRoutedAlias.UNINITIALIZED; assertInvariants(colVogon, uninitialized); @@ -357,7 +362,7 @@ public class CategoryRoutedAliasUpdateProcessorTest extends RoutedAliasUpdatePro final int numReplicas = 1 + random().nextInt(3); CollectionAdminRequest.createCategoryRoutedAlias(getAlias(), categoryField, 20, CollectionAdminRequest.createCollection("_unused_", configName, numShards, numReplicas) - .setMaxShardsPerNode(numReplicas)) + .setMaxShardsPerNode(numReplicas*numShards)) .process(solrClient); // cause some collections to be created @@ -397,36 +402,42 @@ public class CategoryRoutedAliasUpdateProcessorTest extends RoutedAliasUpdatePro } + /* + * We expect the following invariants: + * 1.) to see all the supplied collections + * 2.) Independently Querying all collections we can find to yield the same number of docs as querying the alias + * 3.) find as many docs as have been added but not deleted/failed + */ private void assertInvariants(String... expectedColls) throws IOException, SolrServerException { final int expectNumFound = lastDocId - numDocsDeletedOrFailed; //lastDocId is effectively # generated docs - List cols = new CollectionAdminRequest.ListAliases().process(solrClient).getAliasesAsLists().get(getAlias()); - cols = new ArrayList<>(cols); - cols.sort(String::compareTo); // don't really care about the order here. - assert !cols.isEmpty(); + List observedCols = new CollectionAdminRequest.ListAliases().process(solrClient).getAliasesAsLists().get(getAlias()); + observedCols = new ArrayList<>(observedCols); + observedCols.sort(String::compareTo); // don't really care about the order here. + assert !observedCols.isEmpty(); - int totalNumFound = 0; - for (String col : cols) { + int numFoundViaCollections = 0; + for (String col : observedCols) { final QueryResponse colResponse = solrClient.query(col, params( "q", "*:*", "rows", "0")); long numFound = colResponse.getResults().getNumFound(); if (numFound > 0) { - totalNumFound += numFound; + numFoundViaCollections += numFound; } } final QueryResponse colResponse = solrClient.query(getAlias(), params( "q", "*:*", "rows", "0")); - long aliasNumFound = colResponse.getResults().getNumFound(); - List actual = Arrays.asList(expectedColls); - actual.sort(String::compareTo); - assertArrayEquals("Expected " + expectedColls.length + " collections, found " + cols.size() + ":\n" + - cols + " vs \n" + actual, expectedColls, cols.toArray()); + long numFoundViaAlias = colResponse.getResults().getNumFound(); + List expectedList = Arrays.asList(expectedColls); + expectedList.sort(String::compareTo); + assertArrayEquals("Expected " + expectedColls.length + " collections, found " + observedCols.size() + ":\n" + + observedCols + " vs \n" + expectedList, expectedColls, observedCols.toArray()); assertEquals("Expected collections and alias to have same number of documents", - aliasNumFound, totalNumFound); - assertEquals("Expected to find " + expectNumFound + " docs but found " + aliasNumFound, - expectNumFound, aliasNumFound); + numFoundViaAlias, numFoundViaCollections); + assertEquals("Expected to find " + expectNumFound + " docs but found " + numFoundViaAlias, + expectNumFound, numFoundViaAlias); } private SolrInputDocument newDoc(String routedValue) {