mirror of https://github.com/apache/lucene.git
SOLR-13072: Use the same wait in other simulated tests where the same race condition may occur.
This commit is contained in:
parent
a37e2c609c
commit
7db4121b45
|
@ -21,14 +21,17 @@ import java.lang.invoke.MethodHandles;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.client.solrj.cloud.autoscaling.AutoScalingConfig;
|
||||
import org.apache.solr.cloud.CloudTestUtils;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.Slice;
|
||||
import org.apache.solr.common.util.TimeSource;
|
||||
import org.apache.solr.util.TimeOut;
|
||||
import org.junit.AfterClass;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -63,6 +66,18 @@ public class SimSolrCloudTestCase extends SolrTestCaseJ4 {
|
|||
cluster = null;
|
||||
}
|
||||
|
||||
protected static void assertAutoscalingUpdateComplete() throws Exception {
|
||||
(new TimeOut(30, TimeUnit.SECONDS, cluster.getTimeSource()))
|
||||
.waitFor("OverseerTriggerThread never caught up to the latest znodeVersion", () -> {
|
||||
try {
|
||||
AutoScalingConfig autoscalingConfig = cluster.getDistribStateManager().getAutoScalingConfig();
|
||||
return autoscalingConfig.getZkVersion() == cluster.getOverseerTriggerThread().getProcessedZnodeVersion();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("FAILED", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
|
|
|
@ -100,6 +100,7 @@ public class TestSimComputePlanAction extends SimSolrCloudTestCase {
|
|||
rsp = cluster.request(req);
|
||||
response = rsp.getResponse();
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
assertAutoscalingUpdateComplete();
|
||||
cluster.getTimeSource().sleep(TimeUnit.SECONDS.toMillis(ScheduledTriggers.DEFAULT_COOLDOWN_PERIOD_SECONDS));
|
||||
}
|
||||
|
||||
|
@ -138,6 +139,8 @@ public class TestSimComputePlanAction extends SimSolrCloudTestCase {
|
|||
NamedList<Object> response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
assertAutoscalingUpdateComplete();
|
||||
|
||||
CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection("testNodeLost",
|
||||
"conf",1, 2);
|
||||
create.process(solrClient);
|
||||
|
@ -201,6 +204,8 @@ public class TestSimComputePlanAction extends SimSolrCloudTestCase {
|
|||
NamedList<Object> response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
assertAutoscalingUpdateComplete();
|
||||
|
||||
CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection("testNodeWithMultipleReplicasLost",
|
||||
"conf",2, 3);
|
||||
create.setMaxShardsPerNode(2);
|
||||
|
@ -285,6 +290,8 @@ public class TestSimComputePlanAction extends SimSolrCloudTestCase {
|
|||
response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
assertAutoscalingUpdateComplete();
|
||||
|
||||
CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection("testNodeAdded",
|
||||
"conf",1, 4).setMaxShardsPerNode(-1);
|
||||
create.process(solrClient);
|
||||
|
@ -304,6 +311,8 @@ public class TestSimComputePlanAction extends SimSolrCloudTestCase {
|
|||
response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
assertAutoscalingUpdateComplete();
|
||||
|
||||
// start a node so that the 'violation' created by the previous policy update is fixed
|
||||
String newNode = cluster.simAddNode();
|
||||
assertTrue("Trigger was not fired even after 5 seconds", triggerFiredLatch.await(5, TimeUnit.SECONDS));
|
||||
|
|
|
@ -173,6 +173,8 @@ public class TestSimExecutePlanAction extends SimSolrCloudTestCase {
|
|||
NamedList<Object> response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
assertAutoscalingUpdateComplete();
|
||||
|
||||
String collectionName = "testIntegration";
|
||||
CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName,
|
||||
"conf", 1, 2);
|
||||
|
|
|
@ -120,6 +120,8 @@ public class TestSimExtremeIndexing extends SimSolrCloudTestCase {
|
|||
NamedList<Object> response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
assertAutoscalingUpdateComplete();
|
||||
|
||||
long batchSize = BATCH_SIZE;
|
||||
for (long i = 0; i < NUM_BATCHES; i++) {
|
||||
addDocs(collectionName, i * batchSize, batchSize);
|
||||
|
|
|
@ -174,6 +174,8 @@ public class TestSimLargeCluster extends SimSolrCloudTestCase {
|
|||
response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
assertAutoscalingUpdateComplete();
|
||||
|
||||
cluster.getTimeSource().sleep(5000);
|
||||
|
||||
// pick a few random nodes
|
||||
|
@ -269,6 +271,8 @@ public class TestSimLargeCluster extends SimSolrCloudTestCase {
|
|||
NamedList<Object> response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
assertAutoscalingUpdateComplete();
|
||||
|
||||
// create a collection with more than 1 replica per node
|
||||
String collectionName = "testNodeAdded";
|
||||
CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName,
|
||||
|
@ -472,6 +476,7 @@ public class TestSimLargeCluster extends SimSolrCloudTestCase {
|
|||
response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
assertAutoscalingUpdateComplete();
|
||||
|
||||
// create a collection with 1 replica per node
|
||||
String collectionName = "testNodeLost";
|
||||
|
@ -671,6 +676,7 @@ public class TestSimLargeCluster extends SimSolrCloudTestCase {
|
|||
response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
assertAutoscalingUpdateComplete();
|
||||
|
||||
boolean await = triggerFinishedLatch.await(waitForSeconds * 45000 / SPEED, TimeUnit.MILLISECONDS);
|
||||
assertTrue("The trigger did not fire at all", await);
|
||||
|
|
|
@ -1424,16 +1424,4 @@ public class TestSimTriggerIntegration extends SimSolrCloudTestCase {
|
|||
return event;
|
||||
}
|
||||
|
||||
private static void assertAutoscalingUpdateComplete() throws Exception {
|
||||
(new TimeOut(30, TimeUnit.SECONDS, cluster.getTimeSource()))
|
||||
.waitFor("OverseerTriggerThread never caught up to the latest znodeVersion", () -> {
|
||||
try {
|
||||
AutoScalingConfig autoscalingConfig = cluster.getDistribStateManager().getAutoScalingConfig();
|
||||
return autoscalingConfig.getZkVersion() == cluster.getOverseerTriggerThread().getProcessedZnodeVersion();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("FAILED", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue