-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathk6postTest.js
More file actions
36 lines (34 loc) · 1.07 KB
/
k6postTest.js
File metadata and controls
36 lines (34 loc) · 1.07 KB
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";
export const options = {
vus: 200,
duration: "10s"
};
// Post operations testing
export default function() {
let recommendation = {
listing_id: Math.floor(Math.random() * 10000000 + 1),
price: 260,
homeType: "Entire place",
bedsNumber: 2,
reviewsAverage: 4.5,
numberOfReviews: 15,
likedStatus: 1,
plusStatus: 0,
image1: `http://airbnb-recommendation-photos.s3-website-us-west-1.amazonaws.com/photo1`,
image2: `http://airbnb-recommendation-photos.s3-website-us-west-1.amazonaws.com/photo2`,
image3: `http://airbnb-recommendation-photos.s3-website-us-west-1.amazonaws.com/photo3`
};
var payload = JSON.stringify(recommendation);
var params = { headers: { "Content-Type": "application/json" } };
const res = http.post(
`http://localhost:3004/listings/${recommendation.listing_id}/recommendations`,
payload,
params
);
check(res, {
"status was 200": r => r.status === 200,
"transaction time OK": r => r.timings.duration < 200
});
sleep(0.01);
}