-
Notifications
You must be signed in to change notification settings - Fork 188
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
Showing
3 changed files
with
148 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,8 @@ | ||
# Load Testing | ||
|
||
These files can be run with [k6](https://github.com/loadimpact/k6). They're pretty rudimentary as far as load tests go but they did help to locate a deadlock, so they are being preserved for posterity. | ||
|
||
Example command: | ||
``` | ||
k6 run load/loadtest.js | ||
``` |
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,70 @@ | ||
import http from "k6/http"; | ||
import { check, sleep } from "k6"; | ||
import { Trend } from 'k6/metrics'; | ||
|
||
export let options = { | ||
stages: [ | ||
// Ramp-up from 1 to 5 VUs in 10s | ||
{ | ||
duration: "10s", | ||
target: 50 | ||
}, | ||
|
||
// Stay at rest on 5 VUs for 5s | ||
{ | ||
duration: "5s", | ||
target: 50 | ||
}, | ||
|
||
// Ramp-down from 5 to 0 VUs for 5s | ||
{ | ||
duration: "5s", | ||
target: 0 | ||
}, | ||
// Ramp-down from 5 to 0 VUs for 5s | ||
{ | ||
duration: "10s", | ||
target: 1 | ||
} | ||
] | ||
}; | ||
|
||
let jobs = new Trend('jobs'); | ||
let activeJobs = new Trend('active_jobs'); | ||
let errorCount = new Trend('error_count'); | ||
let successCount = new Trend('success_count'); | ||
|
||
var count = 0; | ||
|
||
function getSchedule(now) { | ||
now.setSeconds(now.getSeconds() + 1); | ||
return 'R5/' + now.toISOString() + '/PT5S'; | ||
} | ||
|
||
export default function() { | ||
let payload = JSON.stringify({ | ||
name: 'job' + (count++), | ||
schedule: getSchedule(new Date()), | ||
command: "bash -c 'date'" | ||
}); | ||
let write = http.post("http://localhost:8000/api/v1/job/", payload); | ||
check(write, { | ||
"status is ok": (r) => r.status === 201 | ||
}); | ||
sleep(1); | ||
let read = http.get("http://localhost:8000/api/v1/job/"); | ||
check(read, { | ||
"status is ok": (r) => r.status === 200 | ||
}); | ||
sleep(1); | ||
let stats = http.get("http://localhost:8000/api/v1/stats/"); | ||
check(stats, { | ||
"status is ok": (r) => r.status === 200 | ||
}); | ||
let parsed = JSON.parse(stats.body); | ||
jobs.add(parsed.Stats.jobs); | ||
activeJobs.add(parsed.Stats.active_jobs); | ||
errorCount.add(parsed.Stats.error_count); | ||
successCount.add(parsed.Stats.success_count); | ||
sleep(1); | ||
} |
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,70 @@ | ||
import http from "k6/http"; | ||
import { check, sleep } from "k6"; | ||
import { Trend } from 'k6/metrics'; | ||
|
||
export let options = { | ||
stages: [ | ||
// Ramp-up from 1 to 5 VUs in 10s | ||
{ | ||
duration: "10s", | ||
target: 5 | ||
}, | ||
|
||
// Stay at rest on 5 VUs for 5s | ||
{ | ||
duration: "5s", | ||
target: 200 | ||
}, | ||
|
||
// Ramp-down from 5 to 0 VUs for 5s | ||
{ | ||
duration: "5s", | ||
target: 5 | ||
}, | ||
// Ramp-down from 5 to 0 VUs for 5s | ||
{ | ||
duration: "10s", | ||
target: 1 | ||
} | ||
] | ||
}; | ||
|
||
let jobs = new Trend('jobs'); | ||
let activeJobs = new Trend('active_jobs'); | ||
let errorCount = new Trend('error_count'); | ||
let successCount = new Trend('success_count'); | ||
|
||
var count = 0; | ||
|
||
function getSchedule(now) { | ||
now.setSeconds(now.getSeconds() + 1); | ||
return 'R5/' + now.toISOString() + '/PT5S'; | ||
} | ||
|
||
export default function() { | ||
let payload = JSON.stringify({ | ||
name: 'job' + (count++), | ||
schedule: getSchedule(new Date()), | ||
command: "bash -c 'date'" | ||
}); | ||
let write = http.post("http://localhost:8000/api/v1/job/", payload); | ||
check(write, { | ||
"status is ok": (r) => r.status === 201 | ||
}); | ||
sleep(1); | ||
let read = http.get("http://localhost:8000/api/v1/job/"); | ||
check(read, { | ||
"status is ok": (r) => r.status === 200 | ||
}); | ||
sleep(1); | ||
let stats = http.get("http://localhost:8000/api/v1/stats/"); | ||
check(stats, { | ||
"status is ok": (r) => r.status === 200 | ||
}); | ||
let parsed = JSON.parse(stats.body); | ||
jobs.add(parsed.Stats.jobs); | ||
activeJobs.add(parsed.Stats.active_jobs); | ||
errorCount.add(parsed.Stats.error_count); | ||
successCount.add(parsed.Stats.success_count); | ||
sleep(1); | ||
} |