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 3af2e1d0f6..9dbea5dea4 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,6 +1,8 @@
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
@@ -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,34 @@ 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), notaryIdentity, counterParty))
+ }
+
+ override fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) {
+ }
+
+ override val additionalArgs: Set
+ get() = setOf(notary, otherParty)
}
\ No newline at end of file