[雪峰磁针石博客]性能测试工具nGrinder介绍

简介: 安装 以linux,这里采用的版本是centos 6 64bit,性能测试工具不建议在Windows上部署。 下载: https://github.com/naver/ngrinder/releases/ 选择最后面的war包。

安装

以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

捕获.JPG

注意:这里的"Remember me"是短暂停留,页面关闭之后还是需要重新登陆的。

登录后点击右上角的admin,选择"下载代理"

捕获.JPG

拷贝下载的文件到agent,现在可以简单理解为agent的功能为执行性能测试,通常不建议与ngrinder-controller部署在同一台,同一台机器也不建议部署多个agent。

客户端启动:


# nohup ./run_agent.sh  &

快速入门

捕获.PNG

  • 配置

捕获.PNG

  • jython脚本

点击 REV:HEAD,可以看到jython脚本

捕获.PNG

  • 运行

点击"复制并运行"

捕获.PNG

  • 查看结果

捕获.PNG

点击"详细测试结果"

捕获.PNG

参考资料

测试配置

注意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

相关实践学习
通过性能测试PTS对云服务器ECS进行规格选择与性能压测
本文为您介绍如何利用性能测试PTS对云服务器ECS进行规格选择与性能压测。
相关文章
|
9天前
|
测试技术 C语言
网站压力测试工具Siege图文详解
网站压力测试工具Siege图文详解
19 0
|
1月前
|
JavaScript jenkins 测试技术
这10款性能测试工具,收藏起来,测试人的工具箱!
这10款性能测试工具,收藏起来,测试人的工具箱!
|
29天前
|
测试技术
现代软件测试中的自动化工具与挑战
传统软件测试面临着越来越复杂的系统架构和不断增长的测试需求,自动化测试工具应运而生。本文将探讨现代软件测试中自动化工具的应用和挑战,深入分析其优势与局限性,为软件测试领域的发展提供思路和启示。
|
25天前
|
jenkins 测试技术 持续交付
现代软件测试中的自动化工具与挑战
随着软件开发领域的不断发展,自动化测试工具在测试过程中扮演着越来越重要的角色。本文将探讨现代软件测试中自动化工具的应用及面临的挑战,旨在帮助开发人员和测试人员更好地理解和应对自动化测试中的问题。
|
9天前
|
测试技术 Linux Apache
网站压力测试工具webbench图文详解
网站压力测试工具webbench图文详解
8 0
|
18天前
|
Java 测试技术 API
软件测试中的自动化工具与策略
软件测试是确保软件质量的重要环节,而自动化测试工具和策略的应用在提高测试效率和准确性方面发挥着重要作用。本文将介绍几种常见的自动化测试工具,并探讨在软件测试中应用自动化测试的最佳实践和策略。
|
20天前
|
Web App开发 Java 测试技术
深入理解与应用软件自动化测试工具Selenium
随着软件开发的快速发展,软件测试在保证产品质量方面发挥着越来越重要的作用。其中,自动化测试以其效率高、成本低的特点受到了广大开发者的欢迎。本文主要介绍了自动化测试工具Selenium的基本概念、原理以及在实际开发中的应用,旨在帮助读者更好地理解和使用Selenium进行高效的自动化测试。
22 4
|
28天前
|
人工智能 测试技术 虚拟化
现代软件测试中的自动化工具与技术
随着信息技术的迅猛发展,现代软件开发和测试领域也在不断创新。本文将探讨现代软件测试中自动化工具与技术的应用。通过分析自动化测试的优势、挑战以及最佳实践,帮助读者更好地理解当前软件测试领域的发展趋势,并为实际工作提供参考。
16 1
|
29天前
|
Web App开发 前端开发 JavaScript
Python Selenium是一个强大的自动化测试工具
Python Selenium是一个强大的自动化测试工具
|
1月前
|
消息中间件 Kafka Linux
Kafka【付诸实践 03】Offset Explorer Kafka 的终极 UI 工具安装+简单上手+关键特性测试(一篇学会使用 Offset Explorer)
【2月更文挑战第21天】Kafka【付诸实践 03】Offset Explorer Kafka 的终极 UI 工具安装+简单上手+关键特性测试(一篇学会使用 Offset Explorer)
157 2