Apache Lucene open-source search software
SOLR-8256: Fix CollectionsAPISolrJTest and UnloadDistributedZkTest failures (caused by first commmit)
Cao Manh Datd0d30464dd71
diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.javaindex df3f8bc2e0b..d7a43c8be75 100644--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java@@ -269,8 +269,8 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {// sanity check our expected defaultfinal ClusterProperties props = new ClusterProperties(zkClient());- assertEquals("Expecting legacyCloud to false as default",- props.getClusterProperty(ZkStateReader.LEGACY_CLOUD, null), "false");+ assertEquals("Expecting prop to default to unset, test needs upated",+ props.getClusterProperty(ZkStateReader.LEGACY_CLOUD, null), null);CollectionAdminResponse response = CollectionAdminRequest.setClusterProperty(ZkStateReader.LEGACY_CLOUD, "true").process(cluster.getSolrClient());diff --git a/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.javaindex c51904fe3f4..460453c387b 100644--- a/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java@@ -151,6 +151,16 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {assertTrue("No longer found collection "+collection, getCommonCloudSolrClient().getZkStateReader().getClusterState().hasCollection(collection));}+ protected SolrCore getFirstCore(String collection, JettySolrRunner jetty) {+ SolrCore solrCore = null;+ for (SolrCore core : jetty.getCoreContainer().getCores()) {+ if (core.getName().startsWith(collection)) {+ solrCore = core;+ }+ }+ return solrCore;+ }+/*** @throws Exception on any problem*/@@ -167,9 +177,8 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {int slices = zkStateReader.getClusterState().getCollection("unloadcollection").getSlices().size();assertEquals(1, slices);- SolrCore solrCore = jetty1.getCoreContainer().getCore("unloadcollection_shard1_replica1");+ SolrCore solrCore = getFirstCore("unloadcollection", jetty1);String core1DataDir = solrCore.getDataDir();- solrCore.close();assertTrue(CollectionAdminRequest.addReplicaToShard("unloadcollection", "shard1")@@ -211,7 +220,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {// so that we start with some versions when we reload...DirectUpdateHandler2.commitOnClose = false;- try (HttpSolrClient addClient = getHttpSolrClient(jettys.get(2).getBaseUrl() + "/unloadcollection_shard1_replica3")) {+ try (HttpSolrClient addClient = getHttpSolrClient(jettys.get(2).getBaseUrl() + "/" + getFirstCore("unloadcollection", jettys.get(2)).getName())) {addClient.setConnectionTimeout(30000);// add a few docs@@ -249,7 +258,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {// ensure there is a leaderzkStateReader.getLeaderRetry("unloadcollection", "shard1", 15000);- try (HttpSolrClient addClient = getHttpSolrClient(jettys.get(1).getBaseUrl() + "/unloadcollection_shard1_replica2")) {+ try (HttpSolrClient addClient = getHttpSolrClient(jettys.get(1).getBaseUrl() + "/" + getFirstCore("unloadcollection", jettys.get(1)).getName())) {addClient.setConnectionTimeout(30000);addClient.setSoTimeout(90000);@@ -301,7 +310,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {long found1, found3;- try (HttpSolrClient adminClient = getHttpSolrClient(jettys.get(1).getBaseUrl() + "/unloadcollection_shard1_replica2")) {+ try (HttpSolrClient adminClient = getHttpSolrClient(jettys.get(1).getBaseUrl() + "/" + getFirstCore("unloadcollection", jettys.get(1)).getName())) {adminClient.setConnectionTimeout(15000);adminClient.setSoTimeout(30000);adminClient.commit();@@ -309,7 +318,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {q.set("distrib", false);found1 = adminClient.query(q).getResults().getNumFound();}- try (HttpSolrClient adminClient = getHttpSolrClient(jettys.get(2).getBaseUrl() + "/unloadcollection_shard1_replica3")) {+ try (HttpSolrClient adminClient = getHttpSolrClient(jettys.get(2).getBaseUrl() + "/" + getFirstCore("unloadcollection", jettys.get(2)).getName())) {adminClient.setConnectionTimeout(15000);adminClient.setSoTimeout(30000);adminClient.commit();@@ -318,7 +327,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {found3 = adminClient.query(q).getResults().getNumFound();}- try (HttpSolrClient adminClient = getHttpSolrClient(jettys.get(3).getBaseUrl() + "/unloadcollection_shard1_replica4")) {+ try (HttpSolrClient adminClient = getHttpSolrClient(jettys.get(3).getBaseUrl() + "/" + getFirstCore("unloadcollection", jettys.get(3)).getName())) {adminClient.setConnectionTimeout(15000);adminClient.setSoTimeout(30000);adminClient.commit();