Skip to content

Commit

Permalink
Add JMeter example application (#51)
Browse files Browse the repository at this point in the history
* Add JMeter example

* Add OpenEnergyBadges

* Pin Docker images with hash

* Improve JMeter test plan
  • Loading branch information
davidkopp authored Dec 14, 2023
1 parent 4699a4f commit f9a0785
Show file tree
Hide file tree
Showing 4 changed files with 520 additions and 0 deletions.
30 changes: 30 additions & 0 deletions jmeter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# JMeter

[Apache JMeter](https://jmeter.apache.org/) is a load and performance testing tool.
This example demonstrates how to use JMeter to execute a test plan that makes HTTP requests to a web application.

It is based on a customized [JMeter Docker image](https://hub.docker.com/r/t2project/jmeter).

As an example web application the reference application [T2-Project](https://t2-documentation.readthedocs.io) is used.

## JMeter Execution

JMeter gets executed as part of the flow in `usage_scenario.yml` with the following command:

```bash
jmeter -Jhostname=gcb-backend -Jport=8080 -JnumExecutions=1 -JnumUser=1 -JrampUp=0 -JnumProducts=1 -JthinkTimeMin=0 -JthinkTimeAdditionalRange=0 -JpauseBeforeExecution=0 -JpauseAfterExecution=0 -JloggingEnabled=true -n -t /tmp/repo/jmeter-test-plan.jmx
```

`hostname`, `port`, `numExecutions`, `numUser`, `rampUp`, `numProducts`, `thinkTimeMin`, `thinkTimeAdditionalRange`, `pauseBeforeExecution`, `pauseAfterExecution` and `loggingEnabled` are environment variables that get passed to JMeter. They are specific for this test plan (`jmeter-test-plan.jmx`).
If you want to understand this test plan you can use the JMeter GUI and open the file `jmeter-test-plan.jmx`.

## Running the measurement

To check how to run the measurements check out our [Documentation](https://docs.green-coding.berlin)

## OpenEnergyBadge

These badges show the energy cost for running this code on a single machine and the emissions per order (SCI score).

<a href="https://metrics.green-coding.berlin/stats.html?id=207c1ae2-d2b5-4fc9-a6ea-b68c2f69073a"><img src="https://api.green-coding.berlin/v1/badge/single/207c1ae2-d2b5-4fc9-a6ea-b68c2f69073a?metric=RAPL"></a>
<a href="https://metrics.green-coding.berlin/stats.html?id=207c1ae2-d2b5-4fc9-a6ea-b68c2f69073a"><img src="https://api.green-coding.berlin/v1/badge/single/207c1ae2-d2b5-4fc9-a6ea-b68c2f69073a?metric=SCI"></a>
36 changes: 36 additions & 0 deletions jmeter/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
version: "2"
services:
gcb-postgres:
image: postgres:15.4
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
networks:
- t2-network
gcb-mongo:
image: mongo:5.0
networks:
- t2-network
gcb-backend:
image: t2project/modulith@sha256:180c620862e6aa936f00245c04fe0510896c2c8059663e3f0fae2a76b7a56966
depends_on:
- gcb-postgres
- gcb-mongo
environment:
MONGO_HOST: gcb-mongo
POSTGRES_HOST: gcb-postgres
SPRING_PROFILES_ACTIVE: gmt
networks:
- t2-network
gcb-jmeter:
image: t2project/jmeter@sha256:8d0543345f747ae512da2f0732fbd0ee760c7168415d2dce87e77d42fd14390a
environment:
JVM_XMN: 100 # maximum nursery size
JVM_XMS: 250 # initial heap size
JVM_XMX: 500 # maximum heap size
networks:
- t2-network

networks:
t2-network:
Loading

0 comments on commit f9a0785

Please sign in to comment.