mirror of
https://github.com/corda/corda.git
synced 2025-06-01 23:20:54 +00:00
Fixes after merge remote-tracking branch 'remotes/open/master' into szymonsztuka/os-merge-20180824
This commit is contained in:
parent
c7f666102f
commit
33e8e05a8d
@ -1050,7 +1050,7 @@ fun configureDatabase(hikariProperties: Properties,
|
|||||||
wellKnownPartyFromAnonymous: (AbstractParty) -> Party?,
|
wellKnownPartyFromAnonymous: (AbstractParty) -> Party?,
|
||||||
schemaService: SchemaService = NodeSchemaService()): CordaPersistence {
|
schemaService: SchemaService = NodeSchemaService()): CordaPersistence {
|
||||||
val isH2Database = isH2Database(hikariProperties.getProperty("dataSource.url", ""))
|
val isH2Database = isH2Database(hikariProperties.getProperty("dataSource.url", ""))
|
||||||
val schemas = if (isH2Database) NodeSchemaService().internalSchemas() else NodeSchemaService().schemaOptions.keys
|
val schemas = if (isH2Database) NodeSchemaService().internalSchemas() else schemaService.schemaOptions.keys
|
||||||
return createCordaPersistence(databaseConfig, wellKnownPartyFromX500Name, wellKnownPartyFromAnonymous, schemaService)
|
return createCordaPersistence(databaseConfig, wellKnownPartyFromX500Name, wellKnownPartyFromAnonymous, schemaService)
|
||||||
.apply { startHikariPool(hikariProperties, databaseConfig, schemas) }
|
.apply { startHikariPool(hikariProperties, databaseConfig, schemas) }
|
||||||
|
|
||||||
|
@ -16,7 +16,8 @@ import net.corda.core.contracts.UniqueIdentifier
|
|||||||
import net.corda.core.identity.AbstractParty
|
import net.corda.core.identity.AbstractParty
|
||||||
import net.corda.core.schemas.CommonSchemaV1
|
import net.corda.core.schemas.CommonSchemaV1
|
||||||
import net.corda.core.schemas.MappedSchema
|
import net.corda.core.schemas.MappedSchema
|
||||||
import net.corda.node.internal.configureDatabase
|
import net.corda.node.internal.createCordaPersistence
|
||||||
|
import net.corda.node.internal.startHikariPool
|
||||||
import net.corda.node.services.schema.NodeSchemaService
|
import net.corda.node.services.schema.NodeSchemaService
|
||||||
import net.corda.nodeapi.internal.persistence.CordaPersistence
|
import net.corda.nodeapi.internal.persistence.CordaPersistence
|
||||||
import net.corda.nodeapi.internal.persistence.DatabaseConfig
|
import net.corda.nodeapi.internal.persistence.DatabaseConfig
|
||||||
@ -32,9 +33,16 @@ import javax.persistence.*
|
|||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class SchemaMigrationTest {
|
class SchemaMigrationTest {
|
||||||
|
|
||||||
|
private fun configureDatabase(hikariProperties: Properties,
|
||||||
|
databaseConfig: DatabaseConfig,
|
||||||
|
schemaService: NodeSchemaService = NodeSchemaService()): CordaPersistence =
|
||||||
|
createCordaPersistence(databaseConfig, { null }, { null }, schemaService)
|
||||||
|
.apply { startHikariPool(hikariProperties, databaseConfig, schemaService.schemaOptions.keys) }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Ensure that runMigration is disabled by default`() {
|
fun `Ensure that runMigration is disabled by default`() {
|
||||||
assertThat(DatabaseConfig().runMigration).isFalse()
|
assertThat(DatabaseConfig().runMigration).isFalse()
|
||||||
@ -43,14 +51,14 @@ class SchemaMigrationTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `Migration is run when runMigration is disabled, and database is H2`() {
|
fun `Migration is run when runMigration is disabled, and database is H2`() {
|
||||||
val dataSourceProps = MockServices.makeTestDataSourceProperties()
|
val dataSourceProps = MockServices.makeTestDataSourceProperties()
|
||||||
val db = configureDatabase(dataSourceProps, DatabaseConfig(runMigration = false), { null }, { null })
|
val db = configureDatabase(dataSourceProps, DatabaseConfig(runMigration = false))
|
||||||
checkMigrationRun(db)
|
checkMigrationRun(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Migration is run when runMigration is enabled`() {
|
fun `Migration is run when runMigration is enabled`() {
|
||||||
val dataSourceProps = MockServices.makeTestDataSourceProperties()
|
val dataSourceProps = MockServices.makeTestDataSourceProperties()
|
||||||
val db = configureDatabase(dataSourceProps, DatabaseConfig(runMigration = true), { null }, { null })
|
val db = configureDatabase(dataSourceProps, DatabaseConfig(runMigration = true))
|
||||||
checkMigrationRun(db)
|
checkMigrationRun(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +72,7 @@ class SchemaMigrationTest {
|
|||||||
migration.runMigration(false)
|
migration.runMigration(false)
|
||||||
|
|
||||||
//start the node with "runMigration = false" and check that it started correctly
|
//start the node with "runMigration = false" and check that it started correctly
|
||||||
val db = configureDatabase(dataSourceProps, DatabaseConfig(runMigration = false), { null }, { null }, schemaService)
|
val db = configureDatabase(dataSourceProps, DatabaseConfig(runMigration = false), schemaService)
|
||||||
checkMigrationRun(db)
|
checkMigrationRun(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +86,7 @@ class SchemaMigrationTest {
|
|||||||
addToClassPath(tmpFolder)
|
addToClassPath(tmpFolder)
|
||||||
|
|
||||||
// run the migrations for DummyTestSchemaV1, which should pick up the migration file
|
// run the migrations for DummyTestSchemaV1, which should pick up the migration file
|
||||||
val db = configureDatabase(dataSourceProps, DatabaseConfig(runMigration = true), { null }, { null }, NodeSchemaService(extraSchemas = setOf(DummyTestSchemaV1)))
|
val db = configureDatabase(dataSourceProps, DatabaseConfig(runMigration = true), NodeSchemaService(extraSchemas = setOf(DummyTestSchemaV1)))
|
||||||
|
|
||||||
// check that the file was picked up
|
// check that the file was picked up
|
||||||
val nrOfChangesOnDiscoveredFile = db.dataSource.connection.use {
|
val nrOfChangesOnDiscoveredFile = db.dataSource.connection.use {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user