mirror of
https://github.com/owncast/owncast.git
synced 2024-11-22 04:40:37 +03:00
Add some simple load tests
This commit is contained in:
parent
a8fe8a1cfa
commit
aebbce4b76
5 changed files with 2029 additions and 0 deletions
8
test/README.md
Normal file
8
test/README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Tests
|
||||
|
||||
## Load Tests
|
||||
|
||||
1. Install [artillery](https://artillery.io/) from NPM/Yarn/Whatever Javascript package manager is popular this week.
|
||||
1. Start an instance of the server on localhost.
|
||||
1. `artillery run httpGetTest.yaml` for endpoint load tests.
|
||||
1. `artillery run websocketTest.yaml` for websocket load tests.
|
16
test/httpGetTest.yaml
Normal file
16
test/httpGetTest.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
config:
|
||||
target: 'http://localhost:8080/'
|
||||
|
||||
ensure:
|
||||
p95: 200
|
||||
maxErrorRate: 1
|
||||
|
||||
phases:
|
||||
- duration: 60
|
||||
arrivalRate: 20
|
||||
scenarios:
|
||||
- flow:
|
||||
- get:
|
||||
url: "/hls/stream.m3u8"
|
||||
- get:
|
||||
url: "/status"
|
1967
test/package-lock.json
generated
Normal file
1967
test/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
14
test/websocketTest.js
Normal file
14
test/websocketTest.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
module.exports = { createTestMessageObject };
|
||||
|
||||
function createTestMessageObject(userContext, events, done) {
|
||||
const randomNumber = Math.floor((Math.random() * 10) + 1);
|
||||
const author = "load-test-user-" + randomNumber
|
||||
const data = {
|
||||
author: author,
|
||||
body: "Test 12345. " + randomNumber,
|
||||
image: "https://robohash.org/" + author + "?size=80x80&set=set3"
|
||||
};
|
||||
// set the "data" variable for the virtual user to use in the subsequent action
|
||||
userContext.vars.data = data;
|
||||
return done();
|
||||
}
|
24
test/websocketTest.yaml
Normal file
24
test/websocketTest.yaml
Normal file
|
@ -0,0 +1,24 @@
|
|||
config:
|
||||
target: "ws://localhost:8080/entry"
|
||||
processor: "./websocketTest.js"
|
||||
|
||||
ensure:
|
||||
p95: 200
|
||||
maxErrorRate: 1
|
||||
|
||||
phases:
|
||||
- duration: 30
|
||||
arrivalRate: 10
|
||||
ws:
|
||||
subprotocols:
|
||||
- json
|
||||
headers:
|
||||
Connection: Upgrade
|
||||
Origin: http://localhost:8080
|
||||
Sec-WebSocket-Version: 13
|
||||
scenarios:
|
||||
- engine: "ws"
|
||||
flow:
|
||||
- function: "createTestMessageObject"
|
||||
- send: "{{ data }}"
|
||||
- think: 5
|
Loading…
Reference in a new issue