From d984b4722e5ac87db9fff7130e18da6617af0162 Mon Sep 17 00:00:00 2001 From: josecoll Date: Mon, 11 Dec 2017 11:42:53 +0000 Subject: [PATCH] Re-enable perftestcordapp and jmeter - fix compilation errors caused by MockServices and DriverDSL refactoring. --- .../contracts/CommercialPaperTests.kt | 4 ++-- .../perftestcordapp/contracts/asset/CashTests.kt | 4 ++-- .../flows/TwoPartyTradeFlowTest.kt | 16 +++++++++++----- .../kotlin/net/corda/test/spring/SpringDriver.kt | 2 +- settings.gradle | 2 ++ .../net/corda/testing/driver/DriverTests.kt | 2 +- tools/jmeter/build.gradle | 1 + .../kotlin/net/corda/verifier/VerifierDriver.kt | 4 ++-- 8 files changed, 22 insertions(+), 13 deletions(-) diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt index 455d2ee71e..9ff77dfe6d 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt @@ -210,8 +210,8 @@ class CommercialPaperTestsGeneric { private lateinit var aliceVaultService: VaultService private lateinit var alicesVault: Vault - private val notaryServices = MockServices(DUMMY_NOTARY_KEY) - private val issuerServices = MockServices(DUMMY_CASH_ISSUER_KEY) + private val notaryServices = MockServices(rigorousMock(), MEGA_CORP.name, DUMMY_NOTARY_KEY) + private val issuerServices = MockServices(rigorousMock(), MEGA_CORP.name, DUMMY_CASH_ISSUER_KEY) private lateinit var moveTX: SignedTransaction diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt index 348929124c..0845271419 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt @@ -104,7 +104,7 @@ class CashTests { @Before fun setUp() = withTestSerialization { LogHelper.setLevel(NodeVaultService::class) - megaCorpServices = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset","com.r3.corda.enterprise.perftestcordapp.schemas"), MEGA_CORP.name, MEGA_CORP_KEY) + megaCorpServices = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset","com.r3.corda.enterprise.perftestcordapp.schemas"), rigorousMock(), MEGA_CORP.name, MEGA_CORP_KEY) val databaseAndServices = makeTestDatabaseAndMockServices( listOf(MINI_CORP_KEY, MEGA_CORP_KEY, OUR_KEY), makeTestIdentityService(listOf(MEGA_CORP_IDENTITY, MINI_CORP_IDENTITY, DUMMY_CASH_ISSUER_IDENTITY, DUMMY_NOTARY_IDENTITY)), @@ -844,7 +844,7 @@ class CashTests { // Double spend. @Test fun chainCashDoubleSpendFailsWith() = withTestSerialization { - val mockService = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), MEGA_CORP.name, MEGA_CORP_KEY) + val mockService = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), rigorousMock(), MEGA_CORP.name, MEGA_CORP_KEY) ledger(mockService) { unverifiedTransaction { diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt index 3cbd3eb293..f7d74983c3 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt @@ -39,6 +39,7 @@ import net.corda.core.utilities.toNonEmptySet import net.corda.core.utilities.unwrap import net.corda.node.internal.StartedNode import net.corda.node.services.api.CheckpointStorage +import net.corda.node.services.api.IdentityServiceInternal import net.corda.node.services.api.WritableTransactionStorage import net.corda.node.services.persistence.DBTransactionStorage import net.corda.node.services.statemachine.Checkpoint @@ -101,7 +102,8 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { // we run in the unit test thread exclusively to speed things up, ensure deterministic results and // allow interruption half way through. mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages) - ledger(MockServices(cordappPackages)) { + val ledgerIdentityService = rigorousMock() + ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) val bobNode = mockNet.createPartyNode(BOB_NAME) @@ -152,7 +154,8 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { @Test(expected = InsufficientBalanceException::class) fun `trade cash for commercial paper fails using soft locking`() { mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages) - ledger(MockServices(cordappPackages)) { + val ledgerIdentityService = rigorousMock() + ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) val bobNode = mockNet.createPartyNode(BOB_NAME) @@ -209,7 +212,8 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { @Test fun `shutdown and restore`() { mockNet = MockNetwork(cordappPackages = cordappPackages) - ledger(MockServices(cordappPackages)) { + val ledgerIdentityService = rigorousMock() + ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) var bobNode = mockNet.createPartyNode(BOB_NAME) @@ -505,7 +509,8 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { @Test fun `dependency with error on buyer side`() { mockNet = MockNetwork(cordappPackages = cordappPackages) - ledger(MockServices(cordappPackages)) { + val ledgerIdentityService = rigorousMock() + ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { runWithError(true, false, "at least one cash input") } } @@ -513,7 +518,8 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { @Test fun `dependency with error on seller side`() { mockNet = MockNetwork(cordappPackages = cordappPackages) - ledger(MockServices(cordappPackages)) { + val ledgerIdentityService = rigorousMock() + ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { runWithError(false, true, "Issuances have a time-window") } } diff --git a/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt b/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt index ba6d7811da..692c252f7a 100644 --- a/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt +++ b/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt @@ -23,7 +23,7 @@ fun springDriver( driverDirectory: Path = defaultParameters.driverDirectory, portAllocation: PortAllocation = defaultParameters.portAllocation, debugPortAllocation: PortAllocation = defaultParameters.debugPortAllocation, - systemProperties: Map = defaultParameters.extraSystemProperties, + systemProperties: Map = defaultParameters.systemProperties, useTestClock: Boolean = defaultParameters.useTestClock, initialiseSerialization: Boolean = defaultParameters.initialiseSerialization, startNodesInProcess: Boolean = defaultParameters.startNodesInProcess, diff --git a/settings.gradle b/settings.gradle index ed81c524ca..6a1ca989ff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -35,6 +35,7 @@ include 'tools:explorer:capsule' include 'tools:demobench' include 'tools:loadtest' include 'tools:graphs' +include 'tools:jmeter' include 'example-code' project(':example-code').projectDir = file("$settingsDir/docs/source/example-code") include 'samples:attachment-demo' @@ -57,4 +58,5 @@ project(':hsm-tool').with { name = 'sgx-hsm-tool' projectDir = file("$settingsDir/sgx-jvm/hsm-tool") } +include 'perftestcordapp' diff --git a/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt b/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt index ed78ae8527..62601c34b0 100644 --- a/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt +++ b/testing/node-driver/src/integration-test/kotlin/net/corda/testing/driver/DriverTests.kt @@ -64,7 +64,7 @@ class DriverTests : IntegrationTest() { // Make sure we're using the log4j2 config which writes to the log file val logConfigFile = projectRootDir / "config" / "dev" / "log4j2.xml" assertThat(logConfigFile).isRegularFile() - driver(isDebug = true, extraSystemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString())) { + driver(isDebug = true, systemProperties = mapOf("log4j.configurationFile" to logConfigFile.toString())) { val baseDirectory = startNode(providedName = DUMMY_BANK_A.name).getOrThrow().configuration.baseDirectory val logFile = (baseDirectory / NodeStartup.LOGS_DIRECTORY_NAME).list { it.sorted().findFirst().get() } val debugLinesPresent = logFile.readLines { lines -> lines.anyMatch { line -> line.startsWith("[DEBUG]") } } diff --git a/tools/jmeter/build.gradle b/tools/jmeter/build.gradle index e75a3c3277..6040fd3739 100644 --- a/tools/jmeter/build.gradle +++ b/tools/jmeter/build.gradle @@ -6,6 +6,7 @@ mainClassName = 'com.r3.corda.jmeter.Launcher' dependencies { compile project(':client:rpc') + compile project(':perftestcordapp') // https://mvnrepository.com/artifact/com.jcraft/jsch compile group: 'com.jcraft', name: 'jsch', version: '0.1.54' diff --git a/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierDriver.kt b/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierDriver.kt index 37270bb054..b5096b46fa 100644 --- a/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierDriver.kt +++ b/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierDriver.kt @@ -54,7 +54,7 @@ fun verifierDriver( driverDirectory: Path = Paths.get("build", getTimestampAsDirectoryName()), portAllocation: PortAllocation = PortAllocation.Incremental(10000), debugPortAllocation: PortAllocation = PortAllocation.Incremental(5005), - extraSystemProperties: Map = emptyMap(), + systemProperties: Map = emptyMap(), useTestClock: Boolean = false, startNodesInProcess: Boolean = false, waitForNodesToFinish: Boolean = false, @@ -67,7 +67,7 @@ fun verifierDriver( DriverDSLImpl( portAllocation = portAllocation, debugPortAllocation = debugPortAllocation, - extraSystemProperties = extraSystemProperties, + systemProperties = systemProperties, driverDirectory = driverDirectory.toAbsolutePath(), useTestClock = useTestClock, isDebug = isDebug,