Skip to content

Latest commit

 

History

History
121 lines (81 loc) · 3.42 KB

README.adoc

File metadata and controls

121 lines (81 loc) · 3.42 KB

Apache JMeter on Openshift

1. Introduction

The Apache JMeter™ application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.

2. JMeter on your laptop: Building the container image

In order to perform some testing locally, you may want to build the JMeter image directly on your laptop.

podman build -t localhost/jmeter:latest ./container-image

3. JMeter on your laptop: Running the image

podman run --rm -it --name jmeter localhost/jmeter:latest

4. JMeter on Openshift: Building the container image

If your have a disconnected Openshift installation, you will also require to build your application locally.

APP_NAMESPACE="jmeter"
GIT_REPOSITORY="https://github.com/alvarolop/jmeter-on-ocp.git"
oc new-project $APP_NAMESPACE --display-name="JMeter Testing" --description="This namespace contains resources to deploy JMeter"

oc process -f templates/jmeter-bc.yaml -p APP_NAMESPACE=$APP_NAMESPACE -p GIT_REPOSITORY=$GIT_REPOSITORY | oc apply -f -

5. JMeter on Openshift: Deploying the image

First, create a ConfigMap that will store your application configuration:

TEST="example"
oc create configmap jmeter-config -n $JMETER_NAMESPACE \
--from-file=${JMETER_TEST}.jmx=tests/${JMETER_TEST}/jmeter-test-plan.jmx \
--from-file=config.properties=tests/${JMETER_TEST}/config-k8s.properties
oc process -f templates/jmeter-dc.yaml \
    -p APP_NAMESPACE=$JMETER_NAMESPACE \
    -p TEST_NAME=$JMETER_TEST | oc apply -f -

6. JMeter on Openshift: Obtaining JMeter reports

# Get JMeter pod name
JMETER_POD=$(oc get pods -l app=jmeter -n $APP_NAMESPACE --template='{{(index .items 0).metadata.name}}')
NOW=$(date +"%Y-%m-%d_%H-%M-%S")
mkdir ./results/$NOW-$TEST
oc rsync $JMETER_POD:/opt/jmeter/results/$TEST-report/ ./results/$NOW-$TEST

8. Annex: Running jmeter in your laptop

JMETER_BASE=$(pwd)
TEST_PLAN=test-03
NOW=$(date +"%Y-%m-%d_%H-%M-%S"); jmeter -n -p "$JMETER_BASE/tests/${TEST_PLAN}/config.properties" -t "$JMETER_BASE/tests/${TEST_PLAN}/jmeter-test-plan.jmx" -l "$JMETER_BASE/results/${NOW}-${TEST_PLAN}.jtl" -e -o "$JMETER_BASE/results/${NOW}-${TEST_PLAN}-report"; cp -r $JMETER_BASE/tests/${TEST_PLAN}/ $JMETER_BASE/results/${NOW}-${TEST_PLAN}-report