From 3b565f52f763340ddea9c238a08f30fe1037d10d Mon Sep 17 00:00:00 2001 From: "rick.parker" Date: Thu, 2 Nov 2017 15:54:40 +0000 Subject: [PATCH] Full config of capsule launched JMeter server (was missing functions previously). --- .../main/kotlin/net/corda/jmeter/Launcher.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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 f06ce17a86..c26dae07a1 100644 --- a/tools/jmeter/src/main/kotlin/net/corda/jmeter/Launcher.kt +++ b/tools/jmeter/src/main/kotlin/net/corda/jmeter/Launcher.kt @@ -1,7 +1,11 @@ package net.corda.jmeter +import net.corda.core.internal.div import org.apache.jmeter.JMeter import org.slf4j.LoggerFactory +import java.nio.file.Files +import java.nio.file.Paths +import kotlin.streams.asSequence class Launcher { companion object { @@ -11,10 +15,22 @@ class Launcher { val jmeter = JMeter() 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 + // We are running under Capsule, so assume we want a JMeter slave 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) + // 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 { jmeter.start(args) }