forked from rcarrata/devsecops-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task-gatling.yaml.j2
57 lines (52 loc) · 1.81 KB
/
task-gatling.yaml.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: gatling
namespace: cicd
spec:
params:
- name: DURATION
description: The duration of running simulations
type: string
default: "30"
- name: CONCURRENT_USERS
description: The number of concurrent users
type: string
default: "10"
- name: APP_URL
description: The application under test url
type: string
- name: REPORTS_REPO_HOST
description: The reports repository host based on https://github.com/chmouel/openshift-django-uploader
default: http://reports-repo:8080
- name: REPORTS_REPO_USERNAME
description: The reports repository username
default: reports
- name: REPORTS_REPO_PASSWORD
description: The reports repository password
default: reports
workspaces:
- description: The workspace consisting of maven project.
name: simulations
steps:
- name: run-tests
image: quay.io/siamaksade/gatling:latest
env:
- name: PIPELINERUN_NAME
valueFrom:
fieldRef:
fieldPath: metadata.labels['tekton.dev/pipelineRun']
script: |
#!/usr/bin/env bash
set -x
cd /opt/gatling/
ls -lhrt
# set simulation params
export JAVA_OPTS="-DtestDuration=$(params.CONCURRENT_USERS) -DuserCount=$(params.DURATION) -Dserver=$(params.APP_URL)"
# run simulation
/opt/gatling/bin/gatling.sh -rd "Spring PetClinic Performance Test" -sf $(workspaces.simulations.path)
# upload results
REPORT=$(ls -td /opt/gatling/results/* | head -1)
for f in $(find $REPORT/ -type f); do
curl -u $(params.REPORTS_REPO_USERNAME):$(params.REPORTS_REPO_PASSWORD) -F path=$PIPELINERUN_NAME${f#/opt/gatling/results} -X POST -F file=@${f} $(params.REPORTS_REPO_HOST)/upload; echo ""
done