Skip to content

OctoPerf Maven Plugin

OctoPerf integrates with Maven, a leading open-source solution for building and organizing software development.

See the OctoPerf Maven Plugin for more information.

Prerequisites

Maven can be downloaded and installed on any operating system.

Run a mvn -v to make sure it is properly installed before you proceed: Maven installed

Tip

If you're running maven from your favorite CI tool you do not need to go through this step since it will be taken care of by the CI tool itself.

Goals

Before we start, we need to pick one the goals provided by the OctoPerf Maven Plugin.

In this tutorial we will go for the octoperf:execute-scenario goal, this will allow us to execute a test from Maven.

Other goals allow you to use OctoPerf as a pure test runner and checkout your scripts from your source control prior to the test.

Configuration

Only one section remains to be completed: editing the pom.xml maven configuration file. Let's create the pom.xml with the configuration needed to run octoperf:execute-scenario (see octoperf:execute-scenario for more information):

<?xml version="1.0" encoding="UTF-8"?>
<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>
  <packaging>pom</packaging>
  <groupId>com.octoperf</groupId>
  <artifactId>octoperf-test</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <build>
    <plugins>
      <plugin>
        <groupId>com.octoperf</groupId>
        <artifactId>octoperf-maven-plugin</artifactId>
        <version>2.4.0</version>
        <configuration>
              <apiKey>YOUR_API_KEY</apiKey>
              <workspaceName>WORKSPACE_NAME</workspaceName>
              <projectName>PROJECT_NAME</projectName>
              <scenarioName>SCENARIO_NAME</scenarioName>
            </configuration>
      </plugin>
    </plugins>
  </build>

  <!-- OctoPerf Maven Repository -->
  <pluginRepositories>
    <pluginRepository>
      <id>octoperf-snapshots</id>
      <name>OctoPerf Snapshots</name>
      <url>https://github.com/octoperf/maven-repository/raw/master/snapshots</url>
    </pluginRepository>
    <pluginRepository>
      <id>octoperf-releases</id>
      <name>OctoPerf Releases</name>
      <url>https://github.com/octoperf/maven-repository/raw/master/releases</url>
    </pluginRepository>
  </pluginRepositories>
</project>

We need to replace the placeholders WORKSPACE_NAME, PROJECT_NAME and SCENARIO_NAME with proper values. Those can be found using OctoPerf's UI.

octoperf Where to get the parameters from OctoPerf

As a result we would have:

<configuration>
    <apiKey>YOUR_API_KEY</apiKey>
    <workspaceName>Demo</workspaceName>
    <projectName>MyProject</projectName>
    <scenarioName>Standard</scenarioName>
</configuration>

The API Key can be found on your User Profile.

For more information on possible configurations available, see Maven Plugin page.

Tip

It is possible to use the command line to pass a parameter to Maven, typically to keep your API key secure you might not want it in a static file. In this case, add -api YOUR_API_KEY to the command line and inside the POM file use ${api}.

Execution

This step can be achieved by running a command line interface or bash, pointing to the folder where your pom.xml is located. Then just run the command line specified in our documentation for this goal: mvn octoperf:execute-scenario

Maven test runs

Maven test runs

When the test is finished or aborted you will see if the final result is on par with SLAs you defined:

Maven test finished

Maven test finished

The test logs and JUnit result will be downloaded automatically, along with the JTL result files if you activated them. For a complete overview of what you can achieve with this plugin, see the OctoPerf Maven Plugin documentation.