mirror of
https://github.com/corda/corda.git
synced 2025-03-14 00:06:45 +00:00
Test doorman with selected dbs only for now (SQL Server and Azure SQL) - for ENT-1447. (#833)
Test doorman with selected dbs (SQL Server and Azure SQL) only in integration test in database mode since not all databases are supported now.
This commit is contained in:
parent
6aa971332d
commit
18393f27dd
@ -26,7 +26,7 @@ import net.corda.nodeapi.internal.crypto.CertificateType
|
||||
import net.corda.nodeapi.internal.persistence.DatabaseConfig
|
||||
import net.corda.testing.internal.IntegrationTest
|
||||
import net.corda.testing.internal.IntegrationTestSchemas
|
||||
import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties
|
||||
import net.corda.testing.node.internal.makeTestDataSourceProperties
|
||||
import net.corda.testing.node.internal.makeTestDatabaseProperties
|
||||
import org.junit.Before
|
||||
import org.junit.ClassRule
|
||||
@ -185,10 +185,10 @@ abstract class HsmBaseTest : IntegrationTest() {
|
||||
}
|
||||
|
||||
fun makeTestDataSourceProperties(): Properties {
|
||||
return makeTestDataSourceProperties(DOORMAN_DB_NAME)
|
||||
return makeTestDataSourceProperties(DOORMAN_DB_NAME, configSupplier = configSupplierForSupportedDatabases())
|
||||
}
|
||||
|
||||
fun makeTestDatabaseProperties(): DatabaseConfig {
|
||||
return makeTestDatabaseProperties(DOORMAN_DB_NAME)
|
||||
return makeTestDatabaseProperties(DOORMAN_DB_NAME, configSupplier = configSupplierForSupportedDatabases())
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ import com.typesafe.config.Config
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.testing.database.DatabaseConstants
|
||||
import net.corda.testing.node.internal.databaseProviderDataSourceConfig
|
||||
|
||||
const val HOST = "localhost"
|
||||
|
||||
@ -28,4 +29,11 @@ fun networkMapInMemoryH2DataSourceConfig(nodeName: String? = null, postfix: Stri
|
||||
DatabaseConstants.DATA_SOURCE_URL to "jdbc:h2:mem:${h2InstanceName};DB_CLOSE_DELAY=-1",
|
||||
DatabaseConstants.DATA_SOURCE_USER to "sa",
|
||||
DatabaseConstants.DATA_SOURCE_PASSWORD to ""))
|
||||
}
|
||||
}
|
||||
|
||||
//TODO add more dbs to test once doorman supports them
|
||||
fun configSupplierForSupportedDatabases(): (String?, String?) -> Config =
|
||||
when (System.getProperty("custom.databaseProvider", "")) {
|
||||
"integration-sql-server", "integration-azure-sql" -> ::databaseProviderDataSourceConfig
|
||||
else -> { _, _ -> ConfigFactory.empty() }
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.r3.corda.networkmanage.doorman
|
||||
|
||||
import com.r3.corda.networkmanage.common.DOORMAN_DB_NAME
|
||||
import com.r3.corda.networkmanage.common.configSupplierForSupportedDatabases
|
||||
import com.r3.corda.networkmanage.common.networkMapInMemoryH2DataSourceConfig
|
||||
import com.r3.corda.networkmanage.common.utils.CertPathAndKey
|
||||
import com.r3.corda.networkmanage.doorman.signer.LocalSigner
|
||||
@ -154,7 +155,8 @@ class NetworkParametersUpdateTest : IntegrationTest() {
|
||||
|
||||
private fun startServer(startNetworkMap: Boolean = true): NetworkManagementServer {
|
||||
val doormanConfig = DoormanConfig(approveAll = true, jira = null, approveInterval = timeoutMillis)
|
||||
val server = NetworkManagementServer(makeTestDataSourceProperties(DOORMAN_DB_NAME, dbNamePostfix, fallBackConfigSupplier = ::networkMapInMemoryH2DataSourceConfig), DatabaseConfig(runMigration = true), doormanConfig, null)
|
||||
val server = NetworkManagementServer(makeTestDataSourceProperties(DOORMAN_DB_NAME, dbNamePostfix, configSupplier = configSupplierForSupportedDatabases(), fallBackConfigSupplier = ::networkMapInMemoryH2DataSourceConfig),
|
||||
DatabaseConfig(runMigration = true), doormanConfig, null)
|
||||
server.start(
|
||||
serverAddress,
|
||||
CertPathAndKey(listOf(doormanCa.certificate, rootCaCert), doormanCa.keyPair.private),
|
||||
@ -173,7 +175,7 @@ class NetworkParametersUpdateTest : IntegrationTest() {
|
||||
private fun applyNetworkParametersAndStart(networkParametersCmd: NetworkParametersCmd) {
|
||||
server?.close()
|
||||
NetworkManagementServer(
|
||||
makeTestDataSourceProperties(DOORMAN_DB_NAME, dbNamePostfix, fallBackConfigSupplier = ::networkMapInMemoryH2DataSourceConfig),
|
||||
makeTestDataSourceProperties(DOORMAN_DB_NAME, dbNamePostfix, configSupplier = configSupplierForSupportedDatabases(), fallBackConfigSupplier = ::networkMapInMemoryH2DataSourceConfig),
|
||||
DatabaseConfig(runMigration = true),
|
||||
DoormanConfig(approveAll = true, jira = null, approveInterval = timeoutMillis),
|
||||
null).use {
|
||||
|
@ -11,6 +11,7 @@
|
||||
package com.r3.corda.networkmanage.doorman
|
||||
|
||||
import com.r3.corda.networkmanage.common.DOORMAN_DB_NAME
|
||||
import com.r3.corda.networkmanage.common.configSupplierForSupportedDatabases
|
||||
import com.r3.corda.networkmanage.common.networkMapInMemoryH2DataSourceConfig
|
||||
import com.r3.corda.networkmanage.common.utils.CertPathAndKey
|
||||
import com.r3.corda.networkmanage.doorman.signer.LocalSigner
|
||||
@ -174,7 +175,8 @@ class NodeRegistrationTest : IntegrationTest() {
|
||||
}
|
||||
|
||||
private fun startServer(startNetworkMap: Boolean = true): NetworkManagementServer {
|
||||
val server = NetworkManagementServer(makeTestDataSourceProperties(DOORMAN_DB_NAME, dbNamePostfix, fallBackConfigSupplier = ::networkMapInMemoryH2DataSourceConfig), makeTestDatabaseProperties(DOORMAN_DB_NAME), doormanConfig, revocationConfig)
|
||||
val server = NetworkManagementServer(makeTestDataSourceProperties(DOORMAN_DB_NAME, dbNamePostfix, configSupplier = configSupplierForSupportedDatabases(), fallBackConfigSupplier = ::networkMapInMemoryH2DataSourceConfig),
|
||||
makeTestDatabaseProperties(configSupplier = configSupplierForSupportedDatabases()), doormanConfig, revocationConfig)
|
||||
server.start(
|
||||
serverAddress,
|
||||
CertPathAndKey(listOf(doormanCa.certificate, rootCaCert), doormanCa.keyPair.private),
|
||||
@ -192,7 +194,8 @@ class NodeRegistrationTest : IntegrationTest() {
|
||||
|
||||
private fun applyNetworkParametersAndStart(networkParametersCmd: NetworkParametersCmd) {
|
||||
server?.close()
|
||||
NetworkManagementServer(makeTestDataSourceProperties(DOORMAN_DB_NAME, dbNamePostfix, fallBackConfigSupplier = ::networkMapInMemoryH2DataSourceConfig), makeTestDatabaseProperties(DOORMAN_DB_NAME), doormanConfig, revocationConfig).use {
|
||||
NetworkManagementServer(makeTestDataSourceProperties(DOORMAN_DB_NAME, dbNamePostfix, configSupplier = configSupplierForSupportedDatabases(), fallBackConfigSupplier = ::networkMapInMemoryH2DataSourceConfig),
|
||||
makeTestDatabaseProperties(configSupplier = configSupplierForSupportedDatabases()), doormanConfig, revocationConfig).use {
|
||||
it.netParamsUpdateHandler.processNetworkParameters(networkParametersCmd)
|
||||
}
|
||||
server = startServer(startNetworkMap = true)
|
||||
|
@ -151,9 +151,9 @@ internal interface InternalMockMessagingService : MessagingService {
|
||||
* @param fallBackConfigSupplier Returns [Config] with dataSourceProperties, invoked with [nodeName] and [nodeNameExtension] parameters.
|
||||
* Defaults to configuration of in-memory H2 instance.
|
||||
*/
|
||||
fun makeTestDataSourceProperties(nodeName: String = SecureHash.randomSHA256().toString(),
|
||||
fun makeTestDataSourceProperties(nodeName: String? = SecureHash.randomSHA256().toString(),
|
||||
nodeNameExtension: String? = null,
|
||||
configSupplier: (String, String?) -> Config = ::databaseProviderDataSourceConfig,
|
||||
configSupplier: (String?, String?) -> Config = ::databaseProviderDataSourceConfig,
|
||||
fallBackConfigSupplier: (String?, String?) -> Config = ::inMemoryH2DataSourceConfig): Properties {
|
||||
val config = configSupplier(nodeName, nodeNameExtension)
|
||||
.withFallback(fallBackConfigSupplier(nodeName, nodeNameExtension))
|
||||
@ -172,9 +172,11 @@ fun makeTestDataSourceProperties(nodeName: String = SecureHash.randomSHA256().to
|
||||
* Make properties appropriate for creating a Database for unit tests.
|
||||
*
|
||||
* @param nodeName Reflects the "instance" of the in-memory database or database username/schema.
|
||||
* @param configSupplier Returns [Config] with databaseProperties, invoked with [nodeName] parameter.
|
||||
*/
|
||||
fun makeTestDatabaseProperties(nodeName: String? = null): DatabaseConfig {
|
||||
val config = databaseProviderDataSourceConfig(nodeName)
|
||||
fun makeTestDatabaseProperties(nodeName: String? = null,
|
||||
configSupplier: (String?, String?) -> Config = ::databaseProviderDataSourceConfig): DatabaseConfig {
|
||||
val config = configSupplier(nodeName, null)
|
||||
val transactionIsolationLevel = if (config.hasPath(DatabaseConstants.TRANSACTION_ISOLATION_LEVEL))
|
||||
TransactionIsolationLevel.valueOf(config.getString(DatabaseConstants.TRANSACTION_ISOLATION_LEVEL))
|
||||
else TransactionIsolationLevel.READ_COMMITTED
|
||||
|
Loading…
x
Reference in New Issue
Block a user