mirror of https://github.com/apache/lucene.git
SOLR-12066: Move test to DeleteInactiveReplicaTest
This commit is contained in:
parent
bd85fd389f
commit
ab092942cf
|
@ -17,6 +17,8 @@
|
|||
package org.apache.solr.cloud;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.nio.file.Files;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
|
@ -26,7 +28,11 @@ 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.cloud.ZkStateReader;
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
import org.apache.solr.common.util.TimeSource;
|
||||
import org.apache.solr.core.CoreDescriptor;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.util.FileUtils;
|
||||
import org.apache.solr.util.TimeOut;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -64,6 +70,10 @@ public class DeleteInactiveReplicaTest extends SolrCloudTestCase {
|
|||
Slice shard = getRandomShard(collectionState);
|
||||
Replica replica = getRandomReplica(shard);
|
||||
JettySolrRunner jetty = cluster.getReplicaJetty(replica);
|
||||
CoreDescriptor replicaCd;
|
||||
try (SolrCore core = jetty.getCoreContainer().getCore(replica.getCoreName())) {
|
||||
replicaCd = core.getCoreDescriptor();
|
||||
}
|
||||
cluster.stopJettySolrRunner(jetty);
|
||||
|
||||
waitForState("Expected replica " + replica.getName() + " on down node to be removed from cluster state", collectionName, (n, c) -> {
|
||||
|
@ -80,13 +90,9 @@ public class DeleteInactiveReplicaTest extends SolrCloudTestCase {
|
|||
|
||||
cluster.startJettySolrRunner(jetty);
|
||||
log.info("restarted jetty");
|
||||
|
||||
CoreContainer cc = jetty.getCoreContainer();
|
||||
CoreContainer.CoreLoadFailure loadFailure = cc.getCoreInitFailures().get(replica.getCoreName());
|
||||
assertNotNull("Deleted core was still loaded!", loadFailure);
|
||||
assertNotNull(loadFailure.exception.getCause());
|
||||
assertTrue("Unexpected load failure message: " + loadFailure.exception.getCause().getMessage(),
|
||||
loadFailure.exception.getCause().getMessage().contains("does not exist in shard"));
|
||||
TimeOut timeOut = new TimeOut(60, TimeUnit.SECONDS, TimeSource.NANO_TIME);
|
||||
timeOut.waitFor("Expected data dir and instance dir of " + replica.getName() + " is deleted", ()
|
||||
-> !Files.exists(replicaCd.getInstanceDir()) && !FileUtils.fileExists(replicaCd.getDataDir()));
|
||||
|
||||
// Check that we can't create a core with no coreNodeName
|
||||
try (SolrClient queryClient = getHttpSolrClient(jetty.getBaseUrl().toString())) {
|
||||
|
|
|
@ -41,10 +41,7 @@ import org.apache.solr.common.cloud.ZkNodeProps;
|
|||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.util.TimeSource;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
import org.apache.solr.core.CoreDescriptor;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.core.ZkContainer;
|
||||
import org.apache.solr.util.FileUtils;
|
||||
import org.apache.solr.util.TimeOut;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -155,36 +152,6 @@ public class DeleteReplicaTest extends SolrCloudTestCase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteReplicaOnDownNode() throws Exception {
|
||||
final String collectionName = "deleteReplicaOnDownNode";
|
||||
CollectionAdminRequest.createCollection(collectionName, "conf", 1, 2).process(cluster.getSolrClient());
|
||||
waitForState("Expected one shards with two replicas", collectionName, clusterShape(1, 2));
|
||||
|
||||
Slice shard = getCollectionState(collectionName).getSlice("shard1");
|
||||
Replica replica = shard.getReplicas(rep -> !rep.getName().equals(shard.getLeader().getName())).get(0);
|
||||
JettySolrRunner replicaJetty = getJettyForReplica(replica);
|
||||
CoreDescriptor replicaCd;
|
||||
try (SolrCore core = replicaJetty.getCoreContainer().getCore(replica.getCoreName())) {
|
||||
replicaCd = core.getCoreDescriptor();
|
||||
}
|
||||
assertNotNull("Expected core descriptor of "+ replica.getName() + " is not null",replicaCd);
|
||||
String replicaJettyNodeName = replicaJetty.getNodeName();
|
||||
|
||||
// shutdown node of a replica
|
||||
replicaJetty.stop();
|
||||
waitForNodeLeave(replicaJettyNodeName);
|
||||
waitForState("Expected one shards with one replica", collectionName, clusterShape(1, 1));
|
||||
CollectionAdminRequest.deleteReplica(collectionName, shard.getName(), replica.getName()).process(cluster.getSolrClient());
|
||||
waitForState("Expected only one replica left", collectionName, (liveNodes, collectionState) -> collectionState.getReplicas().size() == 1);
|
||||
|
||||
// restart the test and make sure the data get deleted
|
||||
replicaJetty.start();
|
||||
TimeOut timeOut = new TimeOut(60, TimeUnit.SECONDS, TimeSource.NANO_TIME);
|
||||
timeOut.waitFor("Expected data dir and instance dir of " + replica.getName() + " is deleted", ()
|
||||
-> !Files.exists(replicaCd.getInstanceDir()) && !FileUtils.fileExists(replicaCd.getDataDir()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteReplicaByCountForAllShards() throws Exception {
|
||||
|
||||
|
|
Loading…
Reference in New Issue