From 63f11d0b54d0f3f8d8d27720fd614d211f56430d Mon Sep 17 00:00:00 2001 From: szymonsztuka Date: Mon, 4 Jun 2018 10:31:56 +0100 Subject: [PATCH] Upgrade integration test for CORDA-1356 to run in database mode (#899) Add SQL setup to run integration test in database mode, add ordering in test because original assumption that rows are returned as inserted doesn't work in Oracle db, ensure distinct names when starting nodes (they can't clash in database mode, as the schema name is taken from node name). --- .../compat/CashExceptionSerialisationTest.kt | 17 ++++++++++++++++- .../kotlin/net/corda/node/BootTests.kt | 10 +++------- .../services/rpc/RpcExceptionHandlingTest.kt | 11 +++++------ .../node/services/vault/VaultQueryTests.kt | 3 ++- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/finance/src/integration-test/kotlin/net/corda/finance/compat/CashExceptionSerialisationTest.kt b/finance/src/integration-test/kotlin/net/corda/finance/compat/CashExceptionSerialisationTest.kt index d26752ee6f..080d677b20 100644 --- a/finance/src/integration-test/kotlin/net/corda/finance/compat/CashExceptionSerialisationTest.kt +++ b/finance/src/integration-test/kotlin/net/corda/finance/compat/CashExceptionSerialisationTest.kt @@ -6,14 +6,29 @@ import net.corda.core.messaging.startFlow import net.corda.core.utilities.getOrThrow import net.corda.finance.flows.CashException import net.corda.node.services.Permissions.Companion.all +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.core.DUMMY_NOTARY_NAME import net.corda.testing.driver.DriverParameters 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 net.corda.testing.node.User import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy +import org.junit.ClassRule import org.junit.Test -class CashExceptionSerialisationTest { +class CashExceptionSerialisationTest : IntegrationTest() { + companion object { + @ClassRule + @JvmField + val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME) + .map { it.toDatabaseSchemaName() }.toTypedArray()) + } + @Test fun `cash exception with a cause can be serialised with AMQP`() { driver(DriverParameters(startNodesInProcess = true)) { diff --git a/node/src/integration-test/kotlin/net/corda/node/BootTests.kt b/node/src/integration-test/kotlin/net/corda/node/BootTests.kt index 28ddd0162f..1842f0ee63 100644 --- a/node/src/integration-test/kotlin/net/corda/node/BootTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/BootTests.kt @@ -25,10 +25,7 @@ import net.corda.node.internal.NodeStartup import net.corda.node.services.Permissions.Companion.startFlow import net.corda.nodeapi.exceptions.InternalNodeException import net.corda.testing.common.internal.ProjectStructure.projectRootDir -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.core.DUMMY_NOTARY_NAME +import net.corda.testing.core.* import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeHandle import net.corda.testing.driver.NodeParameters @@ -52,8 +49,7 @@ class BootTests : IntegrationTest() { companion object { @ClassRule @JvmField - val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME) - .map { it.toDatabaseSchemaName() }.toTypedArray()) + val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName()) } @Test @@ -68,7 +64,7 @@ class BootTests : IntegrationTest() { } } driver { - val devModeNode = startNode(params).getOrThrow() + val devModeNode = startNode(params, BOB_NAME).getOrThrow() val node = startNode(ALICE_NAME, devMode = false, parameters = params).getOrThrow() assertThatThrownBy { devModeNode.attemptJavaDeserialization() }.isInstanceOf(CordaRuntimeException::class.java) diff --git a/node/src/integration-test/kotlin/net/corda/node/services/rpc/RpcExceptionHandlingTest.kt b/node/src/integration-test/kotlin/net/corda/node/services/rpc/RpcExceptionHandlingTest.kt index 56be0c1cde..d8544a89c9 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/rpc/RpcExceptionHandlingTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/rpc/RpcExceptionHandlingTest.kt @@ -37,8 +37,7 @@ class RpcExceptionHandlingTest : IntegrationTest() { companion object { @ClassRule @JvmField - val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_BANK_B_NAME, DUMMY_NOTARY_NAME) - .map { it.toDatabaseSchemaName() }.toTypedArray()) + val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName()) } private val user = User("mark", "dadada", setOf(Permissions.all())) @@ -63,8 +62,8 @@ class RpcExceptionHandlingTest : IntegrationTest() { } driver(DriverParameters(startNodesInProcess = true, notarySpecs = emptyList())) { - val devModeNode = startNode(params).getOrThrow() - val node = startNode(DUMMY_BANK_B_NAME, devMode = false, parameters = params).getOrThrow() + val devModeNode = startNode(params, BOB_NAME).getOrThrow() + val node = startNode(ALICE_NAME, devMode = false, parameters = params).getOrThrow() assertThatThrownExceptionIsReceivedUnwrapped(devModeNode) assertThatThrownExceptionIsReceivedUnwrapped(node) @@ -82,8 +81,8 @@ class RpcExceptionHandlingTest : IntegrationTest() { } driver(DriverParameters(startNodesInProcess = true, notarySpecs = emptyList())) { - val devModeNode = startNode(params).getOrThrow() - val node = startNode(DUMMY_BANK_B_NAME, devMode = false, parameters = params).getOrThrow() + val devModeNode = startNode(params, BOB_NAME).getOrThrow() + val node = startNode(ALICE_NAME, devMode = false, parameters = params).getOrThrow() assertThatThrownBy { devModeNode.throwExceptionFromFlow() }.isInstanceOfSatisfying(FlowException::class.java) { exception -> diff --git a/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt b/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt index 72ef3f6346..133250100a 100644 --- a/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/vault/VaultQueryTests.kt @@ -1194,7 +1194,8 @@ abstract class VaultQueryTestsBase : VaultQueryParties { vaultFiller.fillWithSomeTestLinearStates(1, linearNumber = it.toLong(), linearString = it.toString()) } val max = builder { DummyLinearStateSchemaV1.PersistentDummyLinearState::linearTimestamp.max( - groupByColumns = listOf(DummyLinearStateSchemaV1.PersistentDummyLinearState::linearNumber) + groupByColumns = listOf(DummyLinearStateSchemaV1.PersistentDummyLinearState::linearNumber), + orderBy = Sort.Direction.ASC ) } val maxCriteria = VaultCustomQueryCriteria(max)