GithubHelp home page GithubHelp logo

bazaarvoice / maven-process-plugin Goto Github PK

View Code? Open in Web Editor NEW
62.0 36.0 30.0 67 KB

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

License: Apache License 2.0

Java 100.00%

maven-process-plugin's Introduction

Build Status

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</argument>
        <argument>-jar</argument>
        <argument>drop-wizard-app.jar</argument>
        <argument>server</argument>
        <argument>config.yaml</argument>
    </arguments>
    
  • 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.

  • 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.

NOTE: As of 0.7, killing the maven process (using Ctrl+C or kill command) will stop all the processes started by the plugin.

POM example:

The latest version is 0.7.

<build>
    <plugins>
        <plugin>
            <groupId>com.bazaarvoice.maven.plugins</groupId>
            <artifactId>process-exec-maven-plugin</artifactId>
            <version>0.7</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</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</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>

maven-process-plugin's People

Contributors

bbeck avatar fahdsiddiqui avatar fibrefox avatar olyhuta avatar r48patel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maven-process-plugin's Issues

how to launch?

Would be nice if your README showed how to launch the plugin.
I used this syntax:
mvn com.bazaarvoice.maven.plugins:process-exec-maven-plugin:0.7:start

...but was hoping there was a plugin prefix that was less verbose, as described here:

https://stackoverflow.com/a/40206597/2377579

Make plugin thread-safe

Hi,

would be great to mark the plugin as thread-safe. We have no problem in running it in parallel, yet Maven yields irritating warnings ;)

WorkingDir: Path like ${project.basedir}/../path/segment is treated as relative

I know there is the issue: #11
which has been solved.

There is one narrow situation when it does not work correctly.

Consider having path defined like this:
<workingDir>${project.basedir}/../webmeter-tabs</workingDir>

It throws:

java.lang.RuntimeException: couldn't create directories: 
C:\work\stam\taas_web_jmeter\e2e\target\C:\work\stam\taas_web_jmeter\e2e\..\webmeter-tabs

I looked at source code in ProcessStartMojo.java (line 57).

It seems that the check potentialWorkingDir.isAbsolute() returns false.

Maybe checking only potentialWorkingDir.exists() && potentialWorkingDir.isDirectory() would be enough?

Plugin keeps failing on maven verify. Cannot seem to execute.

Hey guys I really like your plugin but keep seeing this issue. Do you think you can tell me what I am doing wrong:

               <plugin>
                        <groupId>com.bazaarvoice.maven.plugins</groupId>
                        <artifactId>process-exec-maven-plugin</artifactId>
                        <version>0.7</version>
                        <executions>
                            <!--Start process-->
                            <execution>
                                <id>kms-server</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                                <configuration>
                                    <workingDir>${project.basedir}</workingDir>
                                    <arguments>
                                        <argument>java</argument>
                                        <argument>-DkmsRunFromMavenForTest=true</argument>
                                        <argument>-jar</argument>
                                        <argument>${kms-server-exec.jar}</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <!--Stop Process-->
                            <execution>
                                <id>stop-all</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop-all</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 3 (Exit value: 3)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:804)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:751)
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:313)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:200)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:196)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    at java.lang.Thread.run (Thread.java:748)

java.lang.ClassNotFoundException: com.bazaarvoice.maven.plugin.process.CrossMojoState

Hi,
this might be a duplicate of #24 but i don't really see the solving. adding the goals "clean verify" did not give me any improvement on this.

i tried version 0.7-0.9 of the plugin. i checked my local maven-repo for the plugin (removed, re-downloaded, inspected) everything looks ok.

the error that occurs is:

[ERROR] Failed to execute goal com.bazaarvoice.maven.plugins:process-exec-maven-plugin:0.7:start (start-pine-micro-service) on project fhirstore-netty: Execution start-pine-micro-service of goal com.bazaarvoice.maven.plugins:process-exec-maven-plugin:0.7:start failed.: NullPointerException -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Exception in thread "Thread-6" java.lang.NoClassDefFoundError: com/bazaarvoice/maven/plugin/process/CrossMojoState
	at com.bazaarvoice.maven.plugin.process.AbstractProcessMojo$1.run(AbstractProcessMojo.java:61)
Caused by: java.lang.ClassNotFoundException: com.bazaarvoice.maven.plugin.process.CrossMojoState
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 1 more

hope there is a simple solution to help me out.
thanks in advance

Treat HTTP status 401 as healthy

The ProcessHealthCondition class checks for a 2xx stats code to see if the application is running, which means that the application started has to have at least one endpoint that gives a 2xx response without authentication. If the plugin is used to start an application that uses authentication across the board then this is not an option, as all requests will end in a 401 response.

I would like to see 401 being treated as a successful response for the purpose of determining the process health.

Need OS filter for execution

I have a build that is executed on different operation systems. Depending on the os I need to start different executables. Is it possible to configure the execution do be enabled depending on wheder windows, linux or macos is running the build? Maybe even the arc of the processor is relevant: x86 or x86_64.

Option to accept self-signed certificates

Using healthcheckUrl together with self-signed certificates currently fails. It would be great to have an option to accept them instead, as this is super useful for starting an https server on localhost.

Any way to skip?

is there any way to skip this process? We have a tendency to run mci with a -DSkipTests flag which has no need to start the containers.

java shutdown hooks not working

Shutdown hooks doesn't work when calling stop-all which calls process.destroy() function.
Is there a solution for that?

Shutdown hooks like this:
Runtime.getRuntime().addShutdownHook(new Thread(this::stop));

fail the build if the exec fails?

Is there a way to fail the build if the start goal fails to start the executable? I have a test that takes several minutes to run and i'd rather fail fast then wait for everything else to detect the failure

shutdown-all doesn't kill the processes

The Processes are not killed after intergration tests. It can be the same reason as in #51
Below the plugin configuration:

<groupId>com.bazaarvoice.maven.plugins</groupId> 
<artifactId>process-exec-maven-plugin</artifactId> 
<version>0.9</version> 
<executions> 
	<execution> 
		<id>start mock</id> 
		<phase>pre-integration-test</phase> 
		<goals> 
			<goal>start</goal> 
		</goals> 
		<configuration> 
			<name>start-mock</name> 
			<workingDir>${project.build.directory}/../../gui/src/main/app</workingDir> 
			<arguments> 
				<argument>npm.cmd</argument> 
				<argument>run</argument> 
				<argument>start-mock</argument> 
			</arguments> 
		</configuration> 
	</execution> 
	<execution> 
		<id>start angular</id> 
		<phase>pre-integration-test</phase> 
		<goals> 
			<goal>start</goal> 
		</goals> 
		<configuration> 
			<name>start-angular</name> 
			<workingDir>${project.build.directory}/../../gui/src/main/app</workingDir> 
			<arguments> 
				<argument>npm.cmd</argument> 
				<argument>run</argument> 
				<argument>start-angular</argument> 
			</arguments> 
			<healthcheckUrl>http://localhost:4200</healthcheckUrl> 
		</configuration> 
	</execution> 
	<execution> 
		<id>stop-all</id> 
		<phase>post-integration-test</phase> 
		<goals> 
			<goal>stop-all</goal> 
		</goals> 
	</execution> 
</executions> 

Error shown when processes are skipped

We have used the tag to skip over running our processes, and we get this error. Build runs successfully but the error still persists.

Exception in thread "Thread-2" java.lang.NoClassDefFoundError: com/bazaarvoice/maven/plugin/process/CrossMojoState
        at com.bazaarvoice.maven.plugin.process.AbstractProcessMojo$1.run(AbstractProcessMojo.java:64)
Caused by: java.lang.ClassNotFoundException: com.bazaarvoice.maven.plugin.process.CrossMojoState
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 1 more
Exception in thread "Thread-5" Exception in thread "Thread-4" java.lang.NoClassDefFoundError: com/bazaarvoice/maven/plugin/process/CrossMojoState
        at com.bazaarvoice.maven.plugin.process.AbstractProcessMojo$1.run(AbstractProcessMojo.java:64)
java.lang.NoClassDefFoundError: com/bazaarvoice/maven/plugin/process/CrossMojoState
        at com.bazaarvoice.maven.plugin.process.AbstractProcessMojo$1.run(AbstractProcessMojo.java:64)
Exception in thread "Thread-3" java.lang.NoClassDefFoundError: com/bazaarvoice/maven/plugin/process/CrossMojoState
        at com.bazaarvoice.maven.plugin.process.AbstractProcessMojo$1.run(AbstractProcessMojo.java:64)

java.lang.ClassNotFoundException: com.bazaarvoice.maven.plugin.process.CrossMojoState

Thanks in advance for any help on this, can't tell what I'm doing wrong.
This should take 60 seconds for someone to reproduce:

I'm getting this exception:

java.lang.ClassNotFoundException: com.bazaarvoice.maven.plugin.process.CrossMojoState

I'm executing this:
mvn -X process-exec:start

Here is my executable jar file.

Here is my pom.xml file -- pretty trivial.

Here is the stdout with the exception.

The "arguments = []" and "[INFO] Starting process: null" in the output below suggest that my
<configuration> is probably not getting read....but I can't figure out why.

--Erik

[DEBUG] Configuring mojo com.bazaarvoice.maven.plugins:process-exec-maven-plugin:0.7:start from plugin realm ClassRealm[plugin>com.bazaarvoice.maven.plugins:process-exec-maven-plugin:0.7, parent: sun.misc.Launcher$AppClassLoader@55f96302] [DEBUG] Configuring mojo 'com.bazaarvoice.maven.plugins:process-exec-maven-plugin:0.7:start' with basic configurator --> [DEBUG] (f) arguments = [] [DEBUG] (f) skip = false [DEBUG] (f) waitAfterLaunch = 30 [DEBUG] (f) waitForInterrupt = false [DEBUG] (f) project = MavenProject: com.github.eostermueller.myWiremock:myWiremock:0.0.1-SNAPSHOT @ /Users/erikostermueller/Documents/src/jsource/process-exec-maven-plugin/pom.xml [DEBUG] -- end configuration -- [INFO] Full command line: [INFO] Starting process: null [INFO] Using working directory for this process: /Users/erikostermueller/Documents/src/jsource/process-exec-maven-plugin/target

stop process doesn't generate jacoco output file

I'm using the plugin to start a background process to run integration tests on it. The process is a java app. It's launched with the jacoco agent to have coverage data as follows:

<arguments>
     <argument>java</argument>
     <argument>-javaagent:org.jacoco.agent-0.7.2.201409121644-runtime.jar=destfile=${basedir}/target/itjacoco.exec</argument>
     <argument>-jar</argument>
     <argument>${basedir}/target/dependency/im-javase.jar</argument>
</arguments>

Nevertheless the itjacoco.exec file is empty at the end of the maven run. The processes are killed but it seems that in a way the jacoco agent doesn't know and it doesn't dump the coverage data. If I do a Ctrl+C during the execution of the maven goals, the coverage data is performed.

feature request: allow argument filename wildcards

It’d be great to be able to define the jar to run via regex.

That way with a working directory: ${basedir}/../../app/target you can just run the latest version.

<arguments>
    <argument>java</argument>
    <argument>-Dserver.port=8223</argument>
    <argument>-Dspring.profiles.active=dev-local</argument>
    <argument>-jar</argument>
    <argument>[^\\s]+.jar</argument>
</arguments>

Is this possible?

Can anyone help on generating the code coverage report using Jacoco?

I am trying to generate code coverage reports for integration testing of application. The respected .war file is deployed on jboss 7.

Steps I followed:

Step A: Modify / add JVM option in conf file

../jboss/bin/run-fiserver1.conf


JAVA_OPTS=" .. ---   javaagent:/opt/ondot/current/jboss/common/lib/jacocoagent.jar=destfile=/opt/jacoco/jacoco.exec,
includes=*,append=true,output=file 

Step B:Copy jacocoagent.jar jar file in jboss lib directory
../jboss/lib/jacocoagent.jar

Step C: Perform Testing by hitting app url on browser

Step D: Retstart Jboss ...Ouput: jacoco.exec file generated

Step E: Write build.xml ant file to generate reports[html,csv,xml] based on .exec file 

Step F: Copy jacocant.jar file in the path mentioned in build.xml

Step G: Run build.xml ant. it generated report.

The jacoco.exec file is generating empty on jboss shutdown.

Processes are not terminated after integration tests

We use your plugin on a Windows 7 machine and a Windows 8 machine. On Windows 7 it works perfectly and all processes that we start before the integration tests are terminated as expected. On Windows 8 though, the processes are not stopped and "live on".

To be more precisely, we start 3 Spring Boot Apps using mvn spring-boot:run in 3 separate directories.

Do you have any idea why we see this behavior and how we probably could fix it?

Thanks a lot for any support,

Michael

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.