Skip to content

Commit

Permalink
h2 jdbc url fixed, added mac support
Browse files Browse the repository at this point in the history
  • Loading branch information
eostermueller committed May 19, 2020
1 parent 284f325 commit 838ae47
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ private void installJMeterDistribution() throws Snail4jException {
LOGGER.error(err);
throw new Snail4jException(err);
}
File jmeterExe2 = new File( jmeterBinFolder, "jmeter");
if (jmeterExe2.exists()) {
String cmd = "chmod +x " + jmeterExe2.getAbsolutePath().toString();
OsUtils.executeProcess_bash(cmd, jmeterBinFolder);
} else {
String err= "java.util.File is reporting that the jmeter executable doesn't exist. [" + jmeterExe2.toString() + "]. Cmon, we just installed it. It should be there!";
LOGGER.error(err);
throw new Snail4jException(err);
}

File shutdownExe = new File( jmeterBinFolder, "shutdown.sh");
if (shutdownExe.exists()) {
String cmd = "chmod +x " + shutdownExe.getAbsolutePath().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public interface Configuration {
String getJMeterShutdownExeName();
void setUseCaseSearchCriteria(String val);
String getUseCaseSearchCriteria();
void setSutJvmArguments(String val);
String getSutJvmArguments();



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ public class DefaultConfiguration implements Configuration {
private String loadGeneratorShutdownCmd;
private String jmeterShutdownExePath;
private String useCaseSearchCriteria;

/**
* A space-delimited set of JVM parameters that gets passed into
* -Dspring-boot.run.jvmArguments
* https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/html/#goals-run-parameters-details-jvmArguments
* No quotation marks are allowed in this value.
* The following pom.xml file wraps 'this' value in quotes:
* https://github.com/eostermueller/snail4j/blob/master/processManager/pom.xml
*/
private String sutJvmArguments;


@Override
public String getSutJvmArguments() {
return sutJvmArguments;
}
@Override
public void setSutJvmArguments(String val) {
sutJvmArguments = val;
}

/**
* This is the most important constructor in the project :-)
*/
Expand Down Expand Up @@ -151,6 +172,7 @@ public DefaultConfiguration() {
sb2.append(SPACE);sb2.append("-Dsnail4j.h2.hostname=#{h2Hostname}");
sb2.append(SPACE);sb2.append("-Dsnail4j.sut.port=#{sutAppPort}");
sb2.append(SPACE);sb2.append("-Dsnail4j.glowroot.port=#{glowrootPort}");
sb2.append(SPACE);sb2.append("-Dsnail4j.sut.jvmArguments=#{sutJvmArguments}");
sb2.append(SPACE);sb2.append("verify");
this.setProcessManagerLaunchCmd( sb2.toString() );

Expand Down Expand Up @@ -187,6 +209,12 @@ public DefaultConfiguration() {

this.setMavenExePath( createMavenExePath() );
this.setUseCaseSearchCriteria("com.github.eostermueller.tjp2");

sb3 = new StringBuilder();
sb3.append("-Xmx1024m");
sb3.append(SPACE);sb3.append("-XX:NewSize=512m");
sb3.append(SPACE);sb3.append("-XX:MaxNewSize=512m");
this.setSutJvmArguments( sb3.toString() );

}
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void canDoNoHarmToCmdLineWithoutVariables() throws ConfigVariableNotFound
}
/**
* Just testing the API -- not testing any snail4j code quite yet :-)
* This jackson API wants to instantiate the target class.
* This jackson API instantiates the target class.
* That won't work for snail4j, where the instance (DefaultConfiguration) will already exist.
* @stolenFrom: https://www.baeldung.com/jackson-json-node-tree-model
* @throws JsonProcessingException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ public void canTurnOffUseOfSnail4jRepo_processManager() {
Path tjpHome = Paths.get(unix_ABS_PATH_TO_TJP);
Path javaHome = Paths.get(unix_JAVA_HOME);


String baseParameters = "#{mavenExePath} -Dsnail4j.wiremock.port=#{wiremockPort} -Dsnail4j.wiremock.hostname=#{wiremockHostname} -Dsnail4j.h2.port=#{h2Port} -Dsnail4j.h2.hostname=#{h2Hostname} -Dsnail4j.sut.port=#{sutAppPort} -Dsnail4j.glowroot.port=#{glowrootPort} -Dsnail4j.sut.jvmArguments=#{sutJvmArguments} verify";
TestConfiguration testCfg = new TestConfiguration(tjpHome, javaHome);
testCfg.setProcessManagerLaunchCmd(baseParameters);
testCfg.setMavenOnline(true);
testCfg.setSnail4jMavenRepo(false);

//String expectedLaunch = TestConfiguration.MAVEN_EXE_PATH + " -Dsnail4j.wiremock.port=#{wiremockPort} -Dsnail4j.h2.port=#{h2Port} -Dsnail4j.sut.port=#{sutAppPort} -Dsnail4j.glowroot.port=#{glowrootPort} verify";
String baseExpectedLaunch = " -Dsnail4j.wiremock.port=#{wiremockPort} -Dsnail4j.wiremock.hostname=#{wiremockHostname} -Dsnail4j.h2.port=#{h2Port} -Dsnail4j.h2.hostname=#{h2Hostname} -Dsnail4j.sut.port=#{sutAppPort} -Dsnail4j.glowroot.port=#{glowrootPort} verify";
String baseExpectedLaunch = " -Dsnail4j.wiremock.port=#{wiremockPort} -Dsnail4j.wiremock.hostname=#{wiremockHostname} -Dsnail4j.h2.port=#{h2Port} -Dsnail4j.h2.hostname=#{h2Hostname} -Dsnail4j.sut.port=#{sutAppPort} -Dsnail4j.glowroot.port=#{glowrootPort} -Dsnail4j.sut.jvmArguments=#{sutJvmArguments} verify";
String expectedLaunch = TestConfiguration.MAVEN_EXE_PATH + baseExpectedLaunch;

String expectedLaunchWithSnail4jMavenRepo = TestConfiguration.MAVEN_EXE_PATH + " -Dsnail4j.maven.repo.passthru=-Dmaven.repo.local=#{mavenRepositoryHome} -Dmaven.repo.local=#{mavenRepositoryHome}" + baseExpectedLaunch;
Expand Down
50 changes: 47 additions & 3 deletions processManager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<!-- The following allow us to pass in -D parameters to the mvn script -->
<snail4j.wiremock.port>8081</snail4j.wiremock.port>
<snail4j.wiremock.hostname>localhost</snail4j.wiremock.hostname>
<snail4j.sut.arguments></snail4j.sut.arguments>

<snail4j.h2.hostname>localhost</snail4j.h2.hostname>
<snail4j.h2.port>9093</snail4j.h2.port>
Expand Down Expand Up @@ -62,7 +63,22 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
</os>
</activation>
<properties>
<!--
The following "benigh filler args" are ugly tech debt.
To fix this, need to yank the maven-process-plugin
-->
<script.extension>.cmd</script.extension>
<sutApp.cmd.01>cmd.exe</sutApp.cmd.01>
<sutApp.cmd.02>/E:ON</sutApp.cmd.02> <!-- benign filler arg -->
<sutApp.cmd.03>/E:ON</sutApp.cmd.03> <!-- benign filler arg -->
<sutApp.cmd.04>/E:ON</sutApp.cmd.04> <!-- benign filler arg -->
<sutApp.cmd.05>/E:ON</sutApp.cmd.05> <!-- benign filler arg -->
<sutApp.cmd.06>/E:ON</sutApp.cmd.06> <!-- benign filler arg -->
<sutApp.cmd.07>/E:ON</sutApp.cmd.07> <!-- benign filler arg -->
<sutApp.cmd.08>/E:ON</sutApp.cmd.08> <!-- benign filler arg -->
<sutApp.cmd.09>/E:ON</sutApp.cmd.09> <!-- benign filler arg -->
<sutApp.cmd.10>/C</sutApp.cmd.10>
<sutApp.cmd.11>mvn -e -X ${snail4j.maven.offline.passthru} ${snail4j.maven.repo.passthru} -Dspring-boot.run.fork=true -Dspring-boot.run.jvmArguments="-Dsnail4j.wiremock.hostname=${snail4j.wiremock.hostname} -Dsnail4j.h2.port=${snail4j.h2.port} -Dsnail4j.h2.hostname=${snail4j.h2.hostname} -Dsnail4j.wiremock.port=${snail4j.wiremock.port} -Dglowroot.agent.port=${snail4j.glowroot.port} ${snail4j.sut.jvmArguments}" -Dspring-boot.run.agents=${user.home}/.snail4j/glowroot/glowroot/glowroot.jar -Dspring-boot.run.arguments=--server.port=${snail4j.sut.port} spring-boot:run</sutApp.cmd.11>
</properties>
</profile>
<profile>
Expand All @@ -74,6 +90,26 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
</activation>
<properties>
<script.extension></script.extension>
<sutApp.cmd.01>mvn</sutApp.cmd.01>
<sutApp.cmd.02>-e</sutApp.cmd.02>
<sutApp.cmd.03>-X</sutApp.cmd.03>
<sutApp.cmd.04>-debug</sutApp.cmd.04>
<sutApp.cmd.05>${snail4j.maven.offline.passthru}</sutApp.cmd.05>
<sutApp.cmd.06>${snail4j.maven.repo.passthru}</sutApp.cmd.06>
<sutApp.cmd.07>-Dspring-boot.run.fork=true</sutApp.cmd.07>
<!--
The following says "make sure to wrap multiple values between quotes" but on make, that causes a problem and the
-D system parameters were not recognized...big problem.
https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/html/#goals-run-parameters-details-jvmArguments
Oddly, these didnt' have to be removed for MS-Windows...
I'm thinking this is a problem with the maven-process-plugin, because the following works OK with mac and quotes,
but the maven-process-plugin is not used here:
https://github.com/eostermueller/mac-and-windows-processes
-->
<sutApp.cmd.08>-Dspring-boot.run.jvmArguments=-Dsnail4j.wiremock.hostname=${snail4j.wiremock.hostname} -Dsnail4j.h2.port=${snail4j.h2.port} -Dsnail4j.h2.hostname=${snail4j.h2.hostname} -Dsnail4j.wiremock.port=${snail4j.wiremock.port} -Dglowroot.agent.port=${snail4j.glowroot.port} ${snail4j.sut.jvmArguments}</sutApp.cmd.08>
<sutApp.cmd.09>-Dspring-boot.run.agents=${user.home}/.snail4j/glowroot/glowroot/glowroot.jar</sutApp.cmd.09>
<sutApp.cmd.10>-Dspring-boot.run.arguments=--server.port=${snail4j.sut.port}</sutApp.cmd.10>
<sutApp.cmd.11>spring-boot:run</sutApp.cmd.11>
</properties>
</profile>
</profiles>
Expand Down Expand Up @@ -181,9 +217,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<tcpHealthcheckPort>8080</tcpHealthcheckPort>
-->
<arguments>
<argument>cmd.exe</argument>
<argument>/C</argument>
<argument>mvn -e -X ${snail4j.maven.offline.passthru} ${snail4j.maven.repo.passthru} -Dspring-boot.run.fork=true -Dspring-boot.run.jvmArguments="-Dsnail4j.wiremock.hostname=${snail4j.wiremock.hostname} -Dsnail4j.h2.port=${snail4j.h2.port} -Dsnail4j.h2.hostname=${snail4j.h2.hostname} -Dsnail4j.wiremock.port=${snail4j.wiremock.port} -Dglowroot.agent.port=${snail4j.glowroot.port} -Xmx1024m -XX:NewSize=512m -XX:MaxNewSize=512m" -Dspring-boot.run.agents=${user.home}/.snail4j/glowroot/glowroot/glowroot.jar -Dspring-boot.run.arguments=--server.port=${snail4j.sut.port} spring-boot:run</argument>
<argument>${sutApp.cmd.01}</argument>
<argument>${sutApp.cmd.02}</argument>
<argument>${sutApp.cmd.03}</argument>
<argument>${sutApp.cmd.04}</argument>
<argument>${sutApp.cmd.05}</argument>
<argument>${sutApp.cmd.06}</argument>
<argument>${sutApp.cmd.07}</argument>
<argument>${sutApp.cmd.08}</argument>
<argument>${sutApp.cmd.09}</argument>
<argument>${sutApp.cmd.10}</argument>
<argument>${sutApp.cmd.11}</argument>
<!-- @stolenFrom: https://stackoverflow.com/a/46628861/2377579 -->
<!-- @stolenFrom: http://myjavaadventures.com/blog/2018/07/21/spring-boot-pass-arguments/ -->
<!-- <argument>-Dspring-boot.run.jvmArguments="-javaagent:${user.home}/.snail4j/glowroot/glowroot/glowroot.jar,-Dglowroot.agent.port=${snail4j.glowroot.port}"</argument> -->
Expand Down

0 comments on commit 838ae47

Please sign in to comment.