SOLR-5488: Fixing up tests for analytics component

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1545417 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erick Erickson 2013-11-25 21:59:09 +00:00
parent 295ce29bfb
commit 728b740ede
4 changed files with 34 additions and 29 deletions

View File

@ -23,10 +23,10 @@ o.nr.s.sumc=sum(neg_i_dd)
o.nr.s.mean=mean(neg(long_ld))
o.nr.s.meanc=mean(neg_l_dd)
o.nr.s.sum=sum(abs(neg(int_id)))
o.nr.s.sumc=sum(int_id)
o.nr.s.mean=mean(abs(neg(long_ld)))
o.nr.s.meanc=mean(int_id)
o.avr.s.sum=sum(abs(neg(int_id)))
o.avr.s.sumc=sum(int_id)
o.avr.s.mean=mean(abs(neg(int_id)))
o.avr.s.meanc=mean(int_id)
o.cnr.s.sum=sum(const_num(8))
o.cnr.s.sumc=sum(const_8_dd)

View File

@ -15,7 +15,7 @@ o.mr.s.double_dd=mean(double_dd)
o.str.s.int_id=stddev(int_id)
o.str.s.long_ld=stddev(long_ld)
o.st.s.float_fd=stddev(float_fd)
o.str.s.float_fd=stddev(float_fd)
o.str.s.double_dd=stddev(double_dd)
o.medr.s.int_id=median(int_id)

View File

@ -23,7 +23,6 @@ import java.util.List;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@SuppressCodecs({"Lucene3x","Lucene40","Lucene41","Lucene42","Appending","Asserting"})
@ -208,7 +207,7 @@ public class NoFacetTest extends AbstractAnalyticsStatsTest {
assertEquals(doubleResult,doubleTest);
}
@Test @Ignore("SOLR-5488")
@Test
public void stddevTest() throws Exception {
//Int
Double intResult = (Double)getStatResult("str", "int_id", VAL_TYPE.DOUBLE);

View File

@ -21,9 +21,7 @@ package org.apache.solr.analytics.util.valuesource;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.apache.solr.analytics.AbstractAnalyticsStatsTest;
import org.apache.solr.analytics.facet.AbstractAnalyticsFacetTest;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@SuppressCodecs({"Lucene3x","Lucene40","Lucene41","Lucene42","Appending","Asserting"})
@ -92,32 +90,34 @@ public class FunctionTest extends AbstractAnalyticsStatsTest {
double result = (Double)getStatResult("ar", "sum", VAL_TYPE.DOUBLE);
double calculated = (Double)getStatResult("ar", "sumc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("add sum", result, calculated, 0.0);
result = (Double)getStatResult("ar", "mean", VAL_TYPE.DOUBLE);
calculated = (Double)getStatResult("ar", "meanc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("add mean", result, calculated, 0.0);
}
@Test
public void multiplyTest() throws Exception {
double result = (Double)getStatResult("mr", "sum", VAL_TYPE.DOUBLE);
double calculated = (Double)getStatResult("mr", "sumc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("multiply sum", result, calculated, 0.0);
result = (Double)getStatResult("mr", "mean", VAL_TYPE.DOUBLE);
calculated = (Double)getStatResult("mr", "meanc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("multiply mean", result, calculated, 0.0);
}
@Test
public void divideTest() throws Exception {
Double result = (Double)getStatResult("dr", "sum", VAL_TYPE.DOUBLE);
Double calculated = (Double)getStatResult("dr", "sumc", VAL_TYPE.DOUBLE);
assertTrue(result.equals(calculated));
assertEquals("power sum", result, calculated, 0.0);
result = (Double)getStatResult("dr", "mean", VAL_TYPE.DOUBLE);
calculated = (Double)getStatResult("dr", "meanc", VAL_TYPE.DOUBLE);
assertTrue(result.equals(calculated));
assertEquals("power mean", result, calculated, 0.0);
}
@Test
@ -125,32 +125,35 @@ public class FunctionTest extends AbstractAnalyticsStatsTest {
double result = (Double)getStatResult("pr", "sum", VAL_TYPE.DOUBLE);
double calculated = (Double)getStatResult("pr", "sumc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("power sum", result, calculated, 0.0);
result = (Double)getStatResult("pr", "mean", VAL_TYPE.DOUBLE);
calculated = (Double)getStatResult("pr", "meanc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("power mean", result, calculated, 0.0);
}
@Test
public void negateTest() throws Exception {
double result = (Double)getStatResult("nr", "sum", VAL_TYPE.DOUBLE);
double calculated = (Double)getStatResult("nr", "sumc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("negate sum", result, calculated, 0.0);
result = (Double)getStatResult("nr", "mean", VAL_TYPE.DOUBLE);
calculated = (Double)getStatResult("nr", "meanc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("negate mean", result, calculated, 0.0);
}
@Test @Ignore("SOLR-5488")
@Test
public void absoluteValueTest() throws Exception {
double result = (Double)getStatResult("avr", "sum", VAL_TYPE.DOUBLE);
double calculated = (Double)getStatResult("avr", "sumc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
System.out.println(Double.doubleToRawLongBits(result) + " " + Double.doubleToRawLongBits(calculated) );
assertEquals("absolute values sum", result, calculated, 0.0);
result = (Double)getStatResult("avr", "mean", VAL_TYPE.DOUBLE);
calculated = (Double)getStatResult("avr", "meanc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("absolute values mean", result, calculated, 0.0);
}
@Test
@ -158,21 +161,23 @@ public class FunctionTest extends AbstractAnalyticsStatsTest {
double result = (Double)getStatResult("cnr", "sum", VAL_TYPE.DOUBLE);
double calculated = (Double)getStatResult("cnr", "sumc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("constant sum", result, calculated, 0.0);
result = (Double)getStatResult("cnr", "mean", VAL_TYPE.DOUBLE);
calculated = (Double)getStatResult("cnr", "meanc", VAL_TYPE.DOUBLE);
assertTrue(result==calculated);
assertEquals("constant mean", result, calculated, 0.0);
}
@Test
public void dateMathTest() throws Exception {
String result = (String)getStatResult("dmr", "median", VAL_TYPE.STRING);
String calculated = (String)getStatResult("dmr", "medianc", VAL_TYPE.STRING);
assertTrue(result.equals(calculated));
assertEquals("date math median", result, calculated);
result = (String)getStatResult("dmr", "max", VAL_TYPE.STRING);
calculated = (String)getStatResult("dmr", "maxc", VAL_TYPE.STRING);
assertTrue(result.equals(calculated));
assertEquals("date math mean", result, calculated);
}
@Test
@ -180,51 +185,52 @@ public class FunctionTest extends AbstractAnalyticsStatsTest {
String result = (String)getStatResult("cdr", "median", VAL_TYPE.STRING);
String calculated = (String)getStatResult("cdr", "medianc", VAL_TYPE.STRING);
assertTrue(result.equals(calculated));
assertEquals("constant date median", result, calculated);
result = (String)getStatResult("cdr", "max", VAL_TYPE.STRING);
calculated = (String)getStatResult("cdr", "maxc", VAL_TYPE.STRING);
assertTrue(result.equals(calculated));
assertEquals("constant date mean", result, calculated);
}
@Test
public void constantStringTest() throws Exception {
String result = (String)getStatResult("csr", "min", VAL_TYPE.STRING);
String calculated = (String)getStatResult("csr", "minc", VAL_TYPE.STRING);
assertTrue(result.equals(calculated));
assertEquals("constant min", result, calculated);
result = (String)getStatResult("csr", "max", VAL_TYPE.STRING);
calculated = (String)getStatResult("csr", "maxc", VAL_TYPE.STRING);
assertTrue(result.equals(calculated));
assertEquals("constant max", result, calculated);
}
@Test
public void concatenateTest() throws Exception {
String result = (String)getStatResult("cr", "min", VAL_TYPE.STRING);
String calculated = (String)getStatResult("cr", "minc", VAL_TYPE.STRING);
assertTrue(result.equals(calculated));
assertEquals("concat min", result, calculated);
result = (String)getStatResult("cr", "max", VAL_TYPE.STRING);
calculated = (String)getStatResult("cr", "maxc", VAL_TYPE.STRING);
assertTrue(result.equals(calculated));
assertEquals("concat max", result, calculated);
}
@Test
public void reverseTest() throws Exception {
String result = (String)getStatResult("rr", "min", VAL_TYPE.STRING);
String calculated = (String)getStatResult("rr", "minc", VAL_TYPE.STRING);
assertTrue(result.equals(calculated));
assertEquals("reverse min", result, calculated);
result = (String)getStatResult("rr", "max", VAL_TYPE.STRING);
calculated = (String)getStatResult("rr", "maxc", VAL_TYPE.STRING);
assertTrue(result.equals(calculated));
assertEquals("reverse max", result, calculated);
}
@Test
public void missingTest() throws Exception {
double min = (Double)getStatResult("ms", "min", VAL_TYPE.DOUBLE);
double max = (Double)getStatResult("ms", "max", VAL_TYPE.DOUBLE);
Assert.assertEquals((Double)48.0,(Double)max);
Assert.assertEquals((Double)1.0,(Double)min);
assertEquals("missingTest 1", 48.0d, max, 0.0);
assertEquals("missingTest 2", 1.0d, min, 0.0);
}
}