You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2013/07/04 01:26:45 UTC
svn commit: r1499601 [17/20] - in /lucene/dev/branches/security: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/libraries/
dev-tools/idea/solr/core/src/test/ dev-tools/maven/ dev-tools/maven/lucene/
dev-tools/maven/lucene/analysis/stempel/ dev-t...
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java Wed Jul 3 23:26:32 2013
@@ -91,7 +91,7 @@ public class UnloadDistributedZkTest ext
createCmd.setCollection(collection);
String coreDataDir = dataDir.getAbsolutePath() + File.separator
+ System.currentTimeMillis() + collection + "1";
- createCmd.setDataDir(coreDataDir);
+ createCmd.setDataDir(getDataDir(coreDataDir));
createCmd.setNumShards(2);
SolrServer client = clients.get(0);
@@ -107,7 +107,7 @@ public class UnloadDistributedZkTest ext
createCmd.setCollection(collection);
coreDataDir = dataDir.getAbsolutePath() + File.separator
+ System.currentTimeMillis() + collection + "2";
- createCmd.setDataDir(coreDataDir);
+ createCmd.setDataDir(getDataDir(coreDataDir));
server.request(createCmd);
@@ -171,7 +171,7 @@ public class UnloadDistributedZkTest ext
createCmd.setCollection("unloadcollection");
createCmd.setNumShards(1);
String core1DataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection1" + "_1n";
- createCmd.setDataDir(core1DataDir);
+ createCmd.setDataDir(getDataDir(core1DataDir));
server.request(createCmd);
ZkStateReader zkStateReader = getCommonCloudSolrServer().getZkStateReader();
@@ -189,7 +189,7 @@ public class UnloadDistributedZkTest ext
createCmd.setCoreName("unloadcollection2");
createCmd.setCollection("unloadcollection");
String core2dataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection1" + "_2n";
- createCmd.setDataDir(core2dataDir);
+ createCmd.setDataDir(getDataDir(core2dataDir));
server.request(createCmd);
zkStateReader.updateClusterState(true);
@@ -227,7 +227,7 @@ public class UnloadDistributedZkTest ext
createCmd.setCoreName("unloadcollection3");
createCmd.setCollection("unloadcollection");
String core3dataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection" + "_3n";
- createCmd.setDataDir(core3dataDir);
+ createCmd.setDataDir(getDataDir(core3dataDir));
server.request(createCmd);
waitForRecoveriesToFinish("unloadcollection", zkStateReader, false);
@@ -296,7 +296,7 @@ public class UnloadDistributedZkTest ext
createCmd.setCoreName("unloadcollection4");
createCmd.setCollection("unloadcollection");
String core4dataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection" + "_4n";
- createCmd.setDataDir(core4dataDir);
+ createCmd.setDataDir(getDataDir(core4dataDir));
server.request(createCmd);
waitForRecoveriesToFinish("unloadcollection", zkStateReader, false);
@@ -334,7 +334,7 @@ public class UnloadDistributedZkTest ext
createCmd = new Create();
createCmd.setCoreName(leaderProps.getCoreName());
createCmd.setCollection("unloadcollection");
- createCmd.setDataDir(core1DataDir);
+ createCmd.setDataDir(getDataDir(core1DataDir));
server.request(createCmd);
waitForRecoveriesToFinish("unloadcollection", zkStateReader, false);
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java Wed Jul 3 23:26:32 2013
@@ -138,6 +138,19 @@ public class ZkCLITest extends SolrTestC
assertTrue(zkClient.exists("/path/mynewpath", true));
}
+
+ @Test
+ public void testPut() throws Exception {
+ // test bootstrap_conf
+ String data = "my data";
+ String[] args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
+ "put", "/data.txt", data};
+ ZkCLI.main(args);
+
+ zkClient.getData("/data.txt", null, null, true);
+
+ assertArrayEquals(zkClient.getData("/data.txt", null, null, true), data.getBytes("UTF-8"));
+ }
@Test
public void testList() throws Exception {
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java Wed Jul 3 23:26:32 2013
@@ -17,11 +17,6 @@ package org.apache.solr.cloud;
* the License.
*/
-import java.io.File;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
@@ -34,6 +29,11 @@ import org.apache.zookeeper.CreateMode;
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
@Slow
public class ZkControllerTest extends SolrTestCaseJ4 {
@@ -163,7 +163,7 @@ public class ZkControllerTest extends So
cc = getCoreContainer();
ZkController zkController = new ZkController(cc, server.getZkAddress(), TIMEOUT, 10000,
- "127.0.0.1", "8983", "solr", "0", 10000, 10000, new CurrentCoreDescriptorProvider() {
+ "127.0.0.1", "8983", "solr", "0", true, 10000, 10000, new CurrentCoreDescriptorProvider() {
@Override
public List<CoreDescriptor> getCurrentDescriptors() {
@@ -203,7 +203,7 @@ public class ZkControllerTest extends So
cc = getCoreContainer();
zkController = new ZkController(cc, server.getZkAddress(),
- TIMEOUT, 10000, "127.0.0.1", "8983", "solr", "0", 10000, 10000, new CurrentCoreDescriptorProvider() {
+ TIMEOUT, 10000, "127.0.0.1", "8983", "solr", "0", true, 10000, 10000, new CurrentCoreDescriptorProvider() {
@Override
public List<CoreDescriptor> getCurrentDescriptors() {
@@ -240,12 +240,8 @@ public class ZkControllerTest extends So
}
private CoreContainer getCoreContainer() {
- CoreContainer cc = new CoreContainer(TEMP_DIR.getAbsolutePath()) {
- {
- initShardHandler();
- }
- };
-
+ CoreContainer cc = new CoreContainer(TEMP_DIR.getAbsolutePath());
+ cc.load();
return cc;
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/AbstractBadConfigTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/AbstractBadConfigTestBase.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/AbstractBadConfigTestBase.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/AbstractBadConfigTestBase.java Wed Jul 3 23:26:32 2013
@@ -18,9 +18,8 @@
package org.apache.solr.core;
import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
+import java.util.Map;
import java.util.regex.Pattern;
public abstract class AbstractBadConfigTestBase extends SolrTestCaseJ4 {
@@ -50,26 +49,37 @@ public abstract class AbstractBadConfigT
ignoreException(Pattern.quote(errString));
try {
+
if (null == solrHome) {
initCore( solrconfigFile, schemaFile );
} else {
initCore( solrconfigFile, schemaFile, solrHome );
}
- } catch (Exception e) {
- for (Throwable t = e; t != null; t = t.getCause()) {
- // short circuit out if we found what we expected
- if (t.getMessage() != null && -1 != t.getMessage().indexOf(errString)) return;
- }
- // otherwise, rethrow it, possibly completley unrelated
- throw new SolrException
- (ErrorCode.SERVER_ERROR,
- "Unexpected error, expected error matching: " + errString, e);
- } finally {
+ CoreContainer cc = h.getCoreContainer();
+ for (Map.Entry<String, Exception> entry : cc.getCoreInitFailures().entrySet()) {
+ if (matches(entry.getValue(), errString))
+ return;
+ }
+ }
+ catch (Exception e) {
+ if (matches(e, errString))
+ return;
+ throw e;
+ }
+ finally {
deleteCore();
resetExceptionIgnores();
}
fail("Did not encounter any exception from: " + solrconfigFile + " using " + schemaFile);
}
+ private static boolean matches(Exception e, String errString) {
+ for (Throwable t = e; t != null; t = t.getCause()) {
+ if (t.getMessage() != null && -1 != t.getMessage().indexOf(errString))
+ return true;
+ }
+ return false;
+ }
+
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java Wed Jul 3 23:26:32 2013
@@ -17,23 +17,17 @@
package org.apache.solr.core;
-import java.util.Map;
-import java.util.Collection;
-import java.util.regex.Pattern;
-
-import java.io.File;
-
-import org.apache.solr.common.SolrException;
-import org.apache.solr.SolrTestCaseJ4;
-
-import org.apache.lucene.util.IOUtils;
-
import org.apache.commons.io.FileUtils;
-
+import org.apache.lucene.util.IOUtils;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrException;
+import org.junit.After;
import org.xml.sax.SAXParseException;
-import org.junit.Before;
-import org.junit.After;
+import java.io.File;
+import java.util.Collection;
+import java.util.Map;
+import java.util.regex.Pattern;
public class CoreContainerCoreInitFailuresTest extends SolrTestCaseJ4 {
@@ -44,8 +38,7 @@ public class CoreContainerCoreInitFailur
// would be nice to do this in an @Before method,
// but junit doesn't let @Before methods have test names
solrHome = new File(TEMP_DIR, this.getClass().getName() + "_" + dirSuffix);
- assertTrue("Failed to mkdirs solrhome", solrHome.mkdirs());
- cc = new CoreContainer(solrHome.getAbsolutePath());
+ assertTrue("Failed to mkdirs solrhome [" + solrHome + "]", solrHome.mkdirs());
}
@After
@@ -68,7 +61,7 @@ public class CoreContainerCoreInitFailur
Map<String,Exception> failures = null;
Collection<String> cores = null;
Exception fail = null;
-
+
init("empty_flow");
// solr.xml
@@ -77,7 +70,8 @@ public class CoreContainerCoreInitFailur
// ----
// init the CoreContainer
- cc.load(solrHome.getAbsolutePath(), solrXml);
+ cc = new CoreContainer(solrHome.getAbsolutePath());
+ cc.load();
// check that we have the cores we expect
cores = cc.getCoreNames();
@@ -150,22 +144,23 @@ public class CoreContainerCoreInitFailur
FileUtils.write(solrXml, BAD_SOLR_XML, IOUtils.CHARSET_UTF_8.toString());
// our "ok" collection
- FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-basic.xml"),
+ FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
FileUtils.getFile(solrHome, "col_ok", "conf", "solrconfig.xml"));
FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
FileUtils.getFile(solrHome, "col_ok", "conf", "schema.xml"));
-
+
// our "bad" collection
ignoreException(Pattern.quote("DummyMergePolicy"));
FileUtils.copyFile(getFile("solr/collection1/conf/bad-mp-solrconfig.xml"),
FileUtils.getFile(solrHome, "col_bad", "conf", "solrconfig.xml"));
FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
FileUtils.getFile(solrHome, "col_bad", "conf", "schema.xml"));
-
-
+
+
// -----
// init the CoreContainer with the mix of ok/bad cores
- cc.load(solrHome.getAbsolutePath(), solrXml);
+ cc = new CoreContainer(solrHome.getAbsolutePath());
+ cc.load();
// check that we have the cores we expect
cores = cc.getCoreNames();
@@ -198,7 +193,7 @@ public class CoreContainerCoreInitFailur
// -----
// "fix" the bad collection
- FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-basic.xml"),
+ FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
FileUtils.getFile(solrHome, "col_bad", "conf", "solrconfig.xml"));
final CoreDescriptor fixed = new CoreDescriptor(cc, "col_bad", "col_bad");
cc.register("col_bad", cc.create(fixed), false);
@@ -293,8 +288,8 @@ public class CoreContainerCoreInitFailur
fail("corrupt solrconfig.xml failed to trigger exception from reload");
} catch (SolrException e) {
assertTrue("We're supposed to have a wrapped SAXParserException here, but we don't",
- e.getCause() instanceof SAXParseException);
- SAXParseException se = (SAXParseException)e.getCause();
+ e.getCause().getCause() instanceof SAXParseException);
+ SAXParseException se = (SAXParseException)e.getCause().getCause();
assertTrue("reload exception doesn't refer to slrconfig.xml " + se.getSystemId(),
0 < se.getSystemId().indexOf("solrconfig.xml"));
@@ -318,13 +313,13 @@ public class CoreContainerCoreInitFailur
fail = failures.get("col_bad");
assertNotNull("null failure for test core", fail);
assertTrue("init failure isn't SAXParseException",
- fail instanceof SAXParseException);
+ fail.getCause() instanceof SAXParseException);
assertTrue("init failure doesn't mention problem: " + fail.toString(),
- 0 < ((SAXParseException)fail).getSystemId().indexOf("solrconfig.xml"));
+ 0 < ((SAXParseException)fail.getCause()).getSystemId().indexOf("solrconfig.xml"));
// ----
// fix col_bad's config (again) and RELOAD to fix failure
- FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-basic.xml"),
+ FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
FileUtils.getFile(solrHome, "col_bad", "conf", "solrconfig.xml"));
cc.reload("col_bad");
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java Wed Jul 3 23:26:32 2013
@@ -207,9 +207,10 @@ public class OpenCloseCoreStressTest ext
}
} while (secondsRemaining > 0);
- assertTrue("We didn't index any documents, somethings really messsed up", cumulativeDocs > 0);
+ assertTrue("We didn't index any documents, somethings really messed up", cumulativeDocs > 0);
} catch (Exception e) {
e.printStackTrace();
+ fail("Caught unexpected exception");
}
}
@@ -241,6 +242,8 @@ public class OpenCloseCoreStressTest ext
FileUtils.copyFile(new File(testConf, "schema-tiny.xml"), new File(conf, "schema-tiny.xml"));
FileUtils.copyFile(new File(testConf, "solrconfig-minimal.xml"), new File(conf, "solrconfig-minimal.xml"));
+ FileUtils.copyFile(new File(testConf, "solrconfig.snippet.randomindexconfig.xml"),
+ new File(conf, "solrconfig.snippet.randomindexconfig.xml"));
if (!oldStyle) {
FileUtils.copyFile(new File(testSrcRoot, "conf/core.properties"), new File(coreDir, "core.properties"));
@@ -479,7 +482,7 @@ class Queries {
try {
QueryResponse response = server.query(params);
numFound = response.getResults().getNumFound();
- } catch (SolrServerException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
return numFound;
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java Wed Jul 3 23:26:32 2013
@@ -38,7 +38,7 @@ public class QueryResultKeyTest extends
// the hashcode should be the same even when the list
// of filters is in a different order
- Sort sort = new Sort(new SortField("test", SortField.Type.BYTE));
+ Sort sort = new Sort(new SortField("test", SortField.Type.INT));
List<Query> filters = new ArrayList<Query>();
filters.add(new TermQuery(new Term("test", "field")));
filters.add(new TermQuery(new Term("test2", "field2")));
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java Wed Jul 3 23:26:32 2013
@@ -29,6 +29,7 @@ import org.junit.Before;
import org.junit.Test;
import java.io.File;
+import java.util.Map;
public class SolrCoreCheckLockOnStartupTest extends SolrTestCaseJ4 {
@@ -62,13 +63,9 @@ public class SolrCoreCheckLockOnStartupT
try {
//opening a new core on the same index
initCore("solrconfig-simplelock.xml", "schema.xml");
+ if (checkForCoreInitException(LockObtainFailedException.class))
+ return;
fail("Expected " + LockObtainFailedException.class.getSimpleName());
- } catch (Throwable t) {
- assertTrue(t instanceof RuntimeException);
- assertNotNull(t.getCause());
- assertTrue(t.getCause() instanceof RuntimeException);
- assertNotNull(t.getCause().getCause());
- assertTrue(t.getCause().getCause().toString(), t.getCause().getCause() instanceof LockObtainFailedException);
} finally {
indexWriter.close();
directory.close();
@@ -79,24 +76,33 @@ public class SolrCoreCheckLockOnStartupT
@Test
public void testNativeLockErrorOnStartup() throws Exception {
- Directory directory = newFSDirectory(new File(dataDir, "index"), new NativeFSLockFactory());
+ File indexDir = new File(dataDir, "index");
+ log.info("Acquiring lock on {}", indexDir.getAbsolutePath());
+ Directory directory = newFSDirectory(indexDir, new NativeFSLockFactory());
//creates a new IndexWriter without releasing the lock yet
IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_40, null));
try {
//opening a new core on the same index
initCore("solrconfig-nativelock.xml", "schema.xml");
+ CoreContainer cc = h.getCoreContainer();
+ if (checkForCoreInitException(LockObtainFailedException.class))
+ return;
fail("Expected " + LockObtainFailedException.class.getSimpleName());
- } catch(Throwable t) {
- assertTrue(t instanceof RuntimeException);
- assertNotNull(t.getCause());
- assertTrue(t.getCause() instanceof RuntimeException);
- assertNotNull(t.getCause().getCause());
- assertTrue(t.getCause().getCause() instanceof LockObtainFailedException);
} finally {
indexWriter.close();
directory.close();
deleteCore();
}
}
+
+ private boolean checkForCoreInitException(Class<? extends Exception> clazz) {
+ for (Map.Entry<String, Exception> entry : h.getCoreContainer().getCoreInitFailures().entrySet()) {
+ for (Throwable t = entry.getValue(); t != null; t = t.getCause()) {
+ if (clazz.isInstance(t))
+ return true;
+ }
+ }
+ return false;
+ }
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java Wed Jul 3 23:26:32 2013
@@ -50,6 +50,7 @@ public class TestArbitraryIndexDir exten
static String savedFactory;
@BeforeClass
public static void beforeClass() {
+ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
savedFactory = System.getProperty("solr.DirectoryFactory");
System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestConfig.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestConfig.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestConfig.java Wed Jul 3 23:26:32 2013
@@ -138,11 +138,26 @@ public class TestConfig extends SolrTest
// If defaults change, add test methods to cover each version
@Test
public void testDefaults() throws Exception {
+
+ SolrConfig sc = new SolrConfig(new SolrResourceLoader("solr/collection1"), "solrconfig-defaults.xml", null);
+ SolrIndexConfig sic = sc.indexConfig;
+ assertEquals("default ramBufferSizeMB", 100.0D, sic.ramBufferSizeMB, 0.0D);
+ assertEquals("default LockType", SolrIndexConfig.LOCK_TYPE_NATIVE, sic.lockType);
+ assertEquals("default useCompoundFile", false, sic.useCompoundFile);
+
+ }
+
+
+ // sanity check that sys propertis are working as expected
+ public void testSanityCheckTestSysPropsAreUsed() throws Exception {
+ final boolean expectCFS
+ = Boolean.parseBoolean(System.getProperty("useCompoundFile"));
+
SolrConfig sc = new SolrConfig(new SolrResourceLoader("solr/collection1"), "solrconfig-basic.xml", null);
SolrIndexConfig sic = sc.indexConfig;
- assertTrue("default ramBufferSizeMB should be 100", sic.ramBufferSizeMB == 100);
- assertTrue("default useCompoundFile should be false", sic.useCompoundFile == false);
- assertTrue("default LockType should be native", sic.lockType.equals(SolrIndexConfig.LOCK_TYPE_NATIVE));
+ assertEquals("default ramBufferSizeMB", 100.0D, sic.ramBufferSizeMB, 0.0D);
+ assertEquals("default LockType", SolrIndexConfig.LOCK_TYPE_NATIVE, sic.lockType);
+ assertEquals("useCompoundFile sysprop", expectCFS, sic.useCompoundFile);
}
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java Wed Jul 3 23:26:32 2013
@@ -17,6 +17,16 @@
package org.apache.solr.core;
+import org.apache.commons.io.FileUtils;
+import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util._TestUtil;
+import org.apache.solr.SolrTestCaseJ4;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
@@ -27,17 +37,6 @@ import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util._TestUtil;
-import org.apache.solr.SolrTestCaseJ4;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.xml.sax.SAXException;
-
public class TestCoreContainer extends SolrTestCaseJ4 {
private static String oldSolrHome;
@@ -70,9 +69,10 @@ public class TestCoreContainer extends S
assertTrue("Failed to mkdirs workDir", solrHomeDirectory.mkdirs());
FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME()), solrHomeDirectory);
+ System.out.println("Using solrconfig from " + new File(SolrTestCaseJ4.TEST_HOME()).getAbsolutePath());
CoreContainer ret = new CoreContainer(solrHomeDirectory.getAbsolutePath());
- ret.load(solrHomeDirectory.getAbsolutePath(), new File(solrHomeDirectory, "solr.xml"));
+ ret.load();
return ret;
}
@@ -161,13 +161,13 @@ public class TestCoreContainer extends S
SolrCore template = null;
try {
template = cores.getCore("collection1");
- instDir = template.getCoreDescriptor().getInstanceDir();
+ instDir = template.getCoreDescriptor().getRawInstanceDir();
} finally {
if (null != template) template.close();
}
}
- final File instDirFile = new File(instDir);
+ final File instDirFile = new File(cores.getSolrHome(), instDir);
assertTrue("instDir doesn't exist: " + instDir, instDirFile.exists());
// sanity check the basic persistence of the default init
@@ -262,14 +262,8 @@ public class TestCoreContainer extends S
File solrHomeDirectory = new File(TEMP_DIR, this.getClass().getName()
+ "_noCores");
SetUpHome(solrHomeDirectory, EMPTY_SOLR_XML);
- CoreContainer.Initializer init = new CoreContainer.Initializer();
- CoreContainer cores = null;
- try {
- cores = init.initialize();
- }
- catch(Exception e) {
- fail("CoreContainer not created" + e.getMessage());
- }
+ CoreContainer cores = new CoreContainer(solrHomeDirectory.getAbsolutePath());
+ cores.load();
try {
//assert zero cores
assertEquals("There should not be cores", 0, cores.getCores().size());
@@ -362,24 +356,21 @@ public class TestCoreContainer extends S
FileUtils.writeStringToFile(new File(tmpRoot, "explicit-lib-solr.xml"), "<solr sharedLib=\"lib\"><cores/></solr>", "UTF-8");
FileUtils.writeStringToFile(new File(tmpRoot, "custom-lib-solr.xml"), "<solr sharedLib=\"customLib\"><cores/></solr>", "UTF-8");
- final CoreContainer cc1 = new CoreContainer(tmpRoot.getAbsolutePath());
- cc1.load(tmpRoot.getAbsolutePath(), new File(tmpRoot, "default-lib-solr.xml"));
+ final CoreContainer cc1 = CoreContainer.createAndLoad(tmpRoot.getAbsolutePath(), new File(tmpRoot, "default-lib-solr.xml"));
try {
cc1.loader.openResource("defaultSharedLibFile").close();
} finally {
cc1.shutdown();
}
- final CoreContainer cc2 = new CoreContainer(tmpRoot.getAbsolutePath());
- cc2.load(tmpRoot.getAbsolutePath(), new File(tmpRoot, "explicit-lib-solr.xml"));
+ final CoreContainer cc2 = CoreContainer.createAndLoad(tmpRoot.getAbsolutePath(), new File(tmpRoot, "explicit-lib-solr.xml"));
try {
cc2.loader.openResource("defaultSharedLibFile").close();
} finally {
cc2.shutdown();
}
- final CoreContainer cc3 = new CoreContainer(tmpRoot.getAbsolutePath());
- cc3.load(tmpRoot.getAbsolutePath(), new File(tmpRoot, "custom-lib-solr.xml"));
+ final CoreContainer cc3 = CoreContainer.createAndLoad(tmpRoot.getAbsolutePath(), new File(tmpRoot, "custom-lib-solr.xml"));
try {
cc3.loader.openResource("customSharedLibFile").close();
} finally {
@@ -392,22 +383,4 @@ public class TestCoreContainer extends S
" <cores adminPath=\"/admin/cores\" transientCacheSize=\"32\" >\n" +
" </cores>\n" +
"</solr>";
-
- private static final String SOLR_XML_SAME_NAME ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
- "<solr persistent=\"false\">\n" +
- " <cores adminPath=\"/admin/cores\" transientCacheSize=\"32\" >\n" +
- " <core name=\"core1\" instanceDir=\"core1\" dataDir=\"core1\"/> \n" +
- " <core name=\"core1\" instanceDir=\"core2\" dataDir=\"core2\"/> \n " +
- " </cores>\n" +
- "</solr>";
-
- private static final String SOLR_XML_SAME_DATADIR ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
- "<solr persistent=\"false\">\n" +
- " <cores adminPath=\"/admin/cores\" transientCacheSize=\"32\" >\n" +
- " <core name=\"core2\" instanceDir=\"core2\" dataDir=\"../samedatadir\" schema=\"schema-tiny.xml\" config=\"solrconfig-minimal.xml\" /> \n" +
- " <core name=\"core1\" instanceDir=\"core2\" dataDir=\"../samedatadir\" schema=\"schema-tiny.xml\" config=\"solrconfig-minimal.xml\" /> \n " +
- " </cores>\n" +
- "</solr>";
-
-
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java Wed Jul 3 23:26:32 2013
@@ -17,10 +17,6 @@ package org.apache.solr.core;
* limitations under the License.
*/
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.Properties;
-
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.IOUtils;
import org.apache.solr.SolrTestCaseJ4;
@@ -29,6 +25,10 @@ import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Properties;
+
public class TestCoreDiscovery extends SolrTestCaseJ4 {
@BeforeClass
@@ -102,14 +102,12 @@ public class TestCoreDiscovery extends S
assertTrue("Failed to mkdirs for " + confDir.getAbsolutePath(), confDir.mkdirs());
FileUtils.copyFile(new File(top, "schema-tiny.xml"), new File(confDir, "schema-tiny.xml"));
FileUtils.copyFile(new File(top, "solrconfig-minimal.xml"), new File(confDir, "solrconfig-minimal.xml"));
+ FileUtils.copyFile(new File(top, "solrconfig.snippet.randomindexconfig.xml"), new File(confDir, "solrconfig.snippet.randomindexconfig.xml"));
}
private CoreContainer init() throws Exception {
-
- CoreContainer.Initializer init = new CoreContainer.Initializer();
-
- final CoreContainer cores = init.initialize();
- cores.setPersistent(false);
+ final CoreContainer cores = new CoreContainer();
+ cores.load();
return cores;
}
@@ -182,10 +180,14 @@ public class TestCoreDiscovery extends S
cc = init();
fail("Should have thrown exception in testDuplicateNames");
} catch (SolrException se) {
+ Throwable cause = se.getCause();
+ String message = cause.getMessage();
assertTrue("Should have seen an exception because two cores had the same name",
- "Core + desc.getName() + \" defined twice".indexOf(se.getMessage()) != -1);
- assertTrue("/core1 should have been mentioned in the message", "/core1".indexOf(se.getMessage()) != -1);
- assertTrue("/core2 should have been mentioned in the message", "/core2".indexOf(se.getMessage()) != -1);
+ message.indexOf("Core core1 defined more than once") != -1);
+ assertTrue(File.separator + "core1 should have been mentioned in the message: " + message,
+ message.indexOf(File.separator + "core1") != -1);
+ assertTrue(File.separator + "core2 should have been mentioned in the message:" + message,
+ message.indexOf(File.separator + "core2") != -1);
} finally {
if (cc != null) {
cc.shutdown();
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestLazyCores.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestLazyCores.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestLazyCores.java Wed Jul 3 23:26:32 2013
@@ -66,7 +66,7 @@ public class TestLazyCores extends SolrT
File solrXml = new File(solrHomeDirectory, "solr.xml");
FileUtils.write(solrXml, LOTS_SOLR_XML, IOUtils.CHARSET_UTF_8.toString());
final CoreContainer cores = new CoreContainer(solrHomeDirectory.getAbsolutePath());
- cores.load(solrHomeDirectory.getAbsolutePath(), solrXml);
+ cores.load();
// h.getCoreContainer().load(solrHomeDirectory.getAbsolutePath(), new File(solrHomeDirectory, "solr.xml"));
cores.setPersistent(false);
@@ -285,8 +285,8 @@ public class TestLazyCores extends SolrT
CoreAdminParams.CoreAdminAction.CREATE.toString(),
CoreAdminParams.DATA_DIR, dataDir,
CoreAdminParams.NAME, name,
- "schema", "schema-tiny.xml",
- "config", "solrconfig-minimal.xml");
+ "schema", "schema.xml",
+ "config", "solrconfig.xml");
admin.handleRequestBody(request, resp);
fail("Should have thrown an error");
@@ -347,29 +347,29 @@ public class TestLazyCores extends SolrT
CoreDescriptor d1 = new CoreDescriptor(cc, "core1", "./core1");
d1.setTransient(true);
d1.setLoadOnStartup(true);
- d1.setSchemaName("schema-tiny.xml");
- d1.setConfigName("solrconfig-minimal.xml");
+ d1.setSchemaName("schema.xml");
+ d1.setConfigName("solrconfig.xml");
SolrCore core1 = cc.create(d1);
CoreDescriptor d2 = new CoreDescriptor(cc, "core2", "./core2");
d2.setTransient(true);
d2.setLoadOnStartup(false);
- d2.setSchemaName("schema-tiny.xml");
- d2.setConfigName("solrconfig-minimal.xml");
+ d2.setSchemaName("schema.xml");
+ d2.setConfigName("solrconfig.xml");
SolrCore core2 = cc.create(d2);
CoreDescriptor d3 = new CoreDescriptor(cc, "core3", "./core3");
d3.setTransient(false);
d3.setLoadOnStartup(true);
- d3.setSchemaName("schema-tiny.xml");
- d3.setConfigName("solrconfig-minimal.xml");
+ d3.setSchemaName("schema.xml");
+ d3.setConfigName("solrconfig.xml");
SolrCore core3 = cc.create(d3);
CoreDescriptor d4 = new CoreDescriptor(cc, "core4", "./core4");
d4.setTransient(false);
d4.setLoadOnStartup(false);
- d4.setSchemaName("schema-tiny.xml");
- d4.setConfigName("solrconfig-minimal.xml");
+ d4.setSchemaName("schema.xml");
+ d4.setConfigName("solrconfig.xml");
SolrCore core4 = cc.create(d4);
final File oneXml = new File(solrHomeDirectory, "lazy1.solr.xml");
@@ -455,31 +455,23 @@ public class TestLazyCores extends SolrT
private final static String LOTS_SOLR_XML = " <solr persistent=\"false\"> " +
"<cores adminPath=\"/admin/cores\" defaultCoreName=\"collectionLazy2\" transientCacheSize=\"4\"> " +
- "<core name=\"collection1\" instanceDir=\"collection1\" config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+ "<core name=\"collection1\" instanceDir=\"collection1\" /> " +
- "<core name=\"collectionLazy2\" instanceDir=\"collection2\" transient=\"true\" loadOnStartup=\"true\" " +
- " config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+ "<core name=\"collectionLazy2\" instanceDir=\"collection2\" transient=\"true\" loadOnStartup=\"true\" /> " +
- "<core name=\"collectionLazy3\" instanceDir=\"collection3\" transient=\"on\" loadOnStartup=\"false\" " +
- "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+ "<core name=\"collectionLazy3\" instanceDir=\"collection3\" transient=\"on\" loadOnStartup=\"false\" /> " +
- "<core name=\"collectionLazy4\" instanceDir=\"collection4\" transient=\"false\" loadOnStartup=\"false\" " +
- "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+ "<core name=\"collectionLazy4\" instanceDir=\"collection4\" transient=\"false\" loadOnStartup=\"false\" /> " +
- "<core name=\"collectionLazy5\" instanceDir=\"collection5\" transient=\"false\" loadOnStartup=\"true\" " +
- "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+ "<core name=\"collectionLazy5\" instanceDir=\"collection5\" transient=\"false\" loadOnStartup=\"true\" /> " +
- "<core name=\"collectionLazy6\" instanceDir=\"collection6\" transient=\"true\" loadOnStartup=\"false\" " +
- "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+ "<core name=\"collectionLazy6\" instanceDir=\"collection6\" transient=\"true\" loadOnStartup=\"false\" /> " +
- "<core name=\"collectionLazy7\" instanceDir=\"collection7\" transient=\"true\" loadOnStartup=\"false\" " +
- "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+ "<core name=\"collectionLazy7\" instanceDir=\"collection7\" transient=\"true\" loadOnStartup=\"false\" /> " +
- "<core name=\"collectionLazy8\" instanceDir=\"collection8\" transient=\"true\" loadOnStartup=\"false\" " +
- "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+ "<core name=\"collectionLazy8\" instanceDir=\"collection8\" transient=\"true\" loadOnStartup=\"false\" /> " +
- "<core name=\"collectionLazy9\" instanceDir=\"collection9\" transient=\"true\" loadOnStartup=\"false\" " +
- "config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
+ "<core name=\"collectionLazy9\" instanceDir=\"collection9\" transient=\"true\" loadOnStartup=\"false\" /> " +
"</cores> " +
"</solr>";
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java Wed Jul 3 23:26:32 2013
@@ -17,37 +17,173 @@ package org.apache.solr.core;
* limitations under the License.
*/
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.AtomicReader;
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.SegmentReader;
+import org.apache.lucene.index.SegmentInfo;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.MergePolicy;
import org.apache.lucene.index.TieredMergePolicy;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.util.RefCounted;
+import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.SolrTestCaseJ4;
-import org.junit.BeforeClass;
+import org.junit.After;
+import java.util.concurrent.atomic.AtomicInteger;
public class TestMergePolicyConfig extends SolrTestCaseJ4 {
+
+ private static AtomicInteger docIdCounter = new AtomicInteger(42);
+
+ @After
+ public void after() throws Exception {
+ deleteCore();
+ }
+
+ public void testDefaultMergePolicyConfig() throws Exception {
+ initCore("solrconfig-mergepolicy-defaults.xml","schema-minimal.xml");
+ IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
+ assertEquals(false, iwc.getUseCompoundFile());
+
+ TieredMergePolicy tieredMP = assertAndCast(TieredMergePolicy.class,
+ iwc.getMergePolicy());
+ assertEquals(0.0D, tieredMP.getNoCFSRatio(), 0.0D);
+
+ assertCommitSomeNewDocs();
+ assertCompoundSegments(h.getCore(), false);
+ }
+
+ public void testLegacyMergePolicyConfig() throws Exception {
+ final boolean expectCFS
+ = Boolean.parseBoolean(System.getProperty("useCompoundFile"));
- @BeforeClass
- public static void beforeClass() throws Exception {
- initCore("solrconfig-mergepolicy.xml","schema.xml");
+ initCore("solrconfig-mergepolicy-legacy.xml","schema-minimal.xml");
+ IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
+ assertEquals(expectCFS, iwc.getUseCompoundFile());
+
+
+ TieredMergePolicy tieredMP = assertAndCast(TieredMergePolicy.class,
+ iwc.getMergePolicy());
+
+ assertEquals(7, tieredMP.getMaxMergeAtOnce());
+ assertEquals(7.0D, tieredMP.getSegmentsPerTier(), 0.0D);
+ assertEquals(expectCFS ? 1.0D : 0.0D, tieredMP.getNoCFSRatio(), 0.0D);
+
+ assertCommitSomeNewDocs();
+ assertCompoundSegments(h.getCore(), expectCFS);
}
public void testTieredMergePolicyConfig() throws Exception {
+ final boolean expectCFS
+ = Boolean.parseBoolean(System.getProperty("useCompoundFile"));
+
+ initCore("solrconfig-mergepolicy.xml","schema-minimal.xml");
IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
- MergePolicy mp = iwc.getMergePolicy();
- assertTrue(mp instanceof TieredMergePolicy);
- TieredMergePolicy tieredMP = (TieredMergePolicy) mp;
+ assertEquals(expectCFS, iwc.getUseCompoundFile());
- // mp-specific setter
- assertEquals(19, tieredMP.getMaxMergeAtOnceExplicit());
-
- // make sure we apply compoundFile and mergeFactor
- assertEquals(false, tieredMP.getUseCompoundFile());
+
+ TieredMergePolicy tieredMP = assertAndCast(TieredMergePolicy.class,
+ iwc.getMergePolicy());
+
+ // set by legacy <mergeFactor> setting
assertEquals(7, tieredMP.getMaxMergeAtOnce());
- // make sure we overrode segmentsPerTier (split from maxMergeAtOnce out of mergeFactor)
+ // mp-specific setters
+ assertEquals(19, tieredMP.getMaxMergeAtOnceExplicit());
+ assertEquals(0.1D, tieredMP.getNoCFSRatio(), 0.0D);
+ // make sure we overrode segmentsPerTier
+ // (split from maxMergeAtOnce out of mergeFactor)
assertEquals(9D, tieredMP.getSegmentsPerTier(), 0.001);
- // make sure we overrode noCFSRatio (useless because we disabled useCompoundFile,
- // but just to make sure it works)
- assertEquals(1.0D, tieredMP.getNoCFSRatio(), 0.001);
+ assertCommitSomeNewDocs();
+ // even though we have a single segment (which is 100% of the size of
+ // the index which is higher then our 0.6D threashold) the
+ // compound ratio doesn't matter because the segment was never merged
+ assertCompoundSegments(h.getCore(), expectCFS);
+
+ assertCommitSomeNewDocs();
+ assertNumSegments(h.getCore(), 2);
+ assertCompoundSegments(h.getCore(), expectCFS);
+
+ assertU(optimize());
+ assertNumSegments(h.getCore(), 1);
+ // we've now forced a merge, and the MP ratio should be in play
+ assertCompoundSegments(h.getCore(), false);
+ }
+
+ /**
+ * Given a Type and an object asserts that the object is non-null and an
+ * instance of the specified Type. The object is then cast to that type and
+ * returned.
+ */
+ public static <T> T assertAndCast(Class<? extends T> clazz, Object o) {
+ assertNotNull(clazz);
+ assertNotNull(o);
+ assertTrue(clazz.isInstance(o));
+ return clazz.cast(o);
+ }
+
+ public static void assertCommitSomeNewDocs() {
+ for (int i = 0; i < 5; i++) {
+ int val = docIdCounter.getAndIncrement();
+ assertU(adoc("id", "" + val,
+ "a_s", val + "_" + val + "_" + val + "_" + val,
+ "b_s", val + "_" + val + "_" + val + "_" + val,
+ "c_s", val + "_" + val + "_" + val + "_" + val,
+ "d_s", val + "_" + val + "_" + val + "_" + val,
+ "e_s", val + "_" + val + "_" + val + "_" + val,
+ "f_s", val + "_" + val + "_" + val + "_" + val));
+ }
+ assertU(commit());
}
+
+ /**
+ * Given an SolrCore, asserts that the number of leave segments in
+ * the index reader matches the expected value.
+ */
+ public static void assertNumSegments(SolrCore core, int expected) {
+ RefCounted<SolrIndexSearcher> searcherRef = core.getRegisteredSearcher();
+ try {
+ assertEquals(expected, searcherRef.get().getIndexReader().leaves().size());
+ } finally {
+ searcherRef.decref();
+ }
+ }
+
+ /**
+ * Given an SolrCore, asserts that each segment in the (searchable) index
+ * has a compound file status that matches the expected input.
+ */
+ public static void assertCompoundSegments(SolrCore core, boolean compound) {
+ RefCounted<SolrIndexSearcher> searcherRef = core.getRegisteredSearcher();
+ try {
+ assertCompoundSegments(searcherRef.get().getIndexReader(), compound);
+ } finally {
+ searcherRef.decref();
+ }
+ }
+
+ /**
+ * Given an IndexReader, asserts that there is at least one AtomcReader leaf,
+ * and that all AtomicReader leaves are SegmentReader's that have a compound
+ * file status that matches the expected input.
+ */
+ private static void assertCompoundSegments(IndexReader reader,
+ boolean compound) {
+
+ assertNotNull("Null leaves", reader.leaves());
+ assertTrue("no leaves", 0 < reader.leaves().size());
+
+ for (AtomicReaderContext atomic : reader.leaves()) {
+ assertTrue("not a segment reader: " + atomic.reader().toString(),
+ atomic.reader() instanceof SegmentReader);
+
+ assertEquals("Compound status incorrect for: " +
+ atomic.reader().toString(),
+ compound,
+ ((SegmentReader)atomic.reader()).getSegmentInfo().info.getUseCompoundFile());
+ }
+ }
+
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java Wed Jul 3 23:26:32 2013
@@ -29,8 +29,7 @@ import java.io.File;
public class TestShardHandlerFactory extends SolrTestCaseJ4 {
public void testXML() throws Exception {
- CoreContainer cc = new CoreContainer(TEST_HOME());
- cc.load(TEST_HOME(), new File(TEST_HOME(), "solr-shardhandler.xml"));
+ CoreContainer cc = CoreContainer.createAndLoad(TEST_HOME(), new File(TEST_HOME(), "solr-shardhandler.xml"));
ShardHandlerFactory factory = cc.getShardHandlerFactory();
assertTrue(factory instanceof MockShardHandlerFactory);
NamedList args = ((MockShardHandlerFactory)factory).args;
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrIndexConfig.java Wed Jul 3 23:26:32 2013
@@ -19,6 +19,7 @@ package org.apache.solr.core;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.update.LoggingInfoStream;
import org.junit.BeforeClass;
public class TestSolrIndexConfig extends SolrTestCaseJ4 {
@@ -32,5 +33,6 @@ public class TestSolrIndexConfig extends
IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
assertEquals(123, iwc.getMaxThreadStates());
+ assertTrue(iwc.getInfoStream() instanceof LoggingInfoStream);
}
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrXMLSerializer.java Wed Jul 3 23:26:32 2013
@@ -143,6 +143,11 @@ public class TestSolrXMLSerializer exten
solrXMLDef.containerProperties = containerProperties ;
solrXMLDef.solrAttribs = rootSolrAttribs;
solrXMLDef.coresAttribs = coresAttribs;
+ solrXMLDef.loggingAttribs = new HashMap<String, String>();
+ solrXMLDef.shardHandlerProps = new HashMap<String, String>();
+ solrXMLDef.shardHandlerAttribs = new HashMap<String, String>();
+ solrXMLDef.loggingAttribs = new HashMap<String, String>();
+ solrXMLDef.watcherAttribs = new HashMap<String, String>();
return solrXMLDef;
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrXml.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrXml.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/core/TestSolrXml.java Wed Jul 3 23:26:32 2013
@@ -44,7 +44,7 @@ public class TestSolrXml extends SolrTes
boolean oldStyle = (config.getNode("solr/cores", false) != null);
ConfigSolr cfg;
if (oldStyle) {
- cfg = new ConfigSolrXmlOld(config, cc);
+ cfg = new ConfigSolrXmlOld(config);
} else {
cfg = new ConfigSolrXml(config, cc);
}
@@ -103,7 +103,7 @@ public class TestSolrXml extends SolrTes
boolean oldStyle = (config.getNode("solr/cores", false) != null);
ConfigSolr cfg;
if (oldStyle) {
- cfg = new ConfigSolrXmlOld(config, cc);
+ cfg = new ConfigSolrXmlOld(config);
} else {
cfg = new ConfigSolrXml(config, cc);
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java Wed Jul 3 23:26:32 2013
@@ -18,6 +18,7 @@
package org.apache.solr.handler;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
import org.apache.solr.common.util.ContentStreamBase;
@@ -30,7 +31,11 @@ import org.apache.solr.update.DeleteUpda
import org.apache.solr.update.processor.BufferingRequestProcessor;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.xml.sax.SAXException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.List;
import java.util.Map;
public class JsonLoaderTest extends SolrTestCaseJ4 {
@@ -236,6 +241,198 @@ public class JsonLoaderTest extends Solr
,"/response/docs/[0]=={'foo2_s':['hi','there']}"
);
}
+
+ @Test
+ public void testBooleanValuesInAdd() throws Exception {
+ String str = "{'add':[{'id':'1','b1':true,'b2':false,'b3':[false,true]}]}".replace('\'', '"');
+ SolrQueryRequest req = req();
+ SolrQueryResponse rsp = new SolrQueryResponse();
+ BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+ JsonLoader loader = new JsonLoader();
+ loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
+
+ assertEquals(1, p.addCommands.size());
+
+ AddUpdateCommand add = p.addCommands.get(0);
+ SolrInputDocument d = add.solrDoc;
+ SolrInputField f = d.getField("b1");
+ assertEquals(Boolean.TRUE, f.getValue());
+ f = d.getField("b2");
+ assertEquals(Boolean.FALSE, f.getValue());
+ f = d.getField("b3");
+ assertEquals(2, ((List)f.getValue()).size());
+ assertEquals(Boolean.FALSE, ((List)f.getValue()).get(0));
+ assertEquals(Boolean.TRUE, ((List)f.getValue()).get(1));
+
+ req.close();
+ }
+
+ @Test
+ public void testIntegerValuesInAdd() throws Exception {
+ String str = "{'add':[{'id':'1','i1':256,'i2':-5123456789,'i3':[0,1]}]}".replace('\'', '"');
+ SolrQueryRequest req = req();
+ SolrQueryResponse rsp = new SolrQueryResponse();
+ BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+ JsonLoader loader = new JsonLoader();
+ loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
+
+ assertEquals(1, p.addCommands.size());
+
+ AddUpdateCommand add = p.addCommands.get(0);
+ SolrInputDocument d = add.solrDoc;
+ SolrInputField f = d.getField("i1");
+ assertEquals(256L, f.getValue());
+ f = d.getField("i2");
+ assertEquals(-5123456789L, f.getValue());
+ f = d.getField("i3");
+ assertEquals(2, ((List)f.getValue()).size());
+ assertEquals(0L, ((List)f.getValue()).get(0));
+ assertEquals(1L, ((List)f.getValue()).get(1));
+
+ req.close();
+ }
+
+
+ @Test
+ public void testDecimalValuesInAdd() throws Exception {
+ String str = "{'add':[{'id':'1','d1':256.78,'d2':-5123456789.0,'d3':0.0,'d3':1.0,'d4':1.7E-10}]}".replace('\'', '"');
+ SolrQueryRequest req = req();
+ SolrQueryResponse rsp = new SolrQueryResponse();
+ BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+ JsonLoader loader = new JsonLoader();
+ loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
+
+ assertEquals(1, p.addCommands.size());
+
+ AddUpdateCommand add = p.addCommands.get(0);
+ SolrInputDocument d = add.solrDoc;
+ SolrInputField f = d.getField("d1");
+ assertEquals(256.78, f.getValue());
+ f = d.getField("d2");
+ assertEquals(-5123456789.0, f.getValue());
+ f = d.getField("d3");
+ assertEquals(2, ((List)f.getValue()).size());
+ assertTrue(((List)f.getValue()).contains(0.0));
+ assertTrue(((List) f.getValue()).contains(1.0));
+ f = d.getField("d4");
+ assertEquals(1.7E-10, f.getValue());
+
+ req.close();
+ }
+
+ @Test
+ public void testBigDecimalValuesInAdd() throws Exception {
+ String str = ("{'add':[{'id':'1','bd1':0.12345678901234567890123456789012345,"
+ + "'bd2':12345678901234567890.12345678901234567890,'bd3':0.012345678901234567890123456789012345,"
+ + "'bd3':123456789012345678900.012345678901234567890}]}").replace('\'', '"');
+ SolrQueryRequest req = req();
+ SolrQueryResponse rsp = new SolrQueryResponse();
+ BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+ JsonLoader loader = new JsonLoader();
+ loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
+
+ assertEquals(1, p.addCommands.size());
+
+ AddUpdateCommand add = p.addCommands.get(0);
+ SolrInputDocument d = add.solrDoc;
+ SolrInputField f = d.getField("bd1");
+ assertTrue(f.getValue() instanceof String);
+ assertEquals("0.12345678901234567890123456789012345", f.getValue());
+ f = d.getField("bd2");
+ assertTrue(f.getValue() instanceof String);
+ assertEquals("12345678901234567890.12345678901234567890", f.getValue());
+ f = d.getField("bd3");
+ assertEquals(2, ((List)f.getValue()).size());
+ assertTrue(((List)f.getValue()).contains("0.012345678901234567890123456789012345"));
+ assertTrue(((List)f.getValue()).contains("123456789012345678900.012345678901234567890"));
+
+ req.close();
+ }
+
+ @Test
+ public void testBigIntegerValuesInAdd() throws Exception {
+ String str = ("{'add':[{'id':'1','bi1':123456789012345678901,'bi2':1098765432109876543210,"
+ + "'bi3':[1234567890123456789012,10987654321098765432109]}]}").replace('\'', '"');
+ SolrQueryRequest req = req();
+ SolrQueryResponse rsp = new SolrQueryResponse();
+ BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+ JsonLoader loader = new JsonLoader();
+ loader.load(req, rsp, new ContentStreamBase.StringStream(str), p);
+
+ assertEquals(1, p.addCommands.size());
+
+ AddUpdateCommand add = p.addCommands.get(0);
+ SolrInputDocument d = add.solrDoc;
+ SolrInputField f = d.getField("bi1");
+ assertTrue(f.getValue() instanceof String);
+ assertEquals("123456789012345678901", f.getValue());
+ f = d.getField("bi2");
+ assertTrue(f.getValue() instanceof String);
+ assertEquals("1098765432109876543210", f.getValue());
+ f = d.getField("bi3");
+ assertEquals(2, ((List)f.getValue()).size());
+ assertTrue(((List)f.getValue()).contains("1234567890123456789012"));
+ assertTrue(((List)f.getValue()).contains("10987654321098765432109"));
+
+ req.close();
+ }
+
+
+ @Test
+ public void testAddNonStringValues() throws Exception {
+ // BigInteger and BigDecimal should be typed as strings, since there is no direct support for them
+ updateJ(("[{'id':'1','boolean_b':false,'long_l':19,'double_d':18.6,'big_integer_s':12345678901234567890,"
+ +" 'big_decimal_s':0.1234567890123456789012345}]").replace('\'', '"'), params("commit","true"));
+ assertJQ(req("q","id:1", "fl","boolean_b,long_l,double_d,big_integer_s,big_decimal_s")
+ ,"/response/docs/[0]=={'boolean_b':[false],'long_l':[19],'double_d':[18.6],"
+ +"'big_integer_s':['12345678901234567890'],"
+ +"'big_decimal_s':['0.1234567890123456789012345']}]}"
+ );
+ }
+
+
+ @Test
+ public void testAddBigIntegerValueToTrieField() throws Exception {
+ // Adding a BigInteger to a long field should fail
+ // BigInteger.longValue() returns only the low-order 64 bits.
+ try {
+ updateJ(("[{'id':'1','big_integer_tl':12345678901234567890}]").replace('\'', '"'), null);
+ fail("A BigInteger value should overflow a long field");
+ } catch (SolrException e) {
+ if ( ! (e.getCause() instanceof NumberFormatException)) {
+ throw e;
+ }
+ }
+
+ // Adding a BigInteger to an integer field should fail
+ // BigInteger.intValue() returns only the low-order 32 bits.
+ try {
+ updateJ(("[{'id':'1','big_integer_ti':12345678901234567890}]").replace('\'', '"'), null);
+ fail("A BigInteger value should overflow an integer field");
+ } catch (SolrException e) {
+ if ( ! (e.getCause() instanceof NumberFormatException)) {
+ throw e;
+ }
+ }
+
+ }
+
+ @Test
+ public void testAddBigDecimalValueToTrieField() throws Exception {
+ // Adding a BigDecimal to a double field should succeed by reducing precision
+ updateJ(("[{'id':'1','big_decimal_td':100000000000000000000000000001234567890.0987654321}]").replace('\'', '"'),
+ params("commit", "true"));
+ assertJQ(req("q","id:1", "fl","big_decimal_td"),
+ "/response/docs/[0]=={'big_decimal_td':[1.0E38]}"
+ );
+
+ // Adding a BigDecimal to a float field should succeed by reducing precision
+ updateJ(("[{'id':'2','big_decimal_tf':100000000000000000000000000001234567890.0987654321}]").replace('\'', '"'),
+ params("commit", "true"));
+ assertJQ(req("q","id:2", "fl","big_decimal_tf"),
+ "/response/docs/[0]=={'big_decimal_tf':[1.0E38]}"
+ );
+ }
// The delete syntax was both extended for simplification in 4.0
@Test
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java Wed Jul 3 23:26:32 2013
@@ -35,6 +35,7 @@ public class TestCSVLoader extends SolrT
@BeforeClass
public static void beforeClass() throws Exception {
+ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
initCore("solrconfig.xml","schema12.xml");
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Wed Jul 3 23:26:32 2013
@@ -103,7 +103,7 @@ public class TestReplicationHandler exte
super.setUp();
// System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
// For manual testing only
- // useFactory(null); // force an FS factory
+ // useFactory(null); // force an FS factory.
master = new SolrInstance("master", null);
master.setUp();
masterJetty = createJetty(master);
@@ -339,6 +339,40 @@ public class TestReplicationHandler exte
}
}
+
+ /**
+ * Verify that things still work if an IW has not been opened (and hence the CommitPoints have not been communicated to the deletion policy)
+ */
+ public void testNoWriter() throws Exception {
+ useFactory(null); // force a persistent directory
+
+ // stop and start so they see the new directory setting
+ slaveJetty.stop();
+ masterJetty.stop();
+ slaveJetty.start(true);
+ masterJetty.start(true);
+
+ index(slaveClient, "id", "123456");
+ slaveClient.commit();
+ slaveJetty.stop();
+ slaveJetty.start(true);
+
+ // Currently we open a writer on-demand. This is to test that we are correctly testing
+ // the code path when SolrDeletionPolicy.getLatestCommit() returns null.
+ // When we are using an ephemeral directory, an IW will always be opened to create the index and hence
+ // getLatestCommit will always be non-null.
+ CoreContainer cores = ((SolrDispatchFilter) slaveJetty.getDispatchFilter().getFilter()).getCores();
+ Collection<SolrCore> theCores = cores.getCores();
+ assertEquals(1, theCores.size());
+ SolrCore core = (SolrCore)theCores.toArray()[0];
+ assertNull( core.getDeletionPolicy().getLatestCommit() );
+
+
+ pullFromMasterToSlave(); // this will cause SnapPuller to be invoked and we will test when SolrDeletionPolicy.getLatestCommit() returns null
+
+ resetFactory();
+ }
+
/**
* Verify that empty commits and/or commits with openSearcher=false
* on the master do not cause subsequent replication problems on the slave
@@ -1507,7 +1541,7 @@ public class TestReplicationHandler exte
}
public String getDataDir() {
- return dataDir.toString();
+ return dataDir.getAbsolutePath();
}
public String getSolrConfigFile() {
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/admin/LoggingHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/admin/LoggingHandlerTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/admin/LoggingHandlerTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/admin/LoggingHandlerTest.java Wed Jul 3 23:26:32 2013
@@ -17,15 +17,22 @@
package org.apache.solr.handler.admin;
-import java.util.logging.Logger;
-
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.logging.jul.JulInfo;
+import org.apache.solr.logging.log4j.Log4jInfo;
import org.junit.BeforeClass;
import org.junit.Test;
+
public class LoggingHandlerTest extends SolrTestCaseJ4 {
+
+ // TODO: This only tests Log4j at the moment, as that's what's defined
+ // through the CoreContainer.
+
+ // TODO: Would be nice to throw an exception on trying to set a
+ // log level that doesn't exist
@BeforeClass
public static void beforeClass() throws Exception {
@@ -35,7 +42,8 @@ public class LoggingHandlerTest extends
@Test
public void testLogLevelHandlerOutput() throws Exception {
Logger tst = Logger.getLogger("org.apache.solr.SolrTestCaseJ4");
- JulInfo wrap = new JulInfo(tst.getName(), tst);
+ tst.setLevel(Level.INFO);
+ Log4jInfo wrap = new Log4jInfo(tst.getName(), tst);
assertQ("Show Log Levels OK",
req(CommonParams.QT,"/admin/logging")
@@ -46,8 +54,8 @@ public class LoggingHandlerTest extends
assertQ("Set and remove a level",
req(CommonParams.QT,"/admin/logging",
"set", "org.xxx.yyy.abc:null",
- "set", "org.xxx.yyy.zzz:FINEST")
- ,"//arr[@name='loggers']/lst/str[.='org.xxx.yyy.zzz']/../str[@name='level'][.='FINEST']"
+ "set", "org.xxx.yyy.zzz:TRACE")
+ ,"//arr[@name='loggers']/lst/str[.='org.xxx.yyy.zzz']/../str[@name='level'][.='TRACE']"
);
}
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java Wed Jul 3 23:26:32 2013
@@ -17,17 +17,18 @@
package org.apache.solr.handler.admin;
-import java.util.Arrays;
-import java.util.EnumSet;
-
import org.apache.solr.common.luke.FieldFlag;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.util.TestHarness;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import java.util.Arrays;
+import java.util.EnumSet;
+
/**
* :TODO: currently only tests some of the utilities in the LukeRequestHandler
*/
@@ -35,6 +36,7 @@ public class LukeRequestHandlerTest exte
@BeforeClass
public static void beforeClass() throws Exception {
+ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
initCore("solrconfig.xml", "schema12.xml");
}
@@ -155,7 +157,7 @@ public class LukeRequestHandlerTest exte
try {
// First, determine that the two fields ARE there
String response = h.query(req);
- assertNull(h.validateXPath(response,
+ assertNull(TestHarness.validateXPath(response,
getFieldXPathPrefix("solr_t") + "[@name='index']",
getFieldXPathPrefix("solr_s") + "[@name='index']"
));
@@ -164,7 +166,7 @@ public class LukeRequestHandlerTest exte
for (String f : Arrays.asList("solr_ti",
"solr_td", "solr_pl", "solr_dt", "solr_b")) {
- assertNotNull(h.validateXPath(response,
+ assertNotNull(TestHarness.validateXPath(response,
getFieldXPathPrefix(f) + "[@name='index']"));
}
@@ -174,7 +176,7 @@ public class LukeRequestHandlerTest exte
for (String f : Arrays.asList("solr_t", "solr_s", "solr_ti",
"solr_td", "solr_pl", "solr_dt", "solr_b")) {
- assertNull(h.validateXPath(response,
+ assertNull(TestHarness.validateXPath(response,
getFieldXPathPrefix(f) + "[@name='index']"));
}
} catch (Exception e) {
@@ -186,7 +188,7 @@ public class LukeRequestHandlerTest exte
SolrQueryRequest req = req("qt", "/admin/luke", "show", "schema");
String xml = h.query(req);
- String r = h.validateXPath
+ String r = TestHarness.validateXPath
(xml,
field("text") + "/arr[@name='copySources']/str[.='title']",
field("text") + "/arr[@name='copySources']/str[.='subject']",
@@ -216,7 +218,7 @@ public class LukeRequestHandlerTest exte
SolrQueryRequest req = req("qt", "/admin/luke", "show", "schema", "indent", "on");
String xml = h.query(req);
- String result = h.validateXPath(xml, field("bday") + "/arr[@name='copyDests']/str[.='catchall_t']");
+ String result = TestHarness.validateXPath(xml, field("bday") + "/arr[@name='copyDests']/str[.='catchall_t']");
assertNull(xml, result);
// Put back the configuration expected by the rest of the tests in this suite
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/BadComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/BadComponentTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/BadComponentTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/BadComponentTest.java Wed Jul 3 23:26:32 2013
@@ -19,7 +19,6 @@ package org.apache.solr.handler.componen
*/
import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.SolrException;
import org.junit.Test;
/**
@@ -34,14 +33,7 @@ public class BadComponentTest extends So
ignoreException(".*QueryElevationComponent.*");
System.setProperty("elevate.file", "foo.xml");
initCore("solrconfig-elevate.xml", "schema12.xml");
- assertTrue(false);
- } catch (RuntimeException e) {
- //TODO: better way of checking this?
- if (e.getCause() instanceof SolrException){
- assertTrue(true);
- } else {
- assertTrue(false);
- }
+ assertTrue(hasInitException("QueryElevationComponent"));
} finally {
System.clearProperty("elevate.file");
resetExceptionIgnores();
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java Wed Jul 3 23:26:32 2013
@@ -31,6 +31,7 @@ public class TermVectorComponentDistribu
handle.put("maxScore", SKIPVAL);
handle.put("score", SKIPVAL);
handle.put("[docid]", SKIPVAL);
+ handle.put("_version_", SKIPVAL); // not a cloud test, but may use updateLog
// SOLR-3720: TODO: TVC doesn't "merge" df and idf .. should it?
handle.put("df", SKIPVAL);
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java Wed Jul 3 23:26:32 2013
@@ -32,6 +32,7 @@ public class TermsComponentTest extends
@BeforeClass
public static void beforeTest() throws Exception {
+ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
initCore("solrconfig.xml","schema12.xml");
assertNull(h.validateUpdate(adoc("id", "0", "lowerfilt", "a", "standardfilt", "a", "foo_i","1")));
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/request/TestBinaryResponseWriter.java Wed Jul 3 23:26:32 2013
@@ -45,6 +45,7 @@ public class TestBinaryResponseWriter ex
@BeforeClass
public static void beforeClass() throws Exception {
+ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
initCore("solrconfig.xml", "schema12.xml");
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java Wed Jul 3 23:26:32 2013
@@ -32,6 +32,7 @@ import java.util.Arrays;
public class TestCSVResponseWriter extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
+ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
initCore("solrconfig.xml","schema12.xml");
createIndex();
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/NotRequiredUniqueKeyTest.java Wed Jul 3 23:26:32 2013
@@ -32,6 +32,7 @@ public class NotRequiredUniqueKeyTest ex
@BeforeClass
public static void beforeTests() throws Exception {
+ System.setProperty("enable.update.log", "false"); // usecase doesn't work with updateLog
initCore("solrconfig.xml","schema-not-required-unique-key.xml");
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/PrimitiveFieldTypeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/PrimitiveFieldTypeTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/PrimitiveFieldTypeTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/PrimitiveFieldTypeTest.java Wed Jul 3 23:26:32 2013
@@ -40,6 +40,7 @@ public class PrimitiveFieldTypeTest exte
public void setUp() throws Exception {
super.setUp();
// set some system properties for use by tests
+ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
@@ -58,11 +59,9 @@ public class PrimitiveFieldTypeTest exte
TrieIntField ti;
SortableIntField si;
LongField l;
- ShortField sf;
FloatField f;
DoubleField d;
BoolField b;
- ByteField bf;
// ***********************
@@ -94,10 +93,6 @@ public class PrimitiveFieldTypeTest exte
l.init(schema, initMap);
assertFalse(l.hasProperty(FieldType.OMIT_NORMS));
- sf = new ShortField();
- sf.init(schema, initMap);
- assertFalse(sf.hasProperty(FieldType.OMIT_NORMS));
-
f = new FloatField();
f.init(schema, initMap);
assertFalse(f.hasProperty(FieldType.OMIT_NORMS));
@@ -114,10 +109,6 @@ public class PrimitiveFieldTypeTest exte
b.init(schema, initMap);
assertFalse(b.hasProperty(FieldType.OMIT_NORMS));
- bf = new ByteField();
- bf.init(schema, initMap);
- assertFalse(bf.hasProperty(FieldType.OMIT_NORMS));
-
// Non-primitive fields
t = new TextField();
t.init(schema, initMap);
@@ -156,10 +147,6 @@ public class PrimitiveFieldTypeTest exte
l.init(schema, initMap);
assertTrue(l.hasProperty(FieldType.OMIT_NORMS));
- sf = new ShortField();
- sf.init(schema, initMap);
- assertTrue(sf.hasProperty(FieldType.OMIT_NORMS));
-
f = new FloatField();
f.init(schema, initMap);
assertTrue(f.hasProperty(FieldType.OMIT_NORMS));
@@ -176,10 +163,6 @@ public class PrimitiveFieldTypeTest exte
b.init(schema, initMap);
assertTrue(b.hasProperty(FieldType.OMIT_NORMS));
- bf = new ByteField();
- bf.init(schema, initMap);
- assertTrue(bf.hasProperty(FieldType.OMIT_NORMS));
-
// Non-primitive fields
t = new TextField();
t.init(schema, initMap);
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/TestCollationField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/TestCollationField.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/TestCollationField.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/TestCollationField.java Wed Jul 3 23:26:32 2013
@@ -74,6 +74,7 @@ public class TestCollationField extends
// copy over configuration files
FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-basic.xml"), new File(confDir, "solrconfig.xml"));
+ FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig.snippet.randomindexconfig.xml"), new File(confDir, "solrconfig.snippet.randomindexconfig.xml"));
FileUtils.copyFile(getFile("solr/collection1/conf/schema-collate.xml"), new File(confDir, "schema.xml"));
// generate custom collation rules (DIN 5007-2), saving to customrules.dat
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java Wed Jul 3 23:26:32 2013
@@ -55,7 +55,9 @@ public class TestManagedSchema extends A
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "solrconfig-mutable-managed-schema.xml"), tmpConfDir);
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "solrconfig-managed-schema.xml"), tmpConfDir);
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "solrconfig-basic.xml"), tmpConfDir);
+ FileUtils.copyFileToDirectory(new File(testHomeConfDir, "solrconfig.snippet.randomindexconfig.xml"), tmpConfDir);
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "schema-one-field-no-dynamic-field.xml"), tmpConfDir);
+ FileUtils.copyFileToDirectory(new File(testHomeConfDir, "schema-one-field-no-dynamic-field-unique-key.xml"), tmpConfDir);
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "schema-minimal.xml"), tmpConfDir);
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "schema_codec.xml"), tmpConfDir);
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "schema-bm25.xml"), tmpConfDir);
@@ -385,4 +387,39 @@ public class TestManagedSchema extends A
assertQ(req(fieldName + ":thing"), "//*[@numFound='1']");
}
+ public void testPersistUniqueKey() throws Exception {
+ assertSchemaResource(collection, "managed-schema");
+ deleteCore();
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema");
+ assertTrue(managedSchemaFile.delete()); // Delete managed-schema so it won't block parsing a new schema
+ initCore("solrconfig-mutable-managed-schema.xml", "schema-one-field-no-dynamic-field-unique-key.xml", tmpSolrHome.getPath());
+
+ assertTrue(managedSchemaFile.exists());
+ String managedSchemaContents = FileUtils.readFileToString(managedSchemaFile, "UTF-8");
+ assertFalse(managedSchemaContents.contains("\"new_field\""));
+
+ Map<String,Object> options = new HashMap<String,Object>();
+ options.put("stored", "false");
+ IndexSchema oldSchema = h.getCore().getLatestSchema();
+ assertEquals("str", oldSchema.getUniqueKeyField().getName());
+ String fieldName = "new_field";
+ String fieldType = "string";
+ SchemaField newField = oldSchema.newField(fieldName, fieldType, options);
+ IndexSchema newSchema = oldSchema.addField(newField);
+ assertEquals("str", newSchema.getUniqueKeyField().getName());
+ h.getCore().setLatestSchema(newSchema);
+ log.info("####close harness");
+ h.close();
+ log.info("####close harness end");
+ initCore();
+
+ assertTrue(managedSchemaFile.exists());
+ FileInputStream stream = new FileInputStream(managedSchemaFile);
+ managedSchemaContents = IOUtils.toString(stream, "UTF-8");
+ stream.close(); // Explicitly close so that Windows can delete this file
+ assertTrue(managedSchemaContents.contains("<field name=\"new_field\" type=\"string\" stored=\"false\"/>"));
+ IndexSchema newNewSchema = h.getCore().getLatestSchema();
+ assertNotNull(newNewSchema.getUniqueKeyField());
+ assertEquals("str", newNewSchema.getUniqueKeyField().getName());
+ }
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java Wed Jul 3 23:26:32 2013
@@ -47,6 +47,7 @@ public class ReturnFieldsTest extends So
@BeforeClass
public static void beforeClass() throws Exception {
+ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
initCore("solrconfig.xml", "schema12.xml");
String v = "how now brown cow";
assertU(adoc("id","1", "text",v, "text_np", v, "#foo_s", v));
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java Wed Jul 3 23:26:32 2013
@@ -41,6 +41,7 @@ public class TestExtendedDismaxParser ex
@BeforeClass
public static void beforeClass() throws Exception {
+ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
initCore("solrconfig.xml", "schema12.xml");
index();
}
Modified: lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/TestFiltering.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/TestFiltering.java?rev=1499601&r1=1499600&r2=1499601&view=diff
==============================================================================
--- lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/TestFiltering.java (original)
+++ lucene/dev/branches/security/solr/core/src/test/org/apache/solr/search/TestFiltering.java Wed Jul 3 23:26:32 2013
@@ -31,6 +31,7 @@ public class TestFiltering extends SolrT
@BeforeClass
public static void beforeTests() throws Exception {
+ System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
initCore("solrconfig.xml","schema12.xml");
}