Skip to content

Maven: start multiple processes in pre-integration-test phase in order.

License

Notifications You must be signed in to change notification settings

chonton/process-exec-maven-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

process-exec-maven-plugin

Improve end-to-end integration testing with maven. Process Executor Plugin allows you to to start multiple processes in pre-integration-test phase in order, and then stops all the processes in post-integration-test phase, in reverse order.

Goals

  • start - Pre-Integration-test phase. Starts a given process in the pre-integration-test phase. Requires one execution per process.
  • stop-all - Post-Integration-test phase. Stops all processes that are started in the pre-integration-test phase, in reverse order. Requires only one execution for all processes.

Arguments

  • arguments: Command line arguments as you would provide when starting a process in your terminal. So, for example to run something like this
   java -jar drop-wizard-app.jar server config.yaml

set arguments as:

  <arguments>
    <argument>${java.home}/bin/java</argument>
    <argument>-jar</argument>
    <argument>drop-wizard-app.jar</argument>
    <argument>server</argument>
    <argument>config.yaml</argument>
  </arguments>
  • environment: Environment variables for the process
  <environment>
    <TERM>vt100</TERM>
  </environment>
  • name: Give a name to the process to start.
  • workingDir: Give a working directory for your process to start in. Could be same as name. If not provided, the build directory is used.
  • waitForInterrupt: Optional. Setting this value to true will pause your build after starting every process to give you a chance to manually play with your system. Default is false.
  • healthCheckUrl: Recommended, but optional. You should provide a healthcheck url, so the plugin waits until the healthchecks are all green for your process. If not provided, the plugin waits for waitAfterLaunch seconds before moving on.
  • healthCheckValidateSsl: Optional. If healthCheckUrl is specified, and is an HTTPS URL, Java's default SSL TrustManager will be used by default. If you are using a self-signed certificate, this parameter can be set to false to use a TrustManager that doesn't validate the certification path.
  • waitAfterLaunch: Optional. This specifies the maximum time in seconds to wait after launching the process. If healthCheckUrl is specified, then it will move on as soon as the health checks pass. Default is 30 seconds.
  • processLogFile: Optional. Specifying a log file will redirect the process output to the specified file. Recommended as this will avoid cluttering your build's log with the log of external proccesses.

Killing processes on exit

Killing the maven process (using Ctrl+C or kill <pid> command) will stop all the processes started by the plugin.

HealthCheckUrl

The health check url can be any scheme natively supported by JRE, or 'tcp'. Additional url schemes can be supported as described in url-extension

POM example:

<build>
  <plugins>
    <plugin>
      <groupId>org.honton.chas</groupId>
      <artifactId>process-exec-maven-plugin</artifactId>
      <version>0.9.2</version>
      <executions>
        <!--Start process 1, eg., a dropwizard app dependency-->
        <execution>
          <id>switchboard-process</id>
          <phase>pre-integration-test</phase>
          <goals>
            <goal>start</goal>
          </goals>
          <configuration>
            <name>Switchboard2</name>
            <workingDir>switchboard2</workingDir>
            <waitForInterrupt>false</waitForInterrupt>
            <healthCheckUrl>http://localhost:8381/healthcheck</healthCheckUrl>
            <arguments>
              <argument>${java.home}/bin/java</argument>
              <argument>-jar</argument>
              <argument>${basedir}/../../app/target/switchboard-${project.version}.jar</argument>
              <argument>server</argument>
              <argument>${basedir}/bin/switchboard.yaml</argument>
            </arguments>
          </configuration>
        </execution>
        <!--Start process 2, eg., another dropwizard app dependency-->
        <execution>
          <id>emodb-shovel-process</id>
          <phase>pre-integration-test</phase>
          <goals>
            <goal>start</goal>
          </goals>
          <configuration>
            <name>emodb-shovel</name>
            <workingDir>shovel</workingDir>
            <waitForInterrupt>false</waitForInterrupt>
            <healthCheckUrl>http://localhost:8181/healthcheck</healthCheckUrl>
            <arguments>
              <argument>${java.home}/bin/java</argument>
              <argument>-jar</argument>
              <argument>${basedir}/../../app/target/emodb-shovel-app-${project.version}.jar</argument>
              <argument>server</argument>
              <argument>${basedir}/bin/config-local-dc.yaml</argument>
            </arguments>
          </configuration>
        </execution>
        <!--Stop all processes in reverse order-->
        <execution>
          <id>stop-all</id>
          <phase>post-integration-test</phase>
          <goals>
            <goal>stop-all</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

About

Maven: start multiple processes in pre-integration-test phase in order.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Java 100.0%