Skip to content

Commit

Permalink
test it
Browse files Browse the repository at this point in the history
  • Loading branch information
aimee-889 committed Oct 15, 2024
1 parent 6dab7e9 commit 41f8252
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 27 deletions.
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
FROM grafana/k6:0.54.0
USER root

COPY wrapper-script.sh wrapper-script.sh
RUN apk add git && \
chmod +x wrapper-script.sh

ENTRYPOINT ["./wrapper-script.sh"]
27 changes: 19 additions & 8 deletions charts/schulportal-load-tests/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ spec:
suspend: true
jobTemplate:
spec:
# is defined in here but not activaly used?
completions: {{ $job_options.jobsParallelism }}
parallelism: {{ $job_options.jobsParallelism }}
template:
Expand All @@ -21,32 +22,42 @@ spec:
automountServiceAccountToken: false
containers:
- name: {{ $job_name }}
image: {{ $job_options.image }}
image: ghcr.io/dbildungsplattform/schulportal-load-test:{{$job_options.iamge-tag}}
imagePullPolicy: Always
securityContext:
allowPrivilegeEscalation: false
imagePullPolicy: Always
env:
- name: OPTIONS_FILE_PATH
value: testoption.json
- name: BRANCH
value: main
args:
['k6','run', '-u', '0',
'./loadtest/tests/{{ $job_options.scriptPath }}',
'--tag','NAME={{ $job_options.serviceName }}',
#'--out', 'experimental-prometheus-rw',
'-e', 'ENVIRONMENT={{ $job_options.environment }}']
- name: SPSH_BASE
value: main.dev.spsh.dbildungsplattform.de
- name: CONFIG
value: stress
command: ["sh", "-c", "git clone https://github.com/dBildungsplattform/schulportal-load-tests && cd schulportal-load-tests && git checkout DBP-1012-setup-loadtest-env && k6 '$@'"]
args: [ 'k6','run', '-u', '0',
'./loadtest/usecases/{{ $job_options.scriptPath }}',
'--compatibility-mode=experimental_enhanced',
]
volumeMounts:
- name: secret-volume
mountPath: /secrets
readOnly: true
- name: secret-volume-json
mountPath: /data/json
readOnly: true
ports:
- containerPort: {{ $job_options.port }}
name: loadtest-pod
volumes:
- name: secret-volume
secret:
secretName: spsh-loadtest-secret
volumes:
- name: secret-volume-json
secret:
secretName: spsh-loadtest-secret-json
restartPolicy: Never
---
{{- end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: onepassword.com/v1
kind: OnePasswordItem
metadata:
name: spsh-loadtest-secret-json
namespace: spsh
labels:
app.kubernetes.io/managed-by: helm
spec:
itemPath: "vaults/spsh-dev/items/spsh-loadtest-secret-json"
14 changes: 11 additions & 3 deletions charts/schulportal-load-tests/values.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
cronjobs:
dev-scenario:
scriptPath: test.js
scriptPath: 1_goto-sp-oidc.ts # 01, 02, 03 Files
schedule: 0 8 * * *
port: 5656
serviceName: dev-scenario
image: ghcr.io/dbildungsplattform/schulportal-load-tests:latest
# what should be the environment be?
# image-tag: latest
image-tag: SPSH-1012
environment: main.dev.spsh.dbildungsplattform.de
# jobsParallelism: not used yet but available? test it
# staging-scenario:
# scriptPath: test.js
# schedule: 0 8 * * *
# port: 5656
# serviceName: staging-scenario
# image: ghcr.io/dbildungsplattform/schulportal-load-tests:latest
# environment: spsh.staging.dbildungsplattform.de
# prod-scenario:
# scriptPath: test.js
# schedule: 0 8 * * *
# port: 5656
# serviceName: prod-scenario
# image: ghcr.io/dbildungsplattform/schulportal-load-tests:latest
# environment: spsh.dbildungsplattform.de

6 changes: 3 additions & 3 deletions loadtest/util/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ export function getDefaultOptions() {
case CONFIG.SPIKE:
return {
stages: [
{ duration: "30s", target: 100 },
{ duration: "30s", target: 10 },
{ duration: "10s", target: 0 },
],
};
case CONFIG.STRESS:
return {
stages: [
{ duration: "1m", target: 100 },
{ duration: "1m", target: 10 },
// { duration: "5m", target: 100 },
{ duration: "1m", target: 0 },
],
};
case CONFIG.BREAKPOINT:
return {
stages: [{ duration: "5m", target: 100 }],
stages: [{ duration: "5m", target: 10 }],
thresholds: {
http_req_failed: [{ threshold: "rate<0.10", abortOnFail: true }],
http_req_duration: [{ threshold: "p(95)<2000", abortOnFail: true }],
Expand Down
13 changes: 10 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,25 @@ if [[ -z "$PATTERN" ]]; then
PATTERN="*"
fi

# KC_BASE=$2 # not needed yet

# only for local development
SKIP_SSL=""
if [[ "$SPSH_BASE" =~ "localhost" ]]; then
SKIP_SSL="--insecure-skip-tls-verify"
fi

# create output/, if not present
if [[ ! -d output/ ]]; then
mkdir output/
fi


# einmal Grafana ohne out mit der CSV Datei ()
# funktinonieren die Ergebnisse in den Logs auch wenn die Parallel laufen?
for uc in loadtest/usecases/*; do
if [[ "$uc" =~ "$PATTERN" ]]; then
filename=${uc##*/}
csv="output/${filename%.ts}.csv"
touch "$csv"
k6 run --compatibility-mode=experimental_enhanced --out csv="$csv" "$SKIP_SSL" -e SPSH_BASE="$SPSH_BASE" -e CONFIG="$CONFIG" -e KC_BASE="$KC_BASE" "$uc"
k6 run --compatibility-mode=experimental_enhanced --out csv="$csv" "$SKIP_SSL" -e SPSH_BASE="$SPSH_BASE" -e CONFIG="$CONFIG" "$uc"
fi
done
7 changes: 0 additions & 7 deletions wrapper-script.sh

This file was deleted.

0 comments on commit 41f8252

Please sign in to comment.