You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/07/19 17:59:32 UTC
svn commit: r1363400 [28/31] - in /lucene/dev/branches/pforcodec_3892: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/
dev-tools/idea/.idea/copyright/ dev-tools/idea/.idea/libraries/
dev-tools/idea/lucene/ dev-tools/maven/ dev-tools/maven/lucene...
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHTMLStripCharFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHTMLStripCharFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHTMLStripCharFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHTMLStripCharFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -38,7 +38,7 @@ public class TestHTMLStripCharFilterFact
Map<String,String> args = new HashMap<String,String>();
args.put("escapedTags", "a, Title");
factory.init(args);
- CharStream cs = factory.create(CharReader.get(new StringReader(text)));
+ CharFilter cs = factory.create(new StringReader(text));
TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
assertTokenStreamContents(ts,
new String[] { "this", "is", "only", "a", "test." },
@@ -53,7 +53,7 @@ public class TestHTMLStripCharFilterFact
HTMLStripCharFilterFactory factory = new HTMLStripCharFilterFactory();
Map<String,String> args = new HashMap<String,String>();
factory.init(args);
- CharStream cs = factory.create(CharReader.get(new StringReader(text)));
+ CharFilter cs = factory.create(new StringReader(text));
TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
assertTokenStreamContents(ts,
new String[] { "this", "is", "only", "a", "test." },
@@ -69,7 +69,7 @@ public class TestHTMLStripCharFilterFact
Map<String,String> args = new HashMap<String,String>();
args.put("escapedTags", "U i");
factory.init(args);
- CharStream cs = factory.create(CharReader.get(new StringReader(text)));
+ CharFilter cs = factory.create(new StringReader(text));
TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
assertTokenStreamContents(ts,
new String[] { "<u>this</u>", "is", "only", "a", "<I>test</I>." },
@@ -85,7 +85,7 @@ public class TestHTMLStripCharFilterFact
Map<String,String> args = new HashMap<String,String>();
args.put("escapedTags", ",, , ");
factory.init(args);
- CharStream cs = factory.create(CharReader.get(new StringReader(text)));
+ CharFilter cs = factory.create(new StringReader(text));
TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
assertTokenStreamContents(ts,
new String[] { "this", "is", "only", "a", "test." },
@@ -101,7 +101,7 @@ public class TestHTMLStripCharFilterFact
Map<String,String> args = new HashMap<String,String>();
args.put("escapedTags", "");
factory.init(args);
- CharStream cs = factory.create(CharReader.get(new StringReader(text)));
+ CharFilter cs = factory.create(new StringReader(text));
TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
assertTokenStreamContents(ts,
new String[] { "this", "is", "only", "a", "test." },
@@ -117,7 +117,7 @@ public class TestHTMLStripCharFilterFact
Map<String,String> args = new HashMap<String,String>();
args.put("escapedTags", ", B\r\n\t");
factory.init(args);
- CharStream cs = factory.create(CharReader.get(new StringReader(text)));
+ CharFilter cs = factory.create(new StringReader(text));
TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
assertTokenStreamContents(ts,
new String[] { "this", "is", "<b>only</b>", "a", "test." },
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHunspellStemFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHunspellStemFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHunspellStemFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHunspellStemFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -39,7 +39,7 @@ public class TestHunspellStemFilterFacto
args.put("affix", "hunspell-test.aff");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
- factory.inform(new SolrResourceLoader("solr"));
+ factory.inform(new SolrResourceLoader("solr/collection1"));
Reader reader = new StringReader("abc");
TokenStream stream = factory.create(new MockTokenizer(reader, MockTokenizer.WHITESPACE, false));
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHyphenationCompoundWordTokenFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHyphenationCompoundWordTokenFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHyphenationCompoundWordTokenFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestHyphenationCompoundWordTokenFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -40,7 +40,7 @@ public class TestHyphenationCompoundWord
Reader reader = new StringReader("min veninde som er lidt af en læsehest");
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
HyphenationCompoundWordTokenFilterFactory factory = new HyphenationCompoundWordTokenFilterFactory();
- ResourceLoader loader = new SolrResourceLoader(null, null);
+ ResourceLoader loader = new SolrResourceLoader("solr/collection1");
Map<String,String> args = new HashMap<String,String>();
args.put("hyphenator", "da_UTF8.xml");
args.put("dictionary", "da_compoundDictionary.txt");
@@ -64,7 +64,7 @@ public class TestHyphenationCompoundWord
Reader reader = new StringReader("basketballkurv");
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
HyphenationCompoundWordTokenFilterFactory factory = new HyphenationCompoundWordTokenFilterFactory();
- ResourceLoader loader = new SolrResourceLoader(null, null);
+ ResourceLoader loader = new SolrResourceLoader("solr/collection1");
Map<String,String> args = new HashMap<String,String>();
args.put("hyphenator", "da_UTF8.xml");
args.put("minSubwordSize", "2");
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestJapaneseTokenizerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestJapaneseTokenizerFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestJapaneseTokenizerFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestJapaneseTokenizerFactory.java Thu Jul 19 15:58:54 2012
@@ -74,7 +74,10 @@ public class TestJapaneseTokenizerFactor
new String[] { "ã·ãã¢ã½ããã¦ã§ã¢ã¨ã³ã¸ãã¢" }
);
}
-
+
+ /**
+ * Test user dictionary
+ */
public void testUserDict() throws IOException {
String userDict =
"# Custom segmentation for long entries\n" +
@@ -92,4 +95,25 @@ public class TestJapaneseTokenizerFactor
new String[] { "é¢è¥¿", "å½é", "空港", "ã«", "è¡ã£", "ã" }
);
}
+
+ /**
+ * Test preserving punctuation
+ */
+ public void testPreservePunctuation() throws IOException {
+ JapaneseTokenizerFactory factory = new JapaneseTokenizerFactory();
+ Map<String,String> args = new HashMap<String,String>();
+ args.put("discardPunctuation", "false");
+ factory.init(args);
+ factory.inform(new SolrResourceLoader(null, null));
+ TokenStream ts = factory.create(
+ new StringReader("ä»ãã«ã¦ã§ã¼ã«ãã¾ãããæ¥é±ã®é æ¥æ¬ã«æ»ãã¾ãã楽ãã¿ã«ãã¦ãã¾ãï¼ã寿å¸ãé£ã¹ãããªããã")
+ );
+ System.out.println(ts.toString());
+ assertTokenStreamContents(ts,
+ new String[] { "ä»", "ãã«ã¦ã§ã¼", "ã«", "ã", "ã¾ã", "ã", "ã",
+ "æ¥é±", "ã®", "é ", "æ¥æ¬", "ã«", "æ»ã", "ã¾ã", "ã",
+ "楽ãã¿", "ã«", "ã", "ã¦", "ã", "ã¾ã", "ï¼",
+ "ã", "寿å¸", "ã", "é£ã¹", "ãã", "ãª", "ã", "ã", "ã"}
+ );
+ }
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestKeepFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestKeepFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestKeepFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestKeepFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -31,7 +31,7 @@ import java.util.HashMap;
public class TestKeepFilterFactory extends BaseTokenStreamTestCase {
public void testInform() throws Exception {
- ResourceLoader loader = new SolrResourceLoader(null, null);
+ ResourceLoader loader = new SolrResourceLoader("solr/collection1");
assertTrue("loader is null and it shouldn't be", loader != null);
KeepWordFilterFactory factory = new KeepWordFilterFactory();
Map<String, String> args = new HashMap<String, String>();
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestKeywordMarkerFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestKeywordMarkerFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestKeywordMarkerFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestKeywordMarkerFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -40,7 +40,7 @@ public class TestKeywordMarkerFilterFact
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
KeywordMarkerFilterFactory factory = new KeywordMarkerFilterFactory();
Map<String,String> args = new HashMap<String,String>();
- ResourceLoader loader = new SolrResourceLoader(null, null);
+ ResourceLoader loader = new SolrResourceLoader("solr/collection1");
args.put("protected", "protwords.txt");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
@@ -55,7 +55,7 @@ public class TestKeywordMarkerFilterFact
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
KeywordMarkerFilterFactory factory = new KeywordMarkerFilterFactory();
Map<String,String> args = new HashMap<String,String>();
- ResourceLoader loader = new SolrResourceLoader(null, null);
+ ResourceLoader loader = new SolrResourceLoader("solr/collection1");
args.put("protected", "protwords.txt");
args.put("ignoreCase", "true");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestPatternReplaceCharFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestPatternReplaceCharFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestPatternReplaceCharFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestPatternReplaceCharFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -39,8 +39,8 @@ public class TestPatternReplaceCharFilte
args.put("pattern", "(aa)\\s+(bb)\\s+(cc)");
args.put("replacement", "$1$2$3");
factory.init(args);
- CharStream cs = factory.create(
- CharReader.get( new StringReader( BLOCK ) ) );
+ CharFilter cs = factory.create(
+ new StringReader( BLOCK ) );
TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
assertTokenStreamContents(ts,
new String[] { "this", "is", "test." },
@@ -56,8 +56,8 @@ public class TestPatternReplaceCharFilte
Map<String,String> args = new HashMap<String,String>();
args.put("pattern", "(aa)\\s+(bb)\\s+(cc)");
factory.init(args);
- CharStream cs = factory.create(
- CharReader.get( new StringReader( BLOCK ) ) );
+ CharFilter cs = factory.create(
+ new StringReader( BLOCK ) );
TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
ts.reset();
assertFalse(ts.incrementToken());
@@ -75,8 +75,8 @@ public class TestPatternReplaceCharFilte
args.put("pattern", "(aa)\\s+(bb)\\s+(cc)");
args.put("replacement", "$1#$2#$3");
factory.init(args);
- CharStream cs = factory.create(
- CharReader.get( new StringReader( BLOCK ) ) );
+ CharFilter cs = factory.create(
+ new StringReader( BLOCK ) );
TokenStream ts = new MockTokenizer(cs, MockTokenizer.WHITESPACE, false);
assertTokenStreamContents(ts,
new String[] { "aa#bb#cc" },
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestPhoneticFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestPhoneticFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestPhoneticFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestPhoneticFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -27,11 +27,13 @@ import org.apache.lucene.analysis.BaseTo
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.util.LuceneTestCase.Slow;
/**
*
*/
+@Slow
public class TestPhoneticFilterFactory extends BaseTokenStreamTestCase {
private static final int REPEATS = 100000;
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestStemmerOverrideFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestStemmerOverrideFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestStemmerOverrideFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestStemmerOverrideFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -41,7 +41,7 @@ public class TestStemmerOverrideFilterFa
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
StemmerOverrideFilterFactory factory = new StemmerOverrideFilterFactory();
Map<String,String> args = new HashMap<String,String>();
- ResourceLoader loader = new SolrResourceLoader(null, null);
+ ResourceLoader loader = new SolrResourceLoader("solr/collection1");
args.put("dictionary", "stemdict.txt");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
@@ -56,7 +56,7 @@ public class TestStemmerOverrideFilterFa
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
StemmerOverrideFilterFactory factory = new StemmerOverrideFilterFactory();
Map<String,String> args = new HashMap<String,String>();
- ResourceLoader loader = new SolrResourceLoader(null, null);
+ ResourceLoader loader = new SolrResourceLoader("solr/collection1");
args.put("dictionary", "stemdict.txt");
args.put("ignoreCase", "true");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestStopFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestStopFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestStopFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestStopFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -32,7 +32,7 @@ import java.util.HashMap;
public class TestStopFilterFactory extends BaseTokenStreamTestCase {
public void testInform() throws Exception {
- ResourceLoader loader = new SolrResourceLoader(null, null);
+ ResourceLoader loader = new SolrResourceLoader("solr/collection1");
assertTrue("loader is null and it shouldn't be", loader != null);
StopFilterFactory factory = new StopFilterFactory();
Map<String, String> args = new HashMap<String, String>();
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestSynonymFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestSynonymFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestSynonymFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestSynonymFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -41,7 +41,7 @@ public class TestSynonymFilterFactory ex
args.put("synonyms", "synonyms.txt");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
- factory.inform(new SolrResourceLoader(null, null));
+ factory.inform(new SolrResourceLoader("solr/collection1"));
TokenStream ts = factory.create(new MockTokenizer(new StringReader("GB"), MockTokenizer.WHITESPACE, false));
assertTrue(ts instanceof SynonymFilter);
assertTokenStreamContents(ts,
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestTypeTokenFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestTypeTokenFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestTypeTokenFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestTypeTokenFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -35,7 +35,7 @@ public class TestTypeTokenFilterFactory
@Test
public void testInform() throws Exception {
- ResourceLoader loader = new SolrResourceLoader(null, null);
+ ResourceLoader loader = new SolrResourceLoader("solr/collection1");
TypeTokenFilterFactory factory = new TypeTokenFilterFactory();
Map<String, String> args = new HashMap<String, String>();
args.put("types", "stoptypes-1.txt");
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestWordDelimiterFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestWordDelimiterFilterFactory.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestWordDelimiterFilterFactory.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/analysis/TestWordDelimiterFilterFactory.java Thu Jul 19 15:58:54 2012
@@ -197,7 +197,7 @@ public class TestWordDelimiterFilterFact
public void testCustomTypes() throws Exception {
String testText = "I borrowed $5,400.00 at 25% interest-rate";
WordDelimiterFilterFactory factoryDefault = new WordDelimiterFilterFactory();
- ResourceLoader loader = new SolrResourceLoader(null, null);
+ ResourceLoader loader = new SolrResourceLoader("solr/collection1");
Map<String,String> args = new HashMap<String,String>();
args.put("generateWordParts", "1");
args.put("generateNumberParts", "1");
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/AbstractDistributedZkTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/AbstractDistributedZkTestCase.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/AbstractDistributedZkTestCase.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/AbstractDistributedZkTestCase.java Thu Jul 19 15:58:54 2012
@@ -19,7 +19,9 @@ package org.apache.solr.cloud;
import java.io.File;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.commons.io.FileUtils;
import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.common.cloud.CloudState;
@@ -31,12 +33,20 @@ import org.apache.solr.servlet.SolrDispa
import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.Before;
+import org.junit.BeforeClass;
public abstract class AbstractDistributedZkTestCase extends BaseDistributedSearchTestCase {
protected static final String DEFAULT_COLLECTION = "collection1";
private static final boolean DEBUG = false;
protected ZkTestServer zkServer;
+ private AtomicInteger homeCount = new AtomicInteger();
+
+ @BeforeClass
+ public static void beforeThisClass() throws Exception {
+ useFactory(null);
+ }
+
@Before
@Override
@@ -52,9 +62,8 @@ public abstract class AbstractDistribute
System.setProperty("zkHost", zkServer.getZkAddress());
System.setProperty("enable.update.log", "true");
System.setProperty("remove.version.field", "true");
- System
- .setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
-
+
+
AbstractZkTestCase.buildZooKeeper(zkServer.getZkHost(), zkServer.getZkAddress(), "solrconfig.xml", "schema.xml");
// set some system properties for use by tests
@@ -64,15 +73,22 @@ public abstract class AbstractDistribute
@Override
protected void createServers(int numShards) throws Exception {
+ // give everyone there own solrhome
+ File controlHome = new File(new File(getSolrHome()).getParentFile(), "control" + homeCount.incrementAndGet());
+ FileUtils.copyDirectory(new File(getSolrHome()), controlHome);
+
System.setProperty("collection", "control_collection");
- controlJetty = createJetty(testDir, testDir + "/control/data", "control_shard");
+ controlJetty = createJetty(controlHome, null, "control_shard");
System.clearProperty("collection");
controlClient = createNewSolrServer(controlJetty.getLocalPort());
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= numShards; i++) {
if (sb.length() > 0) sb.append(',');
- JettySolrRunner j = createJetty(testDir, testDir + "/jetty" + i, "shard" + (i + 2));
+ // give everyone there own solrhome
+ File jettyHome = new File(new File(getSolrHome()).getParentFile(), "jetty" + homeCount.incrementAndGet());
+ FileUtils.copyDirectory(new File(getSolrHome()), jettyHome);
+ JettySolrRunner j = createJetty(jettyHome, null, "shard" + (i + 2));
jettys.add(j);
clients.add(createNewSolrServer(j.getLocalPort()));
sb.append("localhost:").append(j.getLocalPort()).append(context);
@@ -123,7 +139,7 @@ public abstract class AbstractDistribute
}
}
}
- if (!sawLiveRecovering || cnt == 120) {
+ if (!sawLiveRecovering || cnt == 520) {
if (!sawLiveRecovering) {
if (verbose) System.out.println("no one is recoverying");
} else {
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/AbstractZkTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/AbstractZkTestCase.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/AbstractZkTestCase.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/AbstractZkTestCase.java Thu Jul 19 15:58:54 2012
@@ -101,7 +101,7 @@ public abstract class AbstractZkTestCase
private static void putConfig(SolrZkClient zkClient, final String name)
throws Exception {
- zkClient.makePath("/configs/conf1/" + name, getFile("solr"
+ zkClient.makePath("/configs/conf1/" + name, getFile("solr" + File.separator + "collection1"
+ File.separator + "conf" + File.separator + name), false, true);
}
@@ -147,11 +147,7 @@ public abstract class AbstractZkTestCase
static void tryCleanPath(String zkHost, String path) throws Exception {
SolrZkClient zkClient = new SolrZkClient(zkHost, TIMEOUT);
if (zkClient.exists(path, true)) {
- List<String> children = zkClient.getChildren(path, null, true);
- for (String string : children) {
- tryCleanPath(zkHost, path+"/"+string);
- }
- zkClient.delete(path, -1, true);
+ zkClient.clean(path);
}
zkClient.close();
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java Thu Jul 19 15:58:54 2012
@@ -23,8 +23,10 @@ import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
@@ -34,9 +36,8 @@ import java.util.concurrent.SynchronousQ
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.noggit.JSONUtil;
-import org.apache.noggit.ObjectBuilder;
+import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.lucene.util._TestUtil;
import org.apache.solr.JSONTestUtil;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest;
@@ -46,20 +47,25 @@ import org.apache.solr.client.solrj.impl
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest.Create;
import org.apache.solr.client.solrj.request.QueryRequest;
-import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
+import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.cloud.CloudState;
import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.cloud.ZkCoreNodeProps;
+import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.UpdateParams;
-import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.update.SolrCmdDistributor.Request;
import org.apache.solr.util.DefaultSolrThreadFactory;
@@ -67,7 +73,7 @@ import org.apache.solr.util.DefaultSolrT
/**
*
*/
-// @LuceneTestCase.AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-2161")
+@Slow
public class BasicDistributedZkTest extends AbstractDistributedZkTestCase {
private static final String DEFAULT_COLLECTION = "collection1";
@@ -288,7 +294,8 @@ public class BasicDistributedZkTest exte
// on shards with matches.
// query("q","matchesnothing","fl","*,score", "debugQuery", "true");
-
+ // would be better if these where all separate tests - but much, much
+ // slower
doOptimisticLockingAndUpdating();
testMultipleCollections();
testANewCollectionInOneInstance();
@@ -298,6 +305,8 @@ public class BasicDistributedZkTest exte
testUpdateProcessorsRunOnlyOnce("distrib-dup-test-chain-explicit");
testUpdateProcessorsRunOnlyOnce("distrib-dup-test-chain-implicit");
+
+ testCollectionsAPI();
// Thread.sleep(10000000000L);
if (DEBUG) {
@@ -305,6 +314,287 @@ public class BasicDistributedZkTest exte
}
}
+ private void testCollectionsAPI() throws Exception {
+
+ // TODO: fragile - because we dont pass collection.confName, it will only
+ // find a default if a conf set with a name matching the collection name is found, or
+ // if there is only one conf set. That and the fact that other tests run first in this
+ // env make this pretty fragile
+
+ // create new collections rapid fire
+ Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
+ int cnt = atLeast(3);
+ for (int i = 0; i < cnt; i++) {
+ ModifiableSolrParams params = new ModifiableSolrParams();
+ params.set("action", CollectionAction.CREATE.toString());
+ int numShards = _TestUtil.nextInt(random(), 0, shardCount) + 1;
+ int numReplicas = _TestUtil.nextInt(random(), 0, 5) + 1;
+ params.set("numShards", numShards);
+ params.set("numReplicas", numReplicas);
+ String collectionName = "awholynewcollection_" + i;
+ int clientIndex = random().nextInt(2);
+ List<Integer> list = new ArrayList<Integer>();
+ list.add(numShards);
+ list.add(numReplicas);
+ collectionInfos.put(collectionName, list);
+ params.set("name", collectionName);
+ SolrRequest request = new QueryRequest(params);
+ request.setPath("/admin/collections");
+
+ clients.get(clientIndex).request(request);
+ }
+
+ Set<Entry<String,List<Integer>>> collectionInfosEntrySet = collectionInfos.entrySet();
+ for (Entry<String,List<Integer>> entry : collectionInfosEntrySet) {
+ String collection = entry.getKey();
+ List<Integer> list = entry.getValue();
+ checkForCollection(collection, list.get(0));
+
+ String url = getUrlFromZk(collection);
+
+ HttpSolrServer collectionClient = new HttpSolrServer(url);
+
+ // poll for a second - it can take a moment before we are ready to serve
+ waitForNon404(collectionClient);
+ }
+
+ List<String> collectionNameList = new ArrayList<String>();
+ collectionNameList.addAll(collectionInfos.keySet());
+ String collectionName = collectionNameList.get(random().nextInt(collectionNameList.size()));
+
+ String url = getUrlFromZk(collectionName);
+
+ HttpSolrServer collectionClient = new HttpSolrServer(url);
+
+
+ // lets try and use the solrj client to index and retrieve a couple documents
+ SolrInputDocument doc1 = getDoc(id, 6, i1, -600, tlong, 600, t1,
+ "humpty dumpy sat on a wall");
+ SolrInputDocument doc2 = getDoc(id, 7, i1, -600, tlong, 600, t1,
+ "humpty dumpy3 sat on a walls");
+ SolrInputDocument doc3 = getDoc(id, 8, i1, -600, tlong, 600, t1,
+ "humpty dumpy2 sat on a walled");
+
+ collectionClient.add(doc1);
+
+ collectionClient.add(doc2);
+
+ collectionClient.add(doc3);
+
+ collectionClient.commit();
+
+ assertEquals(3, collectionClient.query(new SolrQuery("*:*")).getResults().getNumFound());
+
+ // lets try a collection reload
+
+ // get core open times
+ Map<String,Long> urlToTimeBefore = new HashMap<String,Long>();
+ collectStartTimes(collectionName, urlToTimeBefore);
+ assertTrue(urlToTimeBefore.size() > 0);
+ ModifiableSolrParams params = new ModifiableSolrParams();
+ params.set("action", CollectionAction.RELOAD.toString());
+ params.set("name", collectionName);
+ QueryRequest request = new QueryRequest(params);
+ request.setPath("/admin/collections");
+
+ // we can use this client because we just want base url
+ clients.get(0).request(request);
+
+ // reloads make take a short while
+ boolean allTimesAreCorrect = waitForReloads(collectionName, urlToTimeBefore);
+ assertTrue("some core start times did not change on reload", allTimesAreCorrect);
+
+ // remove a collection
+ params = new ModifiableSolrParams();
+ params.set("action", CollectionAction.DELETE.toString());
+ params.set("name", collectionName);
+ request = new QueryRequest(params);
+ request.setPath("/admin/collections");
+
+ clients.get(0).request(request);
+
+ // ensure its out of the state
+ checkForMissingCollection(collectionName);
+
+ }
+
+ private boolean waitForReloads(String collectionName, Map<String,Long> urlToTimeBefore) throws SolrServerException, IOException {
+
+
+ long timeoutAt = System.currentTimeMillis() + 30000;
+
+ boolean allTimesAreCorrect = false;
+ while (System.currentTimeMillis() < timeoutAt) {
+ Map<String,Long> urlToTimeAfter = new HashMap<String,Long>();
+ collectStartTimes(collectionName, urlToTimeAfter);
+
+ boolean retry = false;
+ Set<Entry<String,Long>> entries = urlToTimeBefore.entrySet();
+ for (Entry<String,Long> entry : entries) {
+ Long beforeTime = entry.getValue();
+ Long afterTime = urlToTimeAfter.get(entry.getKey());
+ assertNotNull(afterTime);
+ if (afterTime <= beforeTime) {
+ retry = true;
+ break;
+ }
+
+ }
+ if (!retry) {
+ allTimesAreCorrect = true;
+ break;
+ }
+ }
+ return allTimesAreCorrect;
+ }
+
+ private void collectStartTimes(String collectionName,
+ Map<String,Long> urlToTime) throws SolrServerException, IOException {
+ Map<String,Map<String,Slice>> collections = solrj.getZkStateReader()
+ .getCloudState().getCollectionStates();
+ if (collections.containsKey(collectionName)) {
+ Map<String,Slice> slices = collections.get(collectionName);
+
+ Iterator<Entry<String,Slice>> it = slices.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String,Slice> sliceEntry = it.next();
+ Map<String,ZkNodeProps> sliceShards = sliceEntry.getValue().getShards();
+ Iterator<Entry<String,ZkNodeProps>> shardIt = sliceShards.entrySet()
+ .iterator();
+ while (shardIt.hasNext()) {
+ Entry<String,ZkNodeProps> shardEntry = shardIt.next();
+ ZkCoreNodeProps coreProps = new ZkCoreNodeProps(shardEntry.getValue());
+ CoreAdminResponse mcr = CoreAdminRequest.getStatus(
+ coreProps.getCoreName(),
+ new HttpSolrServer(coreProps.getBaseUrl()));
+ long before = mcr.getStartTime(coreProps.getCoreName()).getTime();
+ urlToTime.put(coreProps.getCoreUrl(), before);
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("Could not find collection in :"
+ + collections.keySet());
+ }
+ }
+
+ private String getUrlFromZk(String collection) {
+ CloudState cloudState = solrj.getZkStateReader().getCloudState();
+ Map<String,Slice> slices = cloudState.getCollectionStates().get(collection);
+
+ if (slices == null) {
+ throw new SolrException(ErrorCode.BAD_REQUEST, "Could not find collection:" + collection);
+ }
+
+ for (Map.Entry<String,Slice> entry : slices.entrySet()) {
+ Slice slice = entry.getValue();
+ Map<String,ZkNodeProps> shards = slice.getShards();
+ Set<Map.Entry<String,ZkNodeProps>> shardEntries = shards.entrySet();
+ for (Map.Entry<String,ZkNodeProps> shardEntry : shardEntries) {
+ final ZkNodeProps node = shardEntry.getValue();
+ if (cloudState.liveNodesContain(node.get(ZkStateReader.NODE_NAME_PROP))) {
+ return new ZkCoreNodeProps(node).getCoreUrl();
+ }
+ }
+ }
+
+ throw new RuntimeException("Could not find a live node for collection:" + collection);
+ }
+
+ private void waitForNon404(HttpSolrServer collectionClient)
+ throws Exception {
+
+ long timeoutAt = System.currentTimeMillis() + 30000;
+
+ while (System.currentTimeMillis() < timeoutAt) {
+ boolean missing = false;
+ try {
+ collectionClient.query(new SolrQuery("*:*"));
+ } catch (SolrException e) {
+ // How do I get the response code!?
+ if (!e.getMessage().contains("(404)")) {
+ throw e;
+ }
+ missing = true;
+ }
+ if (!missing) {
+ return;
+ }
+ Thread.sleep(50);
+ }
+ printLayout();
+ fail("Could not find the new collection - 404 : " + collectionClient.getBaseURL());
+ }
+
+ private void checkForCollection(String collectionName, int expectedSlices)
+ throws Exception {
+ // check for an expectedSlices new collection - we poll the state
+ long timeoutAt = System.currentTimeMillis() + 60000;
+ boolean found = false;
+ boolean sliceMatch = false;
+ while (System.currentTimeMillis() < timeoutAt) {
+ solrj.getZkStateReader().updateCloudState(true);
+ CloudState cloudState = solrj.getZkStateReader().getCloudState();
+ Map<String,Map<String,Slice>> collections = cloudState
+ .getCollectionStates();
+ if (collections.containsKey(collectionName)) {
+ Map<String,Slice> slices = collections.get(collectionName);
+ // did we find expectedSlices slices/shards?
+ if (slices.size() == expectedSlices) {
+ sliceMatch = true;
+ found = true;
+ // also make sure each are active
+ Iterator<Entry<String,Slice>> it = slices.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String,Slice> sliceEntry = it.next();
+ Map<String,ZkNodeProps> sliceShards = sliceEntry.getValue()
+ .getShards();
+ Iterator<Entry<String,ZkNodeProps>> shardIt = sliceShards
+ .entrySet().iterator();
+ while (shardIt.hasNext()) {
+ Entry<String,ZkNodeProps> shardEntry = shardIt.next();
+ if (!shardEntry.getValue().get(ZkStateReader.STATE_PROP)
+ .equals(ZkStateReader.ACTIVE)) {
+ found = false;
+ break;
+ }
+ }
+ }
+ if (found) break;
+ }
+ }
+ Thread.sleep(100);
+ }
+ if (!found) {
+ printLayout();
+ if (!sliceMatch) {
+ fail("Could not find new " + expectedSlices + " slice collection called " + collectionName);
+ } else {
+ fail("Found expected # of slices, but some nodes are not active for collection called " + collectionName);
+ }
+ }
+ }
+
+ private void checkForMissingCollection(String collectionName)
+ throws Exception {
+ // check for a collection - we poll the state
+ long timeoutAt = System.currentTimeMillis() + 15000;
+ boolean found = true;
+ while (System.currentTimeMillis() < timeoutAt) {
+ solrj.getZkStateReader().updateCloudState(true);
+ CloudState cloudState = solrj.getZkStateReader().getCloudState();
+ Map<String,Map<String,Slice>> collections = cloudState
+ .getCollectionStates();
+ if (!collections.containsKey(collectionName)) {
+ found = false;
+ break;
+ }
+ Thread.sleep(100);
+ }
+ if (found) {
+ fail("Found collection that should be gone " + collectionName);
+ }
+ }
+
/**
* Expects a RegexReplaceProcessorFactories in the chain which will
* "double up" the values in two (stored) string fields.
@@ -392,7 +682,7 @@ public class BasicDistributedZkTest exte
}
private void testNumberOfCommitsWithCommitAfterAdd()
- throws MalformedURLException, SolrServerException, IOException {
+ throws SolrServerException, IOException {
long startCommits = getNumCommits((HttpSolrServer) clients.get(0));
ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
@@ -406,7 +696,7 @@ public class BasicDistributedZkTest exte
assertEquals(startCommits + 1L, endCommits);
}
- private Long getNumCommits(HttpSolrServer solrServer) throws MalformedURLException,
+ private Long getNumCommits(HttpSolrServer solrServer) throws
SolrServerException, IOException {
HttpSolrServer server = new HttpSolrServer(solrServer.getBaseURL());
ModifiableSolrParams params = new ModifiableSolrParams();
@@ -450,7 +740,7 @@ public class BasicDistributedZkTest exte
assertAllActive(oneInstanceCollection2, solrj.getZkStateReader());
- // TODO: enable when we don't falsly get slice1...
+ // TODO: enable when we don't falsely get slice1...
// solrj.getZkStateReader().getLeaderUrl(oneInstanceCollection2, "slice1", 30000);
// solrj.getZkStateReader().getLeaderUrl(oneInstanceCollection2, "slice2", 30000);
client2.add(getDoc(id, "1"));
@@ -552,15 +842,13 @@ public class BasicDistributedZkTest exte
}
private void createCollection(String collection,
- List<SolrServer> collectionClients, String baseUrl, int num)
- throws MalformedURLException, SolrServerException, IOException, InterruptedException {
+ List<SolrServer> collectionClients, String baseUrl, int num) {
createCollection(collection, collectionClients, baseUrl, num, null);
}
private void createCollection(final String collection,
List<SolrServer> collectionClients, final String baseUrl, final int num,
- final String shardId) throws MalformedURLException, SolrServerException,
- IOException, InterruptedException {
+ final String shardId) {
Callable call = new Callable() {
public Object call() {
HttpSolrServer server;
@@ -594,8 +882,7 @@ public class BasicDistributedZkTest exte
collectionClients.add(createNewSolrServer(collection, baseUrl));
}
- private void testMultipleCollections() throws MalformedURLException,
- SolrServerException, IOException, Exception {
+ private void testMultipleCollections() throws Exception {
// create another 2 collections and search across them
createNewCollection("collection2");
createNewCollection("collection3");
@@ -665,8 +952,7 @@ public class BasicDistributedZkTest exte
client.add(doc);
}
- private void createNewCollection(final String collection)
- throws MalformedURLException, SolrServerException, IOException, InterruptedException {
+ private void createNewCollection(final String collection) throws InterruptedException {
final List<SolrServer> collectionClients = new ArrayList<SolrServer>();
otherCollectionClients.put(collection, collectionClients);
int unique = 0;
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java Thu Jul 19 15:58:54 2012
@@ -19,13 +19,16 @@ package org.apache.solr.cloud;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.LogMergePolicy;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.update.DirectUpdateHandler2;
+import org.apache.solr.util.RefCounted;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -37,6 +40,7 @@ import org.xml.sax.SAXParseException;
* detect if a node is trying to do an update to itself with http - it shouldn't
* do that.
*/
+@Slow
public class BasicZkTest extends AbstractZkTestCase {
@BeforeClass
@@ -58,10 +62,12 @@ public class BasicZkTest extends Abstrac
// test merge factor picked up
SolrCore core = h.getCore();
- IndexWriter writer = ((DirectUpdateHandler2)core.getUpdateHandler()).getSolrCoreState().getIndexWriter(core);
-
- assertEquals("Mergefactor was not picked up", 8, ((LogMergePolicy)writer.getConfig().getMergePolicy()).getMergeFactor());
-
+ RefCounted<IndexWriter> iw = ((DirectUpdateHandler2)core.getUpdateHandler()).getSolrCoreState().getIndexWriter(core);
+ try {
+ assertEquals("Mergefactor was not picked up", 8, ((LogMergePolicy)iw.get().getConfig().getMergePolicy()).getMergeFactor());
+ } finally {
+ iw.decref();
+ }
lrf.args.put(CommonParams.VERSION, "2.2");
assertQ("test query on empty index", request("qlkciyopsbgzyvkylsjhchghjrdf"),
"//result[@numFound='0']");
@@ -158,6 +164,13 @@ public class BasicZkTest extends Abstrac
}
+ // test stats call
+ NamedList stats = core.getStatistics();
+ assertEquals("collection1", stats.get("coreName"));
+ assertEquals("collection1", stats.get("collection"));
+ assertEquals("shard1", stats.get("shard"));
+ assertTrue(stats.get("refCount") != null);
+
//zkController.getZkClient().printLayoutToStdOut();
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkey.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkey.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkey.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkey.java Thu Jul 19 15:58:54 2012
@@ -24,6 +24,7 @@ import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.cloud.FullSolrCloudTest.CloudJettyRunner;
@@ -52,7 +53,6 @@ public class ChaosMonkey {
private ZkTestServer zkServer;
private ZkStateReader zkStateReader;
private String collection;
- private Random random;
private volatile boolean stop = false;
private AtomicInteger stops = new AtomicInteger();
private AtomicInteger starts = new AtomicInteger();
@@ -71,7 +71,7 @@ public class ChaosMonkey {
String collection, Map<String,List<CloudJettyRunner>> shardToJetty,
Map<String,List<SolrServer>> shardToClient,
Map<String,SolrServer> shardToLeaderClient,
- Map<String,CloudJettyRunner> shardToLeaderJetty, Random random) {
+ Map<String,CloudJettyRunner> shardToLeaderJetty) {
this.shardToJetty = shardToJetty;
this.shardToClient = shardToClient;
this.shardToLeaderClient = shardToLeaderClient;
@@ -79,8 +79,7 @@ public class ChaosMonkey {
this.zkServer = zkServer;
this.zkStateReader = zkStateReader;
this.collection = collection;
- this.random = random;
-
+ Random random = LuceneTestCase.random();
expireSessions = random.nextBoolean();
causeConnectionLoss = random.nextBoolean();
}
@@ -227,7 +226,7 @@ public class ChaosMonkey {
List<String> sliceKeyList = new ArrayList<String>(slices.size());
sliceKeyList.addAll(slices.keySet());
- String sliceName = sliceKeyList.get(random.nextInt(sliceKeyList.size()));
+ String sliceName = sliceKeyList.get(LuceneTestCase.random().nextInt(sliceKeyList.size()));
return sliceName;
}
@@ -291,7 +290,7 @@ public class ChaosMonkey {
// we cannot kill anyone
return null;
}
-
+ Random random = LuceneTestCase.random();
int chance = random.nextInt(10);
JettySolrRunner jetty;
if (chance <= 5 && aggressivelyKillLeaders) {
@@ -327,7 +326,7 @@ public class ChaosMonkey {
// get random shard
List<SolrServer> clients = shardToClient.get(slice);
- int index = random.nextInt(clients.size() - 1);
+ int index = LuceneTestCase.random().nextInt(clients.size() - 1);
SolrServer client = clients.get(index);
return client;
@@ -349,7 +348,7 @@ public class ChaosMonkey {
while (!stop) {
try {
Thread.sleep(roundPause);
-
+ Random random = LuceneTestCase.random();
if (random.nextBoolean()) {
if (!deadPool.isEmpty()) {
int index = random.nextInt(deadPool.size());
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java Thu Jul 19 15:58:54 2012
@@ -17,37 +17,35 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import java.io.IOException;
import java.net.ConnectException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.http.client.HttpClient;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.common.SolrInputDocument;
-import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
+@Slow
@Ignore("ignore while investigating jenkins fails")
public class ChaosMonkeyNothingIsSafeTest extends FullSolrCloudTest {
@BeforeClass
- public static void beforeSuperClass() throws Exception {
+ public static void beforeSuperClass() {
}
@AfterClass
- public static void afterSuperClass() throws Exception {
+ public static void afterSuperClass() {
}
@Before
@@ -69,8 +67,8 @@ public class ChaosMonkeyNothingIsSafeTes
public ChaosMonkeyNothingIsSafeTest() {
super();
- shardCount = atLeast(3);
- sliceCount = 2;
+ sliceCount = atLeast(2);
+ shardCount = atLeast(sliceCount * 2);
}
@Override
@@ -102,7 +100,7 @@ public class ChaosMonkeyNothingIsSafeTes
chaosMonkey.startTheMonkey(true, 1500);
try {
- Thread.sleep(atLeast(6000));
+ Thread.sleep(180000);
} finally {
chaosMonkey.stopTheMonkey();
}
@@ -159,8 +157,7 @@ public class ChaosMonkeyNothingIsSafeTes
}
}
- private void waitForThingsToLevelOut() throws KeeperException,
- InterruptedException, Exception, IOException, URISyntaxException {
+ private void waitForThingsToLevelOut() throws Exception {
int cnt = 0;
boolean retry = false;
do {
@@ -210,7 +207,7 @@ public class ChaosMonkeyNothingIsSafeTes
private List<SolrServer> clients;
public FullThrottleStopableIndexingThread(List<SolrServer> clients,
- int startI, boolean doDeletes) throws MalformedURLException {
+ int startI, boolean doDeletes) {
super(startI, doDeletes);
setName("FullThrottleStopableIndexingThread");
setDaemon(true);
@@ -282,18 +279,14 @@ public class ChaosMonkeyNothingIsSafeTes
if (clientIndex > clients.size() - 1) {
clientIndex = 0;
}
- try {
- suss.shutdownNow();
- suss = new ConcurrentUpdateSolrServer(
- ((HttpSolrServer) clients.get(clientIndex)).getBaseURL(),
- httpClient, 30, 3) {
- public void handleError(Throwable ex) {
- log.warn("suss error", ex);
- }
- };
- } catch (MalformedURLException e1) {
- e1.printStackTrace();
- }
+ suss.shutdownNow();
+ suss = new ConcurrentUpdateSolrServer(
+ ((HttpSolrServer) clients.get(clientIndex)).getBaseURL(),
+ httpClient, 30, 3) {
+ public void handleError(Throwable ex) {
+ log.warn("suss error", ex);
+ }
+ };
}
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java Thu Jul 19 15:58:54 2012
@@ -17,15 +17,12 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import java.io.IOException;
-import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.common.SolrInputDocument;
-import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -36,12 +33,12 @@ import org.junit.Ignore;
public class ChaosMonkeySafeLeaderTest extends FullSolrCloudTest {
@BeforeClass
- public static void beforeSuperClass() throws Exception {
+ public static void beforeSuperClass() {
}
@AfterClass
- public static void afterSuperClass() throws Exception {
+ public static void afterSuperClass() {
}
@@ -119,8 +116,7 @@ public class ChaosMonkeySafeLeaderTest e
if (VERBOSE) System.out.println("control docs:" + controlClient.query(new SolrQuery("*:*")).getResults().getNumFound() + "\n\n");
}
- private void waitForThingsToLevelOut() throws KeeperException,
- InterruptedException, Exception, IOException, URISyntaxException {
+ private void waitForThingsToLevelOut() throws Exception {
int cnt = 0;
boolean retry = false;
do {
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java Thu Jul 19 15:58:54 2012
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.CloudState;
import org.apache.solr.common.cloud.Slice;
@@ -39,6 +40,7 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Slow
public class CloudStateUpdateTest extends SolrTestCaseJ4 {
protected static Logger log = LoggerFactory
.getLogger(AbstractZkTestCase.class);
@@ -66,15 +68,13 @@ public class CloudStateUpdateTest extend
private Initializer init2;
@BeforeClass
- public static void beforeClass() throws Exception {
+ public static void beforeClass() {
System.setProperty("solrcloud.skip.autorecovery", "true");
}
@AfterClass
public static void afterClass() throws InterruptedException {
System.clearProperty("solrcloud.skip.autorecovery");
- // wait just a bit for any zk client threads to outlast timeout
- Thread.sleep(2000);
}
@Override
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java Thu Jul 19 15:58:54 2012
@@ -18,9 +18,8 @@ package org.apache.solr.cloud;
*/
import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.concurrent.TimeoutException;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
@@ -44,11 +43,12 @@ import org.junit.BeforeClass;
/**
* Super basic testing, no shard restarting or anything.
*/
+@Slow
public class FullSolrCloudDistribCmdsTest extends FullSolrCloudTest {
@BeforeClass
- public static void beforeSuperClass() throws Exception {
+ public static void beforeSuperClass() {
}
public FullSolrCloudDistribCmdsTest() {
@@ -131,8 +131,7 @@ public class FullSolrCloudDistribCmdsTes
testThatCantForwardToLeaderFails();
}
- private void testThatCantForwardToLeaderFails() throws InterruptedException,
- Exception, TimeoutException, IOException, KeeperException {
+ private void testThatCantForwardToLeaderFails() throws Exception {
ZkNodeProps props = zkStateReader.getLeaderProps(DEFAULT_COLLECTION, "shard1");
chaosMonkey.stopShard("shard1");
@@ -164,8 +163,8 @@ public class FullSolrCloudDistribCmdsTes
assertTrue("A whole shard is down - some of these should fail", fails > 0);
}
- private long addTwoDocsInOneRequest(long docId) throws SolrServerException,
- IOException, Exception {
+ private long addTwoDocsInOneRequest(long docId) throws
+ Exception {
QueryResponse results;
UpdateRequest uReq;
uReq = new UpdateRequest();
@@ -192,7 +191,7 @@ public class FullSolrCloudDistribCmdsTes
return docId;
}
- private long addUpdateDelete() throws Exception, SolrServerException,
+ private long addUpdateDelete() throws Exception,
IOException {
long docId = 99999999L;
indexr("id", docId, t1, "originalcontent");
@@ -230,13 +229,13 @@ public class FullSolrCloudDistribCmdsTes
return docId;
}
- private void testDeleteByQueryDistrib() throws Exception, SolrServerException {
+ private void testDeleteByQueryDistrib() throws Exception {
del("*:*");
commit();
assertEquals(0, query(cloudClient).getResults().getNumFound());
}
- private void testIndexingWithSuss() throws MalformedURLException, Exception {
+ private void testIndexingWithSuss() throws Exception {
ConcurrentUpdateSolrServer suss = new ConcurrentUpdateSolrServer(
((HttpSolrServer) clients.get(0)).getBaseURL(), 3, 1);
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java Thu Jul 19 15:58:54 2012
@@ -17,15 +17,20 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
+import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-import java.util.concurrent.TimeoutException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.http.params.CoreConnectionPNames;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
@@ -46,12 +51,10 @@ import org.apache.solr.common.cloud.ZkSt
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.servlet.SolrDispatchFilter;
-import org.apache.zookeeper.KeeperException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Ignore;
/**
*
@@ -59,9 +62,10 @@ import org.junit.Ignore;
* what we test now - the default update chain
*
*/
+@Slow
public class FullSolrCloudTest extends AbstractDistributedZkTestCase {
@BeforeClass
- public static void beforeFullSolrCloudTest() throws Exception {
+ public static void beforeFullSolrCloudTest() {
// shorten the log output more for this test type
if (formatter != null) formatter.setShorterFormat();
}
@@ -148,15 +152,12 @@ public class FullSolrCloudTest extends A
}
@BeforeClass
- public static void beforeClass() throws Exception {
- System
- .setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
+ public static void beforeClass() {
System.setProperty("solrcloud.update.delay", "0");
}
@AfterClass
public static void afterClass() {
- System.clearProperty("solr.directoryFactory");
System.clearProperty("solrcloud.update.delay");
}
@@ -184,7 +185,7 @@ public class FullSolrCloudTest extends A
chaosMonkey = new ChaosMonkey(zkServer, zkStateReader,
DEFAULT_COLLECTION, shardToJetty, shardToClient, shardToLeaderClient,
- shardToLeaderJetty, random());
+ shardToLeaderJetty);
}
// wait until shards have started registering...
@@ -223,7 +224,7 @@ public class FullSolrCloudTest extends A
System.setProperty("collection", "control_collection");
String numShards = System.getProperty(ZkStateReader.NUM_SHARDS_PROP);
System.clearProperty(ZkStateReader.NUM_SHARDS_PROP);
- controlJetty = createJetty(testDir, testDir + "/control/data",
+ controlJetty = createJetty(new File(getSolrHome()), testDir + "/control/data",
"control_shard");
System.clearProperty("collection");
if(numShards != null) {
@@ -255,7 +256,7 @@ public class FullSolrCloudTest extends A
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= numJettys; i++) {
if (sb.length() > 0) sb.append(',');
- JettySolrRunner j = createJetty(testDir, testDir + "/jetty"
+ JettySolrRunner j = createJetty(new File(getSolrHome()), testDir + "/jetty"
+ this.jettyIntCntr.incrementAndGet(), null, "solrconfig.xml", null);
jettys.add(j);
SolrServer client = createNewSolrServer(j.getLocalPort());
@@ -327,8 +328,7 @@ public class FullSolrCloudTest extends A
}
protected void updateMappingsFromZk(List<JettySolrRunner> jettys,
- List<SolrServer> clients) throws Exception, IOException, KeeperException,
- URISyntaxException {
+ List<SolrServer> clients) throws Exception {
zkStateReader.updateCloudState(true);
shardToClient.clear();
shardToJetty.clear();
@@ -596,8 +596,7 @@ public class FullSolrCloudTest extends A
}
- private long testUpdateAndDelete() throws Exception, SolrServerException,
- IOException {
+ private long testUpdateAndDelete() throws Exception {
long docId = 99999999L;
indexr("id", docId, t1, "originalcontent");
@@ -632,9 +631,7 @@ public class FullSolrCloudTest extends A
return docId;
}
- private void addNewReplica() throws Exception, InterruptedException,
- TimeoutException, IOException, KeeperException, URISyntaxException,
- SolrServerException {
+ private void addNewReplica() throws Exception {
JettySolrRunner newReplica = createJettys(1).get(0);
waitForRecoveriesToFinish(false);
@@ -656,8 +653,7 @@ public class FullSolrCloudTest extends A
super.waitForRecoveriesToFinish(DEFAULT_COLLECTION, zkStateReader, verbose);
}
- private void brindDownShardIndexSomeDocsAndRecover() throws Exception,
- SolrServerException, IOException, InterruptedException {
+ private void brindDownShardIndexSomeDocsAndRecover() throws Exception {
SolrQuery query = new SolrQuery("*:*");
query.set("distrib", false);
@@ -1031,6 +1027,10 @@ public class FullSolrCloudTest extends A
if (verbose) System.err.println("error contacting client: "
+ e.getMessage() + "\n");
continue;
+ } catch (SolrException e) {
+ if (verbose) System.err.println("error contacting client: "
+ + e.getMessage() + "\n");
+ continue;
}
boolean live = false;
@@ -1278,6 +1278,10 @@ public class FullSolrCloudTest extends A
} catch (Exception e) {
System.err.println("REQUEST FAILED:");
e.printStackTrace();
+ if (e instanceof SolrServerException) {
+ System.err.println("ROOT CAUSE:");
+ ((SolrServerException) e).getRootCause().printStackTrace();
+ }
fails.incrementAndGet();
}
}
@@ -1289,6 +1293,10 @@ public class FullSolrCloudTest extends A
} catch (Exception e) {
System.err.println("REQUEST FAILED:");
e.printStackTrace();
+ if (e instanceof SolrServerException) {
+ System.err.println("ROOT CAUSE:");
+ ((SolrServerException) e).getRootCause().printStackTrace();
+ }
fails.incrementAndGet();
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java Thu Jul 19 15:58:54 2012
@@ -29,13 +29,13 @@ import java.util.regex.Pattern;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreContainer.Initializer;
-import org.apache.zookeeper.KeeperException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -43,6 +43,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
+@Slow
public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
protected static Logger log = LoggerFactory
.getLogger(AbstractZkTestCase.class);
@@ -67,7 +68,7 @@ public class LeaderElectionIntegrationTe
private ZkStateReader reader;
@BeforeClass
- public static void beforeClass() throws Exception {
+ public static void beforeClass() {
System.setProperty("solrcloud.skip.autorecovery", "true");
}
@@ -245,7 +246,7 @@ public class LeaderElectionIntegrationTe
//Thread.sleep(100000);
}
- private String getLeader() throws InterruptedException, KeeperException {
+ private String getLeader() throws InterruptedException {
ZkNodeProps props = reader.getLeaderProps("collection1", "shard1", 30000);
String leader = props.get(ZkStateReader.NODE_NAME_PROP);
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java Thu Jul 19 15:58:54 2012
@@ -28,6 +28,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.OnReconnect;
import org.apache.solr.common.cloud.SolrZkClient;
@@ -40,6 +41,7 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+@Slow
public class LeaderElectionTest extends SolrTestCaseJ4 {
static final int TIMEOUT = 30000;
@@ -51,12 +53,12 @@ public class LeaderElectionTest extends
private volatile boolean stopStress = false;
@BeforeClass
- public static void beforeClass() throws Exception {
+ public static void beforeClass() {
createTempDir();
}
@AfterClass
- public static void afterClass() throws InterruptedException {
+ public static void afterClass() {
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Thu Jul 19 15:58:54 2012
@@ -32,6 +32,9 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.CloudState;
import org.apache.solr.common.cloud.Slice;
@@ -39,6 +42,7 @@ import org.apache.solr.common.cloud.Solr
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.handler.component.HttpShardHandlerFactory;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NodeExistsException;
@@ -46,7 +50,9 @@ import org.apache.zookeeper.data.Stat;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.xml.sax.SAXException;
+@Slow
public class OverseerTest extends SolrTestCaseJ4 {
static final int TIMEOUT = 10000;
@@ -202,7 +208,7 @@ public class OverseerTest extends SolrTe
}
});
- System.setProperty("bootstrap_confdir", getFile("solr/conf")
+ System.setProperty("bootstrap_confdir", getFile("solr/collection1/conf")
.getAbsolutePath());
final int numShards=6;
@@ -287,7 +293,7 @@ public class OverseerTest extends SolrTe
});
}
- System.setProperty("bootstrap_confdir", getFile("solr/conf")
+ System.setProperty("bootstrap_confdir", getFile("solr/collection1/conf")
.getAbsolutePath());
@@ -402,7 +408,9 @@ public class OverseerTest extends SolrTe
}
server.shutdown();
for (int i = 0; i < nodeCount; i++) {
- nodeExecutors[i].shutdownNow();
+ if (nodeExecutors[i] != null) {
+ nodeExecutors[i].shutdownNow();
+ }
}
}
}
@@ -582,8 +590,7 @@ public class OverseerTest extends SolrTe
mockController.publishState("core1", null,1);
while(version == getCloudStateVersion(controllerClient));
Thread.sleep(500);
- assertEquals("Shard count does not match", 0, reader.getCloudState()
- .getSlice("collection1", "shard1").getShards().size());
+ assertFalse("collection1 should be gone after publishing the null state", reader.getCloudState().getCollections().contains("collection1"));
} finally {
close(mockController);
@@ -898,11 +905,11 @@ public class OverseerTest extends SolrTe
private SolrZkClient electNewOverseer(String address) throws InterruptedException,
- TimeoutException, IOException, KeeperException {
+ TimeoutException, IOException, KeeperException, ParserConfigurationException, SAXException {
SolrZkClient zkClient = new SolrZkClient(address, TIMEOUT);
ZkStateReader reader = new ZkStateReader(zkClient);
LeaderElector overseerElector = new LeaderElector(zkClient);
- ElectionContext ec = new OverseerElectionContext(address.replaceAll("/", "_"), reader);
+ ElectionContext ec = new OverseerElectionContext(new HttpShardHandlerFactory().getShardHandler(), "/admin/cores", address.replaceAll("/", "_"), reader);
overseerElector.setup(ec);
overseerElector.joinElection(ec);
return zkClient;
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java Thu Jul 19 15:58:54 2012
@@ -19,6 +19,7 @@ package org.apache.solr.cloud;
import java.io.IOException;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
@@ -28,6 +29,7 @@ import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Slow
public class RecoveryZkTest extends FullSolrCloudTest {
//private static final String DISTRIB_UPDATE_CHAIN = "distrib-update-chain";
@@ -35,12 +37,12 @@ public class RecoveryZkTest extends Full
private StopableIndexingThread indexThread;
private StopableIndexingThread indexThread2;
@BeforeClass
- public static void beforeSuperClass() throws Exception {
+ public static void beforeSuperClass() {
}
@AfterClass
- public static void afterSuperClass() throws Exception {
+ public static void afterSuperClass() {
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java Thu Jul 19 15:58:54 2012
@@ -18,7 +18,6 @@
package org.apache.solr.cloud;
import java.io.File;
-import java.io.IOException;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
@@ -43,12 +42,12 @@ public class TestMultiCoreConfBootstrap
protected static String zkDir;
@BeforeClass
- public static void beforeClass() throws Exception {
+ public static void beforeClass() {
createTempDir();
}
@AfterClass
- public static void afterClass() throws IOException {
+ public static void afterClass() {
}
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java Thu Jul 19 15:58:54 2012
@@ -24,16 +24,19 @@ import java.util.Map;
import junit.framework.Assert;
+import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.util.ExternalPaths;
import org.apache.zookeeper.CreateMode;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+@Slow
public class ZkControllerTest extends SolrTestCaseJ4 {
private static final String COLLECTION_NAME = "collection1";
@@ -120,11 +123,11 @@ public class ZkControllerTest extends So
}
});
- zkController.uploadToZK(getFile("solr/conf"),
+ zkController.uploadToZK(new File(ExternalPaths.EXAMPLE_HOME + "/collection1/conf"),
ZkController.CONFIGS_ZKNODE + "/config1");
// uploading again should overwrite, not error...
- zkController.uploadToZK(getFile("solr/conf"),
+ zkController.uploadToZK(new File(ExternalPaths.EXAMPLE_HOME + "/collection1/conf"),
ZkController.CONFIGS_ZKNODE + "/config1");
if (DEBUG) {
@@ -179,7 +182,7 @@ public class ZkControllerTest extends So
}
});
- System.setProperty("bootstrap_confdir", getFile("solr/conf")
+ System.setProperty("bootstrap_confdir", getFile("solr/collection1/conf")
.getAbsolutePath());
final int numShards = 2;
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java Thu Jul 19 15:58:54 2012
@@ -304,7 +304,7 @@ public class ZkTestServer {
reader =
new BufferedReader(
- new InputStreamReader(sock.getInputStream()));
+ new InputStreamReader(sock.getInputStream(), "US-ASCII"));
StringBuilder sb = new StringBuilder();
String line;
while((line = reader.readLine()) != null) {
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java Thu Jul 19 15:58:54 2012
@@ -37,7 +37,7 @@ public class RAMDirectoryFactoryTest ext
final Directory directory = new RAMDirectory();
RAMDirectoryFactory factory = new RAMDirectoryFactory() {
@Override
- protected Directory create(String path) throws IOException {
+ protected Directory create(String path) {
return directory;
}
};
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java Thu Jul 19 15:58:54 2012
@@ -95,7 +95,7 @@ public class ResourceLoaderTest extends
public void testBOMMarkers() throws Exception {
final String fileWithBom = "stopwithbom.txt";
- SolrResourceLoader loader = new SolrResourceLoader(null);
+ SolrResourceLoader loader = new SolrResourceLoader("solr/collection1");
// preliminary sanity check
InputStream bomStream = loader.openResource(fileWithBom);
@@ -121,7 +121,7 @@ public class ResourceLoaderTest extends
public void testWrongEncoding() throws Exception {
String wrongEncoding = "stopwordsWrongEncoding.txt";
- SolrResourceLoader loader = new SolrResourceLoader(null);
+ SolrResourceLoader loader = new SolrResourceLoader("solr/collection1");
// ensure we get our exception
try {
List<String> lines = loader.getLines(wrongEncoding);
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java Thu Jul 19 15:58:54 2012
@@ -27,9 +27,12 @@ import org.apache.solr.response.SolrQuer
import org.apache.solr.util.plugin.SolrCoreAware;
import org.junit.Test;
+import java.io.File;
import java.util.concurrent.*;
import java.util.*;
public class SolrCoreTest extends SolrTestCaseJ4 {
+ private static final String COLLECTION1 = "collection1";
+
@Override
public void setUp() throws Exception {
super.setUp();
@@ -41,6 +44,37 @@ public class SolrCoreTest extends SolrTe
deleteCore();
super.tearDown();
}
+
+ @Test
+ public void testRemoveThenAddDefaultCore() throws Exception {
+ final CoreContainer cores = h.getCoreContainer();
+ SolrCore core = cores.getCore("");
+ assertEquals(COLLECTION1, cores.getDefaultCoreName());
+
+ cores.remove("");
+ core.close();
+ core.close();
+
+
+ SolrCore newCore = new SolrCore(COLLECTION1, dataDir + File.separator
+ + "datadir2", new SolrConfig("solr/collection1", "solrconfig.xml", null), h.getCore().getSchema(),
+ new CoreDescriptor(cores, COLLECTION1, "solr/collection1"));
+
+ cores.register(newCore, false);
+
+ assertEquals(COLLECTION1, cores.getDefaultCoreName());
+
+ // so we should be able to get a core with collection1
+ core = cores.getCore(COLLECTION1);
+ assertNotNull(core);
+ core.close();
+
+ // and with ""
+ core = cores.getCore("");
+ assertNotNull(core);
+
+ core.close();
+ }
@Test
public void testRequestHandlerRegistry() {
Modified: lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java (original)
+++ lucene/dev/branches/pforcodec_3892/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java Thu Jul 19 15:58:54 2012
@@ -49,12 +49,12 @@ public class TestArbitraryIndexDir exten
// TODO: fix this test to not require FSDirectory
static String savedFactory;
@BeforeClass
- public static void beforeClass() throws Exception {
+ public static void beforeClass() {
savedFactory = System.getProperty("solr.DirectoryFactory");
System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");
}
@AfterClass
- public static void afterClass() throws Exception {
+ public static void afterClass() {
if (savedFactory == null) {
System.clearProperty("solr.directoryFactory");
} else {
@@ -71,7 +71,7 @@ public class TestArbitraryIndexDir exten
+ System.getProperty("file.separator") + "data");
dataDir.mkdirs();
- solrConfig = TestHarness.createConfig("solrconfig.xml");
+ solrConfig = TestHarness.createConfig(getSolrHome(), "solrconfig.xml");
h = new TestHarness( dataDir.getAbsolutePath(),
solrConfig,
"schema12.xml");