Full config of capsule launched JMeter server (was missing functions previously).

This commit is contained in:
rick.parker 2017-11-02 15:54:40 +00:00
parent 029cc1c2f0
commit 3b565f52f7

View File

@ -1,7 +1,11 @@
package net.corda.jmeter package net.corda.jmeter
import net.corda.core.internal.div
import org.apache.jmeter.JMeter import org.apache.jmeter.JMeter
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.nio.file.Files
import java.nio.file.Paths
import kotlin.streams.asSequence
class Launcher { class Launcher {
companion object { companion object {
@ -11,10 +15,22 @@ class Launcher {
val jmeter = JMeter() val jmeter = JMeter()
val capsuleDir = System.getProperty("capsule.dir") val capsuleDir = System.getProperty("capsule.dir")
if (capsuleDir != null) { if (capsuleDir != null) {
// We are running under Capsule, so assume we want a JMeter distributed server to be controlled from // We are running under Capsule, so assume we want a JMeter slave server to be controlled from
// elsewhere. // elsewhere.
logger.info("Starting JMeter in server mode from $capsuleDir") logger.info("Starting JMeter in server mode from $capsuleDir")
jmeter.start(arrayOf("-s", "-d", capsuleDir, "-p", "$capsuleDir/jmeter.properties") + args) // Add all JMeter and Corda jars onto the JMeter search_paths
val searchPath = Files.list(Paths.get(capsuleDir)).asSequence().filter {
val filename = it.fileName.toString()
filename.endsWith(".jar") && (filename.contains("corda") || filename.contains("jmeter", true))
}.joinToString(";")
logger.info("search_paths = $searchPath")
System.setProperty("search_paths", searchPath)
// Set the JMeter home as a property rather than command line arg, due to inconsistent code in JMeter.
System.setProperty("jmeter.home", capsuleDir)
// Create two dirs that JMeter expects, if they don't already exist.
Files.createDirectories(Paths.get(capsuleDir) / "lib" / "ext")
Files.createDirectories(Paths.get(capsuleDir) / "lib" / "junit")
jmeter.start(arrayOf("-s", "-p", "$capsuleDir/jmeter.properties") + args)
} else { } else {
jmeter.start(args) jmeter.start(args)
} }