import time
from locust import HttpUser, task, between
import json
import random
game_room_list = [
{
"roomId" : "e47b2a75-003f-4420-bdaa-eed369f121b4",
"gamerId" : 1329
},
{
"roomId": "71cf2f67-0dbd-4540-b1bb-dcfe7468e2c3",
"gamerId": 1330
},
{
"roomId": "fd7906a9-1c6c-414a-9ae6-cdd1130bd60b",
"gamerId": 1331
},
{
"roomId": "941e133b-536d-4d45-817b-3fd1152dce5e",
"gamerId": 1332
},
{
"roomId": "33609155-5960-4686-98b0-36ecde8ba1e4",
"gamerId": 1333
},
{
"roomId": "706bd11b-a91f-469b-af7c-86872e8e2123",
"gamerId": 1334
},
{
"roomId": "13819427-6f64-45f0-9218-655604194b73",
"gamerId": 1335
},
{
"roomId": "62b7d4bd-4fe0-4ebc-adc3-9fb8ca20bf2e",
"gamerId": 1336
},
{
"roomId": "b0795412-4675-4b9b-8b0b-f51ed38892f7",
"gamerId": 1337
},
{
"roomId": "be8fe367-f0ae-4f57-8abd-f635f9def5da",
"gamerId": 1338
},
{
"roomId": "63eedc5e-4b42-49d4-942a-66188a7303b7",
"gamerId": 1339
},
{
"roomId": "7c0ca297-1305-4cb2-9788-780fffb18dab",
"gamerId": 1340
},
{
"roomId": "10c9a2d2-7355-4146-b5d4-5add9d617f41",
"gamerId": 1341
},
{
"roomId": "906fa5b2-233d-45f7-a5c4-083feafb8023",
"gamerId": 1342
},
{
"roomId": "0066ffb9-4862-45e0-9de2-2de1177a709d",
"gamerId": 1343
},
{
"roomId": "159c630a-f1ee-46f1-907f-b1313238e576",
"gamerId": 1344
}
]
class QuickstartUser(HttpUser):
wait_time = between(3, 5)
# 닉네임 조회 Task
@task
def chat_room(self):
self.client.get("/")
self.client.post("/api/members/login", json={"username":"moon5@naver.com", "password":"ssafy123!"})
# 게임 생성 Task
@task
def game_create(self):
self.client.get("/")
self.client.post("/api/games/init", json={"theme":"COVID",
"turnPerTime":"DAY",
"startTime":0,
"totalTurn":10,
"memberIdList":[1]})
# 게임 진행 Task
@task
def game_progress(self):
list_index = random.randrange(0, len(game_room_list))
self.client.get("/")
self.client.post("/api/games/game", json={json.dumps(game_room_list[list_index])})
게임방을 미리 생성해둔 채로 진행.
닉네임 조회, 게임 생성, 게임 조회를 수행하도록 함.
게임방 생성을 계속해서 해줘야 하므로, 한번의 테스트로 Insight를 얻을 수 있도록 Number of Users, spawn rate를 조정