Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 오블완
- Armeria
- 개발 어렵당.ㅠ
- 티스토리챌린지
- UnsupportedOperationException
- pinpoint
- 노드간 통신
- formik
- hbase 저장공간 설정
- 플루터
- jar 배포
- ㅉ때
- Loki 로그
- nGinder
- pinpoint 2.5.3
- 7879
- fake jwt
- intellij
- 월급루팡 일지
- 애자일 싫타
- Ingress Controller Fake
- R2DBC Paging
- LPOS
- 논블록킹 성능
- RedirectService
- jsonMarshaller
- reids
- 핀포인트
- save/update
- OIDC
Archives
- Today
- Total
대머리개발자
nGinder 스크립트 개발환경 구축 본문
728x90
상단 메뉴 [Script] 를 통해서 웹상에서 직접 스크립트를 생성하고 만들 수 있다.
간단 스크립트는 바로 작성해도 되지만 편하게 작성할 수 있도록 스크립트 개발환경을 구축한다.
※ 참고※ JDK 17+버전에서 정상적으로 동작하지 않아서 전부 다운그레이드 해서 진행했다. Java11까지는 지원되는것 같지만 1.8로 진행
java.lang.IllegalArgumentException: Unsupported class file major version 61
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:196)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:177)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:163)
1. 그루비로 프로젝트 생성한다.
2. 필요 없는(?)는 부분은 주석 처리하고 ngrinder-groovy에 대한 의존을 추가한다.
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.19'
implementation 'org.ngrinder:ngrinder-groovy:3.5.8'
// testImplementation platform('org.junit:junit-bom:5.9.1')
// testImplementation 'org.junit.jupiter:junit-jupiter'
}
웹에서 자동으로 생성되는 스크립트를 복사해서 필요한 부분만 수정해서 작성한다.
import net.grinder.script.GTest
import net.grinder.scriptengine.groovy.junit.GrinderRunner
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.ngrinder.http.HTTPRequest
import org.ngrinder.http.HTTPRequestControl
import org.ngrinder.http.HTTPResponse
import org.ngrinder.http.cookie.Cookie
import static net.grinder.script.Grinder.grinder
@RunWith(GrinderRunner)
class ApiTestRunnerMain {
public static GTest test
public static HTTPRequest request
public static Map<String, String> headers = [:]
public static Map<String, Object> params = [:]
public static List<Cookie> cookies = []
@BeforeProcess
static void beforeProcess() {
HTTPRequestControl.setConnectionTimeout(300000)
test = new GTest(1, "Test1")
request = new HTTPRequest()
grinder.logger.info("before process.")
}
@BeforeThread
void beforeThread() {
test.record(this, "test")
grinder.statistics.delayReports = true
grinder.logger.info("before thread.")
}
@Before
void before() {
headers.put("Authorization", "Bearer JWT")
request.setHeaders(headers)
grinder.logger.info("before. init headers and cookies")
}
@Test
void test() {
HTTPResponse response = request.GET("http://127.0.0.1/event/1", params as Map<String, String>)
if (response.statusCode == 301 || response.statusCode == 302) {
grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", response.statusCode)
} else {
grinder.logger.info("OK", response.statusCode)
}
}
}
바로 실행하면 런타임 예외가 발생하지만 해결책을 금방확인 할 수 있는 친절한 메시지와 함께 있다.
에이전트 다운로드 받아서 실행할 때 옵션으로 넣어준다.
-ea -javaagent:d:\P\ngrinder-agent\lib\grinder-dcr-agent-3.9.1.jar
@Before 단계에서 정상적인 JWT 설정하지 않았기 때문에 401 권한 오류 발생!!
정상적인 JWT 설정하고 테스트 !!! OK!!
이제.. 선착순 이벤트 조져 보자!!
728x90
'개발이야기 > 오픈소스 설치' 카테고리의 다른 글
NKS - Pinpoint (0) | 2024.01.09 |
---|---|
이벤트 서버의 성능 테스트 시작(5) (0) | 2023.11.26 |
이벤트 서버의 성능 테스트를 위한 nGinder 설치 (0) | 2023.11.18 |
k8s - 그라파나 (0) | 2023.11.10 |
k8s - 나의 실패한 Pod 배치전략 (1) | 2023.11.06 |