-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
M_Westerholz
committed
Oct 10, 2024
1 parent
d87e76a
commit 9edd39f
Showing
11 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build and push spsh-k6-loadtest Images | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'spsh-k6-loadtest-[0-9]+.[0-9]+.[0-9]+' | ||
jobs: | ||
pre_build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tagName: ${{ steps.tagName.outputs.tag }} | ||
versionName: ${{ steps.versionName.outputs.tag }} | ||
steps: | ||
- name: Filter Tag name | ||
uses: olegtarasov/[email protected] | ||
id: tagName | ||
with: | ||
tagRegex: "(.+?(?=-[0-9]))" | ||
tagRegexGroup: 1 | ||
|
||
- name: Filter Version name | ||
uses: olegtarasov/[email protected] | ||
id: versionName | ||
with: | ||
tagRegex: "${{ steps.tagName.outputs.tag }}-(.*)" | ||
tagRegexGroup: 1 | ||
|
||
build_and_push: | ||
needs: pre_build | ||
uses: hpi-schul-cloud/infra-tools/.github/workflows/build-and-push.yaml@master | ||
with: | ||
registry: ghcr.io | ||
image: dbildungsplattform/${{ needs.pre_build.outputs.tagName }} | ||
tag: ${{ needs.pre_build.outputs.versionName }} | ||
context: ./infrastructure/${{ needs.pre_build.outputs.tagName }}/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
name: spsh-load-test | ||
description: A Helm chart for distributed k6 loadtests in kubernetes. | ||
version: 1.0.0 | ||
appVersion: "1.16.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Create image for running k6 with output for Prometheus | ||
FROM grafana/k6:0.43.1 | ||
USER root | ||
|
||
COPY wrapper-script.sh wrapper-script.sh | ||
RUN apk add git && \ | ||
chmod +x wrapper-script.sh | ||
|
||
ENTRYPOINT ["./wrapper-script.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
git clone https://github.com/dBildungsplattform/schulportal-load-tests | ||
cd schulportal-load-tests | ||
git checkout $BRANCH | ||
|
||
k6 "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{{- range $job_name, $job_options := .Values.cronjobs }} | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: loadtest-spsh-{{ $job_name }} | ||
namespace: loadtest | ||
spec: | ||
schedule: {{ $job_options.schedule }} | ||
suspend: true | ||
jobTemplate: | ||
spec: | ||
completions: {{ $job_options.jobsParallelism }} | ||
parallelism: {{ $job_options.jobsParallelism }} | ||
template: | ||
metadata: | ||
labels: | ||
test: loadtest-{{ $job_options.serviceName }} | ||
pod: {{ $job_name }} | ||
spec: | ||
containers: | ||
- name: {{ $job_name }} | ||
image: {{ $job_options.image }} | ||
imagePullPolicy: Always | ||
env: | ||
- name: OPTIONS_FILE_PATH | ||
value: testoption.json | ||
- name: BRANCH | ||
value: main | ||
args: | ||
['run', '-u', '0', | ||
'./loadtest/tests/{{ $job_options.scriptPath }}', | ||
'--tag','NAME={{ $job_options.serviceName }}', | ||
#'--out', 'experimental-prometheus-rw', | ||
'-e', 'ENVIRONMENT={{ $job_options.environment }}'] | ||
volumeMounts: | ||
- name: secret-volume | ||
mountPath: /secrets | ||
readOnly: true | ||
ports: | ||
- containerPort: {{ $job_options.port }} | ||
name: loadtest-pod | ||
volumes: | ||
- name: secret-volume | ||
secret: | ||
secretName: login-secret | ||
restartPolicy: OnFailure | ||
--- | ||
{{- end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: login-secret | ||
namespace: loadtest | ||
type: Opaque | ||
stringData: | ||
userlogin.json: |- | ||
{{ .Files.Get "userLogin.json" | indent 4}} | ||
managerlogin.json: |- | ||
{{ .Files.Get "managerLogin.json" | indent 4}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cronjobs: | ||
dev-scenario: | ||
scriptPath: test.js | ||
schedule: 0 8 * * * | ||
port: 5656 | ||
serviceName: dev-scenario | ||
image: ghcr.io/dbildungsplattform/spsh-k6-loadtest:latest | ||
environment: spsh.loadtest.dbildungscloud.dev | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"stages": [ | ||
{ "duration": "5s", "target": 1 }, | ||
{ "duration": "20s", "target": 1 }, | ||
{ "duration": "5s", "target": 0 } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log("Test JS executed!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
helpFunction() | ||
{ | ||
echo "" | ||
echo "Usage: ./script.sh -o optionsFile.json" | ||
echo -e "\t-o Selection of the Option File to set virtual Users and test runtime." | ||
echo -e "\t-b Selection of the Branch to use after cloning(Selection of the Loadtest)." | ||
echo -e "Example: \n ./script -o 300s250u.json" | ||
exit 1 # Exit script after printing help | ||
} | ||
|
||
|
||
while getopts "o:b:" opt | ||
do | ||
case "$opt" in | ||
o ) optionsParameter="$OPTARG" ;; #Which options file to use as Loadtest Parameters | ||
#e ) envParameter="$OPTARG" ;; # For later use to change the test environment dynamically | ||
b ) branch="$OPTARG" ;; #To change the branch from where to clone | ||
? ) helpFunction ;; # Print helpFunction in case parameter is non-existent | ||
esac | ||
done | ||
|
||
# Print helpFunction in case parameters are empty | ||
if [ -z "$optionsParameter" ] | ||
then | ||
echo "Some or all of the parameters are empty"; | ||
helpFunction | ||
fi | ||
|
||
for scenario in user-scenario; do | ||
job_name=loadtest-${scenario} | ||
template_cronjob_name=cronjob.batch/loadtest-${scenario} | ||
|
||
kubectl set env cronjob.batch/loadtest-user-scenario OPTIONS_FILE_PATH=$optionsParameter BRANCH=$branch -n loadtest --kubeconfig /home/vscode/.kube/spsh-dev-loadtestdriver.yaml | ||
echo "ENV changed to $optionsParameter" | ||
kubectl create job ${job_name} -n loadtest --kubeconfig /home/vscode/.kube/spsh-dev-loadtestdriver.yaml --from=${template_cronjob_name} | ||
echo "Launched job ${job_name} based on ${template_cronjob_name}" | ||
|
||
done |