ENT-1566 Fixes for db integration tests + ENT-1575 db migrations for db attachment changes (#521)

ENT-1575 Add db migrations for db attachment changes,

ENT-1566 Fixes for db integration tests -following changes in CORDA-926 (obligatory node properties), upgrade db schema setup in draining mode/RPC tests, set runMigration=true in properties files for db tests, add new tables for deletion in SQL setup scrips
Updated db integration tests description in testing.rst
This commit is contained in:
szymonsztuka
2018-03-09 09:52:44 +00:00
committed by GitHub
parent 5f49bfc88a
commit b86071c5c5
61 changed files with 238 additions and 117 deletions

View File

@ -201,11 +201,11 @@ allprojects {
systemProperty(AMQP_ENABLE_PROP_NAME, System.getProperty(AMQP_ENABLE_PROP_NAME)) systemProperty(AMQP_ENABLE_PROP_NAME, System.getProperty(AMQP_ENABLE_PROP_NAME))
// relational database provider to be used by node // relational database provider to be used by node
final DATABASE_PROVIDER = "databaseProvider" final DATABASE_PROVIDER = "custom.databaseProvider"
final DATASOURCE_URL = "dataSourceProperties.dataSource.url" final DATASOURCE_URL = "corda.dataSourceProperties.dataSource.url"
final DATASOURCE_CLASSNAME = "dataSourceProperties.dataSourceClassName" final DATASOURCE_CLASSNAME = "corda.dataSourceProperties.dataSourceClassName"
final DATASOURCE_USER = "dataSourceProperties.dataSource.user" final DATASOURCE_USER = "corda.dataSourceProperties.dataSource.user"
final DATASOURCE_PASSWORD = "dataSourceProperties.dataSource.password" final DATASOURCE_PASSWORD = "corda.dataSourceProperties.dataSource.password"
// integration testing database configuration (to be used in conjunction with a DATABASE_PROVIDER) // integration testing database configuration (to be used in conjunction with a DATABASE_PROVIDER)
final TEST_DB_ADMIN_USER = "test.db.admin.user" final TEST_DB_ADMIN_USER = "test.db.admin.user"

View File

@ -67,7 +67,8 @@ class NodeMonitorModelTest : IntegrationTest() {
private lateinit var newNode: (CordaX500Name) -> NodeInfo private lateinit var newNode: (CordaX500Name) -> NodeInfo
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, CHARLIE_NAME, DUMMY_NOTARY_NAME) val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, CHARLIE_NAME, DUMMY_NOTARY_NAME)
.map { it.toDatabaseSchemaName() }.toTypedArray()) .map { it.toDatabaseSchemaName() }.toTypedArray())
} }

View File

@ -32,7 +32,8 @@ class BlacklistKotlinClosureTest : IntegrationTest() {
companion object { companion object {
const val EVIL: Long = 666 const val EVIL: Long = 666
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName())
} }

View File

@ -63,7 +63,8 @@ class CordaRPCClientTest : NodeBasedTest(listOf("net.corda.finance.contracts", C
connection = client.start(username, password, externalTrace, impersonatedActor) connection = client.start(username, password, externalTrace, impersonatedActor)
} }
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName())
} }

View File

@ -29,7 +29,6 @@ import net.corda.testing.driver.driver
import net.corda.testing.internal.IntegrationTest import net.corda.testing.internal.IntegrationTest
import net.corda.testing.internal.IntegrationTestSchemas import net.corda.testing.internal.IntegrationTestSchemas
import net.corda.testing.internal.toDatabaseSchemaName import net.corda.testing.internal.toDatabaseSchemaName
import net.corda.testing.internal.toDatabaseSchemaNames
import net.corda.testing.internal.chooseIdentity import net.corda.testing.internal.chooseIdentity
import net.corda.testing.node.User import net.corda.testing.node.User
import net.corda.testing.node.internal.NodeBasedTest import net.corda.testing.node.internal.NodeBasedTest
@ -42,10 +41,10 @@ import org.junit.Test
class FlowsExecutionModeRpcTest : IntegrationTest() { class FlowsExecutionModeRpcTest : IntegrationTest() {
companion object { companion object {
@ClassRule @ClassRule
@JvmField @JvmField
val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME).map { it.toDatabaseSchemaNames("", "_10000", "_10003", "_10006") }.flatten().toTypedArray(), DUMMY_NOTARY_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME)
.map { it.toDatabaseSchemaName() }.toTypedArray())
} }
@Test @Test
@ -73,6 +72,12 @@ class FlowsExecutionModeRpcTest : IntegrationTest() {
class FlowsExecutionModeTests : NodeBasedTest(listOf("net.corda.finance.contracts", CashSchemaV1::class.packageName)) { class FlowsExecutionModeTests : NodeBasedTest(listOf("net.corda.finance.contracts", CashSchemaV1::class.packageName)) {
companion object {
@ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName())
}
private val rpcUser = User("user1", "test", permissions = setOf(Permissions.all())) private val rpcUser = User("user1", "test", permissions = setOf(Permissions.all()))
private lateinit var node: StartedNode<Node> private lateinit var node: StartedNode<Node>
private lateinit var client: CordaRPCClient private lateinit var client: CordaRPCClient

View File

@ -38,7 +38,8 @@ import kotlin.test.assertEquals
class IntegrationTestingTutorial : IntegrationTest() { class IntegrationTestingTutorial : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(), val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(),
DUMMY_NOTARY_NAME.toDatabaseSchemaName()) DUMMY_NOTARY_NAME.toDatabaseSchemaName())
} }

View File

@ -60,7 +60,7 @@ Example node configuration for SQL Azure:
Oracle Oracle
```````````````````````` ````````````````````````
Corda supports Oracle 11g RC2 and Oracle 12c with ojdbc6.jar driver.. Corda supports Oracle 11g RC2 (with ojdbc6.jar) and Oracle 12c (ojdbc8.jar).
The minimum transaction isolation level ``database.transactionIsolationLevel`` is 'READ_COMMITTED'. The minimum transaction isolation level ``database.transactionIsolationLevel`` is 'READ_COMMITTED'.
The property ``database.schema`` is optional. The property ``database.schema`` is optional.

View File

@ -43,50 +43,51 @@ TODO: Add instructions on manual testing
External Database Testing External Database Testing
------------------------- -------------------------
Integration test can be parameterised to run against any remote database (by default, integration tests use in-memory H2 instances). Integration tests can be parameterised to run against any remote database (instead of the default embeded H2 instance).
For the purpose of testing other relational database providers or different database setups (for example, H2 in server mode),
we introduce an optional system property called ``databaseProvider`` which is resolved at run-time to load a configuration file on the classpath with the When running Gradle task `integrationTest`, a combination of several system properties (passed as `-Dproperty=...`) can modify the node default JDBC setting and trigger a database setup before and after each test.
name ``$databaseProvider.conf`` containing database configuration properties that override the default H2 settings The property ``custom.databaseProvider`` is resolved at run-time to load a configuration file on the classpath with the
defined in the general node configuration file (see ``reference.conf``). name `$custom.databaseProvider.conf` containing database configuration properties. These settings override the default H2 ones
defined in the node configuration file (see ``reference.conf``).
Integration test runs predefined set of SQL setup scripts selected for a specific database provider by ``test.db.script.dir``. Integration test runs predefined set of SQL setup scripts selected for a specific database provider by ``test.db.script.dir``.
SQL scripts is a template which contains standard SQL DDL statements with a ${schema} placeholder. An integration test runs the SQL scripts SQL scripts are templates which contain SQL DDL statements with the `${schema}` placeholder.
for all nodes involed in the test and replaces ${schema} with appropriate value derived from node name. Integration tests run the script for all nodes involved in the test and replace `${schema}` with the appropriate value, derived from a node name. SQL templates files are executed at different stage of the integration test:
SQL templates files are executed at different stage of an integration test:
``db-global-setup.sql``- before a test class (@BeforeClass), should create database users, schema and permissions - ``db-global-setup.sql``- before a test class (@BeforeClass), should create database users, schema and permissions
``db-setup.sql`` - before a test (@Before), should clean up/drop tables - ``db-setup.sql`` - before a test (@Before), should clean up/drop tables
``db-cleanup.sql` - after a test (@After), may clean up/drop tables - ``db-cleanup.sql`` - after a test (@After), may clean up/drop tables
``db-global-cleanup.sql`` - after a test class (@AfterClass), may drop user and schema - ``db-global-cleanup.sql`` - after a test class (@AfterClass), may drop user and schema
Depends on the database providers not each SQL file is present (e.g. db-setp always deletes tabels so db-cleanp is not needed).
Not all stages need to be present e.g. when ``db-setup.sql`` deletes all tables before a test then ``db-cleanup.sql`` after the test is not needed.
The setup ensures that all nodes involved in a single integration test use different database users to achieve database separation. The setup ensures that all nodes involved in a single integration test use different database users to achieve database separation.
The data source configuration files (denote by ``databaseProvider``) define user and schema by ${custom.nodeOrganizationName} placeholder. The configuration file (denoted by the ``custom.databaseProvider`` property) define a user and a schema as `${custom.nodeOrganizationName}` value.
At a runtime the node resolves the placeholder to its organization name. The value is a placeholder which is resolved at runtime to a node organization name.
To run integration tests against a remote database provide these system properties: To run integration tests against a remote database provide these system properties:
- ``databaseProvider`` - a template dataSource/database configuration for a node, accepted values [“integration-azure-sql”, “integration-sql-server”] - ``custom.databaseProvider`` - the predefined configuration template for a node, the template is a name of the file under resources` folder and a switch to add JDBC driver runtime dependency, accepted values: `integration-azure-sql`, `integration-sql-server`, `integration-oracle-11`, `integration-oracle`, `integration-postgress`
- ``test.db.script.dir`` - a relative directory path with SQL script templates for a given database, - ``test.db.script.dir`` - the path to predefined set of SQL script templates for a given database, accepted values: `database-scripts/azure-sql`, `database-scripts/sql-server`, `database-scripts/oracle`, `database-scripts/postgress`
accepted values [“database-scripts/azure-sql”, “database-scripts/sql-server”]
- ``test.db.admin.user`` - a database user to run SQL setup scripts, the user needs to have permissions to create other users and grant them permissions
- ``test.db.admin.user`` - a database user to run SQL setup scripts, the user need to have permissions
to create other users and grant them permissions
- ``test.db.admin.password`` - a password for the database user to run SQL scripts - ``test.db.admin.password`` - a password for the database user to run SQL scripts
Provided configuration file ``$databaseProvider.conf``file () contains a specific JDBC connection string with a dummy database host, - ``corda.dataSourceProperties.dataSource.url`` - specify full JDBC connection string use by a node to connect to database, JDBC URL provided by the predefined configuration file (by ``databaseProvider``) doesn't contain specific host names and port
the following properties can override JDBC connection string and password:
- ``dataSourceProperties.dataSource.url`` - specify full JDBC connection string use by a node to connect to database - ``corda.dataSourceProperties.dataSource.password`` - optional parameter, currently a database user password in the SQL setup script ``test.db.script.dir`` matches one in the node configuration file ``test.db.script.dir``
- ``dataSourceProperties.dataSource.password`` - optional setup, currently SQL scripts creates users with a given hardcoded
password with matches one in node configuration
All defaults are taken from the ``reference.conf`` file.
Example running Gradle integration tests task against Azure SQL database running at ``mycordadb.database.windows.net``: Example running Gradle integration tests task against Azure SQL database at `mycordadb.database.windows.net` host:
``./gradlew integrationTest -DdataSourceProperties.dataSource.url="jdbc:sqlserver://mycordadb.database.windows.net:1433;databaseName=mycordadb;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30"
-DdatabaseProvider=integration-sql-azure -Dtest.db.admin.user=dbuser@mycordadb -Dtest.db.admin.password='paSSword(!' .. code:: bash
-Dtest.db.script.dir=database-scripts/sql-azure --info``
./gradlew integrationTest -Dcustom.databaseProvider=integration-sql-azure \
-Dcorda.dataSourceProperties.dataSource.url="jdbc:sqlserver://mycordadb.database.windows.net:1433;databaseName=mycordadb;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30" \
-Dtest.db.admin.user=dbuser@mycordadb \
-Dtest.db.admin.password='paSSword(!' \
-Dtest.db.script.dir=database-scripts/sql-azure

View File

@ -27,7 +27,8 @@ import org.junit.Test
class CashConfigDataFlowTest : IntegrationTest() { class CashConfigDataFlowTest : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(), val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(),
DUMMY_BANK_A_NAME.toDatabaseSchemaName()) DUMMY_BANK_A_NAME.toDatabaseSchemaName())
} }

View File

@ -192,7 +192,7 @@ dependencies {
testCompile "org.glassfish.jersey.containers:jersey-container-jetty-http:${jersey_version}" testCompile "org.glassfish.jersey.containers:jersey-container-jetty-http:${jersey_version}"
// Add runtime-only dependency on the JDBC driver for the specified DB provider (used in database integration tests) // Add runtime-only dependency on the JDBC driver for the specified DB provider (used in database integration tests)
def DB_PROVIDER = System.getProperty("databaseProvider") def DB_PROVIDER = System.getProperty("custom.databaseProvider")
switch (DB_PROVIDER) { switch (DB_PROVIDER) {
case null: //DB provider not provided, use default H2 driver (already in the classpath) case null: //DB provider not provided, use default H2 driver (already in the classpath)
break break

View File

@ -48,7 +48,8 @@ import kotlin.test.assertFailsWith
@RunWith(Parameterized::class) @RunWith(Parameterized::class)
class AuthDBTests : NodeBasedTest() { class AuthDBTests : NodeBasedTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName())
private val cacheExpireAfterSecs: Long = 1 private val cacheExpireAfterSecs: Long = 1

View File

@ -40,7 +40,8 @@ import kotlin.test.assertEquals
class BootTests : IntegrationTest() { class BootTests : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME) val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME)
.map { it.toDatabaseSchemaName() }.toTypedArray()) .map { it.toDatabaseSchemaName() }.toTypedArray())
} }

View File

@ -34,7 +34,8 @@ import org.junit.Test
class CordappScanningDriverTest : IntegrationTest() { class CordappScanningDriverTest : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(), val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(),
DUMMY_NOTARY_NAME.toDatabaseSchemaName()) DUMMY_NOTARY_NAME.toDatabaseSchemaName())
} }

View File

@ -32,7 +32,8 @@ import javax.security.auth.x500.X500Principal
class NodeKeystoreCheckTest : IntegrationTest() { class NodeKeystoreCheckTest : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName())
} }

View File

@ -28,7 +28,8 @@ import java.util.concurrent.TimeUnit
@Ignore("Only use locally") @Ignore("Only use locally")
class NodeStartupPerformanceTests : IntegrationTest() { class NodeStartupPerformanceTests : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME) val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME)
.map { it.toDatabaseSchemaName() }.toTypedArray()) .map { it.toDatabaseSchemaName() }.toTypedArray())
} }

View File

@ -29,7 +29,8 @@ import java.util.concurrent.TimeUnit
class NodeUnloadHandlerTests : IntegrationTest() { class NodeUnloadHandlerTests : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName())
val latch = CountDownLatch(1) val latch = CountDownLatch(1)
} }

View File

@ -23,22 +23,30 @@ import net.corda.core.utilities.getOrThrow
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import net.corda.core.utilities.unwrap import net.corda.core.utilities.unwrap
import net.corda.node.services.Permissions import net.corda.node.services.Permissions
import net.corda.testing.core.singleIdentity import net.corda.testing.core.*
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 net.corda.testing.node.User import net.corda.testing.node.User
import org.assertj.core.api.AssertionsForInterfaceTypes.assertThat import org.assertj.core.api.AssertionsForInterfaceTypes.assertThat
import org.junit.After import org.junit.*
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import java.util.concurrent.Executors import java.util.concurrent.Executors
import java.util.concurrent.ScheduledExecutorService import java.util.concurrent.ScheduledExecutorService
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlin.test.fail import kotlin.test.fail
class P2PFlowsDrainingModeTest { class P2PFlowsDrainingModeTest : IntegrationTest() {
companion object {
@ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME)
.map { it.toDatabaseSchemaName() }.toTypedArray())
private val logger = loggerFor<P2PFlowsDrainingModeTest>()
}
private val portAllocation = PortAllocation.Incremental(10000) private val portAllocation = PortAllocation.Incremental(10000)
private val user = User("mark", "dadada", setOf(Permissions.all())) private val user = User("mark", "dadada", setOf(Permissions.all()))
@ -46,10 +54,6 @@ class P2PFlowsDrainingModeTest {
private var executor: ScheduledExecutorService? = null private var executor: ScheduledExecutorService? = null
companion object {
private val logger = loggerFor<P2PFlowsDrainingModeTest>()
}
@Before @Before
fun setup() { fun setup() {
executor = Executors.newSingleThreadScheduledExecutor() executor = Executors.newSingleThreadScheduledExecutor()
@ -64,8 +68,8 @@ class P2PFlowsDrainingModeTest {
fun `flows draining mode suspends consumption of initial session messages`() { fun `flows draining mode suspends consumption of initial session messages`() {
driver(DriverParameters(isDebug = true, startNodesInProcess = true, portAllocation = portAllocation)) { driver(DriverParameters(isDebug = true, startNodesInProcess = true, portAllocation = portAllocation)) {
val initiatedNode = startNode().getOrThrow() val initiatedNode = startNode(providedName = ALICE_NAME).getOrThrow()
val initiating = startNode(rpcUsers = users).getOrThrow().rpc val initiating = startNode(rpcUsers = users, providedName = BOB_NAME).getOrThrow().rpc
val counterParty = initiatedNode.nodeInfo.singleIdentity() val counterParty = initiatedNode.nodeInfo.singleIdentity()
val initiated = initiatedNode.rpc val initiated = initiatedNode.rpc

View File

@ -17,15 +17,26 @@ import net.corda.core.messaging.startFlow
import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.getOrThrow
import net.corda.node.services.Permissions import net.corda.node.services.Permissions
import net.corda.nodeapi.exceptions.RejectedCommandException import net.corda.nodeapi.exceptions.RejectedCommandException
import net.corda.testing.core.*
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 net.corda.testing.node.User import net.corda.testing.node.User
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.catchThrowable import org.assertj.core.api.Assertions.catchThrowable
import org.junit.ClassRule
import org.junit.Test import org.junit.Test
class RpcFlowsDrainingModeTest { class RpcFlowsDrainingModeTest : IntegrationTest() {
companion object {
@ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(),
DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName())
}
private val portAllocation = PortAllocation.Incremental(10000) private val portAllocation = PortAllocation.Incremental(10000)
private val user = User("mark", "dadada", setOf(Permissions.all())) private val user = User("mark", "dadada", setOf(Permissions.all()))

View File

@ -58,7 +58,8 @@ class AttachmentLoadingTests : IntegrationTest() {
private val appContext get() = provider.getAppContext(cordapp) private val appContext get() = provider.getAppContext(cordapp)
private companion object { private companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_BANK_B_NAME.toDatabaseSchemaName(), val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_BANK_B_NAME.toDatabaseSchemaName(),
DUMMY_NOTARY_NAME.toDatabaseSchemaName()) DUMMY_NOTARY_NAME.toDatabaseSchemaName())

View File

@ -56,7 +56,8 @@ import kotlin.test.assertTrue
class BFTNotaryServiceTests : IntegrationTest() { class BFTNotaryServiceTests : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas("node_0", "node_1", "node_2", "node_3", "node_4", "node_5", val databaseSchemas = IntegrationTestSchemas("node_0", "node_1", "node_2", "node_3", "node_4", "node_5",
"node_6", "node_7", "node_8", "node_9") "node_6", "node_7", "node_8", "node_9")
} }

View File

@ -49,7 +49,8 @@ class DistributedServiceTests : IntegrationTest() {
private lateinit var raftNotaryIdentity: Party private lateinit var raftNotaryIdentity: Party
private lateinit var notaryStateMachines: Observable<Pair<Party, StateMachineUpdate>> private lateinit var notaryStateMachines: Observable<Pair<Party, StateMachineUpdate>>
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(*DUMMY_NOTARY_NAME.toDatabaseSchemaNames("_0", "_1", "_2").toTypedArray(), val databaseSchemas = IntegrationTestSchemas(*DUMMY_NOTARY_NAME.toDatabaseSchemaNames("_0", "_1", "_2").toTypedArray(),
ALICE_NAME.toDatabaseSchemaName()) ALICE_NAME.toDatabaseSchemaName())
} }

View File

@ -51,7 +51,8 @@ import kotlin.test.assertFailsWith
class MySQLNotaryServiceTests : IntegrationTest() { class MySQLNotaryServiceTests : IntegrationTest() {
companion object { companion object {
val notaryName = CordaX500Name("MySQL Notary Service", "Zurich", "CH") val notaryName = CordaX500Name("MySQL Notary Service", "Zurich", "CH")
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas("node_0", "node_1", "node_2") val databaseSchemas = IntegrationTestSchemas("node_0", "node_1", "node_2")
} }

View File

@ -40,7 +40,8 @@ import kotlin.test.assertFailsWith
class RaftNotaryServiceTests : IntegrationTest() { class RaftNotaryServiceTests : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas("RAFTNotaryService_0", "RAFTNotaryService_1", "RAFTNotaryService_2", val databaseSchemas = IntegrationTestSchemas("RAFTNotaryService_0", "RAFTNotaryService_1", "RAFTNotaryService_2",
DUMMY_BANK_A_NAME.toDatabaseSchemaName()) DUMMY_BANK_A_NAME.toDatabaseSchemaName())
} }

View File

@ -44,7 +44,8 @@ import kotlin.test.assertEquals
class NetworkMapTest : IntegrationTest() { class NetworkMapTest : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(), val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(),
DUMMY_NOTARY_NAME.toDatabaseSchemaName()) DUMMY_NOTARY_NAME.toDatabaseSchemaName())
} }

View File

@ -35,7 +35,8 @@ class PersistentNetworkMapCacheTest : NodeBasedTest() {
val BOB = TestIdentity(BOB_NAME, 80).party val BOB = TestIdentity(BOB_NAME, 80).party
val DUMMY_REGULATOR = TestIdentity(CordaX500Name("Regulator A", "Paris", "FR"), 100).party val DUMMY_REGULATOR = TestIdentity(CordaX500Name("Regulator A", "Paris", "FR"), 100).party
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(DUMMY_REGULATOR.name.toDatabaseSchemaName(), ALICE.name.toDatabaseSchemaName(), val databaseSchemas = IntegrationTestSchemas(DUMMY_REGULATOR.name.toDatabaseSchemaName(), ALICE.name.toDatabaseSchemaName(),
BOB.name.toDatabaseSchemaName()) BOB.name.toDatabaseSchemaName())
} }

View File

@ -35,7 +35,8 @@ import org.junit.Test
class RpcSslTest : IntegrationTest() { class RpcSslTest : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME) val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME)
.map { it.toDatabaseSchemaName() }.toTypedArray()) .map { it.toDatabaseSchemaName() }.toTypedArray())
} }

View File

@ -30,7 +30,8 @@ import org.junit.Test
class FlowVersioningTest : NodeBasedTest() { class FlowVersioningTest : NodeBasedTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName())
} }

View File

@ -43,7 +43,8 @@ class LargeTransactionsTest : IntegrationTest() {
companion object { companion object {
val BOB = TestIdentity(BOB_NAME, 80).party val BOB = TestIdentity(BOB_NAME, 80).party
val DUMMY_NOTARY = TestIdentity(DUMMY_NOTARY_NAME, 20).party val DUMMY_NOTARY = TestIdentity(DUMMY_NOTARY_NAME, 20).party
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(), val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(),
DUMMY_NOTARY_NAME.toDatabaseSchemaName()) DUMMY_NOTARY_NAME.toDatabaseSchemaName())
} }

View File

@ -37,7 +37,8 @@ class VaultQueryIntegrationTests : VaultQueryTests() {
companion object { companion object {
val MEGA_CORP = TestIdentity(CordaX500Name("MegaCorp", "London", "GB")).name val MEGA_CORP = TestIdentity(CordaX500Name("MegaCorp", "London", "GB")).name
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(MEGA_CORP.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(MEGA_CORP.toDatabaseSchemaName())
@BeforeClass @BeforeClass

View File

@ -55,7 +55,8 @@ import javax.ws.rs.core.Response
class NodeRegistrationTest : IntegrationTest() { class NodeRegistrationTest : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas("NotaryService", "Alice", "Genevieve") val databaseSchemas = IntegrationTestSchemas("NotaryService", "Alice", "Genevieve")
private val notaryName = CordaX500Name("NotaryService", "Zurich", "CH") private val notaryName = CordaX500Name("NotaryService", "Zurich", "CH")

View File

@ -54,7 +54,8 @@ import kotlin.test.assertEquals
*/ */
abstract class MQSecurityTest : NodeBasedTest() { abstract class MQSecurityTest : NodeBasedTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName())
} }

View File

@ -48,7 +48,8 @@ import java.util.concurrent.atomic.AtomicInteger
class P2PMessagingTest : IntegrationTest() { class P2PMessagingTest : IntegrationTest() {
private companion object { private companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), "DistributedService_0", "DistributedService_1") val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), "DistributedService_0", "DistributedService_1")
val DISTRIBUTED_SERVICE_NAME = CordaX500Name("DistributedService", "London", "GB") val DISTRIBUTED_SERVICE_NAME = CordaX500Name("DistributedService", "London", "GB")

View File

@ -50,7 +50,8 @@ import kotlin.test.assertNotNull
class NodeStatePersistenceTests : IntegrationTest() { class NodeStatePersistenceTests : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME) val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME, DUMMY_NOTARY_NAME)
.map { it.toDatabaseSchemaName() }.toTypedArray()) .map { it.toDatabaseSchemaName() }.toTypedArray())
} }

View File

@ -27,17 +27,27 @@ import net.corda.node.internal.Node
import net.corda.node.services.Permissions import net.corda.node.services.Permissions
import net.corda.node.services.messaging.P2PMessagingClient import net.corda.node.services.messaging.P2PMessagingClient
import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.DUMMY_NOTARY_NAME
import net.corda.testing.internal.IntegrationTestSchemas
import net.corda.testing.internal.toDatabaseSchemaName
import net.corda.testing.node.User import net.corda.testing.node.User
import net.corda.testing.node.internal.NodeBasedTest import net.corda.testing.node.internal.NodeBasedTest
import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException
import org.apache.activemq.artemis.api.core.ActiveMQSecurityException import org.apache.activemq.artemis.api.core.ActiveMQSecurityException
import org.assertj.core.api.Assertions import org.assertj.core.api.Assertions
import org.junit.ClassRule
import org.junit.Test import org.junit.Test
import java.util.* import java.util.*
import kotlin.concurrent.thread import kotlin.concurrent.thread
import kotlin.test.assertEquals import kotlin.test.assertEquals
class NodeSuspendAndResumeTest : NodeBasedTest(listOf("net.corda.finance.contracts", CashSchemaV1::class.packageName)) { class NodeSuspendAndResumeTest : NodeBasedTest(listOf("net.corda.finance.contracts", CashSchemaV1::class.packageName)) {
companion object {
@ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, DUMMY_NOTARY_NAME)
.map { it.toDatabaseSchemaName() }.toTypedArray())
}
private val rpcUser = User("user1", "test", permissions = setOf( private val rpcUser = User("user1", "test", permissions = setOf(
Permissions.startFlow<CashIssueFlow>(), Permissions.startFlow<CashIssueFlow>(),

View File

@ -44,7 +44,7 @@ object ConfigHelper {
val parseOptions = ConfigParseOptions.defaults() val parseOptions = ConfigParseOptions.defaults()
val defaultConfig = ConfigFactory.parseResources("reference.conf", parseOptions.setAllowMissing(false)) val defaultConfig = ConfigFactory.parseResources("reference.conf", parseOptions.setAllowMissing(false))
val appConfig = ConfigFactory.parseFile(configFile.toFile(), parseOptions.setAllowMissing(allowMissingConfig)) val appConfig = ConfigFactory.parseFile(configFile.toFile(), parseOptions.setAllowMissing(allowMissingConfig))
val databaseConfig = ConfigFactory.parseResources(System.getProperty("databaseProvider")+".conf", parseOptions.setAllowMissing(true)) val databaseConfig = ConfigFactory.parseResources(System.getProperty("custom.databaseProvider")+".conf", parseOptions.setAllowMissing(true))
val systemOverrides = systemProperties().cordaEntriesOnly() val systemOverrides = systemProperties().cordaEntriesOnly()
val environmentOverrides = systemEnvironment().cordaEntriesOnly() val environmentOverrides = systemEnvironment().cordaEntriesOnly()

View File

@ -15,5 +15,6 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<include file="migration/node-core.changelog-init.xml"/> <include file="migration/node-core.changelog-init.xml"/>
<include file="migration/node-core.changelog-v3.xml"/>
</databaseChangeLog> </databaseChangeLog>

View File

@ -0,0 +1,23 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"
logicalFilePath="migration/node-services.changelog-init.xml">
<changeSet author="R3.Corda" id="add_contract_attachment">
<createTable tableName="node_attchments_contracts">
<column name="att_id" type="NVARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="contract_class_name" type="NVARCHAR(255)"/>
</createTable>
<addForeignKeyConstraint baseColumnNames="att_id" baseTableName="node_attchments_contracts"
constraintName="FK__ctr_class__attachments"
referencedColumnNames="att_id" referencedTableName="node_attachments"/>
<!--this is needed because pre-v3 attachments can't be used-->
<delete tableName="node_attachments"/>
</changeSet>
</databaseChangeLog>

View File

@ -15,5 +15,6 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"> xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<include file="migration/vault-schema.changelog-init.xml"/> <include file="migration/vault-schema.changelog-init.xml"/>
<include file="migration/vault-schema.changelog-v3.xml"/>
</databaseChangeLog> </databaseChangeLog>

View File

@ -0,0 +1,16 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<!--this is needed because pre-v3 states are no longer supported-->
<changeSet author="R3.Corda" id="clean_vault">
<delete tableName="vault_fungible_states_parts"/>
<delete tableName="vault_fungible_states"/>
<delete tableName="vault_linear_states_parts"/>
<delete tableName="vault_linear_states"/>
<delete tableName="vault_states"/>
<delete tableName="vault_transaction_notes"/>
</changeSet>
</databaseChangeLog>

View File

@ -51,7 +51,8 @@ import java.util.concurrent.TimeUnit
class NodePerformanceTests : IntegrationTest() { class NodePerformanceTests : IntegrationTest() {
companion object { companion object {
val ALICE = TestIdentity(ALICE_NAME, 70).party val ALICE = TestIdentity(ALICE_NAME, 70).party
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(*DUMMY_NOTARY_NAME.toDatabaseSchemaNames("_0", "_1", "_2").toTypedArray(), val databaseSchemas = IntegrationTestSchemas(*DUMMY_NOTARY_NAME.toDatabaseSchemaNames("_0", "_1", "_2").toTypedArray(),
DUMMY_BANK_A_NAME.toDatabaseSchemaName()) DUMMY_BANK_A_NAME.toDatabaseSchemaName())
} }

View File

@ -20,7 +20,8 @@ import org.junit.Test
class BankOfCordaCordformTest : IntegrationTest() { class BankOfCordaCordformTest : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas("NotaryService", "BankOfCorda", BIGCORP_NAME.organisation) val databaseSchemas = IntegrationTestSchemas("NotaryService", "BankOfCorda", BIGCORP_NAME.organisation)
} }

View File

@ -34,7 +34,8 @@ import org.junit.Test
class BankOfCordaRPCClientTest : IntegrationTest() { class BankOfCordaRPCClientTest : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(BOC_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName(), val databaseSchemas = IntegrationTestSchemas(BOC_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName(),
BIGCORP_NAME.organisation) BIGCORP_NAME.organisation)
} }

View File

@ -56,7 +56,8 @@ class IRSDemoTest : IntegrationTest() {
companion object { companion object {
private val log = contextLogger() private val log = contextLogger()
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_BANK_B_NAME.toDatabaseSchemaName(), val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_BANK_B_NAME.toDatabaseSchemaName(),
DUMMY_NOTARY_NAME.toDatabaseSchemaName(), "Regulator") DUMMY_NOTARY_NAME.toDatabaseSchemaName(), "Regulator")
} }

View File

@ -40,7 +40,8 @@ class SimmValuationTest : IntegrationTest() {
val nodeBLegalName = DUMMY_BANK_B_NAME val nodeBLegalName = DUMMY_BANK_B_NAME
val testTradeId = "trade1" val testTradeId = "trade1"
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(*listOf(DUMMY_BANK_A_NAME, DUMMY_BANK_B_NAME, DUMMY_NOTARY_NAME) val databaseSchemas = IntegrationTestSchemas(*listOf(DUMMY_BANK_A_NAME, DUMMY_BANK_B_NAME, DUMMY_NOTARY_NAME)
.map { it.toDatabaseSchemaName() }.toTypedArray()) .map { it.toDatabaseSchemaName() }.toTypedArray())
} }

View File

@ -58,7 +58,8 @@ class DriverTests : IntegrationTest() {
addressMustNotBeBound(executorService, hostAndPort) addressMustNotBeBound(executorService, hostAndPort)
} }
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName(), val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName(),
DUMMY_REGULATOR_NAME.toDatabaseSchemaName()) DUMMY_REGULATOR_NAME.toDatabaseSchemaName())
} }

View File

@ -34,6 +34,7 @@ import net.corda.node.internal.cordapp.CordappLoader
import net.corda.node.services.api.SchemaService import net.corda.node.services.api.SchemaService
import net.corda.node.services.api.VaultServiceInternal import net.corda.node.services.api.VaultServiceInternal
import net.corda.node.services.api.WritableTransactionStorage import net.corda.node.services.api.WritableTransactionStorage
import net.corda.node.services.config.ConfigHelper
import net.corda.node.services.config.configOf import net.corda.node.services.config.configOf
import net.corda.node.services.config.parseToDbSchemaFriendlyName import net.corda.node.services.config.parseToDbSchemaFriendlyName
import net.corda.node.services.identity.InMemoryIdentityService import net.corda.node.services.identity.InMemoryIdentityService
@ -330,14 +331,12 @@ fun databaseProviderDataSourceConfig(nodeName: String? = null, postfix: String?
val parseOptions = ConfigParseOptions.defaults() val parseOptions = ConfigParseOptions.defaults()
//read overrides from command line (passed by Gradle as system properties) //read overrides from command line (passed by Gradle as system properties)
val dataSourceKeys = listOf(DATA_SOURCE_URL, DATA_SOURCE_CLASSNAME, DATA_SOURCE_USER, DATA_SOURCE_PASSWORD) val systemConfigOverride = ConfigFactory.parseMap(System.getProperties().filterKeys { (it as String).startsWith(ConfigHelper.CORDA_PROPERTY_PREFIX) }
val dataSourceSystemProperties = Properties() .mapKeys { (it.key as String).removePrefix(ConfigHelper.CORDA_PROPERTY_PREFIX) }
val allSystemProperties = System.getProperties().toList().map { it.first.toString() to it.second.toString() }.toMap() .filterKeys { listOf(DATA_SOURCE_URL, DATA_SOURCE_CLASSNAME, DATA_SOURCE_USER, DATA_SOURCE_PASSWORD).contains(it) })
dataSourceKeys.filter { allSystemProperties.containsKey(it) }.forEach { dataSourceSystemProperties.setProperty(it, allSystemProperties[it]) }
val systemConfigOverride = ConfigFactory.parseProperties(dataSourceSystemProperties, parseOptions)
//read from db vendor specific configuration file //read from db vendor specific configuration file
val databaseConfig = ConfigFactory.parseResources(System.getProperty("databaseProvider") + ".conf", parseOptions.setAllowMissing(true)) val databaseConfig = ConfigFactory.parseResources(System.getProperty("custom.databaseProvider") + ".conf", parseOptions.setAllowMissing(true))
val fixedOverride = ConfigFactory.parseString("baseDirectory = \"\"") val fixedOverride = ConfigFactory.parseString("baseDirectory = \"\"")
//implied property custom.nodeOrganizationName to fill the potential placeholders in db schema/ db user properties //implied property custom.nodeOrganizationName to fill the potential placeholders in db schema/ db user properties

View File

@ -11,8 +11,8 @@
package net.corda.testing.database package net.corda.testing.database
import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigFactory
import com.typesafe.config.ConfigParseOptions
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import net.corda.node.services.config.ConfigHelper
import net.corda.testing.database.DatabaseConstants.DATA_SOURCE_CLASSNAME import net.corda.testing.database.DatabaseConstants.DATA_SOURCE_CLASSNAME
import net.corda.testing.database.DatabaseConstants.DATA_SOURCE_PASSWORD import net.corda.testing.database.DatabaseConstants.DATA_SOURCE_PASSWORD
import net.corda.testing.database.DatabaseConstants.DATA_SOURCE_URL import net.corda.testing.database.DatabaseConstants.DATA_SOURCE_URL
@ -25,7 +25,6 @@ import org.springframework.util.StringUtils
import java.sql.Connection import java.sql.Connection
import java.sql.SQLException import java.sql.SQLException
import java.sql.SQLWarning import java.sql.SQLWarning
import java.util.*
object DbScriptRunner { object DbScriptRunner {
private val logger = loggerFor<DbScriptRunner>() private val logger = loggerFor<DbScriptRunner>()
@ -35,21 +34,24 @@ object DbScriptRunner {
private const val TEST_DB_ADMIN_PASSWORD = "test.db.admin.password" private const val TEST_DB_ADMIN_PASSWORD = "test.db.admin.password"
private fun createDataSource(dbProvider: String): DriverManagerDataSource { private fun createDataSource(dbProvider: String): DriverManagerDataSource {
val parseOptions = ConfigParseOptions.defaults()
val allSystemProperties = System.getProperties().toList().map { it.first.toString() to it.second.toString() }.toMap()
val dataSourceSystemProperties = Properties()
val dataSourceKeys = listOf(TEST_DB_ADMIN_USER, TEST_DB_ADMIN_PASSWORD, DATA_SOURCE_URL, DATA_SOURCE_CLASSNAME,
DATA_SOURCE_USER, DATA_SOURCE_PASSWORD)
dataSourceKeys.filter { allSystemProperties.containsKey(it) }.forEach { dataSourceSystemProperties.setProperty(it, allSystemProperties[it]) }
val databaseConfig = ConfigFactory.parseProperties(dataSourceSystemProperties, parseOptions)
.withFallback(ConfigFactory.parseResources("$dbProvider.conf", parseOptions.setAllowMissing(false)))
val dataSource = DriverManagerDataSource() val cordaConfigs = ConfigFactory.parseMap(System.getProperties().filterKeys { (it as String).startsWith(ConfigHelper.CORDA_PROPERTY_PREFIX) }
dataSource.setDriverClassName(databaseConfig.getString(DATA_SOURCE_CLASSNAME)) .mapKeys { (it.key as String).removePrefix(ConfigHelper.CORDA_PROPERTY_PREFIX) }
dataSource.url = databaseConfig.getString(DATA_SOURCE_URL) .filterKeys { listOf(DATA_SOURCE_URL, DATA_SOURCE_CLASSNAME, DATA_SOURCE_USER, DATA_SOURCE_PASSWORD).contains(it) })
dataSource.username = databaseConfig.getString(TEST_DB_ADMIN_USER)
dataSource.password = databaseConfig.getString(TEST_DB_ADMIN_PASSWORD) val testConfigs = ConfigFactory.parseMap(System.getProperties().filterKeys { listOf(TEST_DB_ADMIN_USER, TEST_DB_ADMIN_PASSWORD).contains(it) }
return dataSource .mapKeys { (it.key as String) })
val databaseConfig = cordaConfigs
.withFallback(testConfigs)
.withFallback(ConfigFactory.parseResources("$dbProvider.conf"))
return (DriverManagerDataSource()).also {
it.setDriverClassName(databaseConfig.getString(DATA_SOURCE_CLASSNAME))
it.url = databaseConfig.getString(DATA_SOURCE_URL)
it.username = databaseConfig.getString(TEST_DB_ADMIN_USER)
it.password = databaseConfig.getString(TEST_DB_ADMIN_PASSWORD)
}
} }
fun runDbScript(dbProvider: String, initScript: String? = null, databaseSchemas: List<String> = emptyList()) { fun runDbScript(dbProvider: String, initScript: String? = null, databaseSchemas: List<String> = emptyList()) {

View File

@ -29,7 +29,7 @@ abstract class IntegrationTest {
// dataSource.password = [PASSWORD] // dataSource.password = [PASSWORD]
// where [PASSWORD] must be the same for all ${custom.nodeOrganizationName} // where [PASSWORD] must be the same for all ${custom.nodeOrganizationName}
companion object { companion object {
private val DATABASE_PROVIDER = "databaseProvider" private val DATABASE_PROVIDER = "custom.databaseProvider"
private val dbProvider = System.getProperty(DATABASE_PROVIDER, "") private val dbProvider = System.getProperty(DATABASE_PROVIDER, "")
private val TEST_DB_SCRIPT_DIR = "test.db.script.dir" private val TEST_DB_SCRIPT_DIR = "test.db.script.dir"
private val testDbScriptDir = System.getProperty(TEST_DB_SCRIPT_DIR, "database-scripts") private val testDbScriptDir = System.getProperty(TEST_DB_SCRIPT_DIR, "database-scripts")

View File

@ -4,6 +4,7 @@ DROP TABLE IF EXISTS ${schema}.cp_states_v2_participants;
DROP TABLE IF EXISTS ${schema}.dummy_linear_state_parts; DROP TABLE IF EXISTS ${schema}.dummy_linear_state_parts;
DROP TABLE IF EXISTS ${schema}.dummy_linear_states_v2_parts; DROP TABLE IF EXISTS ${schema}.dummy_linear_states_v2_parts;
DROP TABLE IF EXISTS ${schema}.dummy_deal_states_parts; DROP TABLE IF EXISTS ${schema}.dummy_deal_states_parts;
DROP TABLE IF EXISTS ${schema}.node_attchments_contracts;
DROP TABLE IF EXISTS ${schema}.node_attachments; DROP TABLE IF EXISTS ${schema}.node_attachments;
DROP TABLE IF EXISTS ${schema}.node_checkpoints; DROP TABLE IF EXISTS ${schema}.node_checkpoints;
DROP TABLE IF EXISTS ${schema}.node_transactions; DROP TABLE IF EXISTS ${schema}.node_transactions;
@ -32,6 +33,7 @@ DROP TABLE IF EXISTS ${schema}.cp_states;
DROP TABLE IF EXISTS ${schema}.node_contract_upgrades; DROP TABLE IF EXISTS ${schema}.node_contract_upgrades;
DROP TABLE IF EXISTS ${schema}.node_identities; DROP TABLE IF EXISTS ${schema}.node_identities;
DROP TABLE IF EXISTS ${schema}.node_named_identities; DROP TABLE IF EXISTS ${schema}.node_named_identities;
DROP TABLE IF EXISTS ${schema}.node_properties;
DROP TABLE IF EXISTS ${schema}.children; DROP TABLE IF EXISTS ${schema}.children;
DROP TABLE IF EXISTS ${schema}.parents; DROP TABLE IF EXISTS ${schema}.parents;
DROP TABLE IF EXISTS ${schema}.contract_cash_states; DROP TABLE IF EXISTS ${schema}.contract_cash_states;

View File

@ -4,6 +4,7 @@ DROP TABLE IF EXISTS ${schema}.cp_states_v2_participants;
DROP TABLE IF EXISTS ${schema}.dummy_linear_state_parts; DROP TABLE IF EXISTS ${schema}.dummy_linear_state_parts;
DROP TABLE IF EXISTS ${schema}.dummy_linear_states_v2_parts; DROP TABLE IF EXISTS ${schema}.dummy_linear_states_v2_parts;
DROP TABLE IF EXISTS ${schema}.dummy_deal_states_parts; DROP TABLE IF EXISTS ${schema}.dummy_deal_states_parts;
DROP TABLE IF EXISTS ${schema}.node_attchments_contracts;
DROP TABLE IF EXISTS ${schema}.node_attachments; DROP TABLE IF EXISTS ${schema}.node_attachments;
DROP TABLE IF EXISTS ${schema}.node_checkpoints; DROP TABLE IF EXISTS ${schema}.node_checkpoints;
DROP TABLE IF EXISTS ${schema}.node_transactions; DROP TABLE IF EXISTS ${schema}.node_transactions;
@ -32,6 +33,7 @@ DROP TABLE IF EXISTS ${schema}.cp_states;
DROP TABLE IF EXISTS ${schema}.node_contract_upgrades; DROP TABLE IF EXISTS ${schema}.node_contract_upgrades;
DROP TABLE IF EXISTS ${schema}.node_identities; DROP TABLE IF EXISTS ${schema}.node_identities;
DROP TABLE IF EXISTS ${schema}.node_named_identities; DROP TABLE IF EXISTS ${schema}.node_named_identities;
DROP TABLE IF EXISTS ${schema}.node_properties;
DROP TABLE IF EXISTS ${schema}.children; DROP TABLE IF EXISTS ${schema}.children;
DROP TABLE IF EXISTS ${schema}.parents; DROP TABLE IF EXISTS ${schema}.parents;
DROP TABLE IF EXISTS ${schema}.contract_cash_states; DROP TABLE IF EXISTS ${schema}.contract_cash_states;

View File

@ -4,6 +4,7 @@ DROP TABLE IF EXISTS ${schema}.cp_states_v2_participants;
DROP TABLE IF EXISTS ${schema}.dummy_linear_state_parts; DROP TABLE IF EXISTS ${schema}.dummy_linear_state_parts;
DROP TABLE IF EXISTS ${schema}.dummy_linear_states_v2_parts; DROP TABLE IF EXISTS ${schema}.dummy_linear_states_v2_parts;
DROP TABLE IF EXISTS ${schema}.dummy_deal_states_parts; DROP TABLE IF EXISTS ${schema}.dummy_deal_states_parts;
DROP TABLE IF EXISTS ${schema}.node_attchments_contracts;
DROP TABLE IF EXISTS ${schema}.node_attachments; DROP TABLE IF EXISTS ${schema}.node_attachments;
DROP TABLE IF EXISTS ${schema}.node_checkpoints; DROP TABLE IF EXISTS ${schema}.node_checkpoints;
DROP TABLE IF EXISTS ${schema}.node_transactions; DROP TABLE IF EXISTS ${schema}.node_transactions;
@ -32,6 +33,7 @@ DROP TABLE IF EXISTS ${schema}.cp_states;
DROP TABLE IF EXISTS ${schema}.node_contract_upgrades; DROP TABLE IF EXISTS ${schema}.node_contract_upgrades;
DROP TABLE IF EXISTS ${schema}.node_identities; DROP TABLE IF EXISTS ${schema}.node_identities;
DROP TABLE IF EXISTS ${schema}.node_named_identities; DROP TABLE IF EXISTS ${schema}.node_named_identities;
DROP TABLE IF EXISTS ${schema}.node_properties;
DROP TABLE IF EXISTS ${schema}.children; DROP TABLE IF EXISTS ${schema}.children;
DROP TABLE IF EXISTS ${schema}.parents; DROP TABLE IF EXISTS ${schema}.parents;
DROP TABLE IF EXISTS ${schema}.contract_cash_states; DROP TABLE IF EXISTS ${schema}.contract_cash_states;

View File

@ -4,6 +4,7 @@ DROP TABLE IF EXISTS ${schema}.cp_states_v2_participants;
DROP TABLE IF EXISTS ${schema}.dummy_linear_state_parts; DROP TABLE IF EXISTS ${schema}.dummy_linear_state_parts;
DROP TABLE IF EXISTS ${schema}.dummy_linear_states_v2_parts; DROP TABLE IF EXISTS ${schema}.dummy_linear_states_v2_parts;
DROP TABLE IF EXISTS ${schema}.dummy_deal_states_parts; DROP TABLE IF EXISTS ${schema}.dummy_deal_states_parts;
DROP TABLE IF EXISTS ${schema}.node_attchments_contracts;
DROP TABLE IF EXISTS ${schema}.node_attachments; DROP TABLE IF EXISTS ${schema}.node_attachments;
DROP TABLE IF EXISTS ${schema}.node_checkpoints; DROP TABLE IF EXISTS ${schema}.node_checkpoints;
DROP TABLE IF EXISTS ${schema}.node_transactions; DROP TABLE IF EXISTS ${schema}.node_transactions;
@ -32,6 +33,7 @@ DROP TABLE IF EXISTS ${schema}.cp_states;
DROP TABLE IF EXISTS ${schema}.node_contract_upgrades; DROP TABLE IF EXISTS ${schema}.node_contract_upgrades;
DROP TABLE IF EXISTS ${schema}.node_identities; DROP TABLE IF EXISTS ${schema}.node_identities;
DROP TABLE IF EXISTS ${schema}.node_named_identities; DROP TABLE IF EXISTS ${schema}.node_named_identities;
DROP TABLE IF EXISTS ${schema}.node_properties;
DROP TABLE IF EXISTS ${schema}.children; DROP TABLE IF EXISTS ${schema}.children;
DROP TABLE IF EXISTS ${schema}.parents; DROP TABLE IF EXISTS ${schema}.parents;
DROP TABLE IF EXISTS ${schema}.contract_cash_states; DROP TABLE IF EXISTS ${schema}.contract_cash_states;

View File

@ -4,6 +4,7 @@ DROP TABLE IF EXISTS ${schema}.cp_states_v2_participants;
DROP TABLE IF EXISTS ${schema}.dummy_linear_state_parts; DROP TABLE IF EXISTS ${schema}.dummy_linear_state_parts;
DROP TABLE IF EXISTS ${schema}.dummy_linear_states_v2_parts; DROP TABLE IF EXISTS ${schema}.dummy_linear_states_v2_parts;
DROP TABLE IF EXISTS ${schema}.dummy_deal_states_parts; DROP TABLE IF EXISTS ${schema}.dummy_deal_states_parts;
DROP TABLE IF EXISTS ${schema}.node_attchments_contracts;
DROP TABLE IF EXISTS ${schema}.node_attachments; DROP TABLE IF EXISTS ${schema}.node_attachments;
DROP TABLE IF EXISTS ${schema}.node_checkpoints; DROP TABLE IF EXISTS ${schema}.node_checkpoints;
DROP TABLE IF EXISTS ${schema}.node_transactions; DROP TABLE IF EXISTS ${schema}.node_transactions;
@ -32,6 +33,7 @@ DROP TABLE IF EXISTS ${schema}.cp_states;
DROP TABLE IF EXISTS ${schema}.node_contract_upgrades; DROP TABLE IF EXISTS ${schema}.node_contract_upgrades;
DROP TABLE IF EXISTS ${schema}.node_identities; DROP TABLE IF EXISTS ${schema}.node_identities;
DROP TABLE IF EXISTS ${schema}.node_named_identities; DROP TABLE IF EXISTS ${schema}.node_named_identities;
DROP TABLE IF EXISTS ${schema}.node_properties;
DROP TABLE IF EXISTS ${schema}.children; DROP TABLE IF EXISTS ${schema}.children;
DROP TABLE IF EXISTS ${schema}.parents; DROP TABLE IF EXISTS ${schema}.parents;
DROP TABLE IF EXISTS ${schema}.contract_cash_states; DROP TABLE IF EXISTS ${schema}.contract_cash_states;

View File

@ -6,6 +6,6 @@ dataSourceProperties = {
} }
database = { database = {
transactionIsolationLevel = READ_COMMITTED transactionIsolationLevel = READ_COMMITTED
initDatabase = true
schema = ${custom.nodeOrganizationName} schema = ${custom.nodeOrganizationName}
runMigration = true
} }

View File

@ -7,4 +7,5 @@ dataSourceProperties = {
database = { database = {
transactionIsolationLevel = READ_COMMITTED transactionIsolationLevel = READ_COMMITTED
schema = ${custom.nodeOrganizationName} schema = ${custom.nodeOrganizationName}
runMigration = true
} }

View File

@ -7,4 +7,5 @@ dataSourceProperties = {
database = { database = {
transactionIsolationLevel = READ_COMMITTED transactionIsolationLevel = READ_COMMITTED
schema = ${custom.nodeOrganizationName} schema = ${custom.nodeOrganizationName}
runMigration = true
} }

View File

@ -7,4 +7,5 @@ dataSourceProperties = {
database = { database = {
transactionIsolationLevel = READ_COMMITTED transactionIsolationLevel = READ_COMMITTED
schema = ${custom.nodeOrganizationName} schema = ${custom.nodeOrganizationName}
runMigration = true
} }

View File

@ -6,6 +6,6 @@ dataSourceProperties = {
} }
database = { database = {
transactionIsolationLevel = READ_COMMITTED transactionIsolationLevel = READ_COMMITTED
initDatabase = true
schema = ${custom.nodeOrganizationName} schema = ${custom.nodeOrganizationName}
runMigration = true
} }

View File

@ -42,7 +42,8 @@ import kotlin.test.fail
class SSHServerTest : IntegrationTest() { class SSHServerTest : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName())
} }

View File

@ -42,7 +42,8 @@ import kotlin.test.assertTrue
class VerifierTests : IntegrationTest() { class VerifierTests : IntegrationTest() {
companion object { companion object {
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), DUMMY_NOTARY_NAME.toDatabaseSchemaName())
} }
@Rule @Rule

View File

@ -37,7 +37,8 @@ class WebserverDriverTests : IntegrationTest() {
addressMustNotBeBound(executorService, webserverAddr) addressMustNotBeBound(executorService, webserverAddr)
} }
@ClassRule @JvmField @ClassRule
@JvmField
val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName()) val databaseSchemas = IntegrationTestSchemas(DUMMY_BANK_A_NAME.toDatabaseSchemaName())
} }