-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstress.js
111 lines (99 loc) · 2.97 KB
/
stress.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import http from "k6/http";
import { check, sleep } from "k6";
export let options = {
stages: [
{ duration: "1m", target: 500 },
{ duration: "4m", target: 500 },
{ duration: "1m", target: 1000 },
{ duration: "4m", target: 1000 },
{ duration: "1m", target: 1500 },
{ duration: "4m", target: 1500 },
{ duration: "1m", target: 2000 },
{ duration: "4m", target: 2000 },
{ duration: "1m", target: 2500 },
{ duration: "4m", target: 2500 },
{ duration: "1m", target: 0 },
],
thresholds: {
http_req_duration: ["p(95)<300"],
},
};
const BASE_URL = "https://thingdong.com";
const ACCESS_TOKEN =
"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ5bWowNjA1IiwiQXV0aCI6IlJPTEVfVVNFUiIsImV4cCI6MTcwMDExODM0OX0.SVDDEHrBeIkRzwXCcd_a9hnTiIBP5a9f1D7_C5kglCw";
const USER_ID = 6;
const requestHeaders = {
Authorization: `Bearer ${ACCESS_TOKEN}`,
};
// 방조회 /api/rooom
function getRoom() {
const url = `${BASE_URL}/api/room?userId=${USER_ID}`;
const params = {
headers: requestHeaders,
};
let pathRes = http.get(url, params);
check(pathRes, {
// 결과를 체크
"success to get path": (res) => res.status === 200, //응답 상태코드가 200이면 성공
});
sleep(1);
}
// 띵구 목록 조회 /api/thinggus
function getThinggus() {
const url = `${BASE_URL}/api/thinggus`;
const params = {
headers: requestHeaders,
};
let pathRes = http.get(url, params);
check(pathRes, {
// 결과를 체크
"success to get path": (res) => res.status === 200, //응답 상태코드가 200이면 성공
});
sleep(1);
}
// 방명록 조회 /api/guest-books
function getGuestBook() {
const url = `${BASE_URL}/api/guest-books?userId=${USER_ID}`;
const params = {
headers: requestHeaders,
};
let pathRes = http.get(url, params);
check(pathRes, {
// 결과를 체크
"success to get path": (res) => res.status === 200, //응답 상태코드가 200이면 성공
});
sleep(1);
}
// 룸 인벤토리에서 오브제 조회 /api/objects/roomInventory
function getObjectFromRoomInventory() {
const url = `${BASE_URL}/api/objects/roomInventory`;
const params = {
headers: requestHeaders,
};
let pathRes = http.get(url, params);
check(pathRes, {
// 결과를 체크
"success to get path": (res) => res.status === 200, //응답 상태코드가 200이면 성공
});
sleep(1);
}
// 인벤토리에서 오브제 조회 /api/objects/inventory
function getObjectFromInventory() {
const url = `${BASE_URL}/api/objects/inventory`;
const params = {
headers: requestHeaders,
};
let pathRes = http.get(url, params);
check(pathRes, {
// 결과를 체크
"success to get path": (res) => res.status === 200, //응답 상태코드가 200이면 성공
});
sleep(1);
}
export default function () {
getObjectFromRoomInventory();
getObjectFromInventory();
getGuestBook();
getThinggus();
getRoom();
}