Add node scheduler db tests inside use block (#3075)

This commit is contained in:
Anthony Keenan 2018-05-04 13:03:02 +01:00 committed by GitHub
parent 57b617c7d9
commit f8a4368310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -234,7 +234,7 @@ class NodeSchedulerPersistenceTest : NodeSchedulerServiceTestBase() {
val timeInTheFuture = mark + 1.days
val stateRef = StateRef(SecureHash.zeroHash, 0)
val database = configureDatabase(dataSourceProps, databaseConfig, rigorousMock())
configureDatabase(dataSourceProps, databaseConfig, rigorousMock()).use { database ->
val scheduler = database.transaction {
createScheduler(database)
}
@ -245,9 +245,10 @@ class NodeSchedulerPersistenceTest : NodeSchedulerServiceTestBase() {
}
// XXX: For some reason without the commit the db closes without writing the transactions
database.dataSource.connection.commit()
// Force the thread to shut down with operations waiting
scheduler.cancelAndWait()
database.close()
}
val flowLogic = rigorousMock<FlowLogic<*>>()
val logicRef = rigorousMock<FlowLogicRef>()
@ -255,15 +256,15 @@ class NodeSchedulerPersistenceTest : NodeSchedulerServiceTestBase() {
transactionStates[stateRef] = transactionStateMock(logicRef, timeInTheFuture)
flows[logicRef] = flowLogic
val newDatabase = configureDatabase(dataSourceProps, DatabaseConfig(), rigorousMock())
val newScheduler = newDatabase.transaction {
createScheduler(newDatabase)
configureDatabase(dataSourceProps, DatabaseConfig(), rigorousMock()).use { database ->
val newScheduler = database.transaction {
createScheduler(database)
}
testClock.advanceBy(1.days)
assertStarted(flowLogic)
newScheduler.join()
newDatabase.close()
}
}
@Ignore("Temporarily")
@ -277,8 +278,8 @@ class NodeSchedulerPersistenceTest : NodeSchedulerServiceTestBase() {
val ssr2 = ScheduledStateRef(stateRef, timeInTheFuture)
val logicRef = rigorousMock<FlowLogicRef>()
val flowLogic = rigorousMock<FlowLogic<*>>()
val database = configureDatabase(dataSourceProps, databaseConfig, rigorousMock())
configureDatabase(dataSourceProps, databaseConfig, rigorousMock()).use { database ->
val scheduler = database.transaction {
createScheduler(database)
}
@ -296,6 +297,6 @@ class NodeSchedulerPersistenceTest : NodeSchedulerServiceTestBase() {
assertStarted(flowLogic)
scheduler.join()
database.close()
}
}
}