Skip to content

Commit

Permalink
Improve management of non plugin related dependencies
Browse files Browse the repository at this point in the history
This closes #262
  • Loading branch information
pmouawad committed Nov 29, 2017
1 parent 01eb2be commit bda4a73
Show file tree
Hide file tree
Showing 5 changed files with 341 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/it/testplan-with-dependencies/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=clean verify
70 changes: 70 additions & 0 deletions src/it/testplan-with-dependencies/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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.lazerycode.jmeter</groupId>
<artifactId>testplan-with-dependencies-integration-test</artifactId>
<version>DEV-SNAPSHOT</version>

<description>Testplan that requires ActiveMQ jars to run JMS tests</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<repositories>
<repository>
<id>apache-snapshots</id>
<name>Apache Snapshots</name>
<url>https://repository.apache.org/content/groups/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<suppressJMeterOutput>false</suppressJMeterOutput>
<testFilesIncluded>
<testFilesIncluded>test.jmx</testFilesIncluded>
</testFilesIncluded>
<testPlanLibraries>
<artifact>org.apache.activemq:activemq-client:5.15.2</artifact>
<artifact>org.apache.activemq:activemq-broker:5.15.2</artifact>
<artifact>org.apache.activemq:activemq-spring:5.15.2</artifact>
</testPlanLibraries>
</configuration>
<executions>
<execution>
<id>configure</id>
<goals>
<goal>configure</goal>
</goals>
</execution>
<execution>
<id>performance test</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
26 changes: 26 additions & 0 deletions src/it/testplan-with-dependencies/src/test/jmeter/activemq.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker xmlns="http://activemq.apache.org/schema/core" useJmx="false" persistent="false">
<transportConnectors>
<transportConnector uri="tcp://localhost:61616"/>
</transportConnectors>
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="64 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="5000 mb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="5000 mb"/>
</tempUsage>
</systemUsage>
</systemUsage>
</broker>
</beans>
216 changes: 216 additions & 0 deletions src/it/testplan-with-dependencies/src/test/jmeter/test.jmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="3.4" jmeter="4.0-SNAPSHOT.20171129">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">true</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
</TestPlan>
<hashTree>
<SetupThreadGroup guiclass="SetupThreadGroupGui" testclass="SetupThreadGroup" testname="setUp Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">stoptest</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</SetupThreadGroup>
<hashTree>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="BSS_startActiveMQ" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="parameters"></stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="script">import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.BrokerFactory;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.commons.io.FileUtils;
import java.io.File;

String activemqFile = JMeterUtils.getJMeterHome()+ &quot;/testFiles/activemq.xml&quot;;
File file = new File(JMeterUtils.getJMeterHome(), &quot;activemq-data&quot;);
log.info(&quot;Deleting {}&quot;, file);
FileUtils.deleteDirectory(file);
log.info(&quot;Creating activemq config from {}&quot;, activemqFile);
try {
String path = activemqFile;
path = path.replace(&apos;\\&apos;, &apos;/&apos;);
path = path.replaceAll(&quot; &quot;, &quot;%20&quot;);
BrokerService broker = BrokerFactory.createBroker(&quot;xbean:file:&quot;+path, true);
props.put(&quot;ACTIVEMQ_BROKER&quot;, broker);
} catch(Exception ex) {
log.error(&quot;Error configuring ActiveMQ&quot;, ex);
}
</stringProp>
</JSR223Sampler>
<hashTree/>
<TestAction guiclass="TestActionGui" testclass="TestAction" testname="Think Time" enabled="true">
<intProp name="ActionProcessor.action">1</intProp>
<intProp name="ActionProcessor.target">0</intProp>
<stringProp name="ActionProcessor.duration">0</stringProp>
</TestAction>
<hashTree>
<UniformRandomTimer guiclass="UniformRandomTimerGui" testclass="UniformRandomTimer" testname="Pause" enabled="true">
<stringProp name="ConstantTimer.delay">1000</stringProp>
<stringProp name="RandomTimer.range">100</stringProp>
</UniformRandomTimer>
<hashTree/>
</hashTree>
</hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="TG-JMS-P2P" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<JMSSampler guiclass="JMSSamplerGui" testclass="JMSSampler" testname="JMS-P2P-DefaultCorrelationId" enabled="true">
<stringProp name="JMSSampler.queueconnectionfactory">ConnectionFactory</stringProp>
<stringProp name="JMSSampler.SendQueue">dynamicQueues/requestQueue0</stringProp>
<stringProp name="JMSSampler.ReceiveQueue">dynamicQueues/requestQueue0</stringProp>
<boolProp name="JMSSampler.isNonPersistent">false</boolProp>
<boolProp name="JMSSampler.useReqMsgIdAsCorrelId">true</boolProp>
<stringProp name="JMSSampler.timeout"></stringProp>
<stringProp name="HTTPSamper.xml_data">Test</stringProp>
<stringProp name="JMSSampler.initialContextFactory">org.apache.activemq.jndi.ActiveMQInitialContextFactory</stringProp>
<stringProp name="JMSSampler.contextProviderUrl">tcp://localhost:61616</stringProp>
<elementProp name="JMSSampler.jndiProperties" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<elementProp name="arguments" elementType="JMSProperties">
<collectionProp name="JMSProperties.properties"/>
</elementProp>
<boolProp name="JMSSampler.useResMsgIdAsCorrelId">true</boolProp>
<intProp name="JMSSampler.communicationStyle">1</intProp>
</JMSSampler>
<hashTree>
<ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
<collectionProp name="Asserion.test_strings">
<stringProp name="2603186">Test</stringProp>
</collectionProp>
<stringProp name="Assertion.test_field">Assertion.response_data</stringProp>
<boolProp name="Assertion.assume_success">false</boolProp>
<intProp name="Assertion.test_type">16</intProp>
</ResponseAssertion>
<hashTree/>
</hashTree>
</hashTree>
<PostThreadGroup guiclass="PostThreadGroupGui" testclass="PostThreadGroup" testname="tearDown Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</PostThreadGroup>
<hashTree>
<ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer" enabled="true">
<stringProp name="ConstantTimer.delay">1100</stringProp>
</ConstantTimer>
<hashTree/>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="BSS_stopActiveMQ" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="parameters"></stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="script">import org.apache.activemq.broker.BrokerService;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.commons.io.FileUtils;

BrokerService broker = props.get(&quot;ACTIVEMQ_BROKER&quot;);
broker.stop();

FileUtils.deleteDirectory(new File(JMeterUtils.getJMeterHome(), &quot;activemq-data&quot;));
</stringProp>
</JSR223Sampler>
<hashTree/>
</hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>false</time>
<latency>false</latency>
<timestamp>false</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<threadCounts>true</threadCounts>
<sampleCount>true</sampleCount>
</value>
</objProp>
<stringProp name="filename">JMS_TESTS.csv</stringProp>
<stringProp name="TestPlan.comments">Clear messages on Send Queue requestQueue6:1 message(s) removed</stringProp>
</ResultCollector>
<hashTree/>
<ResultCollector guiclass="SimpleDataWriter" testclass="ResultCollector" testname="Simple Data Writer" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>false</time>
<latency>false</latency>
<timestamp>false</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>true</xml>
<fieldNames>false</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<threadCounts>true</threadCounts>
<sampleCount>true</sampleCount>
</value>
</objProp>
<stringProp name="filename">JMS_TESTS.xml</stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>
30 changes: 28 additions & 2 deletions src/main/java/com/lazerycode/jmeter/mojo/ConfigureJMeterMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,24 @@ public class ConfigureJMeterMojo extends AbstractJMeterMojo {
* A list of artifacts that should be copied into the lib/junit directory e.g.
* <p/>
* &lt;junitLibraries&gt;
* &nbsp;&nbsp;&lt;artifact&gt;com.lazerycode.junit:junit-test:1.0.0&lt;/artifact&gt;
* &nbsp;&nbsp;&lt;artifact&gt;com.foo.project.junit:junit-test:1.0.0&lt;/artifact&gt;
* &lt;junitLibraries&gt;
*/
@Parameter
protected List<String> junitLibraries = new ArrayList<>();

/**
* A list of artifacts that are used by the test like JMS activemq.
* In a Non Maven JMeter configuration, these libraries would be copied into the lib/ directory
* The maven plugin will copy those in lib/ folder of the built jmeter configuration
* e.g.
* <p/>
* &lt;testPlanLibraries&gt;
* &nbsp;&nbsp;&lt;artifact&gt;org.apache.activemq:activemq-client:5.15.2&lt;/artifact&gt;
* &lt;junitLibraries&gt;
*/
@Parameter
protected List<String> testPlanLibraries = new ArrayList<>();

/**
* Absolute path to JMeter custom (test dependent) properties file.
Expand Down Expand Up @@ -239,6 +252,7 @@ public class ConfigureJMeterMojo extends AbstractJMeterMojo {

/**
* Path under which .properties files are stored.
* Defaults to ${basedir}/src/test/jmeter
*/
@Parameter(defaultValue = "${basedir}/src/test/jmeter")
protected File propertiesFilesDirectory;
Expand Down Expand Up @@ -274,7 +288,7 @@ public class ConfigureJMeterMojo extends AbstractJMeterMojo {

/**
* Set the format of the results generated by JMeter
* Valid values are: xml, csv (XML set by default).
* Valid values are: xml, csv (CSV set by default).
*/
@Parameter(defaultValue = "csv")
protected String resultsFileFormat;
Expand All @@ -301,12 +315,24 @@ public void doExecute() throws MojoExecutionException, MojoFailureException {
getLog().info(LINE_SEPARATOR);
getLog().info(" Configuring JMeter...");
getLog().info(LINE_SEPARATOR);
getLog().info(" Building JMeter directory structure...");
generateJMeterDirectoryTree();
getLog().info(" Configuring JMeter artifacts :"+jmeterArtifacts);
configureJMeterArtifacts();
getLog().info(" Populating JMeter directory ...");
populateJMeterDirectoryTree();
getLog().info(" Copying extensions "+jmeterExtensions+" to JMeter lib/ext directory "
+libExtDirectory+" with downloadExtensionDependencies set to "+downloadExtensionDependencies+" ...");
copyExplicitLibraries(jmeterExtensions, libExtDirectory, downloadExtensionDependencies);
getLog().info(" Copying JUnit libraries "+junitLibraries+" to JMeter junit lib directory "
+libJUnitDirectory+" with downloadLibraryDependencies set to "+downloadLibraryDependencies+" ...");
copyExplicitLibraries(junitLibraries, libJUnitDirectory, downloadLibraryDependencies);
getLog().info(" Copying test libraries "+testPlanLibraries+" to JMeter lib directory "
+libDirectory+" with downloadLibraryDependencies set to "+downloadLibraryDependencies+" ...");
copyExplicitLibraries(testPlanLibraries, libDirectory, downloadLibraryDependencies);
getLog().info(" Configuring jmeter properties ...");
configurePropertiesFiles();
getLog().info(" Generating JSON Test config ...");
generateTestConfig();
JMeterConfigurationHolder.getInstance().freezeConfiguration();
}
Expand Down

0 comments on commit bda4a73

Please sign in to comment.