mirror of
https://github.com/corda/corda.git
synced 2025-06-23 17:53:31 +00:00
Ability to run integration tests against standalone databases (part 2) (#109)
Commit 359610ff14
didn't fully covered:
* Integration tests extends IntegrationTest class which can run SQL scripts before and after a test and before and after test class.
*Driver.kt creates notaries without a table name prefixes (separation is achieved by using different user/schema).
*Revert wrongly altered H2 JDBC connection string for tests.
This commit is contained in:
@ -889,9 +889,7 @@ class DriverDSL(
|
||||
providedName = nodeNames[0],
|
||||
rpcUsers = spec.rpcUsers,
|
||||
verifierType = spec.verifierType,
|
||||
customOverrides = notaryConfig(clusterAddress) + mapOf(
|
||||
"database.serverNameTablePrefix" to nodeNames[0].toString().replace(Regex("[^0-9A-Za-z]+"), "")
|
||||
)
|
||||
customOverrides = notaryConfig(clusterAddress)
|
||||
)
|
||||
|
||||
// All other nodes will join the cluster
|
||||
@ -901,9 +899,7 @@ class DriverDSL(
|
||||
providedName = it,
|
||||
rpcUsers = spec.rpcUsers,
|
||||
verifierType = spec.verifierType,
|
||||
customOverrides = notaryConfig(nodeAddress, clusterAddress) + mapOf(
|
||||
"database.serverNameTablePrefix" to it.toString().replace(Regex("[^0-9A-Za-z]+"), "")
|
||||
)
|
||||
customOverrides = notaryConfig(nodeAddress, clusterAddress)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import net.corda.node.services.config.configOf
|
||||
import net.corda.node.services.config.parseAsNodeConfiguration
|
||||
import net.corda.node.services.config.plus
|
||||
import net.corda.nodeapi.User
|
||||
import net.corda.testing.IntegrationTest
|
||||
import net.corda.testing.SerializationEnvironmentRule
|
||||
import net.corda.testing.common.internal.NetworkParametersCopier
|
||||
import net.corda.testing.common.internal.testNetworkParameters
|
||||
@ -31,7 +32,7 @@ import java.util.concurrent.Executors
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
// TODO Some of the logic here duplicates what's in the driver
|
||||
abstract class NodeBasedTest(private val cordappPackages: List<String> = emptyList()) {
|
||||
abstract class NodeBasedTest(private val cordappPackages: List<String> = emptyList()) : IntegrationTest() {
|
||||
companion object {
|
||||
private val WHITESPACE = "\\s++".toRegex()
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ open class MockServices(
|
||||
|
||||
private fun readDatabaseConfig(nodeName: String? = null, postifx: String? = null): Config {
|
||||
val standarizedNodeName = if (nodeName!= null) nodeName.replace(" ", "").replace("-", "_") else null
|
||||
//in case of H2, the same db instance runs for all integration tests, so adding additional variable postfix to use unique db user/schema each time
|
||||
val h2InstanceName = if (postifx != null) standarizedNodeName + "_" + postifx else standarizedNodeName
|
||||
val parseOptions = ConfigParseOptions.defaults()
|
||||
val databaseConfig = ConfigFactory.parseResources(System.getProperty("databaseProvider") + ".conf", parseOptions.setAllowMissing(true))
|
||||
@ -70,7 +71,7 @@ open class MockServices(
|
||||
val nodeOrganizationNameConfig = if (standarizedNodeName != null) configOf("nodeOrganizationName" to standarizedNodeName) else ConfigFactory.empty()
|
||||
val defaultProps = Properties()
|
||||
defaultProps.setProperty("dataSourceProperties.dataSourceClassName", "org.h2.jdbcx.JdbcDataSource")
|
||||
defaultProps.setProperty("dataSourceProperties.dataSource.url", "jdbc:h2:mem:${h2InstanceName}_persistence;LOCK_TIMEOUT=100;DB_CLOSE_ON_EXIT=TRUE")//;TRACE_LEVEL_SYSTEM_OUT=4")
|
||||
defaultProps.setProperty("dataSourceProperties.dataSource.url", "jdbc:h2:mem:${h2InstanceName}_persistence;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE")
|
||||
defaultProps.setProperty("dataSourceProperties.dataSource.user", "sa")
|
||||
defaultProps.setProperty("dataSourceProperties.dataSource.password", "")
|
||||
val defaultConfig = ConfigFactory.parseProperties(defaultProps, parseOptions)
|
||||
|
Reference in New Issue
Block a user