Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logging capability. #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ rm -rf gatling-charts-highcharts-bundle-${GATLING_VERSION}/user-files/simulation
</properties>
```

5. Add the following two dependencies:
5. Add the following dependencies:

```xml
<dependencies>
Expand Down
18 changes: 18 additions & 0 deletions bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
image: maven:3.3.9
pipelines:
default:
- step:
caches:
- maven
script:
- mvn -B verify
tags:
v*:
- step:
caches:
- maven
script:
- bash configure-maven.sh
- VERSION=$(echo "$BITBUCKET_TAG" | sed -e 's/^v//')
- mvn versions:set -DnewVersion=$VERSION
- mvn deploy
23 changes: 14 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>gatling-aws-maven-plugin</artifactId>
<groupId>com.ea.gatling</groupId>
<groupId>com.fr</groupId>
<version>1.0.18-SNAPSHOT</version>
<name>Gatling AWS Maven Plugin</name>
<description>The Gatling AWS Maven plugin takes the pain out of scaling up your Gatling tests. It runs your load test on a configurable number of EC2 instances, aggregates a single load test report, and uploads the results to S3. All EC2 instances are terminated at the end of the test to ensure you are only paying for what you need.</description>
Expand Down Expand Up @@ -95,21 +95,26 @@
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.kuali.maven.wagons</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.2.1</version>
</extension>
</extensions>
</build>
<profiles>
<profile>
<id>release</id>
<distributionManagement>
<snapshotRepository>
<id>deployment</id>
<name>Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>deployment</id>
<name>Staging</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
<id>fr-maven-release</id>
<url>s3://maven.flexreceipts.com/release</url>
</repository>
<snapshotRepository>
<id>fr-maven-snapshot</id>
<url>s3://maven.flexreceipts.com/snapshot</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/ea/gatling/AwsGatlingExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public class AwsGatlingExecutor implements Runnable {
private final String inheritedGatlingJavaOpts;
private final boolean debugOutputEnabled;
private final boolean runDetached;
private final String remoteLogfile;
private final boolean getRemoteLogFile;

public AwsGatlingExecutor(final String host,final String sshUser, final File sshPrivateKey, final String testName, final File installScript, final File gatlingSourceDir, final String gatlingSimulation, final File simulationConfig, final File gatlingResourcesDir, final File gatlingLocalResultsDir, final List<String> additionalFiles, final int numInstance, final int instanceCount, final ConcurrentHashMap<String, Integer> completedHosts, final String gatlingRoot, final String inheritedGatlingJavaOpts, final boolean debugOutputEnabled, final boolean runDetached) {
public AwsGatlingExecutor(final String host,final String sshUser, final File sshPrivateKey, final String testName, final File installScript, final File gatlingSourceDir, final String gatlingSimulation, final File simulationConfig, final File gatlingResourcesDir, final File gatlingLocalResultsDir, final List<String> additionalFiles, final int numInstance, final int instanceCount, final ConcurrentHashMap<String, Integer> completedHosts, final String gatlingRoot, final String inheritedGatlingJavaOpts, final boolean debugOutputEnabled, final boolean runDetached, final boolean getRemoteLogFile, final String remoteLogFile) {
this.host = host;
this.sshUser = sshUser;
this.sshPrivateKey = sshPrivateKey.getAbsolutePath();
Expand All @@ -53,6 +55,8 @@ public AwsGatlingExecutor(final String host,final String sshUser, final File ssh
this.inheritedGatlingJavaOpts = inheritedGatlingJavaOpts;
this.debugOutputEnabled = debugOutputEnabled;
this.runDetached = runDetached;
this.remoteLogfile = remoteLogFile;
this.getRemoteLogFile = getRemoteLogFile;
}

public void runGatlingTest() throws IOException {
Expand Down Expand Up @@ -131,6 +135,11 @@ private int runProcess(final SshClient.HostInfo hostInfo) throws IOException {
this.debugOutputEnabled);
SshClient.scpDownload(hostInfo, new SshClient.FromTo("simulation.log",
String.format("%s/%s/simulation-%s.log", this.gatlingLocalResultsDir.getAbsolutePath(), this.testName, this.host)));
if(this.getRemoteLogFile) {
this.log("Downloading remote log");
SshClient.scpDownload(hostInfo, new SshClient.FromTo(remoteLogfile,
String.format("%s/%s/remote-log-%s.log", this.gatlingLocalResultsDir.getAbsolutePath(), this.testName, this.host)));
}
}

return resultCode;
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/ea/gatling/GatlingAwsMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public class GatlingAwsMojo extends BaseAwsMojo {
@Parameter(property = "gatling.local.results", defaultValue = "${project.build.directory}/gatling/results")
private File gatlingLocalResultsDir;

@Parameter(property = "gatling.remote.log", defaultValue = "gatling-charts-highcharts-bundle-2.1.4/target/logs/logfile.txt")
private String gatlingRemoteLog;

@Parameter(property = "gatling.remote.download", defaultValue = "false")
private boolean downloadRemoteLog;

@Parameter(property = "gatling.local.home", defaultValue = "${user.home}/gatling/gatling-charts-highcharts-bundle-2.1.4/bin/gatling.sh")
private String gatlingLocalHome;

Expand Down Expand Up @@ -95,6 +101,7 @@ public class GatlingAwsMojo extends BaseAwsMojo {
@Parameter(property = "prefer.private.ip.hostnames", defaultValue = "false")
private boolean preferPrivateIpHostnames;


/**
* When true, this will run Gatling detached, and disconnect from SSH while Gatling is running. Leaves a
* file called 'gatling.pid' with the pid of the java process in it.
Expand Down Expand Up @@ -146,7 +153,9 @@ public void execute() throws MojoExecutionException {
this.gatlingRoot,
this.gatlingJavaOpts,
this.debugOutputEnabled,
this.ec2ExecuteDetached);
this.ec2ExecuteDetached,
this.downloadRemoteLog,
this.gatlingRemoteLog);
executor.execute(worker);
}
executor.shutdown();
Expand Down