Skip to content

Commit 83d3467

Browse files
brunnertbrunnert
and
brunnert
authored
Adding JMeter Test for Spring application (#98)
* Adding JMeter Test for Spring application * Adding JMeter Test for Spring application * Adding JMeter Test for Spring application * Adding JMeter Test for Spring application --------- Co-authored-by: brunnert <brunnert@hm.edu>
2 parents 978a2c6 + 7f91b08 commit 83d3467

File tree

3 files changed

+149
-1
lines changed

3 files changed

+149
-1
lines changed

examples/spring-rest-service/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ If you want to automate the execution of these requests, take a look at the foll
3232

3333
When executing this test method, the test will send requests to the Spring REST application until you manually stop the tests.
3434

35+
As an alternative to generate load on the application, you can also find an [Apache JMeter](https://jmeter.apache.org/) load test script in the following location:
36+
37+
[src/test/resource/jmeter_testplan.jmx](src/test/resources/jmeter_testplan.jmx)
38+
3539
Once you have issued a few requests to one or more of these endpoints you will see the CO2 emissions for each endpoint in Grafana.
3640

3741

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
spring.application.name=spring-carbon-emissions
2-
server.port=8081
2+
server.port=8081
3+
server.tomcat.accept-count=1000
4+
server.tomcat.max-connections=10000
5+
server.tomcat.threads.max=1000
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.6.3">
3+
<hashTree>
4+
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan">
5+
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
6+
<collectionProp name="Arguments.arguments">
7+
<elementProp name="TOTAL_RATE" elementType="Argument">
8+
<stringProp name="Argument.name">TOTAL_RATE</stringProp>
9+
<stringProp name="Argument.value">50</stringProp>
10+
<stringProp name="Argument.metadata">=</stringProp>
11+
</elementProp>
12+
</collectionProp>
13+
</elementProp>
14+
</TestPlan>
15+
<hashTree>
16+
<OpenModelThreadGroup guiclass="OpenModelThreadGroupGui" testclass="OpenModelThreadGroup" testname="Spring Thread Group">
17+
<stringProp name="OpenModelThreadGroup.schedule">rate(${TOTAL_RATE}/sec) random_arrivals(1 min) rate(${TOTAL_RATE}/sec) random_arrivals(10 min) rate(${TOTAL_RATE}/sec) random_arrivals(1 min) rate(0/sec) </stringProp>
18+
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
19+
<elementProp name="ThreadGroup.main_controller" elementType="OpenModelThreadGroupController"/>
20+
</OpenModelThreadGroup>
21+
<hashTree>
22+
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="GET (Spring)" enabled="true">
23+
<stringProp name="HTTPSampler.domain">localhost</stringProp>
24+
<stringProp name="HTTPSampler.port">8081</stringProp>
25+
<stringProp name="HTTPSampler.protocol">http</stringProp>
26+
<stringProp name="HTTPSampler.path">/test-rest-endpoint/getData</stringProp>
27+
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
28+
<stringProp name="HTTPSampler.method">GET</stringProp>
29+
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
30+
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
31+
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
32+
<collectionProp name="Arguments.arguments"/>
33+
</elementProp>
34+
</HTTPSamplerProxy>
35+
<hashTree/>
36+
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="POST (Spring)" enabled="true">
37+
<stringProp name="HTTPSampler.domain">localhost</stringProp>
38+
<stringProp name="HTTPSampler.port">8081</stringProp>
39+
<stringProp name="HTTPSampler.protocol">http</stringProp>
40+
<stringProp name="HTTPSampler.path">/test-rest-endpoint/postData</stringProp>
41+
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
42+
<stringProp name="HTTPSampler.method">POST</stringProp>
43+
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
44+
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
45+
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
46+
<collectionProp name="Arguments.arguments"/>
47+
</elementProp>
48+
</HTTPSamplerProxy>
49+
<hashTree/>
50+
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="DELETE (Spring)" enabled="true">
51+
<stringProp name="HTTPSampler.domain">localhost</stringProp>
52+
<stringProp name="HTTPSampler.port">8081</stringProp>
53+
<stringProp name="HTTPSampler.protocol">http</stringProp>
54+
<stringProp name="HTTPSampler.path">/test-rest-endpoint/deleteData</stringProp>
55+
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
56+
<stringProp name="HTTPSampler.method">DELETE</stringProp>
57+
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
58+
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
59+
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
60+
<collectionProp name="Arguments.arguments"/>
61+
</elementProp>
62+
</HTTPSamplerProxy>
63+
<hashTree/>
64+
</hashTree>
65+
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="false">
66+
<boolProp name="ResultCollector.error_logging">false</boolProp>
67+
<objProp>
68+
<name>saveConfig</name>
69+
<value class="SampleSaveConfiguration">
70+
<time>true</time>
71+
<latency>true</latency>
72+
<timestamp>true</timestamp>
73+
<success>true</success>
74+
<label>true</label>
75+
<code>true</code>
76+
<message>true</message>
77+
<threadName>true</threadName>
78+
<dataType>true</dataType>
79+
<encoding>false</encoding>
80+
<assertions>true</assertions>
81+
<subresults>true</subresults>
82+
<responseData>false</responseData>
83+
<samplerData>false</samplerData>
84+
<xml>false</xml>
85+
<fieldNames>true</fieldNames>
86+
<responseHeaders>false</responseHeaders>
87+
<requestHeaders>false</requestHeaders>
88+
<responseDataOnError>false</responseDataOnError>
89+
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
90+
<assertionsResultsToSave>0</assertionsResultsToSave>
91+
<bytes>true</bytes>
92+
<sentBytes>true</sentBytes>
93+
<url>true</url>
94+
<threadCounts>true</threadCounts>
95+
<idleTime>true</idleTime>
96+
<connectTime>true</connectTime>
97+
</value>
98+
</objProp>
99+
<stringProp name="filename"></stringProp>
100+
</ResultCollector>
101+
<hashTree/>
102+
<ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="Summary Report" enabled="true">
103+
<boolProp name="ResultCollector.error_logging">false</boolProp>
104+
<objProp>
105+
<name>saveConfig</name>
106+
<value class="SampleSaveConfiguration">
107+
<time>true</time>
108+
<latency>true</latency>
109+
<timestamp>true</timestamp>
110+
<success>true</success>
111+
<label>true</label>
112+
<code>true</code>
113+
<message>true</message>
114+
<threadName>true</threadName>
115+
<dataType>true</dataType>
116+
<encoding>false</encoding>
117+
<assertions>true</assertions>
118+
<subresults>true</subresults>
119+
<responseData>false</responseData>
120+
<samplerData>false</samplerData>
121+
<xml>false</xml>
122+
<fieldNames>true</fieldNames>
123+
<responseHeaders>false</responseHeaders>
124+
<requestHeaders>false</requestHeaders>
125+
<responseDataOnError>false</responseDataOnError>
126+
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
127+
<assertionsResultsToSave>0</assertionsResultsToSave>
128+
<bytes>true</bytes>
129+
<sentBytes>true</sentBytes>
130+
<url>true</url>
131+
<threadCounts>true</threadCounts>
132+
<idleTime>true</idleTime>
133+
<connectTime>true</connectTime>
134+
</value>
135+
</objProp>
136+
<stringProp name="filename">jmeter_25_result.txt</stringProp>
137+
</ResultCollector>
138+
<hashTree/>
139+
</hashTree>
140+
</hashTree>
141+
</jmeterTestPlan>

0 commit comments

Comments
 (0)