SOLR-6400: SolrCloud tests are not properly testing session expiration.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1619612 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2014-08-21 22:29:12 +00:00
parent 999f7ab30d
commit 277136452a
6 changed files with 38 additions and 50 deletions

View File

@ -98,7 +98,24 @@ Other Changes
command and DataImportHandler responses. (ehatcher) command and DataImportHandler responses. (ehatcher)
================== 4.11.0 ================= ================== 4.11.0 =================
(No Changes)
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
Versions of Major Components
---------------------
Apache Tika 1.5 (with upgraded Apache POI 3.10.1)
Carrot2 3.9.0
Velocity 1.7 and Velocity Tools 2.0
Apache UIMA 2.3.1
Apache ZooKeeper 3.4.6
Detailed Change List
----------------------
Other Changes
---------------------
* SOLR-6400: SolrCloud tests are not properly testing session expiration. (Mark Miller)
================== 4.10.0 ================= ================== 4.10.0 =================

View File

@ -17,8 +17,6 @@ package org.apache.solr.cloud;
* the License. * the License.
*/ */
import java.io.File;
import org.apache.lucene.util.LuceneTestCase.Slow; import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.ConnectionManager; import org.apache.solr.common.cloud.ConnectionManager;
@ -49,10 +47,9 @@ public class ConnectionManagerTest extends SolrTestCaseJ4 {
SolrZkClient zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT); SolrZkClient zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
ConnectionManager cm = zkClient.getConnectionManager(); ConnectionManager cm = zkClient.getConnectionManager();
try { try {
System.err.println("ISEXPIRED:" + cm.isLikelyExpired());
assertFalse(cm.isLikelyExpired()); assertFalse(cm.isLikelyExpired());
zkClient.getSolrZooKeeper().pauseCnxn(TIMEOUT); zkClient.getSolrZooKeeper().closeCnxn();
long sessionId = zkClient.getSolrZooKeeper().getSessionId(); long sessionId = zkClient.getSolrZooKeeper().getSessionId();
server.expire(sessionId); server.expire(sessionId);

View File

@ -212,7 +212,10 @@ public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
String leader = getLeader(); String leader = getLeader();
int leaderPort = getLeaderPort(leader); int leaderPort = getLeaderPort(leader);
ZkController zkController = containerMap.get(leaderPort).getZkController(); ZkController zkController = containerMap.get(leaderPort).getZkController();
zkController.getZkClient().getSolrZooKeeper().pauseCnxn(zkController.getClientTimeout() + 100);
zkController.getZkClient().getSolrZooKeeper().closeCnxn();
long sessionId = zkClient.getSolrZooKeeper().getSessionId();
zkServer.expire(sessionId);
for (int i = 0; i < 60; i++) { // wait till leader is changed for (int i = 0; i < 60; i++) { // wait till leader is changed
if (leaderPort != getLeaderPort(getLeader())) { if (leaderPort != getLeaderPort(getLeader())) {

View File

@ -38,6 +38,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.util.DefaultSolrThreadFactory; import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NoNodeException; import org.apache.zookeeper.KeeperException.NoNodeException;
import org.apache.zookeeper.KeeperException.SessionExpiredException;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -252,6 +253,8 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
return leaderProps.getCoreUrl(); return leaderProps.getCoreUrl();
} catch (NoNodeException e) { } catch (NoNodeException e) {
Thread.sleep(500); Thread.sleep(500);
} catch (SessionExpiredException e) {
Thread.sleep(500);
} }
} }
zkClient.printLayoutToStdOut(); zkClient.printLayoutToStdOut();
@ -482,8 +485,11 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
int j; int j;
j = random().nextInt(threads.size()); j = random().nextInt(threads.size());
try { try {
threads.get(j).es.zkClient.getSolrZooKeeper().pauseCnxn( threads.get(j).es.zkClient.getSolrZooKeeper().closeCnxn();
ZkTestServer.TICK_TIME * 2); if (random().nextBoolean()) {
long sessionId = zkClient.getSolrZooKeeper().getSessionId();
server.expire(sessionId);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -50,12 +50,7 @@ public class SolrZooKeeper extends ZooKeeper {
return testableLocalSocketAddress(); return testableLocalSocketAddress();
} }
/** public void closeCnxn() {
* Cause this ZooKeeper object to stop receiving from the ZooKeeperServer
* for the given number of milliseconds.
* @param ms the number of milliseconds to pause.
*/
public void pauseCnxn(final long ms) {
final Thread t = new Thread() { final Thread t = new Thread() {
@Override @Override
public void run() { public void run() {
@ -78,10 +73,7 @@ public class SolrZooKeeper extends ZooKeeper {
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Closing Zookeeper send channel failed.", e); throw new RuntimeException("Closing Zookeeper send channel failed.", e);
} }
Thread.sleep(ms);
} }
} catch (InterruptedException e) {
// ignore
} finally { } finally {
spawnedThreads.remove(this); spawnedThreads.remove(this);
} }

View File

@ -124,34 +124,12 @@ public class ChaosMonkey {
if (solrDispatchFilter != null) { if (solrDispatchFilter != null) {
CoreContainer cores = solrDispatchFilter.getCores(); CoreContainer cores = solrDispatchFilter.getCores();
if (cores != null) { if (cores != null) {
causeConnectionLoss(jetty, cores.getZkController().getClientTimeout() + 200); causeConnectionLoss(jetty);
long sessionId = cores.getZkController().getZkClient()
.getSolrZooKeeper().getSessionId();
zkServer.expire(sessionId);
} }
} }
// Thread thread = new Thread() {
// {
// setDaemon(true);
// }
// public void run() {
// SolrDispatchFilter solrDispatchFilter = (SolrDispatchFilter) jetty.getDispatchFilter().getFilter();
// if (solrDispatchFilter != null) {
// CoreContainer cores = solrDispatchFilter.getCores();
// if (cores != null) {
// try {
// Thread.sleep(ZkTestServer.TICK_TIME * 2 + 800);
// } catch (InterruptedException e) {
// // we act as only connection loss
// return;
// }
// long sessionId = cores.getZkController().getZkClient().getSolrZooKeeper().getSessionId();
// zkServer.expire(sessionId);
// }
// }
// }
// };
// thread.start();
} }
public void expireRandomSession() throws KeeperException, InterruptedException { public void expireRandomSession() throws KeeperException, InterruptedException {
@ -176,18 +154,13 @@ public class ChaosMonkey {
} }
public static void causeConnectionLoss(JettySolrRunner jetty) { public static void causeConnectionLoss(JettySolrRunner jetty) {
causeConnectionLoss(jetty, ZkTestServer.TICK_TIME * 2 + 200);
}
public static void causeConnectionLoss(JettySolrRunner jetty, int pauseTime) {
SolrDispatchFilter solrDispatchFilter = (SolrDispatchFilter) jetty SolrDispatchFilter solrDispatchFilter = (SolrDispatchFilter) jetty
.getDispatchFilter().getFilter(); .getDispatchFilter().getFilter();
if (solrDispatchFilter != null) { if (solrDispatchFilter != null) {
CoreContainer cores = solrDispatchFilter.getCores(); CoreContainer cores = solrDispatchFilter.getCores();
if (cores != null) { if (cores != null) {
SolrZkClient zkClient = cores.getZkController().getZkClient(); SolrZkClient zkClient = cores.getZkController().getZkClient();
// must be at least double tick time... zkClient.getSolrZooKeeper().closeCnxn();
zkClient.getSolrZooKeeper().pauseCnxn(pauseTime);
} }
} }
} }