-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38cc2d4
commit d51b7fb
Showing
5 changed files
with
125 additions
and
3 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -37,3 +37,6 @@ bin/ | |
|
||
### Mac OS ### | ||
.DS_Store | ||
|
||
### .env ### | ||
.env |
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
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,66 @@ | ||
package simulation; | ||
|
||
import static io.gatling.javaapi.core.CoreDsl.StringBody; | ||
import static io.gatling.javaapi.core.CoreDsl.constantUsersPerSec; | ||
import static io.gatling.javaapi.core.CoreDsl.jsonPath; | ||
import static io.gatling.javaapi.core.CoreDsl.rampUsersPerSec; | ||
import static io.gatling.javaapi.core.CoreDsl.scenario; | ||
import static io.gatling.javaapi.http.HttpDsl.http; | ||
import static io.gatling.javaapi.http.HttpDsl.status; | ||
import static protocol.Protocol.httpProtocol; | ||
|
||
import io.gatling.javaapi.core.ScenarioBuilder; | ||
import io.gatling.javaapi.core.Simulation; | ||
import java.time.Duration; | ||
import java.time.temporal.ChronoUnit; | ||
import net.datafaker.Faker; | ||
|
||
public class TeumTeumApiSimulation extends Simulation { | ||
|
||
private static final Faker faker = new Faker(); | ||
private final ScenarioBuilder teumteumScn = scenario("TeumTeum 찬해지기 API 부하 테스트를 진행한다.") | ||
.exec(session -> | ||
session | ||
.set("id", java.util.UUID.randomUUID().toString()) | ||
.set("name", faker.name().fullName())) | ||
|
||
.exec(http("User 카드 등록 API 요청") | ||
.post("/users") | ||
.body(StringBody( | ||
"{" | ||
+ "\"id\": \"${id}\", " | ||
+ "\"terms\": {\"service\": true, \"privatePolicy\": true}, " | ||
+ "\"name\": \"${name}\", " | ||
+ "\"birth\": \"20000402\", " | ||
+ "\"characterId\": 2, " | ||
+ "\"authenticated\": \"네이버\", " | ||
+ "\"activityArea\": \"경기 시흥\", " | ||
+ "\"mbti\": \"ENFP\", " | ||
+ "\"status\": \"직장인\", " | ||
+ "\"job\": {\"name\" : \"카카오 뱅크\", \"class\" : \"개발\", \"detailClass\" : \"BE 개발자\"}, " | ||
+ "\"interests\": [\"네트워킹\", \"IT\", \"모여서 각자 일하기\"], " | ||
+ "\"goal\": \"회사에서 좋은 사람들과 멋진 개발하기\"" | ||
+ "}" | ||
)) | ||
.check(status().is(201)) | ||
.check(jsonPath("$.id").saveAs("userId")) | ||
.check(jsonPath("$.accessToken").saveAs("accessToken")) | ||
.check(jsonPath("$.refreshToken").saveAs("refreshToken"))) | ||
|
||
.exec(http("TeumTeum 친해지기 API 요청") | ||
.post("/teum-teum/around") | ||
.header("Authorization", "Bearer ${accessToken}") | ||
.body(StringBody("{\"id\": ${userId}, \"latitude\": 37.5665, \"longitude\": 126.9780," | ||
+ " \"name\": \"test_name\", \"jobDetailClass\": \"test_job\", \"characterId\": 1}")) | ||
.check(status().is(200)) | ||
); | ||
|
||
{ | ||
setUp( | ||
teumteumScn.injectOpen( | ||
constantUsersPerSec(10).during(Duration.of(30, ChronoUnit.SECONDS)), | ||
rampUsersPerSec(10).to(50).during(Duration.of(30, ChronoUnit.SECONDS)) | ||
).protocols(httpProtocol) | ||
); | ||
} | ||
} |
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,54 @@ | ||
package simulation; | ||
|
||
import static io.gatling.javaapi.core.CoreDsl.StringBody; | ||
import static io.gatling.javaapi.core.CoreDsl.atOnceUsers; | ||
import static io.gatling.javaapi.core.CoreDsl.jsonPath; | ||
import static io.gatling.javaapi.core.CoreDsl.scenario; | ||
import static io.gatling.javaapi.http.HttpDsl.http; | ||
import static io.gatling.javaapi.http.HttpDsl.status; | ||
import static protocol.Protocol.httpProtocol; | ||
|
||
import io.gatling.javaapi.core.ScenarioBuilder; | ||
import io.gatling.javaapi.core.Simulation; | ||
|
||
public class UserApiSimulation extends Simulation { | ||
|
||
private final ScenarioBuilder UserScn = scenario("User API 부하 테스트를 진행한다.") | ||
.exec(http("User 카드 등록 API 요청") | ||
.post("/users") | ||
.body(StringBody( | ||
"{\"id\": \"test_id\", " | ||
+ "\"terms\": {\"service\": true, \"privatePolicy\": true}, " | ||
+ "\"name\": \"홍길동\", " | ||
+ "\"birth\": \"1990-01-01\", " | ||
+ "\"characterId\": 1, " | ||
+ "\"authenticated\": \"SNS\", " | ||
+ "\"activityArea\": \"서울\", " | ||
+ "\"mbti\": \"INTJ\", " | ||
+ "\"status\": \"ACTIVE\", " | ||
+ "\"job\": {\"name\": \"개발자\", \"class\": \"IT\", \"detailClass\": \"백엔드\"}, " | ||
+ "\"interests\": [\"코딩\", \"독서\", \"운동\"], " | ||
+ "\"goal\": \"성장하기 위해 노력하는 개발자가 되기\"}" | ||
)) | ||
.check(status().is(201)) | ||
.check(jsonPath("$.id").saveAs("userId")) | ||
.check(jsonPath("$.accessToken").saveAs("accessToken")) | ||
.check(jsonPath("$.refreshToken").saveAs("refreshToken")) | ||
|
||
).exec(http("User 정보 조회 API 요청") | ||
.get("/users/${userId}") | ||
.header("Authorization", "Bearer ${accessToken}") | ||
.check(status().is(200)) | ||
|
||
).exec(http("User 리뷰 조회 API 요청") | ||
.get("/users/${userId}") | ||
.header("Authorization", "Bearer ${accessToken}") | ||
.check(status().is(200))); | ||
|
||
|
||
{ | ||
setUp( | ||
UserScn.injectOpen( | ||
atOnceUsers(10)).protocols(httpProtocol)); | ||
} | ||
} |