I would share the testing experience with you. I wish we'll improve together.

Jmeter(一)简介以及环境搭建

上一篇 / 下一篇  2019-03-06 10:24:05 / 个人分类:性能测试

 

 Apache JMeter是Apache组织开发的基于Java压力测试工具。用于对软件做压力测试,它最初被设计用于Web应用测试,但后来扩展到其他测试领域。 它可以用于测试静态和动态资源,例如静态文件、Java 小服务程序、CGI 脚本、Java 对象、数据库、FTP 服务器, 等等。JMeter 可以用于对服务器、网络或对象模拟巨大的负载,来自不同压力类别下测试它们的强度和分析整体性能。另外,JMeter能够对应用程序做功能/回归测试,通过创建带有断言的脚本来验证你的程序返回了你期望的结果。为了最大限度的灵活性,JMeter允许使用正则表达式创建断言。
Apache jmeter 可以用于对静态的和动态的资源(文件,Servlet,Perl脚本,java 对象,数据库和查询,FTP服务器等等)的性能进行测试。它可以用于对服务器、网络或对象模拟繁重的负载来测试它们的强度或分析不同压力类型下的整体性能。你可以使用它做性能的图形分析或在大并发负载测试你的服务器/脚本/对象。
                                                                ----百度百科
  The Apache JMeter™ application is open source software, a 100% pure Java application designed to load test functional behavior. and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.

What can I do with it?

Apache JMeter may be used to test performance both on static and dynamic resources, Web dynamic applications. 
It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types.

Apache JMeter features include:

    • Ability to load and performance test many different applications/server/protocol types:
      • Web - HTTP, HTTPS (Java, NodeJS, PHP, ASP.NET, …)
      • SOAP / REST Webservices
      • FTP
      • Database via JDBC
      • LDAP
      • Message-oriented middleware (MOM) via JMS
      • Mail - SMTP(S), POP3(S) and IMAP(S)
      • Native commands or shell scripts
      • TCP
      • Java Objects
    • Full featured Test IDE that allows fast Test Plan recording (from Browsers or native applications), building and debugging.
    • Command-line mode (Non GUI / headless mode) to load test from any Java compatible OS (Linux, Windows, Mac OSX, …)
    • A complete and ready to present dynamic HTML report
    • Easy correlation through ability to extract data from most popular response formats, HTMLJSON XML orany textual format
    • Complete portability and 100% Java purity.
    • Full multi-threading framework allows concurrent sampling by many threads and simultaneous sampling of different functions by separate thread groups.
    • Caching and offline analysis/replaying of test results.
    • Highly Extensible core:
      • Pluggable Samplers allow unlimited testing capabilities.
      • Scriptable Samplers (JSR223-compatible languages like Groovy and BeanShell)
      • Several load statistics may be chosen with pluggable timers.
      • Data analysis and visualization plugins allow great extensibility as well as personalization.
      • Functions can be used to provide dynamic input to a test or provide data manipulation.
      • Easy Continuous Integration through 3rd party Open Source libraries for Maven, Graddle and Jenkins                                                                                                                                                                                                                  ---------官方介绍(传送门:http://jmeter.apache.org/)  

  个人见解:Jmeter是一款十分优秀的工具,不过笔者觉得它和平常的工具不一样;首先Jmeter是跨系统的,在windows、Mac、Linux均可使用;一方面在于它支持丰富的协议(HTTP、FTP、JDBC、SOCKET。。。);功能方面也相对比较健全(各种各样的逻辑处理,如条件判断,循环,仅一次等等);各种检查点,对文本、Java对象均可进行处理;丰富的图表展示;此外还有许多第三方插件支持以及第三方集成;且最重要的是开源的。。。

  Jmeter安装:

      Jmeter是在JVM上运行的,因此必须先要安装JDK,不过切记一点,截至今天,Jmeter已经更新到3.3版本,它是不支持JDK1.9的,切记!

      

      传送门(http://jmeter.apache.org/download_jmeter.cgi)

      

      至于JDK安装以及环境变量配置,此处便不再列举;

      Jmeter环境变量配置:

      1,变量名:JMETER_HOME

         变量值:E:\apache-jmeter-3.2(根据自己的解压目录而定,笔者使用的是Jmeter3.2的版本)

      2,变量名:CLASSPATH

         变量值:%JMETER_HOME%\lib\ext\ApacheJMeter_core.jar;%JMETER_HOME%\lib\jorphan.jar;%JMETER_HOME%\lib/logkit-2.0.jar;

   OK,环境变量配置结束,可以至E:\apache-jmeter-3.2\bin(安装目录下bin目录)下寻找jmeter.bat文件,双击打开。(可能安装会遇到各种各样的问题,笔者曾经在某些技术群中发现有不用配置环境变量便可以使用(至于到底什么情况,不是当事者也不清楚);还有找不到bat文件(系统默认将后缀名进行隐藏掉了嘛))

   

  

 

     看到上方小黑窗,随后下方Jmeter的弹窗跳出来。那么恭喜你,Jmeter已经被你给拿下了。

    可以观察该小黑窗中的同时内容,

        Don't use GUI mode for load testing, only for Test creation and Test debugging !
        For load testing, use NON GUI Mode:
        jmeter -n -t [jmx file] -l [results file] -e -o [Path to output folder]
        & adapt Java Heap to your test requirements:
        Modify HEAP="-Xms512m -Xmx512m" in the JMeter batch file

    不要使用GUI模式进行负载测试,只用于测试创建和调试!---------------------what mean?

    GUI模式----便是下方的弹窗,此处的意思便是推荐使用GUI模式进行创建脚本以及调试脚本,不推荐进行负载测试(所谓负载测试是属于性能测试的一种类型,通过测试系统在资源超负荷情况下的表现,以发现设计上的错误和验证系统的负载能力,在这种测试中,将使测试对象承担不同的工作量,以评测和评估测试对象在不同工作量条件下的性能行为,以及持续正常运行的能力;负载测试的目的是确定并确保系统在超出最大预期工作量的情况下仍能正常运行,此外,负载测试还要评估性能特征;例如:响应时间、事务处理速率和其他与时间相关方面),因此可以看出负载测试是比较浪费系统资源的,GUI界面本身便很浪费资源,因此如果出现大并发或者机器处于大负载的情况下,非但不会得到你想要的结果,机器是必然会出现卡死的情况。

    不过,小黑窗的下方一段话也给出了解决方案:

    For load testing, use NON GUI Mode:
        jmeter -n -t [jmx file] -l [results file] -e -o [Path to output folder]
        & adapt Java Heap to your test requirements:
        Modify HEAP="-Xms512m -Xmx512m" in the JMeter batch file

    对于负载测试使用no-GUI的方式进行运行:

        jmeter -n -t [jmx file] -l [results file] -e -o [Path to output folder]

    这段命令便是NO-GUI的方式运行。

    或者进行修改堆内存的大小:

        Jmeter的默认堆为512m,因此,如果使用Jmeter进行负载测试建议将堆内存进行修改到合适的大小;

    修改方法:

      至E:\apache-jmeter-3.2\bin,使用文本编辑器模式将jmeter.bat文件打开,进行修改heap:

  

 

     修改此处的堆内存大小只是一种手段,但并不是万能的。因此,做负载测试还是需要进行谨慎分析,再下结论。

    OK,本篇先记录到这。。

    

 

  

  

 


TAG:

 

评分:0

我来说两句

Open Toolbar