Skip to content

Performance Test Code Integration #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ parameters:
run_automatedtesting:
default: false
type: boolean
run_performancetesting:
default: false
type: boolean
run_basedeployment:
default: true
type: boolean
Expand Down Expand Up @@ -54,7 +57,7 @@ builddeploy_steps: &builddeploy_steps
--url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \
--header "Circle-Token: ${QA_USER_TOKEN}" \
--header 'content-type: application/json' \
--data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_automatedtesting":true , "run_basedeployment": false}}'
--data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_performancetesting":true , "run_automatedtesting":true, "run_basedeployment": false}}'
fi


Expand Down Expand Up @@ -107,8 +110,44 @@ jobs:
npm run test:newman:clear
npm run test:newman
npm run test:newman:clear

"Performance-Testing":
docker:
# specify the version you desire here
- image: circleci/openjdk:8-jdk

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4

working_directory: ~/repo

environment:
# Customize the JVM maximum heap limit
MAVEN_OPTS: -Xmx3200m

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: mvn dependency:go-offline

- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}

- run: mvn verify

- store_artifacts:
path: ./newman
path: target/jmeter/reports

workflows:
version: 2
Expand Down Expand Up @@ -146,3 +185,19 @@ workflows:
only:
- develop
- dev-circleci

Performance Testing:
when: << pipeline.parameters.run_performancetesting >>
jobs:
# Performance Test is executed on "feature/performance" "develop" and "performance" branches only.
- Hold [Performance-Testing]:
type: approval
- Performance-Testing:
context : org-global
requires:
- Hold [Performance-Testing]
filters:
branches:
only:
- develop
- performance
230 changes: 230 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
<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.ubikingenierie.ubikloadpack</groupId>
<artifactId>jmeter-maven-plugin-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmeter-maven-plugin.version>2.9.0</jmeter-maven-plugin.version>
<jmeterScript>Resource API.jmx</jmeterScript>
</properties>
<dependencies>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>5.1</version>
</dependency>
</dependencies>
<build>
<plugins>

</plugins>
</build>
<profiles>
<profile>
<id>standalone</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>${jmeter-maven-plugin.version}</version>
<configuration>
<generateReports>true</generateReports>
<errorRateThresholdInPercent>60</errorRateThresholdInPercent>
<testResultsTimestamp>true</testResultsTimestamp>
<propertiesJMeter>
<BUILD_TAG>${project.version}</BUILD_TAG>
<threads>7</threads>
<duration>30</duration>
</propertiesJMeter>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins-casutg:2.8</artifact>
</jmeterExtensions>
<testPlanLibraries>
<artifact>com.ubikingenierie.ubikloadpack:jmeter-maven-plugin-demo:${project.version}</artifact>
</testPlanLibraries>
<excludedArtifacts>
<exclusion>org.slf4j:slf4j-nop</exclusion>
<exclusion>avalon-framework:*</exclusion>
<exclusion>org.apache.tika:*</exclusion>
<exclusion>excalibur-datasource:excalibur-datasource</exclusion>
<exclusion>excalibur-instrument:excalibur-instrument</exclusion>
<exclusion>excalibur-logger:excalibur-logger</exclusion>
<exclusion>excalibur-pool:*</exclusion>
<exclusion>org.beanshell:bsh:jar:2.0b5</exclusion>
</excludedArtifacts>
<jMeterProcessJVMSettings>
<arguments>
<argument>-XX:MaxMetaspaceSize=512m</argument>
<argument>-Xmx2048m</argument>
<argument>-Xms2048m</argument>
</arguments>
</jMeterProcessJVMSettings>
<testFilesIncluded>
<jMeterTestFile>${jmeterScript}</jMeterTestFile>
</testFilesIncluded>
<testFilesDirectory>./test/jmeter</testFilesDirectory>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
<goal>results</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>worker</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
project.properties["hostname"] = InetAddress.getLocalHost().getHostName()
</source>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>${jmeter-maven-plugin.version}</version>
<configuration>
<propertiesJMeter>
<server.rmi.ssl.disable>true</server.rmi.ssl.disable>
</propertiesJMeter>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins-casutg:2.8</artifact>
</jmeterExtensions>
<testPlanLibraries>
<artifact>com.ubikingenierie.ubikloadpack:jmeter-maven-plugin-demo:${project.version}</artifact>
</testPlanLibraries>
<excludedArtifacts>
<exclusion>org.slf4j:slf4j-nop</exclusion>
<exclusion>avalon-framework:*</exclusion>
<exclusion>org.apache.tika:*</exclusion>
<exclusion>excalibur-datasource:excalibur-datasource</exclusion>
<exclusion>excalibur-instrument:excalibur-instrument</exclusion>
<exclusion>excalibur-logger:excalibur-logger</exclusion>
<exclusion>excalibur-pool:*</exclusion>
<exclusion>org.beanshell:bsh:jar:2.0b5</exclusion>
</excludedArtifacts>
<jMeterProcessJVMSettings>
<arguments>
<argument>-XX:MaxMetaspaceSize=512m</argument>
<argument>-Xmx2048m</argument>
<argument>-Xms2048m</argument>
</arguments>
</jMeterProcessJVMSettings>
<exportedRmiHostname>${hostname}</exportedRmiHostname>
<serverPort>3010</serverPort>
</configuration>
<executions>
<execution>
<id>start-jmeter-server</id>
<goals>
<goal>remote-server</goal>
</goals>
<phase>verify</phase>
<configuration>
<runInBackground>false</runInBackground>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>controller</id>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>${jmeter-maven-plugin.version}</version>
<configuration>
<propertiesUser>
<server.rmi.ssl.disable>true</server.rmi.ssl.disable>
</propertiesUser>
<propertiesGlobal>
<BUILD_TAG>${project.version}</BUILD_TAG>
<threads>7</threads>
<duration>30</duration>
</propertiesGlobal>
<generateReports>true</generateReports>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins-casutg:2.8</artifact>
</jmeterExtensions>
<testPlanLibraries>
<artifact>com.ubikingenierie.ubikloadpack:jmeter-maven-plugin-demo:${project.version}</artifact>
</testPlanLibraries>
<excludedArtifacts>
<exclusion>org.slf4j:slf4j-nop</exclusion>
<exclusion>avalon-framework:*</exclusion>
<exclusion>org.apache.tika:*</exclusion>
<exclusion>excalibur-datasource:excalibur-datasource</exclusion>
<exclusion>excalibur-instrument:excalibur-instrument</exclusion>
<exclusion>excalibur-logger:excalibur-logger</exclusion>
<exclusion>excalibur-pool:*</exclusion>
<exclusion>org.beanshell:bsh:jar:2.0b5</exclusion>
</excludedArtifacts>
<jMeterProcessJVMSettings>
<arguments>
<argument>-XX:MaxMetaspaceSize=512m</argument>
<argument>-Xmx2048m</argument>
<argument>-Xms2048m</argument>
</arguments>
</jMeterProcessJVMSettings>
<remoteConfig>
<serverList>${serverList}</serverList>
<startAndStopServersForEachTest>true</startAndStopServersForEachTest>
</remoteConfig>
</configuration>
<executions>
<execution>
<id>performance-test</id>
<goals>
<goal>jmeter</goal>
<goal>results</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
52 changes: 52 additions & 0 deletions test/jmeter/JsonSample.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
import org.apache.jmeter.services.FileServer
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.ConcurrentHashMap

class JsonSampleHolder {
static samples =
MapWithDefault.newInstance(
new ConcurrentHashMap<String, JsonSample>(), { String f -> new JsonSample(f) }
)

static def next(file) {
return samples.get(file).next()
}
}

class JsonSample {
def data = null
def ite = null

JsonSample(file) {
if(data == null) {
def inputPath = FileServer.getFileServer().getBaseDir() + file
File inputFile = new File(inputPath)
def slurper = new JsonSlurper()
data = new ConcurrentLinkedQueue(slurper.parse(inputFile))
ite = data.iterator()
}
}
synchronized def next() {
if(!ite.hasNext()) {
ite = data.iterator()
}
return ite.next()
}
}


Thread thread = Thread.currentThread();
Long threadNum = thread.getId();
def value = JsonSampleHolder.next(args[0])
def json = JsonOutput.toJson(value)
log.info(threadNum + " : " + value)
vars.putObject(args[1], value)
vars.put(args[1] + "_json", json)

if(binding.hasVariable('SampleResult')) {
SampleResult.setContentType("application/json")
SampleResult.setResponseCodeOK()
SampleResult.setResponseData(json, "utf-8")
}
Loading