Last active
December 3, 2019 10:40
-
-
Save mariusmitrofan/e57ff1acc65ecdfa68a332774a38e39d to your computer and use it in GitHub Desktop.
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
#!groovy | |
def timeout=40 | |
def API_KEY=your_api_key_here | |
pipeline { | |
agent any | |
stages { | |
stage('StartLoadTest') { | |
steps { | |
script { | |
def start = """ | |
#!/bin/bash | |
set -e | |
cat > start.json <<EOF | |
{ | |
"numClients": 500, | |
"hatchRate": 500, | |
"runTime": 30, | |
"maxThreads": 1, | |
"hostname": "netbears.com", | |
"protocol": "https", | |
"workflow": [ | |
{ | |
"path": "/devops/", | |
"method": "GET", | |
"headers": { | |
"Content-Type": "application/json" | |
} | |
} | |
] | |
} | |
EOF | |
curl \ | |
-X POST \ | |
-d "@start.json" \ | |
-H "x-api-key: ${API_KEY}" \ | |
-H "Content-Type: application/json" \ | |
https://beta.rungutan.com/start | jq -r .requestId > request_id | |
sleep ${timeout} | |
export request_id=\$(cat request_id) | |
cat > results.json <<EOF | |
{ | |
"requestId": "\${request_id}" | |
} | |
EOF | |
curl \ | |
-X POST \ | |
-d "@results.json" \ | |
-H "x-api-key: ${API_KEY}" \ | |
-H "Content-Type: application/json" \ | |
https://beta.rungutan.com/result | |
""" | |
sh loadtest | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment