-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostscript.js
36 lines (32 loc) · 950 Bytes
/
postscript.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
import http from "k6/http";
import { check, sleep } from "k6";
const categories = ['Entire guesthouse', 'Entire house', 'Entire apartment', 'Entire cabin', 'Entire guest suite', 'Entire cottage', 'Entire villa', 'Entire bungalow', 'Private room', 'Entire loft', 'Shared room'];
export let options = {
vus: 100,
duration: "60s"
};
export default function() {
const url = 'http://localhost:3000/api/listings';
const body = {
category: `${categories[Math.floor(Math.random() * 11)]}`,
beds: 4,
title: 'urban oasis',
price: 842,
score: 4.2,
reviews: 322,
city: 'Guangzhou',
state: 'Guangdong',
country: 'China'
};
const params = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
};
let res = http.post(url, body, params);
check(res, {
"status was 200": (r) => r.status == 201,
"transaction time OK": (r) => r.timings.duration < 2000
});
sleep(0.01);
}