diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFromKnownStatesFlow.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFromKnownStatesFlow.kt index 610cc41b0c..29990691c1 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFromKnownStatesFlow.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFromKnownStatesFlow.kt @@ -21,6 +21,7 @@ import java.util.* class CashPaymentFromKnownStatesFlow( val inputs: Set, val numberOfStates: Int, + val numberOfChangeStates: Int, val amountPerState: Amount, val recipient: Party, val anonymous: Boolean, @@ -28,9 +29,10 @@ class CashPaymentFromKnownStatesFlow( constructor(inputs: Set, numberOfStates: Int, + numberOfChangeStates: Int, amountPerState: Amount, recipient: Party, - anonymous: Boolean) : this(inputs, numberOfStates, amountPerState, recipient, anonymous, tracker()) + anonymous: Boolean) : this(inputs, numberOfStates, numberOfChangeStates, amountPerState, recipient, anonymous, tracker()) @Suspendable override fun call(): AbstractCashFlow.Result { @@ -46,12 +48,15 @@ class CashPaymentFromKnownStatesFlow( progressTracker.currentStep = AbstractCashFlow.Companion.GENERATING_TX val builder = TransactionBuilder(notary = null) + // TODO: this needs to use a bulk call val cashStateAndRef = inputs.map { serviceHub.toStateAndRef(it) } val amounts = ArrayList(Collections.nCopies(numberOfStates, PartyAndAmount(anonymousRecipient, amountPerState))) - val changeIdentity = serviceHub.keyManagementService.freshKeyAndCert(ourIdentityAndCert, false) - + val changeParty = serviceHub.keyManagementService.freshKeyAndCert(ourIdentityAndCert, false).party.anonymise() + if (numberOfChangeStates > 1) { + amounts += Collections.nCopies(numberOfChangeStates - 1, PartyAndAmount(changeParty, amountPerState)) + } val (spendTx, keysForSigning) = OnLedgerAsset.generateSpend(builder, amounts, cashStateAndRef, - changeIdentity.party.anonymise(), + changeParty, { state, quantity, owner -> deriveState(state, quantity, owner) }, { Cash().generateMoveCommand() }) diff --git a/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Samplers.kt b/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Samplers.kt index 324f067c47..b067c5f567 100644 --- a/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Samplers.kt +++ b/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Samplers.kt @@ -237,18 +237,22 @@ class CashPaySampler : AbstractSampler() { companion object JMeterProperties { val otherParty = Argument("otherPartyName", "", "", "The X500 name of the payee.") val numberOfStatesPerTx = Argument("numberOfStatesPerTx", "1", "", "The number of payment states per transaction.") + val numberOfChangeStatesPerTx = Argument("numberOfChangeStatesPerTx", "1", "", "The number of change states per transaction.") val anonymousIdentities = Argument("anonymousIdentities", "false", "", "True to use anonymous identities and false (or anything else) to use well known identities.") } lateinit var counterParty: Party var numberOfStatesPerTxCount: Int = 1 + var numberOfChangeStatesPerTxCount: Int = 1 var useAnonymousIdentities: Boolean = true - private var inputIndex = 0 + private var inputStartIndex = 0 + private var inputEndIndex = 0 override fun setupTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) { getNotaryIdentity(rpcProxy, testContext) counterParty = getIdentity(rpcProxy, testContext, otherParty) numberOfStatesPerTxCount = testContext.getParameter(numberOfStatesPerTx.name, numberOfStatesPerTx.value).toInt() + numberOfChangeStatesPerTxCount = testContext.getParameter(numberOfChangeStatesPerTx.name, numberOfChangeStatesPerTx.value).toInt() useAnonymousIdentities = testContext.getParameter(anonymousIdentities.name, anonymousIdentities.value).toBoolean() // Now issue lots of USD @@ -259,16 +263,18 @@ class CashPaySampler : AbstractSampler() { } override fun createFlowInvoke(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext): FlowInvoke<*> { - // Change is always Nth output - val input = StateRef((flowResult as AbstractCashFlow.Result).id, inputIndex) + // Change is always the latter outputs + val txId = (flowResult as AbstractCashFlow.Result).id + val inputs = (inputStartIndex..inputEndIndex).map { StateRef(txId, it) }.toSet() val amount = 1.DOLLARS - inputIndex = numberOfStatesPerTxCount - return FlowInvoke(CashPaymentFromKnownStatesFlow::class.java, arrayOf(setOf(input), numberOfStatesPerTxCount, amount, counterParty, useAnonymousIdentities)) + inputStartIndex = numberOfStatesPerTxCount + inputEndIndex = inputStartIndex + (numberOfChangeStatesPerTxCount - 1) + return FlowInvoke(CashPaymentFromKnownStatesFlow::class.java, arrayOf(inputs, numberOfStatesPerTxCount, numberOfChangeStatesPerTxCount, amount, counterParty, useAnonymousIdentities)) } override fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) { } override val additionalArgs: Set - get() = setOf(notary, otherParty, numberOfStatesPerTx, anonymousIdentities) + get() = setOf(notary, otherParty, numberOfStatesPerTx, numberOfChangeStatesPerTx, anonymousIdentities) } \ No newline at end of file diff --git a/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Ssh.kt b/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Ssh.kt index 18c46b246c..29a59159ba 100644 --- a/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Ssh.kt +++ b/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Ssh.kt @@ -71,15 +71,15 @@ class Ssh { // For tunnelling the RMI registry on the remote agent // ssh ${remoteHostAndPort.host} -L 0.0.0.0:${localHostAndPort.port}:localhost:$serverRmiPort -N - createOutboundTunnel(session, NetworkHostAndPort("0.0.0.0", localHostAndPort.port), NetworkHostAndPort("localhost", serverRmiPort)) + createOutboundTunnel(session, NetworkHostAndPort("localhost", localHostAndPort.port), NetworkHostAndPort("localhost", serverRmiPort)) // For tunnelling the actual connection to the remote agent // ssh ${remoteHostAndPort.host} -L 0.0.0.0:$serverRmiLocalPort:localhost:$serverRmiLocalPort -N - createOutboundTunnel(session, NetworkHostAndPort("0.0.0.0", serverRmiLocalPort), NetworkHostAndPort("localhost", serverRmiLocalPort)) + createOutboundTunnel(session, NetworkHostAndPort("localhost", serverRmiLocalPort), NetworkHostAndPort("localhost", serverRmiLocalPort)) // For returning results to the client // ssh ${remoteHostAndPort.host} -R 0.0.0.0:clientRmiLocalPort:localhost:clientRmiLocalPort -N - createInboundTunnel(session, NetworkHostAndPort("0.0.0.0", clientRmiLocalPort), NetworkHostAndPort("localhost", clientRmiLocalPort)) + createInboundTunnel(session, NetworkHostAndPort("localhost", clientRmiLocalPort), NetworkHostAndPort("localhost", clientRmiLocalPort)) } if (wait) { diff --git a/tools/jmeter/src/main/resources/Testplans/NightlyBenchmark.jmx b/tools/jmeter/src/main/resources/Testplans/NightlyBenchmark.jmx index eccde589c3..26f4c4f315 100644 --- a/tools/jmeter/src/main/resources/Testplans/NightlyBenchmark.jmx +++ b/tools/jmeter/src/main/resources/Testplans/NightlyBenchmark.jmx @@ -659,6 +659,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -728,6 +733,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -797,6 +807,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -866,6 +881,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -935,6 +955,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -1004,6 +1029,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -1073,6 +1103,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -1142,6 +1177,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -1211,6 +1251,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -1280,6 +1325,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -1349,6 +1399,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -1418,6 +1473,11 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false @@ -1487,6 +1547,531 @@ 1 = + + numberOfChangeStatesPerTx + 1 + = + + + anonymousIdentities + false + = + + + + com.r3.corda.jmeter.CashPaySampler + + + + + continue + + false + -1 + + 40 + + 1509455820000 + 1509455820000 + true + ${duration} + ${pause} + + + + + + + label + ${__samplerName}-${__groovy(ctx.getThreadGroup().getNumThreads() * vars.get("remoteAgentCount").toInteger())} + = + + + host + ${host} + = + + + port + ${port} + = + + + username + ${username} + = + + + password + ${password} + = + + + notaryName + ${notaryName} + = + + + otherPartyName + ${otherPartyName} + = + + + numberOfStatesPerTx + 5 + = + + + numberOfChangeStatesPerTx + 1 + = + + + anonymousIdentities + false + = + + + + com.r3.corda.jmeter.CashPaySampler + + + + + continue + + false + -1 + + 40 + + 1509455820000 + 1509455820000 + true + ${duration} + ${pause} + + + + + + + label + ${__samplerName}-${__groovy(ctx.getThreadGroup().getNumThreads() * vars.get("remoteAgentCount").toInteger())} + = + + + host + ${host} + = + + + port + ${port} + = + + + username + ${username} + = + + + password + ${password} + = + + + notaryName + ${notaryName} + = + + + otherPartyName + ${otherPartyName} + = + + + numberOfStatesPerTx + 20 + = + + + numberOfChangeStatesPerTx + 1 + = + + + anonymousIdentities + false + = + + + + com.r3.corda.jmeter.CashPaySampler + + + + + continue + + false + -1 + + 40 + + 1509455820000 + 1509455820000 + true + ${duration} + ${pause} + + + + + + + label + ${__samplerName}-${__groovy(ctx.getThreadGroup().getNumThreads() * vars.get("remoteAgentCount").toInteger())} + = + + + host + ${host} + = + + + port + ${port} + = + + + username + ${username} + = + + + password + ${password} + = + + + notaryName + ${notaryName} + = + + + otherPartyName + ${otherPartyName} + = + + + numberOfStatesPerTx + 40 + = + + + numberOfChangeStatesPerTx + 1 + = + + + anonymousIdentities + false + = + + + + com.r3.corda.jmeter.CashPaySampler + + + + + continue + + false + -1 + + 40 + + 1509455820000 + 1509455820000 + true + ${duration} + ${pause} + + + + + + + label + ${__samplerName}-${__groovy(ctx.getThreadGroup().getNumThreads() * vars.get("remoteAgentCount").toInteger())} + = + + + host + ${host} + = + + + port + ${port} + = + + + username + ${username} + = + + + password + ${password} + = + + + notaryName + ${notaryName} + = + + + otherPartyName + ${otherPartyName} + = + + + numberOfStatesPerTx + 80 + = + + + numberOfChangeStatesPerTx + 1 + = + + + anonymousIdentities + false + = + + + + com.r3.corda.jmeter.CashPaySampler + + + + + continue + + false + -1 + + 40 + + 1509455820000 + 1509455820000 + true + ${duration} + ${pause} + + + + + + + label + ${__samplerName}-${__groovy(ctx.getThreadGroup().getNumThreads() * vars.get("remoteAgentCount").toInteger())} + = + + + host + ${host} + = + + + port + ${port} + = + + + username + ${username} + = + + + password + ${password} + = + + + notaryName + ${notaryName} + = + + + otherPartyName + ${otherPartyName} + = + + + numberOfStatesPerTx + 160 + = + + + numberOfChangeStatesPerTx + 1 + = + + + anonymousIdentities + false + = + + + + com.r3.corda.jmeter.CashPaySampler + + + + + continue + + false + -1 + + 40 + + 1509455820000 + 1509455820000 + true + ${duration} + ${pause} + + + + + + + + label + ${__samplerName}-${__groovy(ctx.getThreadGroup().getNumThreads() * vars.get("remoteAgentCount").toInteger())} + = + + + host + ${host} + = + + + port + ${port} + = + + + username + ${username} + = + + + password + ${password} + = + + + notaryName + ${notaryName} + = + + + otherPartyName + ${otherPartyName} + = + + + numberOfStatesPerTx + 320 + = + + + numberOfChangeStatesPerTx + 1 + = + + + anonymousIdentities + false + = + + + + com.r3.corda.jmeter.CashPaySampler + + + + + continue + + false + -1 + + 40 + + 1509455820000 + 1509455820000 + true + ${duration} + ${pause} + + + + + + + + label + ${__samplerName}-${__groovy(ctx.getThreadGroup().getNumThreads() * vars.get("remoteAgentCount").toInteger())} + = + + + host + ${host} + = + + + port + ${port} + = + + + username + ${username} + = + + + password + ${password} + = + + + notaryName + ${notaryName} + = + + + otherPartyName + ${otherPartyName} + = + + + numberOfStatesPerTx + 640 + = + + + numberOfChangeStatesPerTx + 1 + = + anonymousIdentities false