Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make tests deterministic again

  • Loading branch information...
commit ff67835128b6cdbaff5719129d3ff76be977d159 1 parent 4836e80
Holden Karau holdenk authored
30 src/test/scala/com/foursquare/slashem/ElasticQueryTest.scala
@@ -421,6 +421,9 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
421 421
422 422
423 423 @Before
  424 + def setup() {
  425 + hoboPrepIndex()
  426 + }
424 427 def hoboPrepIndex() {
425 428 ESimplePanda.meta.node = ElasticNode.node
426 429 ESimpleGeoPanda.meta.node = ElasticNode.node
@@ -608,6 +611,9 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
608 611
609 612 }
610 613 @After
  614 + def done() {
  615 + hoboDone()
  616 + }
611 617 def hoboDone() {
612 618 ESimplePanda.meta.node = ElasticNode.node
613 619 ESimpleGeoPanda.meta.node = ElasticNode.node
@@ -623,6 +629,30 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
623 629 }
624 630 }
625 631
  632 +//Optimize tests
  633 +
  634 + //We test this because the optimizer screwed this up once
  635 + @Test
  636 + def testTermFiltersOptimize {
  637 + val q = ESimplePanda where (_.hugenums contains 1L) filter(_.termsfield in List("termhit", "randomterm"))
  638 + val res1 = q fetch()
  639 + val res2 = q optimize() fetch()
  640 + Assert.assertEquals(res1.response.results.length, res2.response.results.length)
  641 + }
  642 +
  643 + @Test
  644 + def testTermFiltersMetallFilter {
  645 + val q = ESimpleGeoPanda where (_.name contains "ordertest") filter(_.metall any)
  646 + val q2 = ESimpleGeoPanda where (_.name contains "ordertest")
  647 + val res1 = q fetch()
  648 + val res2 = q optimize() fetch()
  649 + val res3 = q2 fetch()
  650 + Assert.assertEquals(res1.response.results.length, res2.response.results.length)
  651 + Assert.assertEquals(res1.response.results.length, res3.response.results.length)
  652 + Assert.assertEquals(q.optimize(),q2)
  653 + }
  654 +
  655 +
626 656 }
627 657
628 658 object ElasticQueryTest extends ElasticQueryTest {
30 src/test/scala/com/foursquare/slashem/OptimizeTest.scala
@@ -29,27 +29,6 @@ import java.util.concurrent.{Executors, ExecutorService}
29 29
30 30 class OptimizeTest extends SpecsMatchers with ScalaCheckMatchers {
31 31
32   - //We test this because the optimizer screwed this up once
33   - @Test
34   - def testTermFiltersOptimize {
35   - val q = ESimplePanda where (_.hugenums contains 1L) filter(_.termsfield in List("termhit", "randomterm"))
36   - val res1 = q fetch()
37   - val res2 = q optimize() fetch()
38   - Assert.assertEquals(res1.response.results.length, res2.response.results.length)
39   - }
40   -
41   - @Test
42   - def testTermFiltersMetallFilter {
43   - val q = ESimpleGeoPanda where (_.name contains "ordertest") filter(_.metall any)
44   - val q2 = ESimpleGeoPanda where (_.name contains "ordertest")
45   - val res1 = q fetch()
46   - val res2 = q optimize() fetch()
47   - val res3 = q2 fetch()
48   - Assert.assertEquals(res1.response.results.length, res2.response.results.length)
49   - Assert.assertEquals(res1.response.results.length, res3.response.results.length)
50   - Assert.assertEquals(q.optimize(),q2)
51   - }
52   -
53 32 @Test
54 33 def testProduceCorrectListfieldFilterAny {
55 34 val q = SVenueTest where (_.metall any) filter (_.metall any)
@@ -61,14 +40,5 @@ class OptimizeTest extends SpecsMatchers with ScalaCheckMatchers {
61 40 "rows" -> "10").sortWith(_._1 > _._1))
62 41 }
63 42
64   - @Before
65   - def esSetup {
66   - ElasticQueryTest.hoboPrepIndex()
67   - }
68   -
69   - @After
70   - def esDone {
71   - ElasticQueryTest.hoboDone()
72   - }
73 43
74 44 }

0 comments on commit ff67835

Please sign in to comment.
Something went wrong with that request. Please try again.