You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2014/04/05 11:17:24 UTC
svn commit: r1585028 [5/5] - in /lucene/dev/trunk: ./ dev-tools/ lucene/
lucene/analysis/ lucene/analysis/common/
lucene/analysis/common/src/test/org/apache/lucene/analysis/util/
lucene/analysis/stempel/src/test/org/egothor/stemmer/ lucene/benchmark/ l...
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/AddSchemaFieldsUpdateProcessorFactoryTest.java Sat Apr 5 09:17:20 2014
@@ -17,10 +17,12 @@
package org.apache.solr.update.processor;
+import java.io.File;
+import java.util.Date;
+
import org.apache.commons.io.FileUtils;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.schema.IndexSchema;
-import org.apache.solr.schema.TestManagedSchema;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
@@ -28,9 +30,6 @@ import org.joda.time.format.ISODateTimeF
import org.junit.After;
import org.junit.Before;
-import java.io.File;
-import java.util.Date;
-
/**
* Tests for the field mutating update processors
* that parse Dates, Longs, Doubles, and Booleans.
@@ -47,9 +46,7 @@ public class AddSchemaFieldsUpdateProces
@Before
private void initManagedSchemaCore() throws Exception {
- final String tmpSolrHomePath
- = dataDir + File.separator + TestManagedSchema.class.getSimpleName() + System.currentTimeMillis();
- tmpSolrHome = new File(tmpSolrHomePath).getAbsoluteFile();
+ tmpSolrHome = createTempDir();
tmpConfDir = new File(tmpSolrHome, confDir);
File testHomeConfDir = new File(TEST_HOME(), confDir);
FileUtils.copyFileToDirectory(new File(testHomeConfDir, SOLRCONFIG_XML), tmpConfDir);
@@ -60,12 +57,6 @@ public class AddSchemaFieldsUpdateProces
initCore(SOLRCONFIG_XML, SCHEMA_XML, tmpSolrHome.getPath());
}
- @After
- private void deleteCoreAndTempSolrHomeDirectory() throws Exception {
- deleteCore();
- FileUtils.deleteDirectory(tmpSolrHome);
- }
-
public void testSingleField() throws Exception {
IndexSchema schema = h.getCore().getLatestSchema();
final String fieldName = "newfield1";
@@ -219,4 +210,9 @@ public class AddSchemaFieldsUpdateProces
,"//arr[@name='" + fieldName3 + "']/str[.='" + field3String2 + "']"
,"//arr[@name='" + fieldName4 + "']/date[.='" + field4Value1String + "']");
}
+
+ @After
+ private void deleteCoreAndTempSolrHomeDirectory() throws Exception {
+ deleteCore();
+ }
}
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java Sat Apr 5 09:17:20 2014
@@ -17,7 +17,10 @@
package org.apache.solr.client.solrj;
-import org.apache.solr.SolrTestCaseJ4;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
@@ -30,10 +33,6 @@ import org.apache.solr.core.SolrCore;
import org.apache.solr.util.ExternalPaths;
import org.junit.BeforeClass;
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-
/**
* Abstract base class for testing merge indexes command
*
@@ -44,6 +43,7 @@ public abstract class MergeIndexesExampl
protected CoreContainer cores;
private String saveProp;
+ private File dataDir1;
private File dataDir2;
@Override
@@ -67,13 +67,11 @@ public abstract class MergeIndexesExampl
saveProp = System.getProperty("solr.directoryFactory");
System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
super.setUp();
-
+ File dataDir1 = createTempDir();
// setup datadirs
- System.setProperty( "solr.core0.data.dir", SolrTestCaseJ4.dataDir.getCanonicalPath() );
+ System.setProperty( "solr.core0.data.dir", dataDir1.getCanonicalPath() );
- dataDir2 = new File(dataDir, getClass().getName() + "-"
- + System.currentTimeMillis());
- dataDir2.mkdirs();
+ dataDir2 = createTempDir();
System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java Sat Apr 5 09:17:20 2014
@@ -21,6 +21,8 @@ import java.io.File;
import java.util.HashSet;
import java.util.Set;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest.Unload;
@@ -55,18 +57,11 @@ public abstract class MultiCoreExampleTe
@Override public void setUp() throws Exception {
super.setUp();
-
- dataDir1 = new File(dataDir, getClass().getName() + "-core0-"
- + System.currentTimeMillis());
- dataDir1.mkdirs();
-
- dataDir2 = new File(dataDir, getClass().getName() + "-core1-"
- + System.currentTimeMillis());
- dataDir2.mkdirs();
+ dataDir1 = createTempDir();
+ dataDir2 = createTempDir();
System.setProperty( "solr.core0.data.dir", this.dataDir1.getCanonicalPath() );
System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );
-
}
@Override
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestBase.java Sat Apr 5 09:17:20 2014
@@ -47,7 +47,7 @@ abstract public class SolrExampleTestBas
// this sets the property for jetty starting SolrDispatchFilter
System.setProperty( "solr.solr.home", this.getSolrHome() );
- System.setProperty( "solr.data.dir", this.dataDir.getCanonicalPath() );
+ System.setProperty( "solr.data.dir", this.initCoreDataDir.getCanonicalPath() );
}
/**
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java Sat Apr 5 09:17:20 2014
@@ -31,6 +31,7 @@ import org.apache.http.client.HttpClient
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.lucene.util.QuickPatchThreadsFilter;
+import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrIgnoredThreadsFilter;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
@@ -286,8 +287,6 @@ public class TestLBHttpSolrServer extend
public void setUp() throws Exception {
File home = new File(dataDir,
getClass().getName() + "-" + System.currentTimeMillis());
-
-
homeDir = new File(home, name);
dataDir = new File(homeDir + "/collection1", "data");
confDir = new File(homeDir + "/collection1", "conf");
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java Sat Apr 5 09:17:20 2014
@@ -36,13 +36,6 @@ public abstract class AbstractEmbeddedSo
protected CoreContainer cores = null;
protected File tempDir;
- protected void createTempDir() {
- if (tempDir == null) {
- tempDir = new File(dataDir, "solrtest-" + getTestClass().getSimpleName() + "-" + System.currentTimeMillis());
- tempDir.mkdirs();
- }
- }
-
@Override
@Before
public void setUp() throws Exception {
@@ -53,7 +46,7 @@ public abstract class AbstractEmbeddedSo
System.out.println("Solr home: " + SOLR_HOME.getAbsolutePath());
//The index is always stored within a temporary directory
- createTempDir();
+ tempDir = createTempDir();
File dataDir = new File(tempDir,"data1");
File dataDir2 = new File(tempDir,"data2");
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java Sat Apr 5 09:17:20 2014
@@ -23,6 +23,7 @@ import java.util.Random;
import org.apache.commons.io.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.ExternalPaths;
import org.eclipse.jetty.server.Connector;
@@ -58,9 +59,9 @@ public class JettyWebappTest extends Sol
System.setProperty("solr.solr.home", ExternalPaths.EXAMPLE_HOME);
System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
- File dataDir = new File(this.dataDir,
- getClass().getName() + "-" + System.currentTimeMillis());
+ File dataDir = createTempDir();
dataDir.mkdirs();
+
System.setProperty("solr.data.dir", dataDir.getCanonicalPath());
String path = ExternalPaths.WEBAPP_HOME;
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java Sat Apr 5 09:17:20 2014
@@ -17,9 +17,14 @@
package org.apache.solr.client.solrj.request;
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.core.Is.is;
+
+import java.io.File;
+
import org.apache.commons.io.FileUtils;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrIgnoredThreadsFilter;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.AbstractEmbeddedSolrServerTestCase;
@@ -38,10 +43,8 @@ import org.junit.rules.TestRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.core.Is.is;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
@ThreadLeakFilters(defaultFilters = true, filters = {SolrIgnoredThreadsFilter.class})
public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {
@@ -73,7 +76,7 @@ public class TestCoreAdmin extends Abstr
public void testConfigSet() throws Exception {
SolrServer server = getSolrAdmin();
- File testDir = createTestDirectory();
+ File testDir = createTempDir(LuceneTestCase.getTestClass().getSimpleName());
File newCoreInstanceDir = new File(testDir, "newcore");
@@ -91,26 +94,14 @@ public class TestCoreAdmin extends Abstr
}
- private File createTestDirectory() {
- File tmp = new File(dataDir, "solrtest-" + getTestClass().getSimpleName() + "-" + System.currentTimeMillis());
- assertTrue("Couldn't create temporary directory " + tmp.getAbsolutePath(), tmp.mkdirs());
- return tmp;
- }
-
@Test
public void testCustomUlogDir() throws Exception {
SolrServer server = getSolrAdmin();
- File tmp = createTestDirectory();
-
- log.info("Creating cores underneath {}", tmp);
-
- File dataDir = new File(tmp, this.getTestName()
- + System.currentTimeMillis() + "-" + "data");
+ File dataDir = createTempDir("data");
- File newCoreInstanceDir = new File(tmp, this.getTestName()
- + System.currentTimeMillis() + "-" + "instance");
+ File newCoreInstanceDir = createTempDir("instance");
File instanceDir = new File(cores.getSolrHome());
FileUtils.copyDirectory(instanceDir, new File(newCoreInstanceDir,
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java Sat Apr 5 09:17:20 2014
@@ -29,6 +29,7 @@ import java.nio.charset.StandardCharsets
import org.apache.commons.io.IOUtils;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.lucene.util.TestUtil;
import org.apache.solr.core.SolrResourceLoader;
/**
@@ -48,7 +49,7 @@ public class ContentStreamTest extends S
{
InputStream is = new SolrResourceLoader(null, null).openResource( "solrj/README" );
assertNotNull( is );
- File file = new File(dataDir, "README");
+ File file = new File(createTempDir(), "README");
FileOutputStream os = new FileOutputStream(file);
IOUtils.copy(is, os);
os.close();
@@ -77,7 +78,7 @@ public class ContentStreamTest extends S
{
InputStream is = new SolrResourceLoader(null, null).openResource( "solrj/README" );
assertNotNull( is );
- File file = new File(dataDir, "README");
+ File file = new File(createTempDir(), "README");
FileOutputStream os = new FileOutputStream(file);
IOUtils.copy(is, os);
os.close();
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java Sat Apr 5 09:17:20 2014
@@ -37,6 +37,7 @@ import junit.framework.Assert;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.util.Constants;
+import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.SolrServer;
@@ -53,7 +54,6 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.schema.TrieDateField;
-import org.apache.solr.util.AbstractSolrTestCase;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -278,9 +278,7 @@ public abstract class BaseDistributedSea
super.setUp();
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
- testDir = new File(dataDir,
- getClass().getName() + "-" + System.currentTimeMillis());
- testDir.mkdirs();
+ testDir = createTempDir();
}
@Override
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java Sat Apr 5 09:17:20 2014
@@ -56,7 +56,7 @@ abstract public class SolrJettyTestBase
ignoreException("maxWarmingSearchers");
// this sets the property for jetty starting SolrDispatchFilter
- System.setProperty( "solr.data.dir", dataDir.getCanonicalPath() );
+ System.setProperty( "solr.data.dir", createTempDir().getCanonicalPath() );
context = context==null ? "/solr" : context;
SolrJettyTestBase.context = context;
@@ -121,9 +121,6 @@ abstract public class SolrJettyTestBase
// Sets up the necessary config files for Jetty. At least some tests require that the solrconfig from the test
// file directory are used, but some also require that the solr.xml file be explicitly there as of SOLR-4817
public static void setupJettyTestHome(File solrHome, String collection) throws Exception {
- if (solrHome.exists()) {
- FileUtils.deleteDirectory(solrHome);
- }
copySolrHomeToTemp(solrHome, collection);
}
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Sat Apr 5 09:17:20 2014
@@ -134,19 +134,6 @@ public abstract class SolrTestCaseJ4 ext
public String bugUrl() default "None";
}
-
- /**
- * Annotation for test classes to prevent TEMP_DIR cleanup.
- */
- @Documented
- @Inherited
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- public @interface SuppressTempDirCleanUp {
- /** Point to JIRA entry. */
- public String bugUrl() default "None";
- }
-
// these are meant to be accessed sequentially, but are volatile just to ensure any test
// thread will read the latest value
protected static volatile SSLTestConfig sslConfig;
@@ -163,11 +150,9 @@ public abstract class SolrTestCaseJ4 ext
@BeforeClass
@SuppressWarnings("unused")
private static void beforeClass() {
- String cname = getSimpleClassName();
- dataDir = new File(TEMP_DIR,
- "solrtest-" + cname + "-" + System.currentTimeMillis());
- dataDir.mkdirs();
- System.err.println("Creating dataDir: " + dataDir.getAbsolutePath());
+ initCoreDataDir = createTempDir("init-core-data");
+
+ System.err.println("Creating dataDir: " + initCoreDataDir.getAbsolutePath());
System.setProperty("jetty.testMode", "true");
System.setProperty("enable.update.log", usually() ? "true" : "false");
@@ -199,39 +184,19 @@ public abstract class SolrTestCaseJ4 ext
resetFactory();
coreName = ConfigSolrXmlOld.DEFAULT_DEFAULT_CORE_NAME;
} finally {
- try {
- boolean skip = Boolean.getBoolean("solr.test.leavedatadir");
- if (skip) {
- System.err
- .println("NOTE: per solr.test.leavedatadir, dataDir will not be removed: "
- + dataDir.getAbsolutePath());
- } else {
-
- if (dataDir != null && dataDir.exists() && !recurseDelete(dataDir)) {
- String msg = "!!!! WARNING: best effort to remove "
- + dataDir.getAbsolutePath() + " FAILED !!!!!";
- if (RandomizedContext.current().getTargetClass()
- .isAnnotationPresent(SuppressTempDirCleanUp.class)) {
- System.err.println(msg);
- } else {
- fail(msg);
- }
- }
- }
- } finally {
- dataDir = null;
- System.clearProperty("jetty.testMode");
- System.clearProperty("tests.shardhandler.randomSeed");
- System.clearProperty("enable.update.log");
- System.clearProperty("useCompoundFile");
- System.clearProperty("urlScheme");
-
- if (isSSLMode()) {
- HttpClientUtil.setConfigurer(new HttpClientConfigurer());
- }
- // clean up static
- sslConfig = null;
+ initCoreDataDir = null;
+ System.clearProperty("jetty.testMode");
+ System.clearProperty("tests.shardhandler.randomSeed");
+ System.clearProperty("enable.update.log");
+ System.clearProperty("useCompoundFile");
+ System.clearProperty("urlScheme");
+
+ if (isSSLMode()) {
+ HttpClientUtil.setConfigurer(new HttpClientConfigurer());
}
+
+ // clean up static
+ sslConfig = null;
}
IpTables.unblockAllPorts();
@@ -497,7 +462,6 @@ public abstract class SolrTestCaseJ4 ext
SolrException.ignorePatterns.remove(pattern);
}
-
public static void resetExceptionIgnores() {
SolrException.ignorePatterns = null;
ignoreException("ignore_exception"); // always ignore "ignore_exception"
@@ -554,9 +518,9 @@ public abstract class SolrTestCaseJ4 ext
}
/**
- * The directory used to story the index managed by the TestHarness h
+ * The directory used to story the index managed by the TestHarness
*/
- protected static volatile File dataDir;
+ protected static volatile File initCoreDataDir;
// hack due to File dataDir
protected static String hdfsDataDir;
@@ -600,7 +564,7 @@ public abstract class SolrTestCaseJ4 ext
public static void createCore() {
assertNotNull(testSolrHome);
solrConfig = TestHarness.createConfig(testSolrHome, coreName, getSolrConfigFile());
- h = new TestHarness( coreName, hdfsDataDir == null ? dataDir.getAbsolutePath() : hdfsDataDir,
+ h = new TestHarness( coreName, hdfsDataDir == null ? initCoreDataDir.getAbsolutePath() : hdfsDataDir,
solrConfig,
getSchemaFile());
lrf = h.getRequestFactory
@@ -616,7 +580,7 @@ public abstract class SolrTestCaseJ4 ext
public static CoreContainer createDefaultCoreContainer(String solrHome) {
testSolrHome = checkNotNull(solrHome);
- h = new TestHarness("collection1", dataDir.getAbsolutePath(), "solrconfig.xml", "schema.xml");
+ h = new TestHarness("collection1", initCoreDataDir.getAbsolutePath(), "solrconfig.xml", "schema.xml");
lrf = h.getRequestFactory("standard", 0, 20, CommonParams.VERSION, "2.2");
return h.getCoreContainer();
}
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Sat Apr 5 09:17:20 2014
@@ -284,8 +284,7 @@ public abstract class AbstractFullDistri
// System.clearProperty(ZkStateReader.NUM_SHARDS_PROP);
System.setProperty(ZkStateReader.NUM_SHARDS_PROP, "1");
- File controlJettyDir = new File(dataDir,
- getClass().getName() + "-controljetty-" + System.currentTimeMillis());
+ File controlJettyDir = createTempDir();
setupJettySolrHome(controlJettyDir);
controlJetty = createJetty(controlJettyDir, testDir + "/control/data"); // don't pass shard name... let it default to "shard1"
@@ -360,8 +359,9 @@ public abstract class AbstractFullDistri
for (int i = 1; i <= numJettys; i++) {
if (sb.length() > 0) sb.append(',');
int cnt = this.jettyIntCntr.incrementAndGet();
- File jettyDir = new File(dataDir,
- getClass().getName() + "-jetty" + cnt + "-" + System.currentTimeMillis());
+
+ File jettyDir = createTempDir();
+
jettyDir.mkdirs();
setupJettySolrHome(jettyDir);
log.info("create jetty " + i);
@@ -417,7 +417,6 @@ public abstract class AbstractFullDistri
protected SolrServer startCloudJetty(String collection, String shard) throws Exception {
-
// TODO: use the collection string!!!!
collection = DEFAULT_COLLECTION;
@@ -425,8 +424,8 @@ public abstract class AbstractFullDistri
int cnt = this.jettyIntCntr.incrementAndGet();
- File jettyDir = new File(dataDir,
- getClass().getName() + "-jetty" + cnt + "-" + System.currentTimeMillis());
+
+ File jettyDir = createTempDir("jetty");
jettyDir.mkdirs();
org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), jettyDir);
JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" + cnt, shard, "solrconfig.xml", null);
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java?rev=1585028&r1=1585027&r2=1585028&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java Sat Apr 5 09:17:20 2014
@@ -63,8 +63,7 @@ public abstract class AbstractZkTestCase
@BeforeClass
public static void azt_beforeClass() throws Exception {
- zkDir = dataDir.getAbsolutePath() + File.separator
- + "zookeeper/server1/data";
+ zkDir = createTempDir("zkData").getAbsolutePath();
zkServer = new ZkTestServer(zkDir);
zkServer.run();
@@ -155,13 +154,11 @@ public abstract class AbstractZkTestCase
System.clearProperty("jetty.port");
System.clearProperty(ZOOKEEPER_FORCE_SYNC);
- zkServer.shutdown();
-
- zkServer = null;
+ if (zkServer != null) {
+ zkServer.shutdown();
+ zkServer = null;
+ }
zkDir = null;
-
- // wait just a bit for any zk client threads to outlast timeout
- Thread.sleep(2000);
}
protected void printLayout(String zkHost) throws Exception {