SOLR-11388: Add test case

This commit is contained in:
Joel Bernstein 2017-09-23 21:31:22 -04:00
parent e5fc39f551
commit 7da8325cee
1 changed files with 27 additions and 1 deletions

View File

@ -6519,12 +6519,38 @@ public class StreamExpressionTest extends SolrCloudTestCase {
List<Tuple> tuples = getTuples(solrStream);
assertTrue(tuples.size() == 1);
List<Number> out = (List<Number>)tuples.get(0).get("return-value");
assertTrue(out.size()==3);
assertTrue(out.size() == 3);
assertEquals(out.get(0).doubleValue(), 6.0, .0);
assertEquals(out.get(1).doubleValue(), 9.0, .0);
assertEquals(out.get(2).doubleValue(), 10.0, .0);
}
@Test
public void testMonteCarlo() throws Exception {
String cexpr = "let(a=constantDistribution(10), b=constantDistribution(20), c=monteCarlo(add(sample(a), sample(b)), 10))";
ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
paramsLoc.set("expr", cexpr);
paramsLoc.set("qt", "/stream");
String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString()+"/"+COLLECTIONORALIAS;
TupleStream solrStream = new SolrStream(url, paramsLoc);
StreamContext context = new StreamContext();
solrStream.setStreamContext(context);
List<Tuple> tuples = getTuples(solrStream);
assertTrue(tuples.size() == 1);
List<Number> out = (List<Number>)tuples.get(0).get("c");
assertTrue(out.size()==10);
assertEquals(out.get(0).doubleValue(), 30.0, .0);
assertEquals(out.get(1).doubleValue(), 30.0, .0);
assertEquals(out.get(2).doubleValue(), 30.0, .0);
assertEquals(out.get(3).doubleValue(), 30.0, .0);
assertEquals(out.get(4).doubleValue(), 30.0, .0);
assertEquals(out.get(5).doubleValue(), 30.0, .0);
assertEquals(out.get(6).doubleValue(), 30.0, .0);
assertEquals(out.get(7).doubleValue(), 30.0, .0);
assertEquals(out.get(8).doubleValue(), 30.0, .0);
assertEquals(out.get(9).doubleValue(), 30.0, .0);
}
@Test
public void testScale() throws Exception {