Skip to content

Commit

Permalink
소켓 부하 테스트 (#199)
Browse files Browse the repository at this point in the history
* fix: random name util 함수 소소한 버그 수정

- trim
- 타입 명시

* feat: message 이벤트에서 name 한 번 더 검사

부하 테스트 결과, 빈 이름이 올 때가 많았습니다.

* chore: 부하 테스트 툴 artillery 설치

* feat: socket 부하 테스트 yml 추가

* fix: 한 번 더 검증하는 로직 삭제
  • Loading branch information
Kontae authored Dec 3, 2024
1 parent 008eb7f commit e97dbdd
Show file tree
Hide file tree
Showing 4 changed files with 7,163 additions and 186 deletions.
5 changes: 4 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
"test:e2e": "jest --config ./test/jest-e2e.json",
"test:load": "artillery run socket-test.yml"
},
"dependencies": {
"@ffmpeg-installer/ffmpeg": "^1.1.0",
Expand All @@ -38,6 +39,7 @@
"@types/fluent-ffmpeg": "^2.1.27",
"@types/jest": "^29.5.14",
"@types/socket.io": "^3.0.2",
"artillery-engine-socketio-v3": "^1.2.0",
"aws-sdk": "^2.1692.0",
"bcrypt": "^5.1.1",
"cache-manager": "5.2.3",
Expand Down Expand Up @@ -74,6 +76,7 @@
"@types/node": "^22.9.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"artillery": "^2.0.21",
"eslint": "^8.42.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
Expand Down
46 changes: 46 additions & 0 deletions server/socket-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
config:
# 일단 로컬 환경 URL
target: 'http://localhost:3000'
phases:
# 10초 동안
- duration: 10
# 1초에 20명
arrivalRate: 20
engines:
socketio-v3:
transports: ['websocket']
timeout: 10000
variables:
# 원하는 roomId 설정
roomId: '7b82b46b-d705-48a5-9bc5-918ee1a124a0'
scenarios:
- name: 'Chat room flow'
engine: socketio-v3
flow:
- think: 1

- namespace: '/rooms'
connect:
query: 'roomId={{ roomId }}'
headers:
x-forwarded-for: '{{ $randomNumber(1000000, 9999999) }}'

- think: 2

- namespace: '/rooms'
emit:
channel: 'message'
data:
message: 'Test message'
roomId: '{{ roomId }}'

- think: 1

- namespace: '/rooms'
emit:
channel: 'vote'
data:
# 일단 노래 두 개가 있다고 가정하고, 랜덤 값 지정
trackNumber: "{{ $randomNumber(1,2) }}"

- think: 30
6 changes: 3 additions & 3 deletions server/src/common/randomname/random-name.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class RandomNameUtil {
'청결한',
'상냥한',
'예의바른',
'높은 ',
'높은',
'먼',
'정직한',
'성실한',
Expand All @@ -49,7 +49,7 @@ export class RandomNameUtil {
'고릴라',
'자리',
'코뿔소',
'북극곰 ',
'북극곰',
'회색곰',
'침팬지',
'돌고래',
Expand All @@ -59,7 +59,7 @@ export class RandomNameUtil {
'토끼',
];

public static generate() {
public static generate(): string {
const adjectvieLength = RandomNameUtil.adjective.length;
const animalLength = RandomNameUtil.animal.length;

Expand Down
Loading

0 comments on commit e97dbdd

Please sign in to comment.