You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mk...@apache.org on 2017/01/21 04:29:51 UTC
lucene-solr:jira/solr-5944: SOLR-9983: fixing
TestManagedSchemaThreadSafety NPE failure.
Repository: lucene-solr
Updated Branches:
refs/heads/jira/solr-5944 6ff5ce1e4 -> 7bfc42fa7
SOLR-9983: fixing TestManagedSchemaThreadSafety NPE failure.
Also testing session expiration.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/7bfc42fa
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/7bfc42fa
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/7bfc42fa
Branch: refs/heads/jira/solr-5944
Commit: 7bfc42fa7ca892c3ce57b5ae95a0b735f2797b69
Parents: 6ff5ce1
Author: Mikhail Khludnev <mk...@apache.org>
Authored: Fri Jan 20 23:07:42 2017 +0300
Committer: Mikhail Khludnev <mk...@apache.org>
Committed: Sat Jan 21 00:13:48 2017 +0300
----------------------------------------------------------------------
solr/CHANGES.txt | 3 ++
.../org/apache/solr/cloud/MockZkController.java | 36 ++++++++++++++++++++
.../schema/TestManagedSchemaThreadSafety.java | 28 +++++++++++++--
3 files changed, 65 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7bfc42fa/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 748125a..f5cce33 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -126,6 +126,9 @@ Other Changes
----------------------
* SOLR-9980: Expose configVersion in core admin status (Jessica Cheng Mallet via Tom�s Fern�ndez L�bbe)
+* SOLR-9996: Fixing NullPointerException failure by TestManagedSchemaThreadSafety
+ adding check for Zookeeper session expiration (Steve Rowe, Mikhail Khludnev)
+
================== 6.4.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7bfc42fa/solr/core/src/test/org/apache/solr/cloud/MockZkController.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/MockZkController.java b/solr/core/src/test/org/apache/solr/cloud/MockZkController.java
new file mode 100644
index 0000000..ac64f50
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/cloud/MockZkController.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.cloud;
+
+import java.io.IOException;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.solr.core.CloudConfig;
+import org.apache.solr.core.CoreContainer;
+
+public class MockZkController extends ZkController {
+
+ public MockZkController(CoreContainer cc, String zkServerAddress, int zkClientConnectTimeout, CloudConfig cloudConfig,
+ CurrentCoreDescriptorProvider registerOnReconnect) throws InterruptedException, TimeoutException, IOException {
+ super(cc, zkServerAddress, zkClientConnectTimeout, cloudConfig, registerOnReconnect);
+ }
+
+ @Override
+ public CoreContainer getCoreContainer() {
+ return super.getCoreContainer();
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7bfc42fa/solr/core/src/test/org/apache/solr/schema/TestManagedSchemaThreadSafety.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/TestManagedSchemaThreadSafety.java b/solr/core/src/test/org/apache/solr/schema/TestManagedSchemaThreadSafety.java
index e4a5c48..3ef09f3 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestManagedSchemaThreadSafety.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestManagedSchemaThreadSafety.java
@@ -28,17 +28,20 @@ import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.cloud.MockZkController;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.cloud.ZkSolrResourceLoader;
import org.apache.solr.cloud.ZkTestServer;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.util.LogLevel;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NoNodeException;
+import org.apache.zookeeper.KeeperException.SessionExpiredException;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.data.Stat;
import org.junit.AfterClass;
@@ -132,14 +135,35 @@ public class TestManagedSchemaThreadSafety extends SolrTestCaseJ4 {
}
private ZkController createZkController(SolrZkClient client) throws KeeperException, InterruptedException {
- ZkController zkController = mock(ZkController.class,
+
+ CoreContainer mockAlwaysUpCoreContainer = mock(CoreContainer.class,
+ Mockito.withSettings().defaultAnswer(Mockito.CALLS_REAL_METHODS));
+ when(mockAlwaysUpCoreContainer.isShutDown()).thenReturn(Boolean.FALSE); // Allow retry on session expiry
+
+
+ MockZkController zkController = mock(MockZkController.class,
Mockito.withSettings().defaultAnswer(Mockito.CALLS_REAL_METHODS));
+ when(zkController.getCoreContainer()).thenReturn(mockAlwaysUpCoreContainer);
+
when(zkController.getZkClient()).thenReturn(client);
Mockito.doAnswer(new Answer<Boolean>() {
+ volatile boolean sessionExpired=false;
+
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
- return client.exists((String) invocation.getArguments()[0], true);
+ String path = (String) invocation.getArguments()[0];
+ perhapsExpired();
+ Boolean exists = client.exists(path, true);
+ perhapsExpired();
+ return exists;
+ }
+
+ private void perhapsExpired() throws SessionExpiredException {
+ if (!sessionExpired && rarely()) {
+ sessionExpired = true;
+ throw new KeeperException.SessionExpiredException();
+ }
}
}).when(zkController).pathExists(Mockito.anyString());
return zkController;