-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BE#332] 소셜 기능 k6 부하 테스트 코드 작성 (#341)
* test: 소셜 기능 k6 부하 테스트 코드 작성 - 소셜 기능 부하 테스트 코드 작성 - faker를 이용해서 학습 기록 부하 테스트 데이터 현실적인 데이터로 변경 - 소셜 기능 부하 테스트 데이터 현실적인 데이터 faker로 생성 * fix: 폴링 api와 조회 api 통일해서 테스트
- Loading branch information
Showing
4 changed files
with
78 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { SharedArray } from 'k6/data'; | ||
import http from 'k6/http'; | ||
import { check, sleep, group } from 'k6'; | ||
import { setInterval, setTimeout, clearInterval } from 'k6/experimental/timers'; | ||
import moment from 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js'; | ||
import faker from 'https://cdnjs.cloudflare.com/ajax/libs/Faker/3.1.0/faker.min.js'; | ||
|
||
const tokens = new SharedArray('possible tokens', function () { | ||
const mock_users = JSON.parse(open('./loadtest-mock.json')); | ||
return mock_users.map(({ access_token }) => access_token); | ||
}); | ||
|
||
export let options = { | ||
stages: [ | ||
{ duration: '30s', target: 50 }, | ||
{ duration: '20s', target: 0 }, | ||
], | ||
thresholds: { | ||
http_req_duration: ['avg<200', 'p(95)<500', 'max<1000'], | ||
http_reqs: ['rate>100'], | ||
}, | ||
}; | ||
|
||
export default function () { | ||
const token = tokens[__VU % tokens.length]; | ||
const url = 'http://localhost:3000/mates'; | ||
const params = { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
}; | ||
|
||
const date = moment(faker.date.between('2023-11-23', '2023-11-30')); | ||
check(http.get(`${url}?date=${date}`, params), { | ||
'친구 조회 응답 시간이 1초 이내': (r) => r.timings.duration < 1000, | ||
}); | ||
sleep(3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters