This repository has been archived by the owner on Dec 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhorizontal_scale.js
76 lines (62 loc) · 2.17 KB
/
horizontal_scale.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import http from 'k6/http'
import { sleep } from 'k6'
import { Counter, Rate } from 'k6/metrics'
export const options = {
scenarios: {
example_scenario: {
// name of the executor to use
executor: 'ramping-arrival-rate',
// common scenario configuration
startRate: '50',
timeUnit: '1s',
// executor-specific configuration
preAllocatedVUs: 50,
maxVUs: 100,
stages: [
{ target: 200, duration: '30s' },
{ target: 0, duration: '30s' },
],
},
},
}
const count200 = new Counter('status_code_2xx')
const count300 = new Counter('status_code_3xx')
const count400 = new Counter('status_code_4xx')
const count500 = new Counter('status_code_5xx')
const rate200 = new Rate('rate_status_code_2xx')
const rate300 = new Rate('rate_status_code_3xx')
const rate400 = new Rate('rate_status_code_4xx')
const rate500 = new Rate('rate_status_code_5xx')
function recordRates(res) {
if (res.status >= 200 && res.status < 300) {
count200.add(1)
rate200.add(1)
} else if (res.status >= 300 && res.status < 400) {
console.log(res.body)
count300.add(1)
rate300.add(1)
} else if (res.status >= 400 && res.status < 500) {
count400.add(1)
rate400.add(1)
} else if (res.status >= 500 && res.status < 600) {
count500.add(1)
rate500.add(1)
}
}
export default function () {
// console.log(`VU: ${__VU} - ITER: ${__ITER}`)
// Sign up for an account
// recordRates(http.get('http://localhost:3000/app/index'))
// sleep(2);
// recordRates(http.get('http://localhost:3000/app/signup'))
// sleep(2);
const headers = {
'Content-Type': 'application/json',
}
const uniqueUser = `${__VU}-${__ITER}`;
// recordRates(http.get("http://localhost:3000/app/index"))
recordRates(http.post('https://xcurrency.cloudcity.computer/auth/signup', `{"name":"${uniqueUser}","email":"${uniqueUser}@gmail.com","password":"12345678"}`, {headers: headers}))
// After signing up, you are redirected to login to the account automatically
// sleep(2);
recordRates(http.post('https://xcurrency.cloudcity.computer/auth/login', `{"email":"${uniqueUser}@gmail.com","password":"12345678"}`, {headers: headers}))
}