lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Solr JUnit test methods steping on eachother?
Date Wed, 28 Apr 2010 22:57:15 GMT

I was out of hte loop when the changes where made the all of hte Solr test 
to make then more "JUnit4-ish" but now i'm trying to add some new test 
methods and finding that my new tests, even when they succeed, are causing 
ohter tests to fail -- even if i make no changes to the underlying code.

Below is a patch against solr -- as you can see all it does is add a new 
test method that doesn't even assert anything, it just populates the index 
(my real case did more, but i trimmed the example down just to demonstrate 
the problem) if you apply this patch, and then run "ant test-core 
-Dtestcase=SimpleFacetsTest" you'll get a failure from the 
SimpleFacetsTest.testFacetPrefixSingleValued test.  Looking at the test 
output, the failure seems to come from finding an extra "prefix" value in 
the prefix faceting output.

As best i can figure the current setup isn't cleaning out the index 
between each of the running test methods -- i'm basing this on my limited 
understanding of JUnit4, and then call to "initCore" in the 
"beforeClass()" method (presumably this means the core is only 
initialized when the Test class is constructed, and not prior to each 
test method like it use to me).

But even with that in mind, i can't make sense of why the test is failing: 
my new code isn't adding anything to that field.

So WTF is going on?

1) am i understanding "beforeClass" correctly?
2) if so, then how is the current setup suppose to ensure that testAAA
     doesn't leave garbase arround that screws up testBBB ?
3) even if the anwer to #2 is "we don't ensure that" then how is my new 
test method screwing things up in a way that the other exsiting test 
methods aren't ?

(Note: i've seen some other threads about the test parallization stuff 
in the lucene-java tests having problems -- but the solr tests appear to 
be run in a "junit-sequential" target, so i don't think that's the 
problem)

Patch....

Index: src/test/org/apache/solr/request/SimpleFacetsTest.java
===================================================================
--- src/test/org/apache/solr/request/SimpleFacetsTest.java	(revision 939066)
+++ src/test/org/apache/solr/request/SimpleFacetsTest.java	(working copy)
@@ -390,6 +390,31 @@
     }

     @Test
+  public void testDateFacetsWithIncludeOption() {
+    final String f = "bday";
+    final String pre = "//lst[@name='facet_dates']/lst[@name='"+f+"']";
+
+    // similar to testDateFacets
+    final String ooo = "00:00:00.000Z";
+
+    assertU(adoc("id", "0",  f, "1900-01-01T"+ooo));
+    assertU(commit());
+    assertU(adoc("id", "1",  f, "1976-07-01T"+ooo));
+    assertU(adoc("id", "2",  f, "1976-07-04T"+ooo));
+    assertU(adoc("id", "3",  f, "1976-07-05T"+ooo));
+    assertU(adoc("id", "4",  f, "1976-07-05T00:07:67.890Z"));
+    assertU(commit());
+    assertU(adoc("id", "5",  f, "1976-07-07T"+ooo));
+    assertU(adoc("id", "6",  f, "1976-07-13T"+ooo));
+    assertU(adoc("id", "7",  f, "1976-07-13T00:07:67.890Z"));
+    assertU(adoc("id", "8",  f, "1976-07-15T15:15:15.155Z"));
+    assertU(commit());
+    assertU(adoc("id", "9",  f, "2000-01-01T"+ooo));
+    assertU(commit());
+  }
+
+
+  @Test
     public void testFacetMultiValued() {
       doFacetPrefix("t_s", "facet.method","enum");
       doFacetPrefix("t_s", "facet.method", "enum", "facet.enum.cache.minDf", "2");


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message