HOw to run Jmeter tests with Maven? - maven

Can someone suggest how to run Jmeter tests with Maven please? This is just a simple jmeter script with http call to google.com with no variables. Just want to start with a simple one.
I've created the path C:\Jmeterautomation\src\test\jmeter\google.jmx that maven recognizes
I've created pom.xml in this directory C:\Jmeterautomation
This is what pom looks like
<?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>
<groupId>com.adp.ds.services</groupId>
<artifactId>01-run-with-Maven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-Maven-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
when I open command window, and go to this C:\Jmeterautomation and type mvn verify, I'm getting error mvn is not recognized as internal or external command
I've download this jmeter-maven-plugin-1.4.1.jar and kept in C:\Jmeter\apache-jmeter-2.13\lib\ext.
what am I doing wrong here?Tried all possible ways that I know off,Is there any step by step instructions that can go through the process, please suggest.
Thanks in advance

I'm getting error mvn is not recognized as internal or external command
Please install maven first:
https://maven.apache.org/guides/getting-started/windows-prerequisites.html

Related

get error when i try to consume spec openapi in service project backbase

I'm following A tutorial in backbase academy exactly in chapter "Backbase Backend Essentials Course - Service SDK and Direct Integration Services" and i get error when i try to consume specification from service project , this is the error
exchange-rate-service: Compilation failure: Compilation failure:
symbol: method requiredMode()
[ERROR] location: #interface Schema
and this is my pom.xml of spec project
<?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>
<parent>
<groupId>com.backbase.buildingblocks</groupId>
<artifactId>backbase-openapi-spec-starter-parent</artifactId>
<version>11.3.0</version>
</parent>
<groupId>com.backbase.training</groupId>
<artifactId>exchange-rate-specification</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Backbase :: Exchange Rate Specification</name>
<properties>
<!-- plugin versions -->
<boat-maven-plugin.version>0.4.0</boat-maven-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.backbase.oss</groupId>
<artifactId>boat-maven-plugin</artifactId>
<version>${boat-maven-plugin.version}</version>
<executions>
<execution>
<id>boat-validation</id>
<phase>generate-sources</phase>
<goals>
<goal>validate</goal>
</goals>
<configuration>
<input>${project.basedir}/src/main/resources/openapi.yaml</input>
<failOnWarning>true</failOnWarning>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
even with this project i get the same error
https://github.com/Backbase/documentation-code-samples/tree/master/service-sdk/11.0.0/create-openapi-spec-project
these is the steps that i followed :
1.download project from github
2.run cmd "mvn clean install" on project "messaging-api"
until now i get BUILD SUCCESS
3. run cmd "mvn clean install" on project "messaging-service"
i get this error
ErrorItem.java:[67,3] error: cannot find symbol
symbol: class Schema
location: class ErrorItem

JMeter Maven Plugin - How to provide external Properties file while running JUnit Performance Tests

I want to run JUnit tests for the performance testing using JMeter Maven Plugin.
During the JUnit tests run, I use one external properties file located inside <project>/src/resources/env.properties
This file has some configuration which I need to run the tests successfully.
I have given this file in src/test/jmeter location as well but the plugin is not picking up this file.
During performance tests run using JMeter Maven Plugin, This file is not found because of the relative path given inside JUnit tests as
String fileName = "src/resources/env.properties";
I get the below error during the JMeter test run
[INFO] fileName = env.properties
[INFO] java.io.FileNotFoundException: src/resources/env.properties (No such file or directory)
Can you please help, where to give the location of this file? do I need to give in pom.xml?
These tests working perfectly fine using the JMeter application where I put this file under <JMeterApp>/bin/src/resources and run the test.
Please find below pom.xml file
<?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>
<groupId>com</groupId>
<artifactId>myProject</artifactId>
<version>1.0-SNAPSHOT</version>
<name>MyProject</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<!-- Generate JMeter configuration -->
<execution>
<id>configuration</id>
<goals>
<goal>configure</goal>
</goals>
</execution>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<!-- Fail build on errors in test -->
<execution>
<id>jmeter-check-results</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
<configuration>
<generateReports>true</generateReports>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins:pom:1.4.0</artifact>
<artifact>kg.apc:jmeter-plugins-json:2.7</artifact>
</jmeterExtensions>
<junitLibraries>
<artifact>com:myProject:1.0-SNAPSHOT</artifact>
</junitLibraries>
<propertiesFilesDirectory>src/test/jmeter/src/resources</propertiesFilesDirectory>
<downloadExtensionDependencies>false</downloadExtensionDependencies>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
When you run your tests via JMeter Maven Plugin the current working directory looks like:
your_project\target\some-guid-like-structure\jmeter\bin
so in order to access the file which lives under your_project\src\resources you need to refer it like:
String fileName = "../../../../src/resources/env.properties";
More information: How to Use the JMeter Maven Plugin

Properties defined in the properties section of the POM are not seen in external ant build file

I'm using maven-antrun-plugin in my pom.xml with external ant file.
It's said in plugin's document:
All of the properties available to Maven are also available in the
target configuration. However, you may want to call an external Ant
build script using the ant task. To avoid name conflicts, only a
subset of the properties are passed to the external Ant build. These
include all properties defined in the properties section of the POM.
It also includes prefixed versions of some of the commonly used Maven
properties.
So here's my pom, where I define "test.prop" property:
<?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>
<groupId>testant</groupId>
<artifactId>testant</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<test.prop>TestPropValue</test.prop>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>optional</artifactId>
<version>1.5.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-index-properties</id>
<phase>install</phase>
<configuration>
<tasks>
<!--<property name="test.prop" value="${test.prop}"/>-->
<ant antfile="build.xml">
<target name="echo-prop"/>
</ant>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And just trying to echo this property in build.xml:
<project default="test">
<target name="echo-prop">
<echo>${test.prop}</echo>
</target>
</project>
This is what I get:
echo-prop:
[echo] ${test.prop}
So property is not resolved as it should, according to the doc.
And it works fine only in case if I uncomment line with explicit property declaration under "tasks" tag.
Could you please help me in understanding, what am I doing wrong?
Thank you!
You should specify a version for the antrun-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version><!--$NO-MVN-MAN-VER$-->
(...)
</plugin>
ant by default passes all properties of the parent to an underlying "ant"-call. Unless you define inheritAll=false, all properties are passed.
In this case, you should have a look at the effective pom. There a very ancient version of the antrun-plugin is defined.
As soon as you switch to a recent one, the example code works.

Maven flyway 4.0.3 - Executing multiple databases as part of a single pom

I read a lot of articles (on flyway and stackoverflow) before deciding to open a question. Mostly the solutions how to setup your pom for executing multiple databases using maven and flyway surround around version 3.0 of flyway.
I have a requirement where I have to connect to multiple schemas using different user accounts and execute totally different SQL's using flyway.
I tried to setup my pom as per article, but it fails to recognize multiple execution tags and also the id. It throws the error message
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:4.0.3:migrate (default-cli) on project Flyway_001: org.flywaydb.core.api.FlywayExce
ption: Unable to connect to the database. Configure the url, user and password! -> [Help 1]
My pom looks like
<?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>
<groupId>com.flyway</groupId>
<artifactId>Flyway_001</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}-${project.version}</name>
<properties>
<A.db.user>A_DB_USER</A.db.user>
<A.db.password>*******</A.db.password>
<A.db.schema>A_DB_SCHEMA</A.db.schema>
<A.db.url>jdbc:oracle:blah..blah</A.db.url>
<B.db.user>B_DB_USER</B.db.user>
<B.db.password>*******</B.db.password>
<B.db.schema>B_DB_SCHEMA</B.db.schema>
<B.db.url>jdbc:oracle:blah..blah</B.db.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>4.0.3</version>
<executions>
<execution>
<id>flyway-A</id>
<configuration>
<url>${A.db.url}</url>
<user>${A.db.user}</user>
<password>${A.db.password}</password>
<schemas>
<schema>${A.db.schema}</schema>
</schemas>
<table>T_HUB_SCHEMA_VERSION</table>
<baselineOnMigrate>false</baselineOnMigrate>
<locations>
<location>filesystem:src/main/resources/db/A</location>
</locations>
</configuration>
</execution>
<execution>
<id>flyway-B</id>
<configuration>
<url>${B.db.url}</url>
<user>${B.db.user}</user>
<password>${B.db.password}</password>
<schemas>
<schema>${B.db.schema}</schema>
</schemas>
<table>T_HUB_SCHEMA_VERSION</table>
<baselineOnMigrate>false</baselineOnMigrate>
<locations>
<location>filesystem:src/main/resources/db/B</location>
</locations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Has anyone tried connecting to multiple DB's using flyway 4.0? If so will appreciate if someone can give some guidance on whats wrong with my approach.
IDE complained about tags under execution element. Was able to get rid of the complains by specifying the goals tag like so:
<execution>
<id>some-id</id>
<goals>
<goal>migrate</goal>
</goals>
</execution>

copy jars used by plugin to single folder using Maven

In my POM.xml other the plugin configuration, i am not required to configure any dependenices to run the plugin. I would like to download dependent jars used by plugin(soapui-maven-plugin) from the repository into one single folder. I tried the command "mvn dependency:copy-dependencies", but no jars are copied. Is there any way to do it?
<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>
<groupId>service.report</groupId>
<artifactId>service-report</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven 2 SoapUI Sample</name>
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>loadtest</goal>
</goals>
<configuration>
<projectFile>${basedir}/src/main/resources/xxxxx-soapui-project.xml</projectFile>
<testSuite>xxxx</testSuite>
<testCase>sssss</testCase>
<loadTest>LoadTest 1</loadTest>
<outputFolder>${basedir}/target/surefire</outputFolder>
<junitReport>true</junitReport>
<exportAll>true</exportAll>
<printReport>true</printReport>
<testFailIgnore>false</testFailIgnore>
<!-- <projectProperties>
<value>message=Hello World!</value>
</projectProperties> -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
mvn dependency:copy-dependencies is only applied to current maven module only. It won't works on plugins. If you want to download all soapui-maven-plugin dependencies, you need to execute command from soapui-maven-plugin project. You can follow the following steps. I assumed you familiar with GIT CLI. If not, you need to manually download from https://github.com/SmartBear/soapui
git clone https://github.com/SmartBear/soapui
cd soapui/soapui-maven-plugin
mvn dependency:copy-dependencies
You can get list of dependencies in soapui/soapui-maven-plugin/target/dependency (total 82files)
[ERROR] Failed to execute goal on project soapui-maven-plugin: Could not resolve dependencies for project com.smartbear.soapui:soapui-maven-plugin:maven-plugin:5.0.0: Could not find artifact javafx:jfxrt:jar:2.2 at specified path (your jdk path)
If you get the above error, it means your maven jdk is version jdk.1.7 (u6 or earlier) which is not installed with javafx. Download newer jdk that comes with javafx at http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html . Remember change your maven jdk to this newer jdk.
If you want to use the dependency-plugin you could add the dependencies to the pom...and download with the depepndency-plugin...
It works right for me...
<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>
<groupId>com.ab.forge.utility.copydependenciespom</groupId>
<artifactId>copydependenciespom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<!-- BINARIES -->
<dependencies>
<!--CUSTOMER RETURN -->
<dependency>
<groupId>com.ab...</groupId>
<artifactId>customerret.....</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<overWriteIfNewer>true</overWriteIfNewer>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<excludeGroupIds>com.ab.ah.scad.acl</excludeGroupIds>
<excludeTypes>pom</excludeTypes>
<includeGroupIds>com.ab.oneleo</includeGroupIds>
<outputDirectory>${outputDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
After I just run the install passing the -DoutputDirectory parameter....
Try this...
To view all the plugin dependencies you can run a dependency:tree on the pom (where the plugin in configured)

Resources