Browse Source

Add some simple load tests

pull/68/head
Gabe Kangas 5 years ago
parent
commit
aebbce4b76
  1. 8
      test/README.md
  2. 16
      test/httpGetTest.yaml
  3. 1967
      test/package-lock.json
  4. 14
      test/websocketTest.js
  5. 24
      test/websocketTest.yaml

8
test/README.md

@ -0,0 +1,8 @@ @@ -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

@ -0,0 +1,16 @@ @@ -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

File diff suppressed because it is too large Load Diff

14
test/websocketTest.js

@ -0,0 +1,14 @@ @@ -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

@ -0,0 +1,24 @@ @@ -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…
Cancel
Save