mirror of https://github.com/apache/lucene.git
SOLR-12675: Make LeaderVoteWaitTimeoutTest more resilient against side effects of test methods.
Extracted a new method to ensure a given number of jettys are always running in the test setup. Also, delete all collections created by other test methods.
This commit is contained in:
parent
3c9050c3dd
commit
079a81f14f
|
@ -320,6 +320,8 @@ Other Changes
|
||||||
|
|
||||||
* SOLR-12680: Fix ClassCastException and AIOOBE in TestSolrConfigHandlerConcurrent. (shalin)
|
* SOLR-12680: Fix ClassCastException and AIOOBE in TestSolrConfigHandlerConcurrent. (shalin)
|
||||||
|
|
||||||
|
* SOLR-12675: Make LeaderVoteWaitTimeoutTest more resilient against side effects of test methods. (shalin)
|
||||||
|
|
||||||
================== 7.4.0 ==================
|
================== 7.4.0 ==================
|
||||||
|
|
||||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.solr.common.cloud.Replica;
|
||||||
import org.apache.solr.common.cloud.ZkCoreNodeProps;
|
import org.apache.solr.common.cloud.ZkCoreNodeProps;
|
||||||
import org.apache.solr.common.util.NamedList;
|
import org.apache.solr.common.util.NamedList;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -45,6 +46,7 @@ import org.slf4j.LoggerFactory;
|
||||||
public class LeaderVoteWaitTimeoutTest extends SolrCloudTestCase {
|
public class LeaderVoteWaitTimeoutTest extends SolrCloudTestCase {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
|
private static final int NODE_COUNT = 4;
|
||||||
|
|
||||||
private static Map<JettySolrRunner, SocketProxy> proxies;
|
private static Map<JettySolrRunner, SocketProxy> proxies;
|
||||||
private static Map<URI, JettySolrRunner> jettys;
|
private static Map<URI, JettySolrRunner> jettys;
|
||||||
|
@ -55,7 +57,7 @@ public class LeaderVoteWaitTimeoutTest extends SolrCloudTestCase {
|
||||||
System.setProperty("solr.ulog.numRecordsToKeep", "1000");
|
System.setProperty("solr.ulog.numRecordsToKeep", "1000");
|
||||||
System.setProperty("leaderVoteWait", "2000");
|
System.setProperty("leaderVoteWait", "2000");
|
||||||
|
|
||||||
configureCluster(4)
|
configureCluster(NODE_COUNT)
|
||||||
.addConfig("conf", configset("cloud-minimal"))
|
.addConfig("conf", configset("cloud-minimal"))
|
||||||
.configure();
|
.configure();
|
||||||
|
|
||||||
|
@ -86,6 +88,13 @@ public class LeaderVoteWaitTimeoutTest extends SolrCloudTestCase {
|
||||||
System.clearProperty("leaderVoteWait");
|
System.clearProperty("leaderVoteWait");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setupTest() throws Exception {
|
||||||
|
SolrCloudTestCase.ensureRunningJettys(NODE_COUNT, 5);
|
||||||
|
cluster.deleteAllCollections();
|
||||||
|
cluster.getSolrClient().setDefaultCollection(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
//28-June-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 21-May-2018
|
//28-June-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 21-May-2018
|
||||||
public void basicTest() throws Exception {
|
public void basicTest() throws Exception {
|
||||||
|
|
|
@ -64,6 +64,7 @@ import static org.apache.solr.common.cloud.ZkStateReader.SOLR_AUTOSCALING_CONF_P
|
||||||
@LogLevel("org.apache.solr.cloud.autoscaling=DEBUG;org.apache.solr.client.solrj.cloud.autoscaling=DEBUG")
|
@LogLevel("org.apache.solr.cloud.autoscaling=DEBUG;org.apache.solr.client.solrj.cloud.autoscaling=DEBUG")
|
||||||
public class TriggerIntegrationTest extends SolrCloudTestCase {
|
public class TriggerIntegrationTest extends SolrCloudTestCase {
|
||||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
|
private static final int NODE_COUNT = 2;
|
||||||
|
|
||||||
private static volatile CountDownLatch actionConstructorCalled;
|
private static volatile CountDownLatch actionConstructorCalled;
|
||||||
private static volatile CountDownLatch actionInitCalled;
|
private static volatile CountDownLatch actionInitCalled;
|
||||||
|
@ -84,7 +85,7 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setupCluster() throws Exception {
|
public static void setupCluster() throws Exception {
|
||||||
configureCluster(2)
|
configureCluster(NODE_COUNT)
|
||||||
.addConfig("conf", configset("cloud-minimal"))
|
.addConfig("conf", configset("cloud-minimal"))
|
||||||
.configure();
|
.configure();
|
||||||
// disable .scheduled_maintenance
|
// disable .scheduled_maintenance
|
||||||
|
@ -115,19 +116,7 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setupTest() throws Exception {
|
public void setupTest() throws Exception {
|
||||||
// ensure that exactly 2 jetty nodes are running
|
SolrCloudTestCase.ensureRunningJettys(NODE_COUNT, 5);
|
||||||
int numJetties = cluster.getJettySolrRunners().size();
|
|
||||||
log.info("Found {} jetty instances running", numJetties);
|
|
||||||
for (int i = 2; i < numJetties; i++) {
|
|
||||||
int r = random().nextInt(cluster.getJettySolrRunners().size());
|
|
||||||
log.info("Shutdown extra jetty instance at port {}", cluster.getJettySolrRunner(r).getLocalPort());
|
|
||||||
cluster.stopJettySolrRunner(r);
|
|
||||||
}
|
|
||||||
for (int i = cluster.getJettySolrRunners().size(); i < 2; i++) {
|
|
||||||
// start jetty instances
|
|
||||||
cluster.startJettySolrRunner();
|
|
||||||
}
|
|
||||||
cluster.waitForAllNodes(5);
|
|
||||||
|
|
||||||
NamedList<Object> overSeerStatus = cluster.getSolrClient().request(CollectionAdminRequest.getOverseerStatus());
|
NamedList<Object> overSeerStatus = cluster.getSolrClient().request(CollectionAdminRequest.getOverseerStatus());
|
||||||
String overseerLeader = (String) overSeerStatus.get("leader");
|
String overseerLeader = (String) overSeerStatus.get("leader");
|
||||||
|
|
|
@ -371,4 +371,33 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure that the given number of solr instances are running. If less instances are found then new instances are
|
||||||
|
* started. If extra instances are found then they are stopped.
|
||||||
|
* @param nodeCount the number of Solr instances that should be running at the end of this method
|
||||||
|
* @throws Exception on error
|
||||||
|
*/
|
||||||
|
public static void ensureRunningJettys(int nodeCount, int timeoutSeconds) throws Exception {
|
||||||
|
// ensure that exactly nodeCount jetty nodes are running
|
||||||
|
List<JettySolrRunner> jettys = cluster.getJettySolrRunners();
|
||||||
|
List<JettySolrRunner> copyOfJettys = new ArrayList<>(jettys);
|
||||||
|
int numJetties = copyOfJettys.size();
|
||||||
|
for (int i = nodeCount; i < numJetties; i++) {
|
||||||
|
cluster.stopJettySolrRunner(copyOfJettys.get(i));
|
||||||
|
}
|
||||||
|
for (int i = copyOfJettys.size(); i < nodeCount; i++) {
|
||||||
|
// start jetty instances
|
||||||
|
cluster.startJettySolrRunner();
|
||||||
|
}
|
||||||
|
// refresh the count from the source
|
||||||
|
jettys = cluster.getJettySolrRunners();
|
||||||
|
numJetties = jettys.size();
|
||||||
|
for (int i = 0; i < numJetties; i++) {
|
||||||
|
if (!jettys.get(i).isRunning()) {
|
||||||
|
cluster.startJettySolrRunner(jettys.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cluster.waitForAllNodes(timeoutSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue