diff --git a/node/src/integration-test/kotlin/net/corda/node/AuthDBTests.kt b/node/src/integration-test/kotlin/net/corda/node/AuthDBTests.kt index 70293b6074..7314df162c 100644 --- a/node/src/integration-test/kotlin/net/corda/node/AuthDBTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/AuthDBTests.kt @@ -22,6 +22,7 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized +import java.sql.Connection import java.sql.Statement import java.util.* import javax.sql.DataSource @@ -33,7 +34,7 @@ import kotlin.test.assertFailsWith */ @RunWith(Parameterized::class) class AuthDBTests : NodeBasedTest() { - private lateinit var node: NodeWithInfo + private var node: NodeWithInfo? = null private lateinit var client: CordaRPCClient private lateinit var db: UsersDB @@ -93,8 +94,9 @@ class AuthDBTests : NodeBasedTest() { ) ) - node = startNode(ALICE_NAME, rpcUsers = emptyList(), configOverrides = securityConfig) - client = CordaRPCClient(node.node.configuration.rpcOptions.address) + node = startNode(ALICE_NAME, rpcUsers = emptyList(), configOverrides = securityConfig).also { node -> + client = CordaRPCClient(node.node.configuration.rpcOptions.address) + } } @Test(timeout=300_000) @@ -215,6 +217,7 @@ class AuthDBTests : NodeBasedTest() { @After fun tearDown() { + node?.node?.stop() db.close() } @@ -228,7 +231,7 @@ private data class RoleAndPermissions(val role: String, val permissions: List = emptyList(), roleAndPermissions: List = emptyList()) : AutoCloseable { - val jdbcUrl = "jdbc:h2:mem:$name;DB_CLOSE_DELAY=-1" + val jdbcUrl = "jdbc:h2:mem:$name" companion object { const val DB_CREATE_SCHEMA = """ @@ -269,36 +272,34 @@ private class UsersDB(name: String, users: List = emptyList(), rol } } - private val dataSource: DataSource + private val connection: Connection private inline fun session(statement: (Statement) -> Unit) { - dataSource.connection.use { - it.autoCommit = false - it.createStatement().use(statement) - it.commit() - } + connection.createStatement().use(statement) + connection.commit() } init { - dataSource = DataSourceFactory.createDataSource(Properties().apply { + require(users.map { it.username }.toSet().size == users.size) { + "Duplicate username in input" + } + connection = DataSourceFactory.createDataSource(Properties().apply { put("dataSourceClassName", "org.h2.jdbcx.JdbcDataSource") put("dataSource.url", jdbcUrl) }, false) + .connection + .apply { + autoCommit = false + } session { it.execute(DB_CREATE_SCHEMA) } - require(users.map { it.username }.toSet().size == users.size) { - "Duplicate username in input" - } users.forEach { insert(it) } roleAndPermissions.forEach { insert(it) } } override fun close() { - dataSource.connection.use { - it.createStatement().use { - it.execute("DROP ALL OBJECTS") - } - } + // Close the connection, at which point the database will shut down + connection.close() } } diff --git a/node/src/integration-test/kotlin/net/corda/node/services/statemachine/LargeTransactionsTest.kt b/node/src/integration-test/kotlin/net/corda/node/services/statemachine/LargeTransactionsTest.kt index 6d23503efb..7830412980 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/statemachine/LargeTransactionsTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/statemachine/LargeTransactionsTest.kt @@ -22,6 +22,7 @@ import net.corda.testing.driver.driver import net.corda.testing.node.User import net.corda.testing.node.internal.DUMMY_CONTRACTS_CORDAPP import net.corda.testing.node.internal.enclosedCordapp +import org.junit.Ignore import org.junit.Test import kotlin.test.assertEquals @@ -29,6 +30,7 @@ import kotlin.test.assertEquals * Check that we can add lots of large attachments to a transaction and that it works OK, e.g. does not hit the * transaction size limit (which should only consider the hashes). */ +@Ignore("ENT-5679: This test triggers OOM errors") class LargeTransactionsTest { private companion object { val BOB = TestIdentity(BOB_NAME, 80).party diff --git a/node/src/integration-test/kotlin/net/corda/node/services/vault/VaultObserverExceptionTest.kt b/node/src/integration-test/kotlin/net/corda/node/services/vault/VaultObserverExceptionTest.kt index 5cd4529c6d..39cf80be37 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/vault/VaultObserverExceptionTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/vault/VaultObserverExceptionTest.kt @@ -50,6 +50,7 @@ import kotlin.test.assertTrue class VaultObserverExceptionTest { companion object { + val waitForFlowDuration = 45.seconds val log = contextLogger() private fun testCordapps() = listOf( @@ -97,7 +98,7 @@ class VaultObserverExceptionTest { "Syntax Error in Custom SQL", CreateStateFlow.errorTargetsToNum(CreateStateFlow.ErrorTarget.ServiceSqlSyntaxError) ).returnValue.then { testControlFuture.complete(false) } - val foundExpectedException = testControlFuture.getOrThrow(30.seconds) + val foundExpectedException = testControlFuture.getOrThrow(waitForFlowDuration) Assert.assertTrue(foundExpectedException) } @@ -131,7 +132,7 @@ class VaultObserverExceptionTest { "Syntax Error in Custom SQL", CreateStateFlow.errorTargetsToNum(CreateStateFlow.ErrorTarget.ServiceSqlSyntaxError) ).returnValue.then { testControlFuture.complete(false) } - val foundExpectedException = testControlFuture.getOrThrow(30.seconds) + val foundExpectedException = testControlFuture.getOrThrow(waitForFlowDuration) Assert.assertTrue(foundExpectedException) } @@ -222,7 +223,7 @@ class VaultObserverExceptionTest { assertFailsWith("PersistenceException") { aliceNode.rpc.startFlow(CreateStateFlow::Initiator, "EntityManager", errorTargetsToNum( CreateStateFlow.ErrorTarget.TxInvalidState)) - .returnValue.getOrThrow(30.seconds) + .returnValue.getOrThrow(waitForFlowDuration) } } Assert.assertTrue("Flow has not been to hospital", counter > 0) @@ -258,7 +259,7 @@ class VaultObserverExceptionTest { CreateStateFlow.ErrorTarget.TxInvalidState, CreateStateFlow.ErrorTarget.FlowSwallowErrors)) val flowResult = flowHandle.returnValue - assertFailsWith("PersistenceException") { flowResult.getOrThrow(30.seconds) } + assertFailsWith("PersistenceException") { flowResult.getOrThrow(waitForFlowDuration) } Assert.assertTrue("Flow has not been to hospital", counter > 0) } } @@ -289,7 +290,7 @@ class VaultObserverExceptionTest { log.info("Flow has finished") testControlFuture.set(false) } - Assert.assertTrue("Flow has not been kept in hospital", testControlFuture.getOrThrow(30.seconds)) + Assert.assertTrue("Flow has not been kept in hospital", testControlFuture.getOrThrow(waitForFlowDuration)) } } @@ -308,7 +309,7 @@ class VaultObserverExceptionTest { CreateStateFlow.ErrorTarget.ServiceSqlSyntaxError, CreateStateFlow.ErrorTarget.ServiceSwallowErrors)) val flowResult = flowHandle.returnValue - flowResult.getOrThrow(30.seconds) + flowResult.getOrThrow(waitForFlowDuration) } } @@ -409,7 +410,7 @@ class VaultObserverExceptionTest { testControlFuture.complete(true) } startNode(providedName = ALICE_NAME, rpcUsers = listOf(aliceUser), startInSameProcess = true).getOrThrow() - assert(testControlFuture.getOrThrow(30.seconds)) + assert(testControlFuture.getOrThrow(waitForFlowDuration)) } else { throw IllegalStateException("Out of process node is still up and running!") } @@ -459,7 +460,7 @@ class VaultObserverExceptionTest { CreateStateFlow::Initiator, "AllGood", errorTargetsToNum(CreateStateFlow.ErrorTarget.ServiceSqlSyntaxErrorOnConsumed) - ).returnValue.getOrThrow(30.seconds) + ).returnValue.getOrThrow(waitForFlowDuration) println("Created new state") @@ -550,7 +551,7 @@ class VaultObserverExceptionTest { "AllGood", // should be a hospital exception errorTargetsToNum(CreateStateFlow.ErrorTarget.ServiceSqlSyntaxErrorOnConsumed) - ).returnValue.getOrThrow(30.seconds) + ).returnValue.getOrThrow(waitForFlowDuration) val flowHandle = aliceNode.rpc.startFlow( SendStateFlow::PassErroneousOwnableState, @@ -626,7 +627,7 @@ class VaultObserverExceptionTest { CreateStateFlow::Initiator, "AllGood", errorTargetsToNum(CreateStateFlow.ErrorTarget.NoError) - ).returnValue.getOrThrow(30.seconds) + ).returnValue.getOrThrow(waitForFlowDuration) aliceNode.rpc.startFlow( SendStateFlow::PassErroneousOwnableState, @@ -701,7 +702,7 @@ class VaultObserverExceptionTest { CreateStateFlow::Initiator, "AllGood", errorTargetsToNum(CreateStateFlow.ErrorTarget.ServiceSqlSyntaxErrorOnConsumed) - ).returnValue.getOrThrow(30.seconds) + ).returnValue.getOrThrow(waitForFlowDuration) val flowHandle = aliceNode.rpc.startFlow( SendStateFlow::PassErroneousOwnableState, @@ -756,7 +757,7 @@ class VaultObserverExceptionTest { "Flow ${SubscribingRawUpdatesFlow::class.java.name} tried to access VaultService.rawUpdates " + "- Rx.Observables should only be accessed outside the context of a flow " ) { - flowHandle.returnValue.getOrThrow(30.seconds) + flowHandle.returnValue.getOrThrow(waitForFlowDuration) } } }