mirror of
https://github.com/corda/corda.git
synced 2025-01-30 16:14:39 +00:00
Add node scheduler db tests inside use block (#3075)
This commit is contained in:
parent
57b617c7d9
commit
f8a4368310
@ -234,20 +234,21 @@ class NodeSchedulerPersistenceTest : NodeSchedulerServiceTestBase() {
|
|||||||
val timeInTheFuture = mark + 1.days
|
val timeInTheFuture = mark + 1.days
|
||||||
val stateRef = StateRef(SecureHash.zeroHash, 0)
|
val stateRef = StateRef(SecureHash.zeroHash, 0)
|
||||||
|
|
||||||
val database = configureDatabase(dataSourceProps, databaseConfig, rigorousMock())
|
configureDatabase(dataSourceProps, databaseConfig, rigorousMock()).use { database ->
|
||||||
val scheduler = database.transaction {
|
val scheduler = database.transaction {
|
||||||
createScheduler(database)
|
createScheduler(database)
|
||||||
}
|
}
|
||||||
|
|
||||||
val ssr1 = ScheduledStateRef(stateRef, timeInTheFuture)
|
val ssr1 = ScheduledStateRef(stateRef, timeInTheFuture)
|
||||||
database.transaction {
|
database.transaction {
|
||||||
scheduler.scheduleStateActivity(ssr1)
|
scheduler.scheduleStateActivity(ssr1)
|
||||||
|
}
|
||||||
|
// 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()
|
||||||
}
|
}
|
||||||
// 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 flowLogic = rigorousMock<FlowLogic<*>>()
|
||||||
val logicRef = rigorousMock<FlowLogicRef>()
|
val logicRef = rigorousMock<FlowLogicRef>()
|
||||||
@ -255,15 +256,15 @@ class NodeSchedulerPersistenceTest : NodeSchedulerServiceTestBase() {
|
|||||||
transactionStates[stateRef] = transactionStateMock(logicRef, timeInTheFuture)
|
transactionStates[stateRef] = transactionStateMock(logicRef, timeInTheFuture)
|
||||||
flows[logicRef] = flowLogic
|
flows[logicRef] = flowLogic
|
||||||
|
|
||||||
val newDatabase = configureDatabase(dataSourceProps, DatabaseConfig(), rigorousMock())
|
configureDatabase(dataSourceProps, DatabaseConfig(), rigorousMock()).use { database ->
|
||||||
val newScheduler = newDatabase.transaction {
|
val newScheduler = database.transaction {
|
||||||
createScheduler(newDatabase)
|
createScheduler(database)
|
||||||
}
|
}
|
||||||
testClock.advanceBy(1.days)
|
testClock.advanceBy(1.days)
|
||||||
assertStarted(flowLogic)
|
assertStarted(flowLogic)
|
||||||
|
|
||||||
newScheduler.join()
|
newScheduler.join()
|
||||||
newDatabase.close()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("Temporarily")
|
@Ignore("Temporarily")
|
||||||
@ -277,25 +278,25 @@ class NodeSchedulerPersistenceTest : NodeSchedulerServiceTestBase() {
|
|||||||
val ssr2 = ScheduledStateRef(stateRef, timeInTheFuture)
|
val ssr2 = ScheduledStateRef(stateRef, timeInTheFuture)
|
||||||
val logicRef = rigorousMock<FlowLogicRef>()
|
val logicRef = rigorousMock<FlowLogicRef>()
|
||||||
val flowLogic = rigorousMock<FlowLogic<*>>()
|
val flowLogic = rigorousMock<FlowLogic<*>>()
|
||||||
val database = configureDatabase(dataSourceProps, databaseConfig, rigorousMock())
|
|
||||||
|
|
||||||
val scheduler = database.transaction {
|
configureDatabase(dataSourceProps, databaseConfig, rigorousMock()).use { database ->
|
||||||
createScheduler(database)
|
val scheduler = database.transaction {
|
||||||
|
createScheduler(database)
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionStates[stateRef] = transactionStateMock(logicRef, timeInTheFuture)
|
||||||
|
flows[logicRef] = flowLogic
|
||||||
|
|
||||||
|
database.transaction {
|
||||||
|
scheduler.scheduleStateActivity(ssr1)
|
||||||
|
session.flush()
|
||||||
|
scheduler.scheduleStateActivity(ssr2)
|
||||||
|
}
|
||||||
|
assertWaitingFor(ssr1)
|
||||||
|
testClock.advanceBy(1.days)
|
||||||
|
assertStarted(flowLogic)
|
||||||
|
|
||||||
|
scheduler.join()
|
||||||
}
|
}
|
||||||
|
|
||||||
transactionStates[stateRef] = transactionStateMock(logicRef, timeInTheFuture)
|
|
||||||
flows[logicRef] = flowLogic
|
|
||||||
|
|
||||||
database.transaction {
|
|
||||||
scheduler.scheduleStateActivity(ssr1)
|
|
||||||
session.flush()
|
|
||||||
scheduler.scheduleStateActivity(ssr2)
|
|
||||||
}
|
|
||||||
assertWaitingFor(ssr1)
|
|
||||||
testClock.advanceBy(1.days)
|
|
||||||
assertStarted(flowLogic)
|
|
||||||
|
|
||||||
scheduler.join()
|
|
||||||
database.close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user