Multi mechanize
Click here to load reader
-
Upload
sungmin-oh -
Category
Technology
-
view
657 -
download
0
description
Transcript of Multi mechanize
오픈소스 웹 퍼포먼스 & 로
드 테스팅 프레임워크
Multi-Mechanize
Multi-Mechanize
Web : multimechanize.comPyPI : multi-mechanize packageDev : GitHubLicense : GNU LGPv3Author : Corey Goldberg
Multi-Mechanize?
"파이썬으로 만들어진
퍼포먼스 & 로드 테스트 프레임웍"
- 웹 성능 및 확장성 테스트에서 사용
- 원격 API에 대한 부하를 생성하는데 사용할수 있음
- 출력물은 HTML 또는 JMeter 호환 XML로 저장
설치 ( For Debian/Ubuntu Linux)
@ Linux를 위한 설치 예제입니다. 하지만, 다른 플랫폼에서도 일반적으로 설치방법과 의존성은 같습니다.
- 필수 요구사항* Python 2.6 or 2.7
- 의존성 설치$ sudo apt-get install python-pip python-matplotlib
- multi-mechanize 설치$ sudo pip install -U multi-mechanize
사용방법 (1/2)
- 테스트 프로젝트 생성 : multimech-newproject
$ multimech-newproject PROJECT_PATH
생성한 테스트 프로젝트에는 아래의 파일이 존재하게 됩니다.
● config.cfg : Multi-Mechanize의 구성 파일
- 테스트를 위한 옵션을 설정 합니다.
● test_scripts : 가상 유저를 위한 스크립트가 존재하는 디렉토리
- 테스트를 위한 수행 스크립트를 등록합니다.
● results : 테스트를 수행한 결과자료가 존재하는 디렉토리
- 테스트를 수행하면 Timestamp형태의 이름으로 생성됩니다.
- 로드 테스트 실행 : multimech-run
$ multimech-run project_path
프로젝트 내부의 results 디렉토리 안에
Timestamp 형태의 디렉토리에 결과 파일이 생성 됩니다.
사용방법 (2/2)
Config.cfg 설정 (1/2)
Config.cfg ?테스트 설정을 정의하는 파일로 각각의 프로젝트는 config.cfg 파일을 포함한다.
최소 구성 방법 모든 구성 방법
[global]run_time = 100rampup = 100results_ts_interval = 10
[user_group-1]threads = 10script = vu_script.py
[global]run_time = 300rampup = 300results_ts_interval = 30progress_bar = onconsole_logging = offxml_report = offresults_database = sqlite:///my_project/results.dbpost_run_script = python my_project/foo.py
[user_group-1]threads = 30script = vu_script1.py
[user_group-2]threads = 30script = vu_script2.py
- global options● run_time : 테스트 시간 (초) [필수]● rampup : 사용자의 이용증가 시간(초) [필수]● results_ts_interval : 테스트 결과물의 시간 간격(초) [필수]● progress_bar : 콘솔에 테스트 진행 사항을 표시● console_loggin : 콘솔에 테스트 로그를 표시● xml_report : xml/jtl 리포트를 생성● results_database : 데이터베이스 커넥션 정보● post_run_script : 테스트가 완료된후 수행될 후킹 프로그램 설정
- user groups● thread : 쓰레드/가상유저 수● script : 가상 유저가 테스트 수행할 스크립트 파일
Config.cfg 설정 (2/2)
script (1/2)
- 각 테스트 script 파일은 반드시 Transaction() 클래스를 구현해야한다.
- Transaction 클래스는 run() 메서드를 반드시 구현해야 한다.
- Transaction 클래스는 인스턴스 초기화를 위해 한번 호출되는 __init__() 메서드를 구현할수 있다.
class Transaction : def run(self) : # do something here
script (2/2)
- Transaction 클래스는 인스턴스 초기화를 위해
단 한번 호출되는 __init__() 메서드를 구현할수 있다.
- run() 메서드는 반복해서 호출이 된다.
class Transaction : def __init__(self) : # this gets called once
def run(self) : # this get called repeatedly
로드 테스트 (실습 1/2)
config.cfg script.py
[global]run_time = 120rampup = 120results_ts_interval = 10progress_bar = onconsole_logging = offxml_report = off# results_database = sqlite:///my_project/results.db# post_run_script = python my_project/foo.py
[user_group-1]threads = 100script = v_user1.py
[user_group-2]threads = 100script = v_user2.py
[user_group-3]threads = 100script = v_user3.py
import mechanize
class Transaction:def run(self):
br = mechanize.Browser()br.set_handle_robots(False)resp = br.open('http://www.example.com')assert (resp.code == 200), 'Bad HTTP Response'assert ('"responseCode" : 200' in resp.get_data()), 'API Returned Error'if '"responseCode" : 200' not in resp.get_data() :
print resp.get_data()print '====='
로드 테스트 (실습 2/2)
- multimech-run 실행
- multimech-run 실행 완료
로드 테스트 (결과 리포트 1/3)
통계
- 테스트 요약
- 트랜젝션 타이머
- 사용자 정의 타이머
- time-series/interval data- count- rate/throughput- response time● average, min, max, stdev● percentiles (80, 90, 95)
로드 테스트 (결과 리포트 2/3)
그래프응답시간 분포도
초당 처리량
응답 대기시간
마치며..
Multi-Mechanize는 아래와 같은 장점을 갖음.
- 무료
- 멀티플랫폼 지원 (nix, win)
- Python 으로 구성되는 script로 Python lib를 사용 가능
- 자동 문서 생성
- 단계별 부하 생성
- 상태를 종합하여 결과 생성