From bc630a03816318335f4cdedc92184280fc1ab409 Mon Sep 17 00:00:00 2001 From: Rick Parker Date: Tue, 5 Dec 2017 15:39:08 +0000 Subject: [PATCH] Local perftestcordapp cluster using driver (#154) * Issue and pay sampler now allows to bypass coin selection. * Local driver based launch of nodes running perftestcordapp * Fixed comments. --- tools/jmeter/README.md | 9 + tools/jmeter/build.gradle | 11 ++ .../kotlin/com/r3/corda/jmeter/Samplers.kt | 12 +- .../resources/LocalIssueAndPay Request.jmx | 187 ++++++++++++++++++ .../r3/corda/jmeter/StartLocalPerfCorDapp.kt | 36 ++++ 5 files changed, 253 insertions(+), 2 deletions(-) create mode 100644 tools/jmeter/src/main/resources/LocalIssueAndPay Request.jmx create mode 100644 tools/jmeter/src/test/kotlin/com/r3/corda/jmeter/StartLocalPerfCorDapp.kt diff --git a/tools/jmeter/README.md b/tools/jmeter/README.md index 6e67cce028..b555e7c982 100644 --- a/tools/jmeter/README.md +++ b/tools/jmeter/README.md @@ -55,3 +55,12 @@ remote user name is different from the current user name, `-XsshUser ", "The X500 name of the payee.") + val coinSelection = Argument("useCoinSelection", "true", "", "True to use coin selection and false (or anything else) to avoid coin selection.") } lateinit var counterParty: Party + var useCoinSelection: Boolean = true override fun setupTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) { getNotaryIdentity(rpcProxy,testContext) counterParty = getIdentity(rpcProxy, testContext, otherParty) + useCoinSelection = testContext.getParameter(coinSelection.name, coinSelection.value).toBoolean() } override fun createFlowInvoke(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext): FlowInvoke<*> { val amount = 2_000_000.POUNDS - return FlowInvoke(CashIssueAndPaymentFlow::class.java, arrayOf(amount, OpaqueBytes.of(1), counterParty, true, notaryIdentity)) + if (useCoinSelection) { + return FlowInvoke(CashIssueAndPaymentFlow::class.java, arrayOf(amount, OpaqueBytes.of(1), counterParty, true, notaryIdentity)) + } else { + return FlowInvoke(CashIssueAndPaymentNoSelection::class.java, arrayOf(amount, OpaqueBytes.of(1), counterParty, true, notaryIdentity)) + } } override fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) { } override val additionalArgs: Set - get() = setOf(notary, otherParty) + get() = setOf(notary, otherParty, coinSelection) } \ No newline at end of file diff --git a/tools/jmeter/src/main/resources/LocalIssueAndPay Request.jmx b/tools/jmeter/src/main/resources/LocalIssueAndPay Request.jmx new file mode 100644 index 0000000000..d36d667bca --- /dev/null +++ b/tools/jmeter/src/main/resources/LocalIssueAndPay Request.jmx @@ -0,0 +1,187 @@ + + + + + + false + false + + + + + + + + continue + + false + 100 + + 3 + + 1509455820000 + 1509455820000 + false + + + + + + + + + host + localhost + = + + + port + 10004 + = + + + username + perf + = + + + password + perf + = + + + notaryName + O=Notary Service,L=Zurich,C=CH,CN=corda.notary.simple + = + + + otherPartyName + O=Bank B,L=New York,C=US + = + + + useCoinSelection + true + = + + + + com.r3.corda.jmeter.CashIssueAndPaySampler + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + + + + + + + + true + + + + diff --git a/tools/jmeter/src/test/kotlin/com/r3/corda/jmeter/StartLocalPerfCorDapp.kt b/tools/jmeter/src/test/kotlin/com/r3/corda/jmeter/StartLocalPerfCorDapp.kt new file mode 100644 index 0000000000..359398d44f --- /dev/null +++ b/tools/jmeter/src/test/kotlin/com/r3/corda/jmeter/StartLocalPerfCorDapp.kt @@ -0,0 +1,36 @@ +package com.r3.corda.jmeter + +import net.corda.core.utilities.getOrThrow +import net.corda.nodeapi.User +import net.corda.testing.DUMMY_NOTARY +import net.corda.testing.node.NotarySpec +import java.io.BufferedReader +import java.io.InputStreamReader + +class StartLocalPerfCorDapp { + companion object { + @JvmStatic + fun main(args: Array) { + // Typically the RPC port of Bank A is 10004. + val demoUser = User("perf", "perf", setOf(net.corda.node.services.Permissions.Companion.all())) + net.corda.testing.driver.driver(startNodesInProcess = false, + waitForAllNodesToFinish = true, + notarySpecs = listOf(NotarySpec(DUMMY_NOTARY.name, validating = false)), + extraCordappPackagesToScan = listOf("com.r3.corda.enterprise.perftestcordapp")) { + val (nodeA, nodeB) = listOf( + startNode(providedName = net.corda.testing.DUMMY_BANK_A.name, rpcUsers = listOf(demoUser)), + startNode(providedName = net.corda.testing.DUMMY_BANK_B.name, rpcUsers = listOf(demoUser)) + ).map { it.getOrThrow() } + println("Nodes started!") + val input = BufferedReader(InputStreamReader(System.`in`)) + do { + Ssh.log.info("Type 'quit' to exit cleanly.") + } while (input.readLine() != "quit") + println("Quitting... (this sometimes takes a while)") + nodeA.stop() + nodeB.stop() + defaultNotaryHandle.nodeHandles.getOrThrow().map { it.stop() } + } + } + } +} \ No newline at end of file