diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/Currencies.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/Currencies.kt index 29c8d1a5ed..ceaf4e87ab 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/Currencies.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/Currencies.kt @@ -17,15 +17,26 @@ import java.util.* fun AMOUNT(amount: Int, token: T): Amount = Amount.fromDecimal(BigDecimal.valueOf(amount.toLong()), token) fun AMOUNT(amount: Double, token: T): Amount = Amount.fromDecimal(BigDecimal.valueOf(amount), token) +fun AMOUNT(amount: Long, token: T): Amount = Amount.fromDecimal(BigDecimal.valueOf(amount), token) fun DOLLARS(amount: Int): Amount = AMOUNT(amount, USD) fun DOLLARS(amount: Double): Amount = AMOUNT(amount, USD) +fun DOLLARS(amount: Long): Amount = AMOUNT(amount, USD) fun POUNDS(amount: Int): Amount = AMOUNT(amount, GBP) +fun POUNDS(amount: Double): Amount = AMOUNT(amount, GBP) +fun POUNDS(amount: Long): Amount = AMOUNT(amount, GBP) fun SWISS_FRANCS(amount: Int): Amount = AMOUNT(amount, CHF) +fun SWISS_FRANCS(amount: Double): Amount = AMOUNT(amount, CHF) +fun SWISS_FRANCS(amount: Long): Amount = AMOUNT(amount, CHF) val Int.DOLLARS: Amount get() = DOLLARS(this) val Double.DOLLARS: Amount get() = DOLLARS(this) +val Long.DOLLARS: Amount get() = DOLLARS(this) val Int.POUNDS: Amount get() = POUNDS(this) +val Double.POUNDS: Amount get() = POUNDS(this) +val Long.POUNDS: Amount get() = POUNDS(this) val Int.SWISS_FRANCS: Amount get() = SWISS_FRANCS(this) +val Double.SWISS_FRANCS: Amount get() = SWISS_FRANCS(this) +val Long.SWISS_FRANCS: Amount get() = SWISS_FRANCS(this) infix fun Currency.`issued by`(deposit: PartyAndReference) = issuedBy(deposit) infix fun Amount.`issued by`(deposit: PartyAndReference) = issuedBy(deposit) diff --git a/tools/jmeter/build.gradle b/tools/jmeter/build.gradle index aa041346fc..f6dbb86b94 100644 --- a/tools/jmeter/build.gradle +++ b/tools/jmeter/build.gradle @@ -6,7 +6,7 @@ mainClassName = 'com.r3.corda.jmeter.Launcher' dependencies { compile project(':client:rpc') - compile project(':finance') + compile project(':perftestcordapp') // https://mvnrepository.com/artifact/com.jcraft/jsch compile group: 'com.jcraft', name: 'jsch', version: '0.1.54' 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 e23cc399cc..3987837cab 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 @@ -1,11 +1,13 @@ package com.r3.corda.jmeter +import com.r3.corda.enterprise.perftestcordapp.DOLLARS +import com.r3.corda.enterprise.perftestcordapp.POUNDS +import com.r3.corda.enterprise.perftestcordapp.flows.CashIssueAndPaymentFlow +import com.r3.corda.enterprise.perftestcordapp.flows.CashIssueFlow import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.messaging.CordaRPCOps import net.corda.core.utilities.OpaqueBytes -import net.corda.finance.DOLLARS -import net.corda.finance.flows.CashIssueFlow import org.apache.jmeter.config.Argument import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext @@ -19,12 +21,16 @@ abstract class AbstractSampler : BaseFlowSampler() { val notary = Argument("notaryName", "", "", "The X500 name of the notary.") } - protected fun getIdentities(rpc: CordaRPCOps, testContext: JavaSamplerContext) { - if (!testContext.containsParameter(notary.name)) { - throw IllegalStateException("You must specify the '${notary.name}' property.") + protected fun getIdentity( rpc: CordaRPCOps, testContext: JavaSamplerContext, arg: Argument):Party{ + if (!testContext.containsParameter(arg.name)) { + throw IllegalStateException("You must specify the '${arg.name}' property.") } - val notaryName = CordaX500Name.parse(testContext.getParameter(notary.name)) - notaryIdentity = rpc.wellKnownPartyFromX500Name(notaryName) ?: throw IllegalStateException("Don't know $notaryName") + val argName = CordaX500Name.parse(testContext.getParameter(arg.name)) + return rpc.wellKnownPartyFromX500Name(argName) ?: throw IllegalStateException("Don't know $argName") + } + + protected fun getNotaryIdentity(rpc: CordaRPCOps, testContext: JavaSamplerContext) { + notaryIdentity = getIdentity(rpc,testContext, notary) } } @@ -37,7 +43,7 @@ class CashIssueSampler : AbstractSampler() { override val additionalArgs: Set = setOf(notary) override fun setupTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) { - getIdentities(rpcProxy, testContext) + getNotaryIdentity(rpcProxy, testContext) } override fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) { @@ -47,5 +53,33 @@ class CashIssueSampler : AbstractSampler() { val amount = 1_100_000_000_000.DOLLARS return FlowInvoke(CashIssueFlow::class.java, arrayOf(amount, OpaqueBytes.of(1), notaryIdentity)) } +} +/** + * A sampler that issues cash and pays it to a specified party, thus invoking the notary and the payee + * via P2P + */ +class CashIssueAndPaySampler : AbstractSampler() { + companion object JMeterProperties { + val otherParty = Argument("otherPartyName", "", "", "The X500 name of the payee.") + } + + lateinit var counterParty: Party + + override fun setupTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) { + getNotaryIdentity(rpcProxy,testContext) + counterParty = getIdentity(rpcProxy, testContext, otherParty) + } + + + 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)) + } + + override fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) { + } + + override val additionalArgs: Set + get() = setOf(notary, otherParty) } \ No newline at end of file diff --git a/tools/jmeter/src/main/resources/Example Flow Request.jmx b/tools/jmeter/src/main/resources/Example Flow Request.jmx index 6a2d25cfcf..7a6e027265 100644 --- a/tools/jmeter/src/main/resources/Example Flow Request.jmx +++ b/tools/jmeter/src/main/resources/Example Flow Request.jmx @@ -51,7 +51,7 @@ notaryName - O=Perf-10.155.0.4, OU=Corda, L=London, C=GB + O=Perf-10.155.0.8,OU=Corda,L=London,C=GB,CN=corda.node.simple = diff --git a/tools/jmeter/src/main/resources/IssueAndPay Request.jmx b/tools/jmeter/src/main/resources/IssueAndPay Request.jmx new file mode 100644 index 0000000000..187cb219ce --- /dev/null +++ b/tools/jmeter/src/main/resources/IssueAndPay Request.jmx @@ -0,0 +1,182 @@ + + + + + + false + false + + + + + + + + continue + + false + 1000 + + 3 + + 1509455820000 + 1509455820000 + false + + + + + + + + + host + localhost + = + + + port + 10003 + = + + + username + corda + = + + + password + corda_is_awesome + = + + + notaryName + O=Perf-10.155.0.8,OU=Corda,L=London,C=GB,CN=corda.node.simple + = + + + otherPartyName + O=Perf-10.155.0.7, OU=Corda, L=London, C=GB + = + + + + 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 + + + +