Clean up, renaming etc

This commit is contained in:
rick.parker 2017-11-14 13:48:35 +00:00
parent c543129408
commit b0a8c3c305
8 changed files with 115 additions and 115 deletions

View File

@ -2,7 +2,7 @@ apply plugin: 'kotlin'
apply plugin: 'us.kirchmeier.capsule'
apply plugin: 'application'
mainClassName = 'net.corda.jmeter.Launcher'
mainClassName = 'com.r3.corda.jmeter.Launcher'
dependencies {
compile project(':client:rpc')
@ -33,7 +33,7 @@ dependencies {
task(runServer, dependsOn: 'classes', type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'net.corda.jmeter.Launcher'
main = 'com.r3.corda.jmeter.Launcher'
systemProperty "search_paths", project(':tools:jmeter').configurations.runtime.files.join(";")
systemProperty "java.rmi.server.hostname", "0.0.0.0"
systemProperty "jmeter.home", sourceSets.main.resources.getSrcDirs().first().getPath()
@ -45,7 +45,7 @@ task(runServer, dependsOn: 'classes', type: JavaExec) {
task(runSsh, dependsOn: 'classes', type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'net.corda.jmeter.Ssh'
main = 'com.r3.corda.jmeter.Ssh'
if ( project.hasProperty("jmeterHosts") ) {
args Eval.me(jmeterHosts)
}
@ -79,7 +79,7 @@ jar {
// Run with: java -jar corda-jmeter-<version>.jar
// No additional args required but will be passed if specified.
task buildJMeterJAR(type: FatCapsule, dependsOn: 'jar') {
applicationClass 'net.corda.jmeter.Launcher'
applicationClass 'com.r3.corda.jmeter.Launcher'
archiveName "jmeter-corda-${corda_release_version}.jar"
applicationSource = files(
project(':tools:jmeter').jar

View File

@ -1,4 +1,4 @@
package net.corda.jmeter
package com.r3.corda.jmeter
import net.corda.client.rpc.CordaRPCClient
import net.corda.client.rpc.CordaRPCConnection
@ -12,25 +12,30 @@ import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext
import org.apache.jmeter.samplers.SampleResult
class CordaRPCSampler() : AbstractJavaSamplerClient() {
abstract class FlowSampler() : AbstractJavaSamplerClient() {
companion object {
val host = Argument("host", "localhost", "<meta>", "The remote network address (hostname or IP address) to connect to for RPC.")
val port = Argument("port", "10000", "<meta>", "The remote port to connect to for RPC.")
val username = Argument("username", "corda", "<meta>", "The RPC user to connect to connect as.")
val password = Argument("password", "corda_is_awesome", "<meta>", "The password for the RPC user.")
val className = Argument("pluginClassName", "", "<meta>", "The class name of the implementation of ${CordaRPCSampler.Plugin::class.java}.")
val allArgs = setOf(host, port, username, password, className)
val allArgs = setOf(host, port, username, password)
}
var rpcClient: CordaRPCClient? = null
var rpcConnection: CordaRPCConnection? = null
var rpcProxy: CordaRPCOps? = null
var plugin: Plugin? = null
override fun getDefaultParameters(): Arguments {
// Add copies of all args, since they seem to be mutable.
return Arguments().apply { for(arg in allArgs) { addArgument(arg.clone() as Argument) } }
return Arguments().apply {
for (arg in allArgs) {
addArgument(arg.clone() as Argument)
}
for (arg in additionalArgs) {
addArgument(arg.clone() as Argument)
}
}
}
override fun setupTest(context: JavaSamplerContext) {
@ -38,12 +43,11 @@ class CordaRPCSampler() : AbstractJavaSamplerClient() {
rpcClient = CordaRPCClient(NetworkHostAndPort(context.getParameter(host.name), context.getIntParameter(port.name)))
rpcConnection = rpcClient!!.start(context.getParameter(username.name), context.getParameter(password.name))
rpcProxy = rpcConnection!!.proxy
plugin = Class.forName(context.getParameter(className.name)).newInstance() as Plugin
plugin!!.setupTest(rpcProxy!!, context)
setupTest(rpcProxy!!, context)
}
override fun runTest(context: JavaSamplerContext): SampleResult {
val flowInvoke = plugin!!.createFlowInvoke(rpcProxy!!, context)
val flowInvoke = createFlowInvoke(rpcProxy!!, context)
val result = SampleResult()
result.sampleStart()
val handle = rpcProxy!!.startFlowDynamic(flowInvoke!!.flowLogicClass, *(flowInvoke!!.args))
@ -64,8 +68,7 @@ class CordaRPCSampler() : AbstractJavaSamplerClient() {
}
override fun teardownTest(context: JavaSamplerContext) {
plugin!!.teardownTest(rpcProxy!!, context)
plugin = null
teardownTest(rpcProxy!!, context)
rpcProxy = null
rpcConnection!!.close()
rpcConnection = null
@ -73,11 +76,10 @@ class CordaRPCSampler() : AbstractJavaSamplerClient() {
super.teardownTest(context)
}
interface Plugin {
fun setupTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext)
fun createFlowInvoke(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext): FlowInvoke<*>
fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext)
}
abstract val additionalArgs: Set<Argument>
abstract fun setupTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext)
abstract fun createFlowInvoke(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext): FlowInvoke<*>
abstract fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext)
class FlowInvoke<T : FlowLogic<*>>(val flowLogicClass: Class<out T>, val args: Array<Any?>)
}

View File

@ -1,4 +1,4 @@
package net.corda.jmeter
package com.r3.corda.jmeter
import net.corda.core.internal.div
import org.apache.jmeter.JMeter

View File

@ -0,0 +1,44 @@
package com.r3.corda.jmeter
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
abstract class AbstractSampler : FlowSampler() {
lateinit var notaryIdentity: Party
companion object JMeterProperties {
val notary = Argument("notaryName", "", "<meta>", "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.")
}
val notaryName = CordaX500Name.parse(testContext.getParameter(notary.name))
notaryIdentity = rpc.wellKnownPartyFromX500Name(notaryName) ?: throw IllegalStateException("Don't know $notaryName")
}
}
class CashIssueSampler : AbstractSampler() {
override val additionalArgs: Set<Argument> = setOf(notary)
override fun setupTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) {
getIdentities(rpcProxy, testContext)
}
override fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) {
}
override fun createFlowInvoke(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext): FlowInvoke<CashIssueFlow> {
val amount = 1_100_000_000_000.DOLLARS
return FlowInvoke<CashIssueFlow>(CashIssueFlow::class.java, arrayOf(amount, OpaqueBytes.of(1), notaryIdentity))
}
}

View File

@ -1,4 +1,4 @@
package net.corda.jmeter
package com.r3.corda.jmeter
import com.jcraft.jsch.JSch
import com.jcraft.jsch.Session

View File

@ -1,46 +0,0 @@
package net.corda.jmeter
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 net.corda.jmeter.CordaRPCSampler.FlowInvoke
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext
abstract class AsbtractTraderDemoPlugin : CordaRPCSampler.Plugin {
//lateinit var buyer: Party
//lateinit var seller: Party
lateinit var notary: Party
//val bankA = CordaX500Name(organisation = "Bank A", locality = "London", country = "GB")
//val bankB = CordaX500Name(organisation = "Bank B", locality = "New York", country = "US")
val node1 = CordaX500Name(commonName = null, state = null, organisation = "Perf-10.155.0.4", organisationUnit = "Corda", locality = "London", country = "GB")
protected fun getIdentities(rpc: CordaRPCOps) {
//buyer = rpc.wellKnownPartyFromX500Name(bankA) ?: throw IllegalStateException("Don't know $bankA")
//seller = rpc.wellKnownPartyFromX500Name(bankB) ?: throw IllegalStateException("Don't know $bankB")
//notary = rpc.notaryIdentities().first()
notary = rpc.wellKnownPartyFromX500Name(node1) ?: throw IllegalStateException("Don't know $node1")
}
}
class CashIssuerPlugin : AsbtractTraderDemoPlugin() {
override fun setupTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) {
getIdentities(rpcProxy)
}
override fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) {
}
override fun createFlowInvoke(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext): FlowInvoke<CashIssueFlow> {
val amount = 1_100_000_000_000.DOLLARS
//val amounts = calculateRandomlySizedAmounts(amount, 3, 10, Random())
//rpc.startFlow(net.corda.finance.flows::CashIssueFlow, amount, OpaqueBytes.of(1), notary).returnValue.getOrThrow()
return FlowInvoke<CashIssueFlow>(CashIssueFlow::class.java, arrayOf(amount, OpaqueBytes.of(1), notary))
}
}

View File

@ -15,7 +15,7 @@
<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">10</stringProp>
<stringProp name="LoopController.loops">1000</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">3</stringProp>
<stringProp name="ThreadGroup.ramp_time"></stringProp>
@ -26,7 +26,7 @@
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Java Request" enabled="true">
<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">
@ -36,66 +36,30 @@
</elementProp>
<elementProp name="port" elementType="Argument">
<stringProp name="Argument.name">port</stringProp>
<stringProp name="Argument.value">10012</stringProp>
<stringProp name="Argument.value">10003</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="username" elementType="Argument">
<stringProp name="Argument.name">username</stringProp>
<stringProp name="Argument.value">demo</stringProp>
<stringProp name="Argument.value">corda</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="password" elementType="Argument">
<stringProp name="Argument.name">password</stringProp>
<stringProp name="Argument.value">demo</stringProp>
<stringProp name="Argument.value">corda_is_awesome</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="pluginClassName" elementType="Argument">
<stringProp name="Argument.name">pluginClassName</stringProp>
<stringProp name="Argument.value">net.corda.jmeter.CashIssuerPlugin</stringProp>
<elementProp name="notaryName" elementType="Argument">
<stringProp name="Argument.name">notaryName</stringProp>
<stringProp name="Argument.value">O=Perf-10.155.0.4, OU=Corda, L=London, C=GB</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="classname">net.corda.jmeter.CordaRPCSampler</stringProp>
<stringProp name="classname">com.r3.corda.jmeter.CashIssueSampler</stringProp>
</JavaSampler>
<hashTree/>
</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/>
<ResultCollector guiclass="StatGraphVisualizer" testclass="ResultCollector" testname="Aggregate Graph" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
@ -168,6 +132,42 @@
<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>

View File

@ -238,7 +238,7 @@ gui.quick_9=ViewResultsFullVisualizer
#---------------------------------------------------------------------------
# Remote Hosts - comma delimited
remote_hosts=127.0.0.1:20099
remote_hosts=127.0.0.1:20100,127.0.0.1:20101,127.0.0.1:20102,127.0.0.1:20103,127.0.0.1:20104
#remote_hosts=localhost:1099,localhost:2010
# RMI port to be used by the server (must start rmiregistry with same port)