Some clean up. Remote slave via capsule is working.

This commit is contained in:
rick.parker 2017-11-02 14:58:47 +00:00
parent 6b0291d420
commit ed898778c8
6 changed files with 69 additions and 18 deletions

View File

@ -1,10 +1,12 @@
apply plugin: 'kotlin' apply plugin: 'kotlin'
apply plugin: 'us.kirchmeier.capsule'
apply plugin: 'application' apply plugin: 'application'
mainClassName = 'net.corda.jmeter.Launcher' mainClassName = 'net.corda.jmeter.Launcher'
dependencies { dependencies {
compile project(':client:rpc') compile project(':client:rpc')
compile project(":finance")
// JMeter // JMeter
ext.jmVersion = "3.3" 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_ftp', version: "$jmVersion"
runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_functions', version: "$jmVersion" runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_functions', version: "$jmVersion"
runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_http', 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_jdbc', version: "$jmVersion"
runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_jms', version: "$jmVersion" runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_jms', version: "$jmVersion"
runtime group: 'org.apache.jmeter', name: 'ApacheJMeter_junit', 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_config', version: "$jmVersion"
runtime group: 'org.apache.jmeter', name: 'ApacheJMeter', version: "$jmVersion" runtime group: 'org.apache.jmeter', name: 'ApacheJMeter', version: "$jmVersion"
runtime group: 'org.apache.jmeter', name: 'jorphan', version: "$jmVersion" runtime group: 'org.apache.jmeter', name: 'jorphan', version: "$jmVersion"
//compile project(":test-utils")
compile project(":finance")
} }
task(runServer, dependsOn: 'classes', type: JavaExec) { task(runServer, dependsOn: 'classes', type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath classpath = sourceSets.main.runtimeClasspath
main = 'net.corda.jmeter.Launcher' main = 'net.corda.jmeter.Launcher'
systemProperty "search_paths", project(':tools:jmeter').configurations.runtime.files.join(";") systemProperty "search_paths", project(':tools:jmeter').configurations.runtime.files.join(";")
systemProperty "java.rmi.server.hostname", InetAddress.getLocalHost().getHostName() systemProperty "java.rmi.server.hostname", "0.0.0.0"
//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", args+= [ "-p", sourceSets.main.resources.getSrcDirs().first().getPath()+"/jmeter.properties",
"-d", sourceSets.main.resources.getSrcDirs().first().getPath(), "-d", sourceSets.main.resources.getSrcDirs().first().getPath(),
"-j", buildDir.getPath()+"/jmeter.log",
"-s" ] "-s" ]
} }
run { run {
systemProperty "search_paths", project(':tools:jmeter').configurations.runtime.files.join(";") 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", args+= [ "-p", sourceSets.main.resources.getSrcDirs().first().getPath()+"/jmeter.properties",
"-d", sourceSets.main.resources.getSrcDirs().first().getPath(), "-d", sourceSets.main.resources.getSrcDirs().first().getPath() ]
"-j", buildDir.getPath()+"/jmeter.log" ]
} }
jar { jar {
from(configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
manifest { manifest {
attributes( attributes(
'Automatic-Module-Name': 'net.corda.tools.jmeter', 'Automatic-Module-Name': 'net.corda.tools.jmeter',
@ -65,3 +59,27 @@ jar {
} }
zip64 = true zip64 = true
} }
// 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-<version>.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']
}
}

View File

@ -1,13 +1,23 @@
package net.corda.jmeter package net.corda.jmeter
import org.apache.jmeter.JMeter import org.apache.jmeter.JMeter
import org.slf4j.LoggerFactory
class Launcher { class Launcher {
companion object { companion object {
@JvmStatic @JvmStatic
fun main(args: Array<String>) { fun main(args: Array<String>) {
val logger = LoggerFactory.getLogger(this::class.java)
val jmeter = JMeter() 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)
}
} }
} }
} }

View File

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

View File

@ -0,0 +1 @@
This directory is expected by JMeter

View File

@ -0,0 +1 @@
This directory is expected by JMeter

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info">
<Properties>
<Property name="defaultLogLevel">info</Property>
</Properties>
<ThresholdFilter level="trace"/>
<Appenders>
<Console name="Console-Appender" target="SYSTEM_OUT">
<PatternLayout
pattern="%highlight{%level{length=1} %date{HH:mm:ssZ} [%t] %c{2}.%method - %msg%n}{INFO=white,WARN=red,FATAL=bright red}"/>
</Console>
</Appenders>
<Loggers>
<Root level="${sys:defaultLogLevel}">
<AppenderRef ref="Console-Appender" level="${sys:defaultLogLevel}"/>
</Root>
</Loggers>
</Configuration>