mirror of
https://github.com/corda/corda.git
synced 2024-12-26 16:11:12 +00:00
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.
This commit is contained in:
parent
c87f37af3e
commit
bc630a0381
@ -55,3 +55,12 @@ remote user name is different from the current user name, `-XsshUser <remote use
|
||||
can be used to set this, or in the gradle call:
|
||||
|
||||
`./gradlew tools:jmeter:runSsh -PjmeterHosts="['hostname1', 'hostname2']" -PsshUser="'username'"`
|
||||
|
||||
To run up 3 nodes (2 nodes, 1 non-validating notary) locally for testing anything in the `perftestcordapp` (e.g. samplers,
|
||||
custom flows), you can use gradle to run:
|
||||
|
||||
`./gradlew tools:jmeter:runDriver`
|
||||
|
||||
This uses the driver test infrastructure to fire up the nodes. See `StartLocalPerfCorDapp` for X500 names of nodes,
|
||||
RPC user logins etc. The RPC port of Bank A is typically 10004, but they are all reporting in the console output. A
|
||||
sample JMeter config for this setup has been included as `LocalIssueAndPay Request.jmx` under resources.
|
||||
|
@ -39,6 +39,9 @@ dependencies {
|
||||
runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_config', version: "$jmVersion"
|
||||
runtime group: 'org.apache.jmeter', name: 'ApacheJMeter', version: "$jmVersion"
|
||||
runtime group: 'org.apache.jmeter', name: 'jorphan', version: "$jmVersion"
|
||||
|
||||
testCompile project(':test-utils')
|
||||
testCompile project(':node-driver')
|
||||
}
|
||||
|
||||
// Run JMeter as server process/agent on current host.
|
||||
@ -72,6 +75,14 @@ task(runSsh, dependsOn: 'classes', type: JavaExec) {
|
||||
standardInput = System.in
|
||||
}
|
||||
|
||||
// Use the driver to launch 2 local nodes and the notary running the perftestcordapp.
|
||||
// To use for development of samplers and flows locally.
|
||||
task(runDriver, dependsOn: 'classes', type: JavaExec) {
|
||||
classpath = sourceSets.test.runtimeClasspath
|
||||
main = 'com.r3.corda.jmeter.StartLocalPerfCorDapp'
|
||||
standardInput = System.in
|
||||
}
|
||||
|
||||
// Run JMeter (by default the UI).
|
||||
// Extra args can be passed by setting jmeterArgs (e.g. -n to run in non-UI mode).
|
||||
// e.g. ./gradlew tools:jmeter:run -PjmeterArgs="['-n']"
|
||||
|
@ -3,6 +3,7 @@ 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.CashIssueAndPaymentNoSelection
|
||||
import com.r3.corda.enterprise.perftestcordapp.flows.CashIssueFlow
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.identity.Party
|
||||
@ -62,24 +63,31 @@ class CashIssueSampler : AbstractSampler() {
|
||||
class CashIssueAndPaySampler : AbstractSampler() {
|
||||
companion object JMeterProperties {
|
||||
val otherParty = Argument("otherPartyName", "", "<meta>", "The X500 name of the payee.")
|
||||
val coinSelection = Argument("useCoinSelection", "true", "<meta>", "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>(CashIssueAndPaymentFlow::class.java, arrayOf(amount, OpaqueBytes.of(1), counterParty, true, notaryIdentity))
|
||||
if (useCoinSelection) {
|
||||
return FlowInvoke<CashIssueAndPaymentFlow>(CashIssueAndPaymentFlow::class.java, arrayOf(amount, OpaqueBytes.of(1), counterParty, true, notaryIdentity))
|
||||
} else {
|
||||
return FlowInvoke<CashIssueAndPaymentNoSelection>(CashIssueAndPaymentNoSelection::class.java, arrayOf(amount, OpaqueBytes.of(1), counterParty, true, notaryIdentity))
|
||||
}
|
||||
}
|
||||
|
||||
override fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) {
|
||||
}
|
||||
|
||||
override val additionalArgs: Set<Argument>
|
||||
get() = setOf(notary, otherParty)
|
||||
get() = setOf(notary, otherParty, coinSelection)
|
||||
}
|
187
tools/jmeter/src/main/resources/LocalIssueAndPay Request.jmx
Normal file
187
tools/jmeter/src/main/resources/LocalIssueAndPay Request.jmx
Normal file
@ -0,0 +1,187 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jmeterTestPlan version="1.2" properties="3.2" jmeter="3.3 r1808647">
|
||||
<hashTree>
|
||||
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
|
||||
<stringProp name="TestPlan.comments"></stringProp>
|
||||
<boolProp name="TestPlan.functional_mode">false</boolProp>
|
||||
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
|
||||
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
|
||||
<collectionProp name="Arguments.arguments"/>
|
||||
</elementProp>
|
||||
<stringProp name="TestPlan.user_define_classpath"></stringProp>
|
||||
</TestPlan>
|
||||
<hashTree>
|
||||
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
|
||||
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
|
||||
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
|
||||
<boolProp name="LoopController.continue_forever">false</boolProp>
|
||||
<stringProp name="LoopController.loops">100</stringProp>
|
||||
</elementProp>
|
||||
<stringProp name="ThreadGroup.num_threads">3</stringProp>
|
||||
<stringProp name="ThreadGroup.ramp_time"></stringProp>
|
||||
<longProp name="ThreadGroup.start_time">1509455820000</longProp>
|
||||
<longProp name="ThreadGroup.end_time">1509455820000</longProp>
|
||||
<boolProp name="ThreadGroup.scheduler">false</boolProp>
|
||||
<stringProp name="ThreadGroup.duration"></stringProp>
|
||||
<stringProp name="ThreadGroup.delay"></stringProp>
|
||||
</ThreadGroup>
|
||||
<hashTree>
|
||||
<JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Cash Issue Request" enabled="true">
|
||||
<elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
|
||||
<collectionProp name="Arguments.arguments">
|
||||
<elementProp name="host" elementType="Argument">
|
||||
<stringProp name="Argument.name">host</stringProp>
|
||||
<stringProp name="Argument.value">localhost</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="port" elementType="Argument">
|
||||
<stringProp name="Argument.name">port</stringProp>
|
||||
<stringProp name="Argument.value">10004</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="username" elementType="Argument">
|
||||
<stringProp name="Argument.name">username</stringProp>
|
||||
<stringProp name="Argument.value">perf</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="password" elementType="Argument">
|
||||
<stringProp name="Argument.name">password</stringProp>
|
||||
<stringProp name="Argument.value">perf</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="notaryName" elementType="Argument">
|
||||
<stringProp name="Argument.name">notaryName</stringProp>
|
||||
<stringProp name="Argument.value">O=Notary Service,L=Zurich,C=CH,CN=corda.notary.simple</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="otherPartyName" elementType="Argument">
|
||||
<stringProp name="Argument.name">otherPartyName</stringProp>
|
||||
<stringProp name="Argument.value">O=Bank B,L=New York,C=US</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
<elementProp name="useCoinSelection" elementType="Argument">
|
||||
<stringProp name="Argument.name">useCoinSelection</stringProp>
|
||||
<stringProp name="Argument.value">true</stringProp>
|
||||
<stringProp name="Argument.metadata">=</stringProp>
|
||||
</elementProp>
|
||||
</collectionProp>
|
||||
</elementProp>
|
||||
<stringProp name="classname">com.r3.corda.jmeter.CashIssueAndPaySampler</stringProp>
|
||||
</JavaSampler>
|
||||
<hashTree/>
|
||||
</hashTree>
|
||||
<ResultCollector guiclass="StatGraphVisualizer" testclass="ResultCollector" testname="Aggregate Graph" enabled="true">
|
||||
<boolProp name="ResultCollector.error_logging">false</boolProp>
|
||||
<objProp>
|
||||
<name>saveConfig</name>
|
||||
<value class="SampleSaveConfiguration">
|
||||
<time>true</time>
|
||||
<latency>true</latency>
|
||||
<timestamp>true</timestamp>
|
||||
<success>true</success>
|
||||
<label>true</label>
|
||||
<code>true</code>
|
||||
<message>true</message>
|
||||
<threadName>true</threadName>
|
||||
<dataType>true</dataType>
|
||||
<encoding>false</encoding>
|
||||
<assertions>true</assertions>
|
||||
<subresults>true</subresults>
|
||||
<responseData>false</responseData>
|
||||
<samplerData>false</samplerData>
|
||||
<xml>false</xml>
|
||||
<fieldNames>true</fieldNames>
|
||||
<responseHeaders>false</responseHeaders>
|
||||
<requestHeaders>false</requestHeaders>
|
||||
<responseDataOnError>false</responseDataOnError>
|
||||
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
|
||||
<assertionsResultsToSave>0</assertionsResultsToSave>
|
||||
<bytes>true</bytes>
|
||||
<sentBytes>true</sentBytes>
|
||||
<threadCounts>true</threadCounts>
|
||||
<idleTime>true</idleTime>
|
||||
<connectTime>true</connectTime>
|
||||
</value>
|
||||
</objProp>
|
||||
<stringProp name="filename"></stringProp>
|
||||
</ResultCollector>
|
||||
<hashTree/>
|
||||
<ResultCollector guiclass="GraphVisualizer" testclass="ResultCollector" testname="Graph Results" enabled="true">
|
||||
<boolProp name="ResultCollector.error_logging">false</boolProp>
|
||||
<objProp>
|
||||
<name>saveConfig</name>
|
||||
<value class="SampleSaveConfiguration">
|
||||
<time>true</time>
|
||||
<latency>true</latency>
|
||||
<timestamp>true</timestamp>
|
||||
<success>true</success>
|
||||
<label>true</label>
|
||||
<code>true</code>
|
||||
<message>true</message>
|
||||
<threadName>true</threadName>
|
||||
<dataType>true</dataType>
|
||||
<encoding>false</encoding>
|
||||
<assertions>true</assertions>
|
||||
<subresults>true</subresults>
|
||||
<responseData>false</responseData>
|
||||
<samplerData>false</samplerData>
|
||||
<xml>false</xml>
|
||||
<fieldNames>true</fieldNames>
|
||||
<responseHeaders>false</responseHeaders>
|
||||
<requestHeaders>false</requestHeaders>
|
||||
<responseDataOnError>false</responseDataOnError>
|
||||
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
|
||||
<assertionsResultsToSave>0</assertionsResultsToSave>
|
||||
<bytes>true</bytes>
|
||||
<sentBytes>true</sentBytes>
|
||||
<threadCounts>true</threadCounts>
|
||||
<idleTime>true</idleTime>
|
||||
<connectTime>true</connectTime>
|
||||
</value>
|
||||
</objProp>
|
||||
<stringProp name="filename"></stringProp>
|
||||
</ResultCollector>
|
||||
<hashTree/>
|
||||
<ResultCollector guiclass="TableVisualizer" testclass="ResultCollector" testname="View Results in Table" enabled="true">
|
||||
<boolProp name="ResultCollector.error_logging">false</boolProp>
|
||||
<objProp>
|
||||
<name>saveConfig</name>
|
||||
<value class="SampleSaveConfiguration">
|
||||
<time>true</time>
|
||||
<latency>true</latency>
|
||||
<timestamp>true</timestamp>
|
||||
<success>true</success>
|
||||
<label>true</label>
|
||||
<code>true</code>
|
||||
<message>true</message>
|
||||
<threadName>true</threadName>
|
||||
<dataType>true</dataType>
|
||||
<encoding>false</encoding>
|
||||
<assertions>true</assertions>
|
||||
<subresults>true</subresults>
|
||||
<responseData>false</responseData>
|
||||
<samplerData>false</samplerData>
|
||||
<xml>false</xml>
|
||||
<fieldNames>true</fieldNames>
|
||||
<responseHeaders>false</responseHeaders>
|
||||
<requestHeaders>false</requestHeaders>
|
||||
<responseDataOnError>false</responseDataOnError>
|
||||
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
|
||||
<assertionsResultsToSave>0</assertionsResultsToSave>
|
||||
<bytes>true</bytes>
|
||||
<sentBytes>true</sentBytes>
|
||||
<threadCounts>true</threadCounts>
|
||||
<idleTime>true</idleTime>
|
||||
<connectTime>true</connectTime>
|
||||
</value>
|
||||
</objProp>
|
||||
<stringProp name="filename"></stringProp>
|
||||
</ResultCollector>
|
||||
<hashTree/>
|
||||
</hashTree>
|
||||
<WorkBench guiclass="WorkBenchGui" testclass="WorkBench" testname="WorkBench" enabled="true">
|
||||
<boolProp name="WorkBench.save">true</boolProp>
|
||||
</WorkBench>
|
||||
<hashTree/>
|
||||
</hashTree>
|
||||
</jmeterTestPlan>
|
@ -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<String>) {
|
||||
// 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() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user