Skip to content

Commit

Permalink
finos#1196 fix intermittently failing tests
Browse files Browse the repository at this point in the history
- with this fix we also improve performance for IgniteOrderStoreTest
  as now we only clear cache instead of restarting whole ignite before
  each test.
  • Loading branch information
junaidzm13 committed Feb 20, 2024
1 parent 95a8474 commit 28c3a38
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package org.finos.vuu.example.ignite
import org.apache.ignite.cache.query.IndexQueryCriteriaBuilder
import org.apache.ignite.{Ignite, IgniteCache}
import org.finos.vuu.core.module.simul.model.{ChildOrder, ParentOrder}
import org.scalatest.BeforeAndAfter
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach}
import org.scalatest.funsuite.AnyFunSuiteLike
import org.scalatest.matchers.should.Matchers

class IgniteOrderStoreTest extends AnyFunSuiteLike with BeforeAndAfter with Matchers {
class IgniteOrderStoreTest extends AnyFunSuiteLike with BeforeAndAfterAll with BeforeAndAfterEach with Matchers {
private var ignite: Ignite = _
private var parentOrderCache: IgniteCache[Int, ParentOrder] = _
private var childOrderCache: IgniteCache[Int, ChildOrder] = _
Expand All @@ -16,13 +16,18 @@ class IgniteOrderStoreTest extends AnyFunSuiteLike with BeforeAndAfter with Matc
private val emptySortQueries: String = ""
private val emptyFilterQueries: String = ""

before {
override def beforeAll(): Unit = {
ignite = TestUtils.setupIgnite()
parentOrderCache = ignite.getOrCreateCache("parentOrderCache")
childOrderCache = ignite.getOrCreateCache("childOrderCache")
orderStore = new IgniteOrderStore(parentOrderCache, childOrderCache)
}

override def beforeEach(): Unit = {
childOrderCache.clear()
parentOrderCache.clear()
}

test("Ignite Store And Find Order") {
GivenParentOrder(1)

Expand Down Expand Up @@ -225,7 +230,7 @@ class IgniteOrderStoreTest extends AnyFunSuiteLike with BeforeAndAfter with Matc
updatedParentOrder
}

after {
override def afterAll(): Unit = {
ignite.close()
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
package org.finos.vuu.example.ignite.provider

import org.apache.ignite.IgniteCache
import org.apache.ignite.Ignite
import org.finos.vuu.core.module.simul.model.{ChildOrder, ParentOrder}
import org.finos.vuu.core.sort.SortDirection
import org.finos.vuu.example.ignite.module.IgniteOrderDataModule
import org.finos.vuu.example.ignite.schema.IgniteChildOrderEntity
import org.finos.vuu.example.ignite.{IgniteOrderStore, TestUtils}
import org.finos.vuu.feature.ignite.schema.SchemaMapper
import org.finos.vuu.net.FilterSpec
import org.scalatest.BeforeAndAfterAll
import org.scalatest.funsuite.AnyFunSuiteLike
import org.scalatest.matchers.should.Matchers

class IgniteOrderDataQueryFunctionalTest extends AnyFunSuiteLike with Matchers {

private val ignite = TestUtils.setupIgnite()
private val parentOrderCache: IgniteCache[Int, ParentOrder] = ignite.getOrCreateCache("parentOrderCache")
private val childOrderCache: IgniteCache[Int, ChildOrder] = ignite.getOrCreateCache("childOrderCache")
private val orderStore = new IgniteOrderStore(parentOrderCache, childOrderCache)
class IgniteOrderDataQueryFunctionalTest extends AnyFunSuiteLike with BeforeAndAfterAll with Matchers {
private val schemaMapper = SchemaMapper(IgniteChildOrderEntity.getSchema, IgniteOrderDataModule.columns, IgniteOrderDataProvider.columnNameByExternalField)
private val dataQuery = IgniteOrderDataQuery(orderStore, schemaMapper)
private var ignite: Ignite = _
private var orderStore: IgniteOrderStore = _
private var dataQuery: IgniteOrderDataQuery = _

override def beforeAll(): Unit = {
ignite = TestUtils.setupIgnite()
val parentOrderCache = ignite.getOrCreateCache[Int, ParentOrder]("parentOrderCache")
val childOrderCache = ignite.getOrCreateCache[Int, ChildOrder]("childOrderCache")
orderStore = new IgniteOrderStore(parentOrderCache, childOrderCache)
dataQuery = IgniteOrderDataQuery(orderStore, schemaMapper)
}

override def afterAll(): Unit = {
ignite.close()
}

test("Can parse and apply filtering and sorting when fetching") {
test("Can parse and apply filters and sort when fetching") {
val testOrder1 = TestUtils.createChildOrder(1, ric = "ABC.HK", price = 5.55)
val testOrder2 = TestUtils.createChildOrder(2, ric = "ABC.LDN", price = 6.0)
val testOrder3 = TestUtils.createChildOrder(3, ric = "ABC.NY", price = 4.5)
Expand Down

0 comments on commit 28c3a38

Please sign in to comment.