安裝
以linux拒啰,這里采用的版本是centos 6 64bit幔亥,性能測(cè)試工具不建議在Windows上部署予借。
下載:
https://github.com/naver/ngrinder/releases/
選擇最后面的war包宇姚。
服務(wù)器端啟動(dòng):
# java -XX:MaxPermSize=200m -jar ngrinder-controller-3.4.war --port 8058
這樣nGrinder的管理頁(yè)面就部署好尝哆,你可以簡(jiǎn)單的把ngrinder-controller的功能理解為性能測(cè)試展示和控制秉撇,后面會(huì)進(jìn)行詳細(xì)介紹。
打開網(wǎng)址:
http://183.131.22.113:8058
默認(rèn)用戶名和密碼都為admin
注意:這里的"Remember me"是短暫停留秋泄,頁(yè)面關(guān)閉之后還是需要重新登陸的琐馆。
登錄后點(diǎn)擊右上角的admin,選擇"下載代理"
拷貝下載的文件到agent恒序,現(xiàn)在可以簡(jiǎn)單理解為agent的功能為執(zhí)行性能測(cè)試瘦麸,通常不建議與ngrinder-controller部署在同一臺(tái),同一臺(tái)機(jī)器也不建議部署多個(gè)agent歧胁。
客戶端啟動(dòng):
# nohup ./run_agent.sh &
快速入門
- 輸入網(wǎng)址
http://172.30.249.160
- 配置
- jython腳本
點(diǎn)擊 REV:HEAD滋饲,可以看到j(luò)ython腳本
- 運(yùn)行
點(diǎn)擊"復(fù)制并運(yùn)行"
- 查看結(jié)果
點(diǎn)擊"詳細(xì)測(cè)試結(jié)果"
參考資料
- 技術(shù)支持qq群144081101(代碼和模型存放)
- 本文最新版本地址
- 本文涉及的python測(cè)試開發(fā)庫(kù) 謝謝點(diǎn)贊!
- 本文相關(guān)海量書籍下載
- 2018最佳人工智能機(jī)器學(xué)習(xí)工具書及下載(持續(xù)更新)
- 接口測(cè)試面試題.pdf
- 軟件測(cè)試精品書籍下載
測(cè)試配置
注意agent RAM up配置是基于進(jìn)程的喊巍,一般每個(gè)agent有10個(gè)進(jìn)程屠缭。
腳本
首先要配置:grinder.properties,通常在用戶目錄的.ngrinder目錄下崭参。
腳本使用Grinder腳本API呵曹,參見:http://grinder.sourceforge.net/g3/script-javadoc/index.html
腳本中的grinder對(duì)象是ScriptContext實(shí)例,這樣就可以獲取上下文信息何暮。
Hello World
# Hello World
#
# A minimal script that tests The Grinder logging facility.
#
# This script shows the recommended style for scripts, with a
# TestRunner class. The script is executed just once by each worker
# process and defines the TestRunner class. The Grinder creates an
# instance of TestRunner for each worker thread, and repeatedly calls
# the instance for each run of that thread.
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
# A shorter alias for the grinder.logger.info() method.
log = grinder.logger.info
# Create a Test with a test number and a description. The test will be
# automatically registered with The Grinder console if you are using
# it.
test1 = Test(1, "Log method")
# Instrument the info() method with our Test.
test1.record(log)
# A TestRunner instance is created for each thread. It can be used to
# store thread-specific data.
class TestRunner:
# This method is called for every run.
def __call__(self):
log("Hello World")
Simple HTTP example
# A simple example using the HTTP plugin that shows the retrieval of a
# single page via HTTP. The resulting page is written to a file.
#
# More complex HTTP scripts are best created with the TCPProxy.
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest
test1 = Test(1, "Request resource")
request1 = HTTPRequest()
test1.record(request1)
class TestRunner:
def __call__(self):
result = request1.GET("http://localhost:7001/")
# result is a HTTPClient.HTTPResult. We get the message body
# using the getText() method.
writeToFile(result.text)
# Utility method that writes the given string to a uniquely named file.
def writeToFile(text):
filename = "%s-page-%d.html" % (grinder.processName, grinder.runNumber)
file = open(filename, "w")
print >> file, text
file.close()
更多腳本奄喂,參見: http://grinder.sourceforge.net/g3/script-gallery.html