From ad372f91eaabb877681565587a236449088f40d8 Mon Sep 17 00:00:00 2001 From: "markrmiller@gmail.com" Date: Tue, 14 Jul 2020 19:35:24 -0500 Subject: [PATCH] #162- Knock down some test timeouts. --- .../cloud/TestSolrCloudWithKerberosAlt.java | 4 +- ...TestCollectionsAPIViaSolrCloudCluster.java | 3 +- .../cloud/cdcr/BaseCdcrDistributedZkTest.java | 37 +------------------ .../TestSolrCloudWithHadoopAuthPlugin.java | 3 +- .../solr/cloud/AbstractDistribZkTestBase.java | 9 ++--- 5 files changed, 8 insertions(+), 48 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithKerberosAlt.java b/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithKerberosAlt.java index ae1175ec2198..cffe0348b2ec 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithKerberosAlt.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithKerberosAlt.java @@ -141,9 +141,7 @@ private void testCollectionCreateSearchDelete() throws Exception { // delete the collection we created earlier CollectionAdminRequest.deleteCollection(collectionName).process(client); - - AbstractDistribZkTestBase.waitForCollectionToDisappear - (collectionName, client.getZkStateReader(), true, 330); + cluster.waitForRemovedCollection(collectionName); } @Override diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java index f3bad87d2a3c..47709ad8c9d2 100644 --- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java +++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionsAPIViaSolrCloudCluster.java @@ -169,8 +169,7 @@ public void testCollectionCreateSearchDelete() throws Exception { assertEquals(nodeCount, cluster.getJettySolrRunners().size()); CollectionAdminRequest.deleteCollection(collectionName).process(client); - AbstractDistribZkTestBase.waitForCollectionToDisappear - (collectionName, client.getZkStateReader(), true, 330); + cluster.waitForRemovedCollection(collectionName); // create it again createCollection(collectionName, null); diff --git a/solr/core/src/test/org/apache/solr/cloud/cdcr/BaseCdcrDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/cdcr/BaseCdcrDistributedZkTest.java index b63752a0c1a1..87bdac165560 100644 --- a/solr/core/src/test/org/apache/solr/cloud/cdcr/BaseCdcrDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/cdcr/BaseCdcrDistributedZkTest.java @@ -354,18 +354,6 @@ private void createSourceCollection() throws Exception { this.updateMappingsFromZk(SOURCE_COLLECTION); } - /** - * Clear the source collection. It will delete then create the collection through the collection API. - * The collection will have a new fresh index, i.e., including a new update log. - */ - protected void clearSourceCollection() throws Exception { - this.deleteCollection(SOURCE_COLLECTION); - this.waitForCollectionToDisappear(SOURCE_COLLECTION); - this.createCollection(SOURCE_COLLECTION); - this.waitForRecoveriesToFinish(SOURCE_COLLECTION, true); - this.updateMappingsFromZk(SOURCE_COLLECTION); - } - /** * Starts the servers, saves and associates the node names to the target collection, * and finally creates the target collection. @@ -378,18 +366,6 @@ private void createTargetCollection() throws Exception { this.updateMappingsFromZk(TARGET_COLLECTION); } - /** - * Clear the source collection. It will delete then create the collection through the collection API. - * The collection will have a new fresh index, i.e., including a new update log. - */ - protected void clearTargetCollection() throws Exception { - this.deleteCollection(TARGET_COLLECTION); - this.waitForCollectionToDisappear(TARGET_COLLECTION); - this.createCollection(TARGET_COLLECTION); - this.waitForRecoveriesToFinish(TARGET_COLLECTION, true); - this.updateMappingsFromZk(TARGET_COLLECTION); - } - /** * Create a new collection through the Collection API. It enforces the use of one max shard per node. * It will define the nodes to spread the new collection across by using the mapping {@link #collectionToNodeNames}, @@ -492,17 +468,6 @@ protected CollectionAdminResponse deleteCollection(String collectionName) throws return res; } - private void waitForCollectionToDisappear(String collection) throws Exception { - CloudSolrClient client = this.createCloudClient(null); - try { - client.connect(); - ZkStateReader zkStateReader = client.getZkStateReader(); - AbstractDistribZkTestBase.waitForCollectionToDisappear(collection, zkStateReader, true, 15); - } finally { - client.close(); - } - } - private void waitForRecoveriesToFinish(String collection, boolean verbose) throws Exception { CloudSolrClient client = this.createCloudClient(null); try { @@ -611,7 +576,7 @@ protected List startServers(int nServer) throws Exception { this.waitForRecoveriesToFinish(temporaryCollection,zkStateReader, true); // delete the temporary collection - we will create our own collections later this.deleteCollection(temporaryCollection); - this.waitForCollectionToDisappear(temporaryCollection); + this.waitForCollectionToDisappear(temporaryCollection, zkStateReader); System.clearProperty("collection"); return nodeNames; diff --git a/solr/core/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithHadoopAuthPlugin.java b/solr/core/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithHadoopAuthPlugin.java index 877f396cc664..c59eaf925535 100644 --- a/solr/core/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithHadoopAuthPlugin.java +++ b/solr/core/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithHadoopAuthPlugin.java @@ -138,8 +138,7 @@ protected void testCollectionCreateSearchDelete() throws Exception { CollectionAdminRequest.Delete deleteReq = CollectionAdminRequest.deleteCollection(collectionName); deleteReq.process(solrClient); - AbstractDistribZkTestBase.waitForCollectionToDisappear(collectionName, - solrClient.getZkStateReader(), true, 330); + cluster.waitForRemovedCollection(collectionName); assertAuthMetricsMinimums(14, 8, 0, 6, 0, 0); } } diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java index 8e28cd0da17e..480c23313e1e 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java @@ -201,13 +201,12 @@ public static void waitForRecoveriesToFinish(String collection, } - public static void waitForCollectionToDisappear(String collection, - ZkStateReader zkStateReader, boolean failOnTimeout, int timeoutSeconds) + public static void waitForCollectionToDisappear(String collection, ZkStateReader zkStateReader) throws Exception { - log.info("Wait for collection to disappear - collection: {} failOnTimeout:{} timeout (sec):{}" - , collection, failOnTimeout, timeoutSeconds); + log.info("Wait for collection to disappear - collection: {}" + , collection); - zkStateReader.waitForState(collection, timeoutSeconds, TimeUnit.SECONDS, (docCollection) -> docCollection == null); + zkStateReader.waitForState(collection, 10, TimeUnit.SECONDS, (docCollection) -> docCollection == null); log.info("Collection has disappeared - collection:{}", collection); }