From 1e2cc3e2df94f43e7c29e8a5f208ac687b5039a9 Mon Sep 17 00:00:00 2001 From: szymonsztuka Date: Wed, 10 Jan 2018 10:56:55 +0000 Subject: [PATCH] Database integration tests - added NotaryService schema to database setup. (#328) * Added NotaryService schema to database setup for two integration tests. * SQL Server setup scripts - create Login only if not preset (as it's done for Azure SQL). --- node/src/integration-test/kotlin/net/corda/node/BootTests.kt | 4 +++- .../kotlin/net/corda/node/CordappScanningDriverTest.kt | 3 ++- .../resources/database-scripts/sql-server/db-global-setup.sql | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) 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 f32b573259..4cbb60a068 100644 --- a/node/src/integration-test/kotlin/net/corda/node/BootTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/BootTests.kt @@ -14,6 +14,7 @@ import net.corda.testing.common.internal.ProjectStructure.projectRootDir 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.internal.toDatabaseSchemaNames import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy @@ -27,7 +28,8 @@ class BootTests : IntegrationTest() { companion object { @ClassRule @JvmField val databaseSchemas = IntegrationTestSchemas(*listOf(ALICE_NAME, BOB_NAME, DUMMY_BANK_A_NAME) - .map { it.toDatabaseSchemaNames("", "_10000", "_10003") }.flatten().toTypedArray()) + .map { it.toDatabaseSchemaNames("", "_10000", "_10003") }.flatten().toTypedArray() + + DUMMY_NOTARY_NAME.toDatabaseSchemaName()) } @Test diff --git a/node/src/integration-test/kotlin/net/corda/node/CordappScanningDriverTest.kt b/node/src/integration-test/kotlin/net/corda/node/CordappScanningDriverTest.kt index de34d975e2..d4a97c24fd 100644 --- a/node/src/integration-test/kotlin/net/corda/node/CordappScanningDriverTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/CordappScanningDriverTest.kt @@ -21,7 +21,8 @@ import org.junit.Test class CordappScanningDriverTest : IntegrationTest() { companion object { @ClassRule @JvmField - val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName()) + val databaseSchemas = IntegrationTestSchemas(ALICE_NAME.toDatabaseSchemaName(), BOB_NAME.toDatabaseSchemaName(), + DUMMY_NOTARY_NAME.toDatabaseSchemaName()) } @Test diff --git a/testing/test-utils/src/main/resources/database-scripts/sql-server/db-global-setup.sql b/testing/test-utils/src/main/resources/database-scripts/sql-server/db-global-setup.sql index 64527cda93..78f93c3b80 100644 --- a/testing/test-utils/src/main/resources/database-scripts/sql-server/db-global-setup.sql +++ b/testing/test-utils/src/main/resources/database-scripts/sql-server/db-global-setup.sql @@ -52,7 +52,7 @@ DROP SEQUENCE IF EXISTS ${schema}.hibernate_sequence; DROP USER IF EXISTS ${schema}; DROP LOGIN ${schema}; DROP SCHEMA IF EXISTS ${schema}; -CREATE LOGIN ${schema} WITH PASSWORD = 'yourStrong(!)Password'; +IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE name = N'${schema}') CREATE LOGIN ${schema} WITH PASSWORD = 'yourStrong(!)Password'; CREATE SCHEMA ${schema}; CREATE USER ${schema} FOR LOGIN ${schema} WITH DEFAULT_SCHEMA = ${schema}; GRANT ALTER, DELETE, EXECUTE, INSERT, REFERENCES, SELECT, UPDATE, VIEW DEFINITION ON SCHEMA::${schema} TO ${schema};