-
Locust - Performance Test ManualStudy 2023. 5. 17. 11:21
시작하며
- Python 스크립트 기반 성능 테스트 도구
- 테스트 시나리오 아카이빙, 문서 자동 완성
- Ramp-up에 대한 유연성
- 비동기 접근 방식 처리로 단일 시스템에서 수천명의 동시 사용자 구현 가능 (Gevent)
- ( 메뚜기 떼가 휩쓰는 이미지가 성능 테스트와 비슷하다고 해서 메뚜기(Locust)로 작명 )
안내서
Writing a locustfile — Locust 2.15.1 documentation
HttpUser is the most commonly used User. It adds a client attribute which is used to make HTTP requests. client attribute / HttpSession client is an instance of HttpSession. HttpSession is a subclass/wrapper for requests.Session, so its features are well d
docs.locust.io
소스코드
# locustfile.py # TEST START : locust # TEST with Tags : locust --tags (TAG NAME) from locust import FastHttpUser, task, between, TaskSet, tag, events from urllib3 import PoolManager @events.test_start.add_listener # 테스트가 시작되면서 실행하는 task def on_test_start(environment, **kwargs): print("A swarm of locusts is approaching.") @events.test_stop.add_listener # 테스트가 종료되면서 실행하는 task def on_test_stop(environment, **kwargs): print("There is nothing left.") class TaskList(TaskSet): @tag('GET') # 태그 지정을 통해 단일 테스트 실행 가능 @task(3) # 숫자가 높을 수록 테스트 비중 증가 def get(self): self.client.get('/get') @tag('POST') @task(1) def post(self): self.client.post('/post', json={"text": "LOCUST"}) class LocustUser(FastHttpUser): host = "<http://localhost:8080>" tasks = [TaskList] wait_time = between(0.5, 1.5) # task 사이의 대기시간 pool_manager = PoolManager(num_pools=10) # 커넥션 풀 사이즈
실행
- Number of Users : 최종 유저 수
- Spawn Rate : 초당 증가하는 유저 수
- Host : 테스트 URL
보고서
'Study' 카테고리의 다른 글
Optimizing JVM GC: Choosing Wisely (0) 2024.01.17 Leveraging BDD for Effective Spring Boot Test Cases (0) 2023.10.10 Network Notebook (0) 2023.04.18 Security Filter Chain (0) 2023.03.16 GitHub Action :: Gradle Build 캐싱 (0) 2022.11.24