Jmeter Maven Plugin - Remote server config with parameters in pom.xml - jmeter

I am trying to execute a jmeter test using the maven plugin on a remote server leveraging a pom.xml file that is completely parameterized as below.(I was able to successfully run a maven-jmeter remote test, where the servername, port, protocol and other info are all hard coded in the jmx file.
My pom.xml file is below
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jmeter-demo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>jmeter-demo</name>
<url>http://maven.apache.org</url>
<description>
Executes a JMeter test.
</description>
<properties>
<webapp.protocol>http</webapp.protocol>
<!--<webapp.host>www.mozilla.com</webapp.host>-->
<webapp.host>fsa-mia-dev2.fsalabs.io</webapp.host>
<webapp.port>80</webapp.port>
<test.duration>30</test.duration>
<test.threads>10</test.threads>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.9.0</version>
<executions>
<execution>
<!--
1)
first test run warms up the webserver.
Used to fill caches.
With a different set of properties since it runs much shorter than a normal test
and also the rate of requests/second may be much lower.
Maybe also use a different URL set.
-->
<id>warmup</id>
<phase>integration-test</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<propertiesUser>
<!--Accesses urls for warmup (compiles JSPs, fills caches, ...)-->
<!--************Setup Config for Threadgroup 23***************-->
<threadgroup23.name>S23_SFA_Org_CO</threadgroup23.name>
<threadgroup23.Transactionname>T23_SFA_Org_CO</threadgroup23.Transactionname>
<threadgroup23.ThinkTime>5000</threadgroup23.ThinkTime>
<threadgroup23.comment>T23_SFA_Org_CO</threadgroup23.comment>
<!--number of threads to use-->
<threadgroup23.numberOfThreads>5</threadgroup23.numberOfThreads>
<!--delay of the test in seconds-->
<threadgroup23.scheduledDelay>0</threadgroup23.scheduledDelay>
<!--duration of the test in seconds-->
<threadgroup23.scheduledDuration>60</threadgroup23.scheduledDuration>
<!--how long till all threads are up and running in seconds-->
<threadgroup23.rampUp>1</threadgroup23.rampUp>
<threadgroup23.dataFile>/home/ubuntu/mproj/data/S23_SFA_Org_CO.dat</threadgroup23.dataFile>
</propertiesUser>
</configuration>
</execution>
</executions>
<configuration>
<testFilesIncluded>
<testFilesIncluded>01_SA_CU_GetCPS.jmx</testFilesIncluded>
</testFilesIncluded>
<!-- protocol, server and port of tested webapp -->
<propertiesUser>
<protocol>${webapp.protocol}</protocol>
<server>${webapp.host}</server>
<port>${webapp.port}</port>
</propertiesUser>
<resultsFileFormat>csv</resultsFileFormat>
<testResultsTimestamp>false</testResultsTimestamp>
<ignoreResultFailures>true</ignoreResultFailures>
<remoteConfig>
<startServersBeforeTests>true</startServersBeforeTests>
<serverList>10.36.14.170</serverList>
</remoteConfig>
<suppressJMeterOutput>false</suppressJMeterOutput>
<propertiesSystem>
</propertiesSystem>
<propertiesJMeter><log_level.jmeter>DEBUG</log_level.jmeter></propertiesJMeter>
</configuration>
</plugin>
</plugins>
</build>
</project>
The issue is.. jmeter-server detects a request to execute and almost immediately stops.
Here is the info from log file post run
[debug] JMeter is called with the following command line arguments: -n -t /home/ubuntu/mProj/src/test/jmeter/01_SA_CU_GetCPS.jmx -l /home/ubuntu/mProj/target/jmeter/results/01_SA_CU_GetCPS.csv -d /home/ubuntu/mProj/target/jmeter -j /home/ubuntu/mProj/target/jmeter/logs/01_SA_CU_GetCPS.jmx.log -r -R 10.36.14.170
[info] Executing test: 01_SA_CU_GetCPS.jmx
[info] Created the tree successfully using /home/ubuntu/mProj/src/test/jmeter/01_SA_CU_GetCPS.jmx
[info] Configuring remote engine for 10.36.14.170
[info] Using remote object: UnicastRef [liveRef: [endpoint:[10.36.14.170:37913](remote),objID:[-10468c89:14fba100421:-7fff, -1854422229136130507]]]
[info] Starting remote engines
[info] Starting the test # Fri Sep 11 01:42:27 UTC 2015 (1441935747716)
[info] Remote engines have been started
[info] Waiting for possible shutdown message on port 4445
[info] Tidying up remote # Fri Sep 11 01:42:29 UTC 2015 (1441935749973)
[info] Completed Test: 01_SA_CU_GetCPS.jmx
[INFO]
[INFO] Test Results:
[INFO]
[INFO] Tests Run: 1, Failures: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25.280s
[INFO] Finished at: Fri Sep 11 01:42:35 UTC 2015
[INFO] Final Memory: 11M/57M
[INFO] ------------------------------------------------------------------------
(The pom-file works well without the remoteConfig - in localhost)
(There's no networking issues any where and the remote server is able to access the host and works when servername, port, protocol is hardcoded in jmx files)
Is this a known limitation of the maven-jmeter plugin?

First use a recent version of jmeter-maven-plugin, 2.8.3 as of 15th january 2019.
To pass parameters, enter in pom.xml as child of configuration:
<propertiesJMeter>
<BUILD_TAG>${project.version}</BUILD_TAG>
<threads>7</threads>
<duration>30</duration>
</propertiesJMeter>
And in jmeter, to use threads for example, you would use __P function:
${__P(threads,5)
This blog explains the whole process.

Related

OWASP Tricks to speed up vulnerabilities checks

I use the maven project with the OWASP plugin to check the vulnerabilities on each commit in the CI pull requests.
The configuration looks pretty simple
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>${version.dependency-check-maven}</version>
<executions>
<execution>
<goals>
<goal>aggregate</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
<configuration>
<showSummary>true</showSummary>
<!-- this will work only in the top-level maven module -->
<suppressionFile>${user.dir}/owasp-suppressions.xml</suppressionFile>
<format>ALL</format>
<failBuildOnAnyVulnerability>true</failBuildOnAnyVulnerability>
<!-- alternative: fail on level (High starts at 7, Critical at 9) -->
<!-- <failBuildOnCVSS>4</failBuildOnCVSS> -->
<assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
<cveUrlModified>address of the NVD local mirror</cveUrlModified>
<cveUrlBase>address of the NVD local mirror</cveUrlBase>
<cveWaitTime>1</cveWaitTime> <!--value in milliseconds, default is 4000-->
</configuration>
</plugin>
For CI builds I use PROW - https://docs.prow.k8s.io/docs/overview/
For local mirror approach is described here https://jeremylong.github.io/DependencyCheck/data/mirrornvd.html and the mirror is used from here https://github.com/stevespringett/nist-data-mirror/
Still the process to download CVEs from mirror takes quite a lot of time (around 3 minutes). From the logs I can see the most of time is spent on downloading CVEs
[INFO] Download Started for NVD CVE - 2003
[INFO] Download Complete for NVD CVE - 2003 (5 ms)
[INFO] Processing Started for NVD CVE - 2003
[INFO] Processing Complete for NVD CVE - 2002 (4608 ms)
[INFO] Processing Complete for NVD CVE - 2003 (1131 ms)
...
and for doing some DB maintenance?
[INFO] Begin database maintenance
[INFO] Updated the CPE ecosystem on 128773 NVD records
[INFO] Removed the CPE ecosystem on 3604 NVD records
[INFO] End database maintenance (13482 ms)
[INFO] Begin database defrag
[INFO] End database defrag (3765 ms)
[INFO] Check for updates complete (112132 ms)
Do you know any tricks to speed up OWASP checks?
This was replied on this other thread: How to cache OWASP dependecy check NVD database on CI
Basically you need to tell PROW to cache the location of the NVD database which when using the Maven plugin is:
$MAVEN_HOME/.m2/repository/org/owasp/dependency-check-data/7.0/nvdcache/
** Considering that you use Dependency-Check version 7.+

nexus-staging-maven-plugin refuse to upload after deferred deployment

I have a multi-module project that has nexus-staging-maven-plugin configured in parent pom.xml:
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.6</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<!--<autoReleaseAfterClose>true</autoReleaseAfterClose>-->
</configuration>
</plugin>
By default it should be inherited by all submodules (except those disabled using technique in How to disable nexus-staging-maven-plugin in sub-modules)
However, when I start deployment:
mvn clean deploy -DskipTests=true -Prelease-sign-artifacts -Dgpg.passphrase=*****
I see the following message:
[INFO] Installing Nexus Staging features:
[INFO] ... total of 5 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
...
[INFO] --- nexus-staging-maven-plugin:1.6.6:deploy (injected-nexus-deploy) # spookystuff-core ---
[INFO] Performing deferred deploys (gathering into "/home/peng/git/spookystuff/target/nexus-staging/deferred")...
[INFO] Installing /home/peng/git/spookystuff/core/target/spookystuff-core-0.3.2-SNAPSHOT.jar to /home/peng/git/spookystuff/target/nexus-staging/deferred/com/tribbloids/spookystuff/spookystuff-core/0.3.2-SNAPSHOT/spookystuff-core-0.3.2-SNAPSHOT.jar
...
[INFO] Reactor Summary:
...
[INFO] BUILD SUCCESS
No upload happens whatsoever. The artifact that should be uploaded to nexus were still cached under:
/target/nexus-staging/deferred
but neither the log nor nexus server record indicates that it has been uploaded. What has been wrong here and what should I do to fix it?

How to redeploy a war on remote Tomcat 7 using maven-tomcat-plugin

I am trying to redeploy a war from my local machine to a remote Tomcat 7 using command prompt in Windows. I am able to upload the war with the tomcat-maven-plugin for the first time but subsequent uploads gives me a message something like this.
pom.xml
<!-- Deploy to Remote Tomcat -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>${unix.tomcat.url}</url>
<server>sandbox-tomcat</server>
<path>/${project.artifactId}</path>
</configuration>
</plugin>
Maven Command:
mvn tomcat7:redeploy
Maven Log:
[INFO] Deploying war to http://secdevapp11.gspt.net:8080/istore-tax-service
Uploading: http://secdevapp11.gspt.net:8080/manager/text/deploy?path=%2Fistore-tax-service&update=true
Uploaded: http://secdevapp11.gspt.net:8080/manager/text/deploy?path=%2Fistore-tax-service&update=true (1334 KB at 512.7 KB/sec)
[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] FAIL - Unable to delete [/nfs/home_04/chandeln/installations/apache-tomcat-7.0.52/webapps/istore-tax-service]. The continued presence of this file may cause problems.
[INFO] FAIL - Application already exists at path /istore-tax-service
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.704s
[INFO] Finished at: Wed Mar 26 15:34:55 EDT 2014
[INFO] Final Memory: 21M/224M
[INFO] ------------------------------------------------------------------------
I also had this problem.
For me it worked putting in the update-tag in the tomcat-plugin
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
...
<update>true</update>
...
and using the tomcat7:deploy command (and not 'redeploy') again.
(just noticed the answer still was there..., sorry for duplicating)
This happens probably due to the file being locked by tomcat.
you can unlock it by adding <Context antiResourceLocking="true"> to tomcat context
Use
<update>true</update>
http://tomcat.apache.org/maven-plugin-2.2/tomcat7-maven-plugin/deploy-mojo.html#update
This problem happened to me when deploying maven application from Netbeans IDE 8.0.2 and path in context.xml was set with trailing slash.
<Context antiJARLocking="true" path="/foo/" />
Removing the trailing slash resolved the issue for me.
<Context antiJARLocking="true" path="/foo" />
I added antiJARLocking = "true" to my context.xml file as follows
<Context antiJARLocking = "true" path="/somepath" />
then right click on project and select "Clean and Build",
and RUN your project.
This worked for me.

Maven build hanged with release and gpg plugins

I've been struggling with a Maven 3.0.5 build, trying to deploy to Sonatype repo, using maven release plugin and maven gpg plugin in a Windows XP system. My problem is exactly the same as this SO question, but none of the solutions provided there is working for me.
The relevant fragments of my pom.xml are:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
<!-- see http://jira.codehaus.org/browse/MGPG-9 -->
<mavenExecutorId>forked-path</mavenExecutorId>
</configuration>
</plugin>
<profiles>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<configuration>
<passphrase>${gpg.passphrase}</passphrase>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<scm>
<connection>scm:git:https://github.com/pentasoft/s3-static-uploader.git</connection>
<developerConnection>scm:git:https://github.com/pentasoft/s3-static-uploader.git</developerConnection>
<url>https://github.com/pentasoft/s3-static-uploader</url>
<tag>s3-static-uploader-1.0</tag>
</scm>
The ouptut of my build is the following:
---
[INFO] BUILD SUCCESS
[INFO] ---------------------------------------------------------------------
---
[INFO] Total time: 29.737s
[INFO] Finished at: Fri Jul 05 15:58:20 CEST 2013
[INFO] Final Memory: 16M/40M
[INFO] ---------------------------------------------------------------------
---
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml s3-static-uploader-plugin\po
m.xml s3-static-uploader-example1\pom.xml"
[INFO] Working directory: c:\Inetpub\wwwroot\Pentasoft.git\s3-static-uploader
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: c:\Inetpub\wwwroot\Pentasoft.git\s3-static-uploader
[INFO] Executing: cmd.exe /X /C "git commit --verbose -F C:\DOCUME~1\jgg\CONFIG~
1\Temp\maven-scm-870876840.commit pom.xml s3-static-uploader-plugin\pom.xml s3-s
tatic-uploader-example1\pom.xml"
[INFO] Working directory: c:\Inetpub\wwwroot\Pentasoft.git\s3-static-uploader
[INFO] Executing: cmd.exe /X /C "git symbolic-ref HEAD"
[INFO] Working directory: c:\Inetpub\wwwroot\Pentasoft.git\s3-static-uploader
[INFO] Executing: cmd.exe /X /C "git push https://github.com/pentasoft/s3-static
-uploader.git master:master"
[INFO] Working directory: c:\Inetpub\wwwroot\Pentasoft.git\s3-static-uploader
The build hangs here.
I've tried all the solutions provided in the previously referenced SO question and all of them produce the same result.
After a long fight with this, there were two problems mainly. The first one was related to the urls specified in scm section of the pom.xml file. My schemas were https and github was prompting me for the user, but there were no output on the screen showing that prompt. So the first step was changing the url schemas to the following:
<scm>
<connection>scm:git:git#github.com:pentasoft/s3-static-uploader.git</connection>
<developerConnection>scm:git:git#github.com:pentasoft/s3-static-uploader.git</developerConnection>
<url>https://github.com/pentasoft/s3-static-uploader</url>
</scm>
where the https schemas have been replaced by the ssh schema.
After fixing this there was a second problem regarding to the ssh access to Github. When launching the build, Github was answering with the following:
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
As in the previous problem these prompt doesn't show and the feel is that the build is hanged again. In order to fix this, I issued the command ssh -T git#github.com (see this Github guide) and I answered yes to that question in order to avoid that prompt in the future.
After all this the build is not hanged anymore (following the instructions of #AWhitford in the previously referenced SO question).
May be all this would have been easier with a non Windows box...

Selenium tests failing in Unix

I am trying to integrate Selenium tests in Bamboo. I am able to invoke the tests on a Windows box but when I try to replicate the same on the Unix server I get the following error:
*rror 29-Aug-2012 17:03:54 17:03:54.792 WARN - Caution: '/usr/bin/google-chrome': file is a script file, not a real executable. The browser environment is no longer fully under RC control
build 29-Aug-2012 17:03:54 17:03:54.803 INFO - Launching Google Chrome...
build 29-Aug-2012 17:33:55 17:33:55.319 INFO - Killing Google Chrome...
build 29-Aug-2012 17:33:57 [INFO] ------------------------------------------------------------------------
build 29-Aug-2012 17:33:57 [INFO] BUILD FAILURE
build 29-Aug-2012 17:33:57 [INFO] ------------------------------------------------------------------------
build 29-Aug-2012 17:33:57 [INFO] Total time: 33:21.497s
build 29-Aug-2012 17:33:57 [INFO] Finished at: Wed Aug 29 17:33:57 BST 2012
build 29-Aug-2012 17:33:57 [INFO] Final Memory: 28M/164M
build 29-Aug-2012 17:33:57 [INFO] ------------------------------------------------------------------------
build 29-Aug-2012 17:33:57 [ERROR] Failed to execute goal org.codehaus.mojo:selenium-maven-plugin:2.3:selenese (test) on project iopscience-webapp: Execution test of goal org.codehaus.mojo:selenium-maven-plugin:2.3:selenese failed. SeleniumCommandTimedOutException -> [Help 1]*
I am using the selenium-maven-plugin to run the selenese tests suits. Following is the extract of my pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<browser>*googlechrome</browser>
<suite>Testsuite-UI.html</suite>
<startURL>http://localhost:8082/</startURL>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>integration-test</phase>
<goals>
<goal>selenese</goal>
</goals>
</execution>
</executions>
</plugin>
Please let me know if there is any specific configuration to be done on Linux to run the test suites?

Resources