Skip to content

Commit f70d007

Browse files
committed
Performance Code
1 parent 7bfac47 commit f70d007

File tree

6 files changed

+6627
-3
lines changed

6 files changed

+6627
-3
lines changed

.circleci/config.yml

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
version: 2
1+
version: 2.1
2+
parameters:
3+
run_performancetesting:
4+
default: false
5+
type: boolean
6+
run_basedeployment:
7+
default: true
8+
type: boolean
29
defaults: &defaults
310
docker:
411
- image: circleci/python:2.7-stretch-browsers
@@ -37,7 +44,17 @@ builddeploy_steps: &builddeploy_steps
3744
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar
3845
source buildenvvar
3946
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}
40-
47+
#testing code changes
48+
if [[ true ]]; then
49+
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-qa-v1-appvar
50+
source buildenvvar
51+
curl --request POST \
52+
--url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \
53+
--header "Circle-Token: ${QA_USER_TOKEN}" \
54+
--header 'content-type: application/json' \
55+
--data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_basedeployment": false, run_performancetesting":true}}'
56+
fi
57+
4158
jobs:
4259
# Build & Deploy against development backend
4360
"build-dev":
@@ -56,9 +73,48 @@ jobs:
5673
APPNAME: "member-api-v5"
5774
steps: *builddeploy_steps
5875

76+
"Performance-Testing":
77+
docker:
78+
# specify the version you desire here
79+
- image: circleci/openjdk:8-jdk
80+
81+
# Specify service dependencies here if necessary
82+
# CircleCI maintains a library of pre-built images
83+
# documented at https://circleci.com/docs/2.0/circleci-images/
84+
# - image: circleci/postgres:9.4
85+
86+
working_directory: ~/repo
87+
88+
environment:
89+
# Customize the JVM maximum heap limit
90+
MAVEN_OPTS: -Xmx3200m
91+
92+
steps:
93+
- checkout
94+
95+
# Download and cache dependencies
96+
- restore_cache:
97+
keys:
98+
- v1-dependencies-{{ checksum "pom.xml" }}
99+
# fallback to using the latest cache if no exact match is found
100+
- v1-dependencies-
101+
102+
- run: mvn dependency:go-offline
103+
104+
- save_cache:
105+
paths:
106+
- ~/.m2
107+
key: v1-dependencies-{{ checksum "pom.xml" }}
108+
109+
- run: mvn verify
110+
111+
- store_artifacts:
112+
path: target/jmeter/reports
113+
59114
workflows:
60115
version: 2
61116
build:
117+
when: << pipeline.parameters.run_basedeployment >>
62118
jobs:
63119
# Development builds are executed on "develop" branch only.
64120
- "build-dev":
@@ -74,4 +130,21 @@ workflows:
74130
context : org-global
75131
filters:
76132
branches:
77-
only: master
133+
only: master
134+
135+
Performance Testing:
136+
when: << pipeline.parameters.run_performancetesting >>
137+
jobs:
138+
# Performance Test is executed on "feature/performance" branch only.
139+
- Hold [Performance-Testing]:
140+
type: approval
141+
- Performance-Testing:
142+
context : org-global
143+
requires:
144+
- Hold [Performance-Testing]
145+
filters:
146+
branches:
147+
only:
148+
- develop
149+
- feature/performance
150+
- performance

pom.xml

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.ubikingenierie.ubikloadpack</groupId>
5+
<artifactId>jmeter-maven-plugin-demo</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<properties>
8+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
9+
<jmeter-maven-plugin.version>2.9.0</jmeter-maven-plugin.version>
10+
<jmeterScript>Member API.jmx</jmeterScript>
11+
</properties>
12+
<dependencies>
13+
<dependency>
14+
<groupId>commons-codec</groupId>
15+
<artifactId>commons-codec</artifactId>
16+
<version>1.11</version>
17+
</dependency>
18+
<dependency>
19+
<groupId>org.slf4j</groupId>
20+
<artifactId>slf4j-api</artifactId>
21+
<version>1.7.25</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.apache.jmeter</groupId>
25+
<artifactId>ApacheJMeter_core</artifactId>
26+
<version>5.1</version>
27+
</dependency>
28+
</dependencies>
29+
<build>
30+
<plugins>
31+
32+
</plugins>
33+
</build>
34+
<profiles>
35+
<profile>
36+
<id>standalone</id>
37+
<activation>
38+
<activeByDefault>true</activeByDefault>
39+
</activation>
40+
<build>
41+
<plugins>
42+
<plugin>
43+
<groupId>com.lazerycode.jmeter</groupId>
44+
<artifactId>jmeter-maven-plugin</artifactId>
45+
<version>${jmeter-maven-plugin.version}</version>
46+
<configuration>
47+
<generateReports>true</generateReports>
48+
<errorRateThresholdInPercent>60</errorRateThresholdInPercent>
49+
<testResultsTimestamp>true</testResultsTimestamp>
50+
<propertiesJMeter>
51+
<BUILD_TAG>${project.version}</BUILD_TAG>
52+
<threads>7</threads>
53+
<duration>30</duration>
54+
</propertiesJMeter>
55+
<jmeterExtensions>
56+
<artifact>kg.apc:jmeter-plugins-casutg:2.8</artifact>
57+
</jmeterExtensions>
58+
<testPlanLibraries>
59+
<artifact>com.ubikingenierie.ubikloadpack:jmeter-maven-plugin-demo:${project.version}</artifact>
60+
</testPlanLibraries>
61+
<excludedArtifacts>
62+
<exclusion>org.slf4j:slf4j-nop</exclusion>
63+
<exclusion>avalon-framework:*</exclusion>
64+
<exclusion>org.apache.tika:*</exclusion>
65+
<exclusion>excalibur-datasource:excalibur-datasource</exclusion>
66+
<exclusion>excalibur-instrument:excalibur-instrument</exclusion>
67+
<exclusion>excalibur-logger:excalibur-logger</exclusion>
68+
<exclusion>excalibur-pool:*</exclusion>
69+
<exclusion>org.beanshell:bsh:jar:2.0b5</exclusion>
70+
</excludedArtifacts>
71+
<jMeterProcessJVMSettings>
72+
<arguments>
73+
<argument>-XX:MaxMetaspaceSize=512m</argument>
74+
<argument>-Xmx2048m</argument>
75+
<argument>-Xms2048m</argument>
76+
</arguments>
77+
</jMeterProcessJVMSettings>
78+
<testFilesIncluded>
79+
<jMeterTestFile>${jmeterScript}</jMeterTestFile>
80+
</testFilesIncluded>
81+
<testFilesDirectory>./test/jmeter</testFilesDirectory>
82+
</configuration>
83+
<executions>
84+
<execution>
85+
<id>jmeter-tests</id>
86+
<phase>verify</phase>
87+
<goals>
88+
<goal>jmeter</goal>
89+
<goal>results</goal>
90+
</goals>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
</plugins>
95+
</build>
96+
</profile>
97+
<profile>
98+
<id>worker</id>
99+
<build>
100+
<plugins>
101+
<plugin>
102+
<groupId>org.codehaus.groovy.maven</groupId>
103+
<artifactId>gmaven-plugin</artifactId>
104+
<version>1.0</version>
105+
<executions>
106+
<execution>
107+
<phase>generate-resources</phase>
108+
<goals>
109+
<goal>execute</goal>
110+
</goals>
111+
<configuration>
112+
<source>
113+
project.properties["hostname"] = InetAddress.getLocalHost().getHostName()
114+
</source>
115+
</configuration>
116+
</execution>
117+
</executions>
118+
</plugin>
119+
<plugin>
120+
<groupId>com.lazerycode.jmeter</groupId>
121+
<artifactId>jmeter-maven-plugin</artifactId>
122+
<version>${jmeter-maven-plugin.version}</version>
123+
<configuration>
124+
<propertiesJMeter>
125+
<server.rmi.ssl.disable>true</server.rmi.ssl.disable>
126+
</propertiesJMeter>
127+
<jmeterExtensions>
128+
<artifact>kg.apc:jmeter-plugins-casutg:2.8</artifact>
129+
</jmeterExtensions>
130+
<testPlanLibraries>
131+
<artifact>com.ubikingenierie.ubikloadpack:jmeter-maven-plugin-demo:${project.version}</artifact>
132+
</testPlanLibraries>
133+
<excludedArtifacts>
134+
<exclusion>org.slf4j:slf4j-nop</exclusion>
135+
<exclusion>avalon-framework:*</exclusion>
136+
<exclusion>org.apache.tika:*</exclusion>
137+
<exclusion>excalibur-datasource:excalibur-datasource</exclusion>
138+
<exclusion>excalibur-instrument:excalibur-instrument</exclusion>
139+
<exclusion>excalibur-logger:excalibur-logger</exclusion>
140+
<exclusion>excalibur-pool:*</exclusion>
141+
<exclusion>org.beanshell:bsh:jar:2.0b5</exclusion>
142+
</excludedArtifacts>
143+
<jMeterProcessJVMSettings>
144+
<arguments>
145+
<argument>-XX:MaxMetaspaceSize=512m</argument>
146+
<argument>-Xmx2048m</argument>
147+
<argument>-Xms2048m</argument>
148+
</arguments>
149+
</jMeterProcessJVMSettings>
150+
<exportedRmiHostname>${hostname}</exportedRmiHostname>
151+
<serverPort>3010</serverPort>
152+
</configuration>
153+
<executions>
154+
<execution>
155+
<id>start-jmeter-server</id>
156+
<goals>
157+
<goal>remote-server</goal>
158+
</goals>
159+
<phase>verify</phase>
160+
<configuration>
161+
<runInBackground>false</runInBackground>
162+
</configuration>
163+
</execution>
164+
</executions>
165+
</plugin>
166+
</plugins>
167+
</build>
168+
</profile>
169+
<profile>
170+
<id>controller</id>
171+
<build>
172+
<plugins>
173+
<plugin>
174+
<groupId>com.lazerycode.jmeter</groupId>
175+
<artifactId>jmeter-maven-plugin</artifactId>
176+
<version>${jmeter-maven-plugin.version}</version>
177+
<configuration>
178+
<propertiesUser>
179+
<server.rmi.ssl.disable>true</server.rmi.ssl.disable>
180+
</propertiesUser>
181+
<propertiesGlobal>
182+
<BUILD_TAG>${project.version}</BUILD_TAG>
183+
<threads>7</threads>
184+
<duration>30</duration>
185+
</propertiesGlobal>
186+
<generateReports>true</generateReports>
187+
<jmeterExtensions>
188+
<artifact>kg.apc:jmeter-plugins-casutg:2.8</artifact>
189+
</jmeterExtensions>
190+
<testPlanLibraries>
191+
<artifact>com.ubikingenierie.ubikloadpack:jmeter-maven-plugin-demo:${project.version}</artifact>
192+
</testPlanLibraries>
193+
<excludedArtifacts>
194+
<exclusion>org.slf4j:slf4j-nop</exclusion>
195+
<exclusion>avalon-framework:*</exclusion>
196+
<exclusion>org.apache.tika:*</exclusion>
197+
<exclusion>excalibur-datasource:excalibur-datasource</exclusion>
198+
<exclusion>excalibur-instrument:excalibur-instrument</exclusion>
199+
<exclusion>excalibur-logger:excalibur-logger</exclusion>
200+
<exclusion>excalibur-pool:*</exclusion>
201+
<exclusion>org.beanshell:bsh:jar:2.0b5</exclusion>
202+
</excludedArtifacts>
203+
<jMeterProcessJVMSettings>
204+
<arguments>
205+
<argument>-XX:MaxMetaspaceSize=512m</argument>
206+
<argument>-Xmx2048m</argument>
207+
<argument>-Xms2048m</argument>
208+
</arguments>
209+
</jMeterProcessJVMSettings>
210+
<remoteConfig>
211+
<serverList>${serverList}</serverList>
212+
<startAndStopServersForEachTest>true</startAndStopServersForEachTest>
213+
</remoteConfig>
214+
</configuration>
215+
<executions>
216+
<execution>
217+
<id>performance-test</id>
218+
<goals>
219+
<goal>jmeter</goal>
220+
<goal>results</goal>
221+
</goals>
222+
<phase>verify</phase>
223+
</execution>
224+
</executions>
225+
</plugin>
226+
</plugins>
227+
</build>
228+
</profile>
229+
</profiles>
230+
</project>

test/jmeter/JsonSample.groovy

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import groovy.json.JsonSlurper
2+
import groovy.json.JsonOutput
3+
import org.apache.jmeter.services.FileServer
4+
import java.util.concurrent.ConcurrentLinkedQueue
5+
import java.util.concurrent.ConcurrentHashMap
6+
7+
class JsonSampleHolder {
8+
static samples =
9+
MapWithDefault.newInstance(
10+
new ConcurrentHashMap<String, JsonSample>(), { String f -> new JsonSample(f) }
11+
)
12+
13+
static def next(file) {
14+
return samples.get(file).next()
15+
}
16+
}
17+
18+
class JsonSample {
19+
def data = null
20+
def ite = null
21+
22+
JsonSample(file) {
23+
if(data == null) {
24+
def inputPath = FileServer.getFileServer().getBaseDir() + file
25+
File inputFile = new File(inputPath)
26+
def slurper = new JsonSlurper()
27+
data = new ConcurrentLinkedQueue(slurper.parse(inputFile))
28+
ite = data.iterator()
29+
}
30+
}
31+
synchronized def next() {
32+
if(!ite.hasNext()) {
33+
ite = data.iterator()
34+
}
35+
return ite.next()
36+
}
37+
}
38+
39+
40+
Thread thread = Thread.currentThread();
41+
Long threadNum = thread.getId();
42+
def value = JsonSampleHolder.next(args[0])
43+
def json = JsonOutput.toJson(value)
44+
log.info(threadNum + " : " + value)
45+
vars.putObject(args[1], value)
46+
vars.put(args[1] + "_json", json)
47+
48+
if(binding.hasVariable('SampleResult')) {
49+
SampleResult.setContentType("application/json")
50+
SampleResult.setResponseCodeOK()
51+
SampleResult.setResponseData(json, "utf-8")
52+
}

0 commit comments

Comments
 (0)