安装
以linux,这里采用的版本是centos 6 64bit,性能测试工具不建议在Windows上部署。
下载:
https://github.com/naver/ngrinder/releases/
选择最后面的war包。
服务器端启动:
# java -XX:MaxPermSize=200m -jar ngrinder-controller-3.4.war --port 8058
这样nGrinder的管理页面就部署好,你可以简单的把ngrinder-controller的功能理解为性能测试展示和控制,后面会进行详细介绍。
打开网址:
http://183.131.22.113:8058
默认用户名和密码都为admin
注意:这里的"Remember me"是短暂停留,页面关闭之后还是需要重新登陆的。
登录后点击右上角的admin,选择"下载代理"
拷贝下载的文件到agent,现在可以简单理解为agent的功能为执行性能测试,通常不建议与ngrinder-controller部署在同一台,同一台机器也不建议部署多个agent。
客户端启动:
# nohup ./run_agent.sh &
快速入门
- 输入网址 http://172.30.249.160
- 配置
- jython脚本
点击 REV:HEAD,可以看到jython脚本
- 运行
点击"复制并运行"
- 查看结果
点击"详细测试结果"
参考资料
- 技术支持qq群144081101(代码和模型存放)
- 本文最新版本地址
- 本文涉及的python测试开发库 谢谢点赞!
- 本文相关海量书籍下载
- 2018最佳人工智能机器学习工具书及下载(持续更新)
- 接口测试面试题.pdf
- 软件测试精品书籍下载
测试配置
注意agent RAM up配置是基于进程的,一般每个agent有10个进程。
脚本
首先要配置:grinder.properties,通常在用户目录的.ngrinder目录下。
脚本使用Grinder脚本API,参见:http://grinder.sourceforge.net/g3/script-javadoc/index.html
脚本中的grinder对象是ScriptContext实例,这样就可以获取上下文信息。
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
参考资料
- 讨论 qq群144081101 567351477
- 本文最新版本地址
- 本文涉及的python测试开发库 谢谢点赞!
- 本文相关海量书籍下载
- 道家技术-手相手诊看相中医等钉钉群21734177 qq群:391441566 184175668 338228106 看手相、面相、舌相、抽签、体质识别。服务费50元每人次起。请联系钉钉或者微信pythontesting
- 接口自动化性能测试线上培训大纲
- Monitoring