mirror of https://github.com/apache/lucene.git
SOLR-8961: Add a test-the-tests module for solr-test-framework
This commit is contained in:
parent
932c436d07
commit
d8a2600cc6
|
@ -7,6 +7,8 @@
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
|
<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/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>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
|
|
@ -61,6 +61,11 @@
|
||||||
<directory>${module-path}/src/resources</directory>
|
<directory>${module-path}/src/resources</directory>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
<testResources>
|
||||||
|
<testResource>
|
||||||
|
<directory>${module-path}/src/test-files</directory>
|
||||||
|
</testResource>
|
||||||
|
</testResources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
|
@ -105,6 +105,8 @@ Other Changes
|
||||||
|
|
||||||
* SOLR-9406: SolrSuggester should selectively register close hook (Gethin James, Joel Bernstein)
|
* 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 ==================
|
================== 6.2.0 ==================
|
||||||
|
|
||||||
Versions of Major Components
|
Versions of Major Components
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.apache.solr.cloud;
|
package org.apache.solr.cloud;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -27,10 +26,8 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
|
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
|
||||||
|
|
||||||
import org.apache.lucene.index.TieredMergePolicy;
|
import org.apache.lucene.index.TieredMergePolicy;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
|
import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;
|
||||||
|
@ -235,70 +232,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
|
@Test
|
||||||
public void testCollectionCreateWithoutCoresThenDelete() throws Exception {
|
public void testCollectionCreateWithoutCoresThenDelete() throws Exception {
|
||||||
|
|
||||||
|
|
|
@ -127,20 +127,6 @@ public class TestMiniSolrCloudClusterKerberos extends TestMiniSolrCloudCluster {
|
||||||
public void testCollectionCreateSearchDelete() throws Exception {
|
public void testCollectionCreateSearchDelete() throws Exception {
|
||||||
super.testCollectionCreateSearchDelete();
|
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
|
@Override
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
|
|
|
@ -51,9 +51,6 @@
|
||||||
|
|
||||||
<!-- redefine the clover setup, because we dont want to run clover for the test-framework -->
|
<!-- redefine the clover setup, because we dont want to run clover for the test-framework -->
|
||||||
<target name="-clover.setup" if="run.clover"/>
|
<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 -->
|
<!-- redefine the forbidden apis for tests, as we check ourselves -->
|
||||||
<target name="-check-forbidden-tests" depends="-init-forbidden-apis,compile-core">
|
<target name="-check-forbidden-tests" depends="-init-forbidden-apis,compile-core">
|
||||||
|
|
|
@ -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
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue