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:
szymonsztuka 2018-07-17 12:40:05 +01:00 committed by GitHub
parent cb4e428ec4
commit 2003881b77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 8 deletions

View File

@ -3,18 +3,30 @@ package net.corda.node
import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.NetworkHostAndPort
import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.getOrThrow
import net.corda.core.internal.errors.AddressBindingException 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.DriverParameters
import net.corda.testing.driver.PortAllocation import net.corda.testing.driver.PortAllocation
import net.corda.testing.driver.driver 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.assertThat
import org.assertj.core.api.Assertions.assertThatThrownBy import org.assertj.core.api.Assertions.assertThatThrownBy
import org.junit.Assume.assumeTrue
import org.junit.ClassRule
import org.junit.Test import org.junit.Test
import java.net.InetSocketAddress import java.net.InetSocketAddress
import java.net.ServerSocket import java.net.ServerSocket
class AddressBindingFailureTests { class AddressBindingFailureTests: IntegrationTest() {
companion object { 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) 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())) } fun `rpc admin address`() = assertBindExceptionForOverrides { address -> mapOf("rpcSettings" to mapOf("adminAddress" to address.toString())) }
@Test @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?>) { private fun assertBindExceptionForOverrides(overrides: (NetworkHostAndPort) -> Map<String, Any?>) {

View File

@ -51,8 +51,8 @@ class FlowRetryTest : IntegrationTest() {
portAllocation = RandomFree, portAllocation = RandomFree,
notarySpecs = emptyList() notarySpecs = emptyList()
)) { )) {
val nodeAHandle = startNode(rpcUsers = listOf(user)).getOrThrow() val nodeAHandle = startNode(providedName = ALICE_NAME, rpcUsers = listOf(user)).getOrThrow()
val nodeBHandle = startNode(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 { val result = CordaRPCClient(nodeAHandle.rpcAddress).start(user.username, user.password).use {
it.proxy.startFlow(::InitiatorFlow, numSessions, numIterations, nodeBHandle.nodeInfo.singleIdentity()).returnValue.getOrThrow() it.proxy.startFlow(::InitiatorFlow, numSessions, numIterations, nodeBHandle.nodeInfo.singleIdentity()).returnValue.getOrThrow()

View File

@ -61,7 +61,7 @@ abstract class IntegrationTest {
@BeforeClass @BeforeClass
@JvmStatic @JvmStatic
fun globalSetUp() { fun globalSetUp() {
if (dbProvider.isNotEmpty()) { if (isRemoteDatabaseMode()) {
runDbScript(dbProvider,"$testDbScriptDir/db-global-cleanup.sql", databaseSchemas) runDbScript(dbProvider,"$testDbScriptDir/db-global-cleanup.sql", databaseSchemas)
runDbScript(dbProvider,"$testDbScriptDir/db-global-setup.sql", databaseSchemas) runDbScript(dbProvider,"$testDbScriptDir/db-global-setup.sql", databaseSchemas)
} }
@ -69,23 +69,25 @@ abstract class IntegrationTest {
@AfterClass @AfterClass
@JvmStatic @JvmStatic
fun globalTearDown() { fun globalTearDown() {
if (dbProvider.isNotEmpty()) { if (isRemoteDatabaseMode()) {
runDbScript(dbProvider,"$testDbScriptDir/db-global-cleanup.sql", databaseSchemas) runDbScript(dbProvider,"$testDbScriptDir/db-global-cleanup.sql", databaseSchemas)
} }
} }
fun isRemoteDatabaseMode() = dbProvider.isNotEmpty()
} }
@Before @Before
@Throws(Exception::class) @Throws(Exception::class)
open fun setUp() { open fun setUp() {
if (dbProvider.isNotEmpty()) { if (isRemoteDatabaseMode()) {
runDbScript(dbProvider,"$testDbScriptDir/db-setup.sql", databaseSchemas) runDbScript(dbProvider,"$testDbScriptDir/db-setup.sql", databaseSchemas)
} }
} }
@After @After
open fun tearDown() { open fun tearDown() {
if (dbProvider.isNotEmpty()) { if (isRemoteDatabaseMode()) {
runDbScript(dbProvider,"$testDbScriptDir/db-cleanup.sql", databaseSchemas) runDbScript(dbProvider,"$testDbScriptDir/db-cleanup.sql", databaseSchemas)
} }
} }