From ed898778c8a89495809e4bd9cb2ea41a31f3da8f Mon Sep 17 00:00:00 2001 From: "rick.parker" Date: Thu, 2 Nov 2017 14:58:47 +0000 Subject: [PATCH] Some clean up. Remote slave via capsule is working. --- tools/jmeter/build.gradle | 50 +++++++++++++------ .../main/kotlin/net/corda/jmeter/Launcher.kt | 12 ++++- .../src/main/resources/jmeter.properties | 2 +- .../src/main/resources/lib/ext/readme.txt | 1 + .../src/main/resources/lib/junit/readme.txt | 1 + tools/jmeter/src/main/resources/log4j2.xml | 21 ++++++++ 6 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 tools/jmeter/src/main/resources/lib/ext/readme.txt create mode 100644 tools/jmeter/src/main/resources/lib/junit/readme.txt create mode 100644 tools/jmeter/src/main/resources/log4j2.xml diff --git a/tools/jmeter/build.gradle b/tools/jmeter/build.gradle index 65b170d3aa..7e7abbd9f8 100644 --- a/tools/jmeter/build.gradle +++ b/tools/jmeter/build.gradle @@ -1,10 +1,12 @@ apply plugin: 'kotlin' +apply plugin: 'us.kirchmeier.capsule' apply plugin: 'application' mainClassName = 'net.corda.jmeter.Launcher' dependencies { compile project(':client:rpc') + compile project(":finance") // JMeter ext.jmVersion = "3.3" @@ -14,7 +16,7 @@ dependencies { runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_ftp', version: "$jmVersion" runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_functions', version: "$jmVersion" runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_http', version: "$jmVersion" - compile group: 'org.apache.jmeter', name: 'ApacheJMeter_java', version: "$jmVersion" + compile group: 'org.apache.jmeter', name: 'ApacheJMeter_java', version: "$jmVersion" // 'compile' because we extend Java sampler. runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_jdbc', version: "$jmVersion" runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_jms', version: "$jmVersion" runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_junit', version: "$jmVersion" @@ -26,37 +28,29 @@ 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" - - //compile project(":test-utils") - compile project(":finance") } task(runServer, dependsOn: 'classes', type: JavaExec) { classpath = sourceSets.main.runtimeClasspath main = 'net.corda.jmeter.Launcher' systemProperty "search_paths", project(':tools:jmeter').configurations.runtime.files.join(";") - systemProperty "java.rmi.server.hostname", InetAddress.getLocalHost().getHostName() - //jvmArgs += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" + systemProperty "java.rmi.server.hostname", "0.0.0.0" + systemProperty "jmeter.home", sourceSets.main.resources.getSrcDirs().first().getPath() + // If you want to debug: jvmArgs += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" args+= [ "-p", sourceSets.main.resources.getSrcDirs().first().getPath()+"/jmeter.properties", "-d", sourceSets.main.resources.getSrcDirs().first().getPath(), - "-j", buildDir.getPath()+"/jmeter.log", "-s" ] } run { systemProperty "search_paths", project(':tools:jmeter').configurations.runtime.files.join(";") - //jvmArgs += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" + systemProperty "jmeter.home", sourceSets.main.resources.getSrcDirs().first().getPath() + // If you want to debug: jvmArgs += "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" args+= [ "-p", sourceSets.main.resources.getSrcDirs().first().getPath()+"/jmeter.properties", - "-d", sourceSets.main.resources.getSrcDirs().first().getPath(), - "-j", buildDir.getPath()+"/jmeter.log" ] + "-d", sourceSets.main.resources.getSrcDirs().first().getPath() ] } jar { - from(configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }) { - exclude "META-INF/*.SF" - exclude "META-INF/*.DSA" - exclude "META-INF/*.RSA" - } manifest { attributes( 'Automatic-Module-Name': 'net.corda.tools.jmeter', @@ -64,4 +58,28 @@ jar { ) } zip64 = true -} \ No newline at end of file +} + +// For building a runnable jar with no other dependencies for remote JMeter slave server, that has Corda code on classpath. +// Run with: java -jar corda-jmeter-.jar +// No additional args required but will be passed if specified. +task buildJMeterJAR(type: FatCapsule, dependsOn: 'jar') { + applicationClass 'net.corda.jmeter.Launcher' + archiveName "corda-jmeter-${corda_release_version}.jar" + applicationSource = files( + project(':tools:jmeter').jar + ) + from 'NOTICE' // Copy CDDL notice + from { "$rootDir/tools/jmeter/build/resources/main/jmeter.properties" } + from { "$rootDir/tools/jmeter/build/resources/main/log4j2.xml" } + + capsuleManifest { + applicationVersion = corda_release_version + systemProperties['java.rmi.server.hostname'] = '0.0.0.0' + minJavaVersion = '1.8.0' + minUpdateVersion['1.8'] = java8_minUpdateVersion + + // JVM configuration. Can be overridden on java command line. + jvmArgs = ['-Xms512m', '-Xmx512m', '-XX:+UseG1GC'] + } +} diff --git a/tools/jmeter/src/main/kotlin/net/corda/jmeter/Launcher.kt b/tools/jmeter/src/main/kotlin/net/corda/jmeter/Launcher.kt index 47787db764..f06ce17a86 100644 --- a/tools/jmeter/src/main/kotlin/net/corda/jmeter/Launcher.kt +++ b/tools/jmeter/src/main/kotlin/net/corda/jmeter/Launcher.kt @@ -1,13 +1,23 @@ package net.corda.jmeter import org.apache.jmeter.JMeter +import org.slf4j.LoggerFactory class Launcher { companion object { @JvmStatic fun main(args: Array) { + val logger = LoggerFactory.getLogger(this::class.java) val jmeter = JMeter() - jmeter.start(args) + val capsuleDir = System.getProperty("capsule.dir") + if (capsuleDir != null) { + // We are running under Capsule, so assume we want a JMeter distributed server to be controlled from + // elsewhere. + logger.info("Starting JMeter in server mode from $capsuleDir") + jmeter.start(arrayOf("-s", "-d", capsuleDir, "-p", "$capsuleDir/jmeter.properties") + args) + } else { + jmeter.start(args) + } } } } \ No newline at end of file diff --git a/tools/jmeter/src/main/resources/jmeter.properties b/tools/jmeter/src/main/resources/jmeter.properties index 4a7f1b6f66..5fc50531b6 100644 --- a/tools/jmeter/src/main/resources/jmeter.properties +++ b/tools/jmeter/src/main/resources/jmeter.properties @@ -238,7 +238,7 @@ gui.quick_9=ViewResultsFullVisualizer #--------------------------------------------------------------------------- # Remote Hosts - comma delimited -remote_hosts=127.0.0.1 +remote_hosts=Rick-Parker.local #remote_hosts=localhost:1099,localhost:2010 # RMI port to be used by the server (must start rmiregistry with same port) diff --git a/tools/jmeter/src/main/resources/lib/ext/readme.txt b/tools/jmeter/src/main/resources/lib/ext/readme.txt new file mode 100644 index 0000000000..6243f40248 --- /dev/null +++ b/tools/jmeter/src/main/resources/lib/ext/readme.txt @@ -0,0 +1 @@ +This directory is expected by JMeter \ No newline at end of file diff --git a/tools/jmeter/src/main/resources/lib/junit/readme.txt b/tools/jmeter/src/main/resources/lib/junit/readme.txt new file mode 100644 index 0000000000..6243f40248 --- /dev/null +++ b/tools/jmeter/src/main/resources/lib/junit/readme.txt @@ -0,0 +1 @@ +This directory is expected by JMeter \ No newline at end of file diff --git a/tools/jmeter/src/main/resources/log4j2.xml b/tools/jmeter/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..7c81df7e7c --- /dev/null +++ b/tools/jmeter/src/main/resources/log4j2.xml @@ -0,0 +1,21 @@ + + + + info + + + + + + + + + + + + + + + +