mirror of
https://github.com/corda/corda.git
synced 2025-03-16 00:55:24 +00:00
Features/fix integration test in database mode (#1276)
Fix new/altered integration tests to run in database mode, disable new H2 db specific test when running against a remote database.
This commit is contained in:
parent
cb4e428ec4
commit
2003881b77
@ -3,18 +3,30 @@ package net.corda.node
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.core.internal.errors.AddressBindingException
|
||||
import net.corda.testing.core.ALICE_NAME
|
||||
import net.corda.testing.core.BOB_NAME
|
||||
import net.corda.testing.core.DUMMY_BANK_A_NAME
|
||||
import net.corda.testing.driver.DriverParameters
|
||||
import net.corda.testing.driver.PortAllocation
|
||||
import net.corda.testing.driver.driver
|
||||
import net.corda.testing.internal.IntegrationTest
|
||||
import net.corda.testing.internal.IntegrationTestSchemas
|
||||
import net.corda.testing.internal.toDatabaseSchemaName
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.junit.Assume.assumeTrue
|
||||
import org.junit.ClassRule
|
||||
import org.junit.Test
|
||||
import java.net.InetSocketAddress
|
||||
import java.net.ServerSocket
|
||||
|
||||
class AddressBindingFailureTests {
|
||||
class AddressBindingFailureTests: IntegrationTest() {
|
||||
|
||||
companion object {
|
||||
@ClassRule
|
||||
@JvmField
|
||||
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(), DUMMY_BANK_A_NAME.toDatabaseSchemaName())
|
||||
|
||||
private val portAllocation = PortAllocation.Incremental(20_000)
|
||||
}
|
||||
|
||||
@ -28,7 +40,10 @@ class AddressBindingFailureTests {
|
||||
fun `rpc admin address`() = assertBindExceptionForOverrides { address -> mapOf("rpcSettings" to mapOf("adminAddress" to address.toString())) }
|
||||
|
||||
@Test
|
||||
fun `H2 address`() = assertBindExceptionForOverrides { address -> mapOf("h2Settings" to mapOf("address" to address.toString())) }
|
||||
fun `H2 address`() {
|
||||
assumeTrue(!IntegrationTest.isRemoteDatabaseMode()) // Enterprise only - disable test where running against remote database
|
||||
assertBindExceptionForOverrides { address -> mapOf("h2Settings" to mapOf("address" to address.toString())) }
|
||||
}
|
||||
|
||||
private fun assertBindExceptionForOverrides(overrides: (NetworkHostAndPort) -> Map<String, Any?>) {
|
||||
|
||||
|
@ -51,8 +51,8 @@ class FlowRetryTest : IntegrationTest() {
|
||||
portAllocation = RandomFree,
|
||||
notarySpecs = emptyList()
|
||||
)) {
|
||||
val nodeAHandle = startNode(rpcUsers = listOf(user)).getOrThrow()
|
||||
val nodeBHandle = startNode(rpcUsers = listOf(user)).getOrThrow()
|
||||
val nodeAHandle = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user)).getOrThrow()
|
||||
val nodeBHandle = startNode(providedName = BOB_NAME, rpcUsers = listOf(user)).getOrThrow()
|
||||
|
||||
val result = CordaRPCClient(nodeAHandle.rpcAddress).start(user.username, user.password).use {
|
||||
it.proxy.startFlow(::InitiatorFlow, numSessions, numIterations, nodeBHandle.nodeInfo.singleIdentity()).returnValue.getOrThrow()
|
||||
|
@ -61,7 +61,7 @@ abstract class IntegrationTest {
|
||||
@BeforeClass
|
||||
@JvmStatic
|
||||
fun globalSetUp() {
|
||||
if (dbProvider.isNotEmpty()) {
|
||||
if (isRemoteDatabaseMode()) {
|
||||
runDbScript(dbProvider,"$testDbScriptDir/db-global-cleanup.sql", databaseSchemas)
|
||||
runDbScript(dbProvider,"$testDbScriptDir/db-global-setup.sql", databaseSchemas)
|
||||
}
|
||||
@ -69,23 +69,25 @@ abstract class IntegrationTest {
|
||||
@AfterClass
|
||||
@JvmStatic
|
||||
fun globalTearDown() {
|
||||
if (dbProvider.isNotEmpty()) {
|
||||
if (isRemoteDatabaseMode()) {
|
||||
runDbScript(dbProvider,"$testDbScriptDir/db-global-cleanup.sql", databaseSchemas)
|
||||
}
|
||||
}
|
||||
|
||||
fun isRemoteDatabaseMode() = dbProvider.isNotEmpty()
|
||||
}
|
||||
|
||||
@Before
|
||||
@Throws(Exception::class)
|
||||
open fun setUp() {
|
||||
if (dbProvider.isNotEmpty()) {
|
||||
if (isRemoteDatabaseMode()) {
|
||||
runDbScript(dbProvider,"$testDbScriptDir/db-setup.sql", databaseSchemas)
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
open fun tearDown() {
|
||||
if (dbProvider.isNotEmpty()) {
|
||||
if (isRemoteDatabaseMode()) {
|
||||
runDbScript(dbProvider,"$testDbScriptDir/db-cleanup.sql", databaseSchemas)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user