Skip to content

Commit 7327567

Browse files
committed
feat(artillery): add scripts for artillery load testing
1 parent 56b3e76 commit 7327567

File tree

11 files changed

+2525
-90
lines changed

11 files changed

+2525
-90
lines changed

bun.lock

Lines changed: 1580 additions & 89 deletions
Large diffs are not rendered by default.

e2e/artillery/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# 🚀 Run Artillery tests
2+
3+
- LOG_LEVEL= `debug` | `info` | `silent` | `debug2` (raw console.log)
4+
- NETWORK= `naga-dev` | `naga-staging`
5+
6+
### Basic functionality verification
7+
8+
**⭐️ Purpose**: Basic sanity check
9+
10+
- **Users**: 3 people max, 1 new user every minute
11+
- **Duration**: 30 seconds
12+
- **Tests**: All main functions once
13+
- **When to use**: Before releasing code, quick health check, "did I break anything?"
14+
15+
```jsx
16+
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:smoke
17+
```
18+
19+
### Normal traffic simulation
20+
21+
**⭐️ Purpose**: Simulates typical everyday usage
22+
23+
- **Users**: 30 people max, 10 new users per second during peak
24+
- **Duration**: 5 minutes total (1min ramp up, 3min steady, 1min ramp down)
25+
- **Tests**: All functions with realistic ratios (40% signing, 30% encryption, 20% JS execution, 10% viewing)
26+
- **When to use**: "Will this handle our normal traffic?"
27+
28+
```jsx
29+
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:load
30+
```
31+
32+
### Find breaking points
33+
34+
**⭐️ Purpose**: Pushes system beyond normal limits to find where it breaks
35+
36+
- **Users**: 200 people max, up to 50 new users per second
37+
- **Duration**: 11 minutes of gradually increasing pressure
38+
- **Tests**: Same mix as load test but much more intense
39+
- **When to use**: "How much traffic can we handle before things go wrong?"
40+
41+
```jsx
42+
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:stress
43+
```
44+
45+
### Test traffic spikes
46+
47+
**⭐️ Purpose**: Sudden traffic bursts (like when your app goes viral)
48+
49+
- **Users**: 400 people max during spikes, jumps from 2 to 150 users/second instantly
50+
- **Duration**: 6 minutes with two sudden traffic spikes
51+
- **Tests**: Focuses on signing and encryption (most critical functions)
52+
- **When to use**: "What happens if we suddenly get 100x more traffic?"
53+
54+
```jsx
55+
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:spike
56+
```
57+
58+
### PKP Sign Focused
59+
60+
**⭐️ Purpose**: Hammers the PKP signing functionality specifically
61+
62+
- **Users**: 50 people max, 15 new users per second during peak
63+
- **Duration**: 7 minutes with sustained high signing load
64+
- **Tests**: ONLY PKP signing with different authentication methods
65+
- **When to use**: "Is our signing service robust enough for heavy use?"
66+
67+
```jsx
68+
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:pkp-sign
69+
```
70+
71+
### Encrypt-Decrypt Focused
72+
73+
**⭐️ Purpose**: Hammers encryption/decryption functionality specifically
74+
75+
- **Users**: 30 people max, 8 new users per second during peak
76+
- **Duration**: 6 minutes of sustained encryption/decryption
77+
- **Tests**: ONLY encryption and decryption functions
78+
- **When to use**: "Can our encryption handle lots of data processing?"
79+
80+
```jsx
81+
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:encrypt-decrypt
82+
```
83+
84+
## (Optional) Generating a report
85+
86+
Generating a report required an API key, you can add that to the root `.env` file. You can find your key at [https://app.artillery.io/](https://app.artillery.io/oivpr8dw4i00f)
87+
88+
```jsx
89+
ARTILLERY_KEY = xxx;
90+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
config:
2+
target: "dummy" # Not used but required by Artillery
3+
phases:
4+
- duration: 60
5+
arrivalRate: 3
6+
maxVusers: 15
7+
name: "Ramp Up"
8+
- duration: 240
9+
arrivalRate: 8
10+
maxVusers: 30
11+
name: "Sustained Encrypt/Decrypt"
12+
- duration: 60
13+
arrivalRate: 3
14+
maxVusers: 15
15+
name: "Ramp Down"
16+
processor: "../processors/multi-endpoint.ts"
17+
http:
18+
defaults:
19+
think:
20+
jitter: 75
21+
variables:
22+
parallelism: 6
23+
testSuite: "encrypt-decrypt-focused"
24+
25+
scenarios:
26+
- name: "PKP Encrypt/Decrypt Flow"
27+
weight: 50
28+
flow:
29+
- function: "runPkpEncryptDecryptTest"
30+
- name: "Complete Encrypt/Decrypt Flow"
31+
weight: 50
32+
flow:
33+
- function: "runEncryptDecryptFlowTest"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
config:
2+
target: "dummy" # Not used but required by Artillery
3+
phases:
4+
- duration: 60
5+
arrivalRate: 5
6+
maxVusers: 15
7+
name: "Ramp Up"
8+
- duration: 180
9+
arrivalRate: 10
10+
maxVusers: 30
11+
name: "Sustained Load"
12+
- duration: 60
13+
arrivalRate: 5
14+
maxVusers: 15
15+
name: "Ramp Down"
16+
processor: "../processors/multi-endpoint.ts"
17+
http:
18+
defaults:
19+
think:
20+
jitter: 100
21+
variables:
22+
parallelism: 5
23+
testSuite: "load"
24+
25+
scenarios:
26+
- name: "PKP Sign Load Test"
27+
weight: 40
28+
flow:
29+
- function: "runPkpSignTest"
30+
- name: "Encrypt/Decrypt Load Test"
31+
weight: 30
32+
flow:
33+
- function: "runEncryptDecryptTest"
34+
- name: "Execute JS Load Test"
35+
weight: 20
36+
flow:
37+
- function: "runExecuteJsTest"
38+
- name: "View PKPs Load Test"
39+
weight: 10
40+
flow:
41+
- function: "runViewPkpsTest"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
config:
2+
target: "dummy" # Not used but required by Artillery
3+
phases:
4+
- duration: 60
5+
arrivalRate: 5
6+
maxVusers: 20
7+
name: "Ramp Up"
8+
- duration: 300
9+
arrivalRate: 15
10+
maxVusers: 50
11+
name: "Sustained PKP Signing"
12+
- duration: 60
13+
arrivalRate: 5
14+
maxVusers: 20
15+
name: "Ramp Down"
16+
processor: "../processors/multi-endpoint.ts"
17+
http:
18+
defaults:
19+
think:
20+
jitter: 50
21+
variables:
22+
parallelism: 8
23+
testSuite: "pkp-sign-focused"
24+
25+
scenarios:
26+
- name: "PKP Sign with EOA Auth"
27+
weight: 40
28+
flow:
29+
- function: "runPkpSignTestWithEoa"
30+
- name: "PKP Sign with PKP Auth"
31+
weight: 40
32+
flow:
33+
- function: "runPkpSignTestWithPkp"
34+
- name: "PKP Sign with Custom Auth"
35+
weight: 20
36+
flow:
37+
- function: "runPkpSignTestWithCustom"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
config:
2+
target: "dummy" # Not used but required by Artillery
3+
phases:
4+
- duration: 30
5+
arrivalRate: 1
6+
maxVusers: 3
7+
name: "Smoke Test - Basic Functionality"
8+
processor: "../processors/multi-endpoint.ts"
9+
http:
10+
defaults:
11+
think:
12+
jitter: 0
13+
variables:
14+
parallelism: 1
15+
testSuite: "smoke"
16+
17+
scenarios:
18+
- name: "Multi-Endpoint Smoke Test"
19+
weight: 100
20+
flow:
21+
- function: "runMultiEndpointTest"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
config:
2+
target: "dummy" # Not used but required by Artillery
3+
phases:
4+
- duration: 60
5+
arrivalRate: 2
6+
maxVusers: 10
7+
name: "Normal Load"
8+
- duration: 30
9+
arrivalRate: 100
10+
maxVusers: 300
11+
name: "Traffic Spike"
12+
- duration: 120
13+
arrivalRate: 2
14+
maxVusers: 10
15+
name: "Recovery Period"
16+
- duration: 30
17+
arrivalRate: 150
18+
maxVusers: 400
19+
name: "Second Spike"
20+
- duration: 90
21+
arrivalRate: 2
22+
maxVusers: 10
23+
name: "Final Recovery"
24+
processor: "../processors/multi-endpoint.ts"
25+
http:
26+
defaults:
27+
think:
28+
jitter: 25
29+
variables:
30+
parallelism: 15
31+
testSuite: "spike"
32+
33+
scenarios:
34+
- name: "PKP Sign Spike Test"
35+
weight: 60
36+
flow:
37+
- function: "runPkpSignTest"
38+
- name: "Encrypt/Decrypt Spike Test"
39+
weight: 40
40+
flow:
41+
- function: "runEncryptDecryptTest"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
config:
2+
target: "dummy" # Not used but required by Artillery
3+
phases:
4+
- duration: 120
5+
arrivalRate: 10
6+
maxVusers: 50
7+
name: "Initial Ramp Up"
8+
- duration: 240
9+
arrivalRate: 25
10+
maxVusers: 100
11+
name: "High Load"
12+
- duration: 180
13+
arrivalRate: 50
14+
maxVusers: 200
15+
name: "Peak Stress"
16+
- duration: 120
17+
arrivalRate: 10
18+
maxVusers: 50
19+
name: "Cool Down"
20+
processor: "../processors/multi-endpoint.ts"
21+
http:
22+
defaults:
23+
think:
24+
jitter: 50
25+
variables:
26+
parallelism: 10
27+
testSuite: "stress"
28+
29+
scenarios:
30+
- name: "PKP Sign Stress Test"
31+
weight: 50
32+
flow:
33+
- function: "runPkpSignTest"
34+
- name: "Encrypt/Decrypt Stress Test"
35+
weight: 30
36+
flow:
37+
- function: "runEncryptDecryptTest"
38+
- name: "Execute JS Stress Test"
39+
weight: 20
40+
flow:
41+
- function: "runExecuteJsTest"

0 commit comments

Comments
 (0)