Skip to content

Commit

Permalink
Merge pull request #7 from aws-cloud-clubs/test/6-load-testing
Browse files Browse the repository at this point in the history
Load Testing 페이로드 spec에 맞게 수정
  • Loading branch information
Coldot authored Aug 2, 2024
2 parents e6b22b4 + a0fe44f commit 5228b8e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/.DS_Store
.idea
31 changes: 31 additions & 0 deletions chat/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SOURCE
FROM alpine as source
RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
RUN echo Asia/Seoul > /etc/timezone

WORKDIR /project
COPY . .


# BUILD (INCLUDE TEST)
FROM azul/zulu-openjdk-alpine:17-latest AS build
RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
RUN echo Asia/Seoul > /etc/timezone

WORKDIR /project
COPY --from=source project .

ENTRYPOINT ["./gradlew", "build"]


# RUNNER
FROM azul/zulu-openjdk-alpine:17-jre-latest AS runner
RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
RUN echo Asia/Seoul > /etc/timezone

WORKDIR /project

ARG JAR_FILE=project/build/libs/*.jar
COPY ${JAR_FILE} app.jar

ENTRYPOINT ["java", "-jar", "app.jar"]
13 changes: 11 additions & 2 deletions performance_test/src/load/locustfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import time
import json
from datetime import datetime
from locust import User, task, between

from src.common.stomp import StompClient
Expand All @@ -25,7 +27,7 @@ def on_start(self):
for i in range(self.vuser):
self.__stomp_clients.append(StompClient(self.host, self.port, self.endpoint))
self.__stomp_clients[i].connect()
self.__stomp_clients[i].subscribe(f"/topic/chat/{self.room_id}")
self.__stomp_clients[i].subscribe(f"/topic/chat/{self.room_id}", f"user{i}")

def on_stop(self):
for i in range(self.vuser):
Expand All @@ -35,7 +37,14 @@ def on_stop(self):
def send_receive_hello(self):
start_time = time.time()

self.__stomp_clients[0].send("/topic/chat", "Hello, world!")
payload = json.dumps({
"chatRoomId": self.room_id,
"type": "MESSAGE",
"createdBy": "user0",
"text": "Hello, world!",
"createdAt": datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
})
self.__stomp_clients[0].send("/topic/chat", payload)

for i in range(1, self.vuser):
msg = self.__stomp_clients[i].receive()
Expand Down

0 comments on commit 5228b8e

Please sign in to comment.