Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make tests deterministic again

  • Loading branch information...
commit ff67835128b6cdbaff5719129d3ff76be977d159 1 parent 4836e80
@holdenk holdenk authored
View
30 src/test/scala/com/foursquare/slashem/ElasticQueryTest.scala
@@ -421,6 +421,9 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
@Before
+ def setup() {
+ hoboPrepIndex()
+ }
def hoboPrepIndex() {
ESimplePanda.meta.node = ElasticNode.node
ESimpleGeoPanda.meta.node = ElasticNode.node
@@ -608,6 +611,9 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
}
@After
+ def done() {
+ hoboDone()
+ }
def hoboDone() {
ESimplePanda.meta.node = ElasticNode.node
ESimpleGeoPanda.meta.node = ElasticNode.node
@@ -623,6 +629,30 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
}
}
+//Optimize tests
+
+ //We test this because the optimizer screwed this up once
+ @Test
+ def testTermFiltersOptimize {
+ val q = ESimplePanda where (_.hugenums contains 1L) filter(_.termsfield in List("termhit", "randomterm"))
+ val res1 = q fetch()
+ val res2 = q optimize() fetch()
+ Assert.assertEquals(res1.response.results.length, res2.response.results.length)
+ }
+
+ @Test
+ def testTermFiltersMetallFilter {
+ val q = ESimpleGeoPanda where (_.name contains "ordertest") filter(_.metall any)
+ val q2 = ESimpleGeoPanda where (_.name contains "ordertest")
+ val res1 = q fetch()
+ val res2 = q optimize() fetch()
+ val res3 = q2 fetch()
+ Assert.assertEquals(res1.response.results.length, res2.response.results.length)
+ Assert.assertEquals(res1.response.results.length, res3.response.results.length)
+ Assert.assertEquals(q.optimize(),q2)
+ }
+
+
}
object ElasticQueryTest extends ElasticQueryTest {
View
30 src/test/scala/com/foursquare/slashem/OptimizeTest.scala
@@ -29,27 +29,6 @@ import java.util.concurrent.{Executors, ExecutorService}
class OptimizeTest extends SpecsMatchers with ScalaCheckMatchers {
- //We test this because the optimizer screwed this up once
- @Test
- def testTermFiltersOptimize {
- val q = ESimplePanda where (_.hugenums contains 1L) filter(_.termsfield in List("termhit", "randomterm"))
- val res1 = q fetch()
- val res2 = q optimize() fetch()
- Assert.assertEquals(res1.response.results.length, res2.response.results.length)
- }
-
- @Test
- def testTermFiltersMetallFilter {
- val q = ESimpleGeoPanda where (_.name contains "ordertest") filter(_.metall any)
- val q2 = ESimpleGeoPanda where (_.name contains "ordertest")
- val res1 = q fetch()
- val res2 = q optimize() fetch()
- val res3 = q2 fetch()
- Assert.assertEquals(res1.response.results.length, res2.response.results.length)
- Assert.assertEquals(res1.response.results.length, res3.response.results.length)
- Assert.assertEquals(q.optimize(),q2)
- }
-
@Test
def testProduceCorrectListfieldFilterAny {
val q = SVenueTest where (_.metall any) filter (_.metall any)
@@ -61,14 +40,5 @@ class OptimizeTest extends SpecsMatchers with ScalaCheckMatchers {
"rows" -> "10").sortWith(_._1 > _._1))
}
- @Before
- def esSetup {
- ElasticQueryTest.hoboPrepIndex()
- }
-
- @After
- def esDone {
- ElasticQueryTest.hoboDone()
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.