Apache Lucene open-source search software
SOLR-11507: randomize parallelUpdates for test CloudSolrClientBuilder
David Smileya43c318a51d3
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex db550699534..6c8dab7741f 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -157,6 +157,8 @@ Other Changes* SOLR-10469: Move CloudSolrClient.setParallelUpdates to its Builder. (David Smiley)+* SOLR-11507: Randomize SolrTestCaseJ4.CloudSolrClientBuilder more, and simplify it. (David Smiley)+================== 7.1.0 ==================Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.diff --git a/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.java b/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.javaindex 55915f9c4b8..f0ae1269044 100644--- a/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.java+++ b/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.java@@ -77,7 +77,6 @@ public class ConnectionReuseTest extends SolrCloudTestCase {return getHttpSolrClient(url.toString() + "/" + COLLECTION, httpClient);case 2:CloudSolrClient client = getCloudSolrClient(cluster.getZkServer().getZkAddress(), random().nextBoolean(), httpClient, 30000, 60000);- client.setParallelUpdates(random().nextBoolean());client.setDefaultCollection(COLLECTION);return client;}diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.javaindex f8a13624209..96fe67be27e 100644--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java@@ -107,7 +107,6 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBaseprotected CloudSolrClient createCloudClient(String defaultCollection, int socketTimeout) {CloudSolrClient client = getCloudSolrClient(zkServer.getZkAddress(), random().nextBoolean(), 30000, socketTimeout);- client.setParallelUpdates(random().nextBoolean());if (defaultCollection != null) client.setDefaultCollection(defaultCollection);return client;}diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPullReplicasTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPullReplicasTest.javaindex 64c042db59a..c032f6c63b4 100644--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPullReplicasTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPullReplicasTest.java@@ -130,7 +130,6 @@ public class ChaosMonkeyNothingIsSafeWithPullReplicasTest extends AbstractFullDiprotected CloudSolrClient createCloudClient(String defaultCollection, int socketTimeout) {CloudSolrClient client = getCloudSolrClient(zkServer.getZkAddress(), random().nextBoolean(), 30000, socketTimeout);- client.setParallelUpdates(random().nextBoolean());if (defaultCollection != null) client.setDefaultCollection(defaultCollection);return client;}diff --git a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.javaindex 95c22459098..58ebbf9ce27 100644--- a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java@@ -100,7 +100,6 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {.withConnectionTimeout(30000).withSocketTimeout(60000).build();- client.setParallelUpdates(random().nextBoolean());if (defaultCollection != null) client.setDefaultCollection(defaultCollection);return client;}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.javaindex e3a00a894ea..42af0834890 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@@ -194,7 +194,6 @@ public class BaseCdcrDistributedZkTest extends AbstractDistribZkTestBase {protected CloudSolrClient createCloudClient(String defaultCollection) {CloudSolrClient server = getCloudSolrClient(zkServer.getZkAddress(), random().nextBoolean());- server.setParallelUpdates(random().nextBoolean());if (defaultCollection != null) server.setDefaultCollection(defaultCollection);return server;}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.javaindex 8779a7108db..ffe59cff99d 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java@@ -292,8 +292,10 @@ public class CloudSolrClientTest extends SolrCloudTestCase {assertEquals(0, docs.getNumFound());// Test Multi-Threaded routed updates for UpdateRequest- try (CloudSolrClient threadedClient = getCloudSolrClient(cluster.getZkServer().getZkAddress())) {- threadedClient.setParallelUpdates(true);+ try (CloudSolrClient threadedClient = new CloudSolrClientBuilder()+ .withZkHost(cluster.getZkServer().getZkAddress())+ .withParallelUpdates(true)+ .build()) {threadedClient.setDefaultCollection(COLLECTION);response = threadedClient.request(request);if (threadedClient.isDirectUpdatesToLeadersOnly()) {diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.javaindex 3b1c4692cfa..449af4e2509 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java@@ -2227,20 +2227,18 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {}/**- * A variant of {@link org.apache.solr.client.solrj.impl.CloudSolrClient.Builder} that will randomize which nodes receive updates- * unless otherwise specified by the caller.- *- * @see #sendDirectUpdatesToAnyShardReplica- * @see #sendDirectUpdatesToShardLeadersOnly+ * A variant of {@link org.apache.solr.client.solrj.impl.CloudSolrClient.Builder} that will randomize+ * some internal settings.*/public static class CloudSolrClientBuilder extends CloudSolrClient.Builder {- private boolean configuredDUTflag = false;-public CloudSolrClientBuilder() {- super();+ this.directUpdatesToLeadersOnly = random().nextBoolean();+ this.shardLeadersOnly = random().nextBoolean();+ this.parallelUpdates = random().nextBoolean();}+ /** Randomly chooses the cluster state provider -- either ZK based or HTTP. */public CloudSolrClient.Builder withCluster(MiniSolrCloudCluster cluster) {if (random().nextBoolean()) {return withZkHost(cluster.getZkServer().getZkAddress());@@ -2249,40 +2247,6 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {}}- @Override- public CloudSolrClient.Builder sendDirectUpdatesToShardLeadersOnly() {- configuredDUTflag = true;- return super.sendDirectUpdatesToShardLeadersOnly();- }-- @Override- public CloudSolrClient.Builder sendDirectUpdatesToAnyShardReplica() {- configuredDUTflag = true;- return super.sendDirectUpdatesToAnyShardReplica();- }-- private void randomlyChooseDirectUpdatesToLeadersOnly() {- if (random().nextBoolean()) {- sendDirectUpdatesToShardLeadersOnly();- } else {- sendDirectUpdatesToAnyShardReplica();- }- }-- @Override- public CloudSolrClient build() {- if (configuredDUTflag == false) {- // flag value not explicitly configured- if (random().nextBoolean()) {- // so randomly choose a value- randomlyChooseDirectUpdatesToLeadersOnly();- } else {- // or go with whatever the default value is- configuredDUTflag = true;- }- }- return super.build();- }}/**diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.javaindex 90d5bd9315f..fb79cf5cd81 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java@@ -296,7 +296,6 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesprotected CloudSolrClient createCloudClient(String defaultCollection) {CloudSolrClient client = getCloudSolrClient(zkServer.getZkAddress(), random().nextBoolean(), 30000, 60000);- client.setParallelUpdates(random().nextBoolean());if (defaultCollection != null) client.setDefaultCollection(defaultCollection);return client;}@@ -1821,14 +1820,12 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesprotected CloudSolrClient getCommonCloudSolrClient() {synchronized (this) {if (commonCloudSolrClient == null) {- boolean updatesToLeaders = random().nextBoolean();- boolean parallelUpdates = random().nextBoolean();commonCloudSolrClient = getCloudSolrClient(zkServer.getZkAddress(),- updatesToLeaders, 5000, 120000);- commonCloudSolrClient.setParallelUpdates(parallelUpdates);+ random().nextBoolean(), 5000, 120000);commonCloudSolrClient.setDefaultCollection(DEFAULT_COLLECTION);commonCloudSolrClient.connect();- log.info("Created commonCloudSolrClient with updatesToLeaders={} and parallelUpdates={}", updatesToLeaders, parallelUpdates);+ log.info("Created commonCloudSolrClient with updatesToLeaders={} and parallelUpdates={}",+ commonCloudSolrClient.isUpdatesToLeaders(), commonCloudSolrClient.isParallelUpdates());}}return commonCloudSolrClient;