Skip to content
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

Performance Code Integration #43

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
79 changes: 76 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
version: 2
version: 2.1
parameters:
run_performancetesting:
default: false
type: boolean
run_basedeployment:
default: true
type: boolean
defaults: &defaults
docker:
- image: circleci/python:2.7-stretch-browsers
Expand Down Expand Up @@ -37,7 +44,17 @@ builddeploy_steps: &builddeploy_steps
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar
source buildenvvar
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}

#testing code changes
if [[ true ]]; then
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-qa-v1-appvar
source buildenvvar
curl --request POST \
--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_basedeployment": false, run_performancetesting":true}}'
fi

jobs:
# Build & Deploy against development backend
"build-dev":
Expand All @@ -56,9 +73,48 @@ jobs:
APPNAME: "member-api-v5"
steps: *builddeploy_steps

"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: target/jmeter/reports

workflows:
version: 2
build:
when: << pipeline.parameters.run_basedeployment >>
jobs:
# Development builds are executed on "develop" branch only.
- "build-dev":
Expand All @@ -74,4 +130,21 @@ workflows:
context : org-global
filters:
branches:
only: master
only: master

Performance Testing:
when: << pipeline.parameters.run_performancetesting >>
jobs:
# Performance Test is executed on "feature/performance" branch only.
- Hold [Performance-Testing]:
type: approval
- Performance-Testing:
context : org-global
requires:
- Hold [Performance-Testing]
filters:
branches:
only:
- develop
- feature/performance
- 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>Member 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