You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2016/09/06 13:04:55 UTC
[4/6] lucene-solr:branch_6x: SOLR-8961: Add a test-the-tests module
for solr-test-framework
SOLR-8961: Add a test-the-tests module for solr-test-framework
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d8a2600c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d8a2600c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d8a2600c
Branch: refs/heads/branch_6x
Commit: d8a2600cc690bf87b0b578d0e4f4c6e3a5e79db0
Parents: 932c436
Author: Alan Woodward <ro...@apache.org>
Authored: Fri Sep 2 13:15:58 2016 +0100
Committer: Alan Woodward <ro...@apache.org>
Committed: Tue Sep 6 13:34:19 2016 +0100
----------------------------------------------------------------------
.../solr/test-framework/solr-test-framework.iml | 2 +
.../maven/solr/test-framework/pom.xml.template | 5 +
solr/CHANGES.txt | 2 +
.../solr/cloud/TestMiniSolrCloudCluster.java | 67 ------------
.../cloud/TestMiniSolrCloudClusterKerberos.java | 14 ---
solr/test-framework/build.xml | 3 -
.../src/test-files/log4j.properties | 11 ++
.../solr/cloud/MiniSolrCloudClusterTest.java | 105 +++++++++++++++++++
8 files changed, 125 insertions(+), 84 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8a2600c/dev-tools/idea/solr/test-framework/solr-test-framework.iml
----------------------------------------------------------------------
diff --git a/dev-tools/idea/solr/test-framework/solr-test-framework.iml b/dev-tools/idea/solr/test-framework/solr-test-framework.iml
index 1b3f064..b990f7a 100644
--- a/dev-tools/idea/solr/test-framework/solr-test-framework.iml
+++ b/dev-tools/idea/solr/test-framework/solr-test-framework.iml
@@ -7,6 +7,8 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/resources" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test-files" type="java-test-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8a2600c/dev-tools/maven/solr/test-framework/pom.xml.template
----------------------------------------------------------------------
diff --git a/dev-tools/maven/solr/test-framework/pom.xml.template b/dev-tools/maven/solr/test-framework/pom.xml.template
index 22f2fb0..17dab4c 100644
--- a/dev-tools/maven/solr/test-framework/pom.xml.template
+++ b/dev-tools/maven/solr/test-framework/pom.xml.template
@@ -61,6 +61,11 @@
<directory>${module-path}/src/resources</directory>
</resource>
</resources>
+ <testResources>
+ <testResource>
+ <directory>${module-path}/src/test-files</directory>
+ </testResource>
+ </testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8a2600c/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 32004ca..78846fc 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -105,6 +105,8 @@ Other Changes
* SOLR-9406: SolrSuggester should selectively register close hook (Gethin James, Joel Bernstein)
+* SOLR-8961: Add a test module for solr-test-framework (Alan Woodward)
+
================== 6.2.0 ==================
Versions of Major Components
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8a2600c/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java b/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java
index 00dbfd0..c2c99a1 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudCluster.java
@@ -17,7 +17,6 @@
package org.apache.solr.cloud;
import java.io.File;
-import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.URL;
import java.util.ArrayList;
@@ -27,10 +26,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
-
import org.apache.lucene.index.TieredMergePolicy;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
@@ -236,70 +233,6 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
}
@Test
- public void testErrorsInStartup() throws Exception {
-
- AtomicInteger jettyIndex = new AtomicInteger();
-
- MiniSolrCloudCluster cluster = null;
- try {
- cluster = new MiniSolrCloudCluster(3, createTempDir(), JettyConfig.builder().build()) {
- @Override
- public JettySolrRunner startJettySolrRunner(String name, String context, JettyConfig config) throws Exception {
- if (jettyIndex.incrementAndGet() != 2)
- return super.startJettySolrRunner(name, context, config);
- throw new IOException("Fake exception on startup!");
- }
- };
- fail("Expected an exception to be thrown from MiniSolrCloudCluster");
- }
- catch (Exception e) {
- assertEquals("Error starting up MiniSolrCloudCluster", e.getMessage());
- assertEquals("Expected one suppressed exception", 1, e.getSuppressed().length);
- assertEquals("Fake exception on startup!", e.getSuppressed()[0].getMessage());
- }
- finally {
- if (cluster != null)
- cluster.shutdown();
- }
- }
-
- @Test
- public void testErrorsInShutdown() throws Exception {
-
- AtomicInteger jettyIndex = new AtomicInteger();
-
- MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(3, createTempDir(), JettyConfig.builder().build()) {
- @Override
- protected JettySolrRunner stopJettySolrRunner(JettySolrRunner jetty) throws Exception {
- JettySolrRunner j = super.stopJettySolrRunner(jetty);
- if (jettyIndex.incrementAndGet() == 2)
- throw new IOException("Fake IOException on shutdown!");
- return j;
- }
- };
-
- try {
- cluster.shutdown();
- fail("Expected an exception to be thrown on MiniSolrCloudCluster shutdown");
- }
- catch (Exception e) {
- assertEquals("Error shutting down MiniSolrCloudCluster", e.getMessage());
- assertEquals("Expected one suppressed exception", 1, e.getSuppressed().length);
- assertEquals("Fake IOException on shutdown!", e.getSuppressed()[0].getMessage());
- }
-
- }
-
- @Test
- public void testExtraFilters() throws Exception {
- Builder jettyConfig = JettyConfig.builder();
- jettyConfig.waitForLoadingCoresToFinish(null);
- jettyConfig.withFilter(JettySolrRunner.DebugFilter.class, "*");
- MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), jettyConfig.build());
- cluster.shutdown();
- }
-
- @Test
public void testCollectionCreateWithoutCoresThenDelete() throws Exception {
final String collectionName = "testSolrCloudCollectionWithoutCores";
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8a2600c/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudClusterKerberos.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudClusterKerberos.java b/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudClusterKerberos.java
index d644967..e2b0aea 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudClusterKerberos.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudClusterKerberos.java
@@ -127,20 +127,6 @@ public class TestMiniSolrCloudClusterKerberos extends TestMiniSolrCloudCluster {
public void testCollectionCreateSearchDelete() throws Exception {
super.testCollectionCreateSearchDelete();
}
-
- @AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/HADOOP-9893")
- @Test
- @Override
- public void testErrorsInShutdown() throws Exception {
- super.testErrorsInShutdown();
- }
-
- @AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/HADOOP-9893")
- @Test
- @Override
- public void testErrorsInStartup() throws Exception {
- super.testErrorsInStartup();
- }
@Override
public void tearDown() throws Exception {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8a2600c/solr/test-framework/build.xml
----------------------------------------------------------------------
diff --git a/solr/test-framework/build.xml b/solr/test-framework/build.xml
index 1e0d7b5..baea996 100644
--- a/solr/test-framework/build.xml
+++ b/solr/test-framework/build.xml
@@ -51,9 +51,6 @@
<!-- redefine the clover setup, because we dont want to run clover for the test-framework -->
<target name="-clover.setup" if="run.clover"/>
-
- <!-- redefine the test compilation, so it's just a no-op -->
- <target name="compile-test"/>
<!-- redefine the forbidden apis for tests, as we check ourselves -->
<target name="-check-forbidden-tests" depends="-init-forbidden-apis,compile-core">
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8a2600c/solr/test-framework/src/test-files/log4j.properties
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/test-files/log4j.properties b/solr/test-framework/src/test-files/log4j.properties
new file mode 100644
index 0000000..f6fedb6
--- /dev/null
+++ b/solr/test-framework/src/test-files/log4j.properties
@@ -0,0 +1,11 @@
+# Logging level
+log4j.rootLogger=INFO, CONSOLE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Target=System.err
+log4j.appender.CONSOLE.layout=org.apache.log4j.EnhancedPatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%-4r %-5p (%t) [%X{node_name} %X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n
+log4j.logger.org.apache.zookeeper=WARN
+log4j.logger.org.apache.hadoop=WARN
+log4j.logger.org.apache.directory=WARN
+log4j.logger.org.apache.solr.hadoop=INFO
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d8a2600c/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java b/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java
new file mode 100644
index 0000000..90eea94
--- /dev/null
+++ b/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.atomic.AtomicInteger;
+
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.embedded.JettyConfig;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.util.RevertDefaultThreadHandlerRule;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
+
+@LuceneTestCase.SuppressSysoutChecks(bugUrl = "Solr logs to JUL")
+public class MiniSolrCloudClusterTest extends LuceneTestCase {
+
+ @ClassRule
+ public static TestRule solrClassRules = RuleChain.outerRule(
+ new SystemPropertiesRestoreRule()).around(
+ new RevertDefaultThreadHandlerRule());
+
+ @Test
+ public void testErrorsInStartup() throws Exception {
+
+ AtomicInteger jettyIndex = new AtomicInteger();
+
+ MiniSolrCloudCluster cluster = null;
+ try {
+ cluster = new MiniSolrCloudCluster(3, createTempDir(), JettyConfig.builder().build()) {
+ @Override
+ public JettySolrRunner startJettySolrRunner(String name, String context, JettyConfig config) throws Exception {
+ if (jettyIndex.incrementAndGet() != 2)
+ return super.startJettySolrRunner(name, context, config);
+ throw new IOException("Fake exception on startup!");
+ }
+ };
+ fail("Expected an exception to be thrown from MiniSolrCloudCluster");
+ }
+ catch (Exception e) {
+ assertEquals("Error starting up MiniSolrCloudCluster", e.getMessage());
+ assertEquals("Expected one suppressed exception", 1, e.getSuppressed().length);
+ assertEquals("Fake exception on startup!", e.getSuppressed()[0].getMessage());
+ }
+ finally {
+ if (cluster != null)
+ cluster.shutdown();
+ }
+ }
+
+ @Test
+ public void testErrorsInShutdown() throws Exception {
+
+ AtomicInteger jettyIndex = new AtomicInteger();
+
+ MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(3, createTempDir(), JettyConfig.builder().build()) {
+ @Override
+ protected JettySolrRunner stopJettySolrRunner(JettySolrRunner jetty) throws Exception {
+ JettySolrRunner j = super.stopJettySolrRunner(jetty);
+ if (jettyIndex.incrementAndGet() == 2)
+ throw new IOException("Fake IOException on shutdown!");
+ return j;
+ }
+ };
+
+ try {
+ cluster.shutdown();
+ fail("Expected an exception to be thrown on MiniSolrCloudCluster shutdown");
+ }
+ catch (Exception e) {
+ assertEquals("Error shutting down MiniSolrCloudCluster", e.getMessage());
+ assertEquals("Expected one suppressed exception", 1, e.getSuppressed().length);
+ assertEquals("Fake IOException on shutdown!", e.getSuppressed()[0].getMessage());
+ }
+
+ }
+
+ @Test
+ public void testExtraFilters() throws Exception {
+ JettyConfig.Builder jettyConfig = JettyConfig.builder();
+ jettyConfig.waitForLoadingCoresToFinish(null);
+ jettyConfig.withFilter(JettySolrRunner.DebugFilter.class, "*");
+ MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(random().nextInt(3) + 1, createTempDir(), jettyConfig.build());
+ cluster.shutdown();
+ }
+
+}