"Turn" JMeter tutorial installation and specific operation

Source: Internet
Author: User
Tags jmeter tutorial jconsole

1. Download Jmeter : HTTP://JMETER.APACHE.ORG/DOWNLOAD_JMETER.CGI is currently the latest version of 2.9, the remaining files such as source code can also be downloaded from the following official website: http://jmeter.apache.org/download_jmeter.cgi 2. Before installing JMeterBefore installing JMeter, you need to configure JavaEnvironment, we download is jmeter2.9, so the Java version is best to choose Java6 later version.  The steps to install JDk1.6 are as follows: Click on the downloaded JDK file-dk-6u18-windows-i586.exe, click Next until the installation is complete, and then start configuring the environment:  Click My Computer----properties----Advanced----environment variable----in the system variable----Click New, enter in the variable name: Java_home variable Value input: C:\Program Files (x86) \java\jdk1.6.0_18 Click New again: Enter in the variable name: CLASSPATH, enter the value of the variable:.;  %java_home%/lib/dt.jar;%java_home%/lib/tools.jar; Then find the path in the system variable, click Edit, add:%java_home%/bin;%java_home%/jre/bin in the value of the variable;  Need to add) after the configuration is complete, click OK to save, then cmd to open the command window input: Java or Javac, a large string indicating the configuration was successful.  You can also enter: Java-version View the Java version to see if the configuration was successful. After the OK,JDK installation is successful, you can install JMeter in the next step. 3, installation JMeterUnzip the Apache-jmeter-2.9.zip file to the directory, mine is the D:\Program files directory.  Click My Computer----properties----advanced----environment variables----in the system variable----Click New, variable name input: Jmeter_home variable Value input: D:\Program files\apache-jmeter-2.9 Then edit the classpath variable, plus%jmeter_home%\lib\ext\apachejmeter_core.jar;%jmeter_home%\lib\jorphan.jar;%jmeter_home%\lib\  Logkit-2.0.jar, and then make sure that the above steps can be done, we will be able to click on the JMeter Bin directory under the Jmeter.bat file to open JMeter. Note: When opened there will be two windows, jmeter Command window and jmeter graphical operation interface, can not close the command window. Second, recording JMeter scriptThere are two ways to record a jmeter script, one is to set up an agent, and the other is to use Badboy software, Badboy software to support the export of JMX scripts.  Here we introduce the second method, use Badboy to record the script, and then export the JMX files required by JMeter. First, enter the address of the script to be recorded in the Address bar, then click the Green button to start recording (the red button in the toolbar can also be clicked for recording), click the Square Black button next to the Red round button to end the script recording (if you used LoadRunner, the steps are the same), To operate on an embedded browser you need to TestAction, it will record your related actions. Then click on the Black button when recording is complete, we can export the Jmx file: Save as "login developer. Jmx". iii. start testing with JMeter  1, open the script with JMeter open the file we saved above.  Open after: 2, modify the script A, the thread group in the test plan select Add to see both the thread group. such as: Name: Can be arbitrarily taken, we keep creating is automatically assigned the name of the comment: arbitrary action to be performed after the sampler error: We choose to continue, after the error continues to execute the number of threads: generally we used to represent how many users, that is, we test the number of users ramp-up Period (in Seco NDS): Indicates the delay time per user startup, the above I set to 1 seconds, indicating that the system will start 1 seconds before the end of the 1000 users I set up, if set to 1000 seconds, then the system will start 1000 seconds before the end of the 1000 users, start the user's delay of 1 seconds, if I set to 0 seconds,  means that all users are started immediately.  Number of cycles: if you want to limit the number of cycles to 10 times, you can cancel the last tick, and then fill in the text box in the following 10; Here we tick forever, indicating that if you do not stop or the time limit will continue to execute, it is to facilitate the dispatch of the call. Scheduler configuration: When we tick the scheduler, this panel start time will appear when we start the script, when you do not want to start the script test immediately, but the time to start the script will not be next to the computer, you can set a startup time, and then run there click to start, the system will not run immediately,  Instead, it waits until the time you fill in to start running.  End time: Corresponds to the start time, indicating the time at which the script ended running. Duration: Indicates how long the script is running, in seconds, such as if you want to allow users to log on continuously for 1 hours, you can fill in the text box 3600.  If within 1 hours, the end time has arrived, it will overwrite the end time and continue execution.  Startup delay: Indicates the time when the script delayed startup, after clicking Start, if the start time has arrived, but there is no time to start the delay, then the startup delay will overwrite the start time, wait until the start delay time arrives, then run the system. Note: If we need to use the scheduler to set the duration, if the number of threads is not enough until the end of the duration, we must tick the number of cycles to always, specifically, if there are other loops in the thread group, we also need to tick the number of cycles to always (as Step1 in the script I recorded above is also a loop  , need to be always checked), otherwise, according to my configuration, will always remove the tick, the text filled 1, then regardless of the duration of the start time you set the end time and so on how much, the system runs 1000 times, will stop running again.  b, about HTTP requests about HTTP requests, we recorded the script inside there, here are some of the commonly used properties. : Click HttP request, the following interface will appear: Where: Name: Can be arbitrarily taken, we can be based on the path of the recording script to name the comment: You can do a simple introduction to the interface server name or IP: that is, our server or IP address, I am in this machine on the project, so fill localhost,  can fill in 127.0.0.1.  Port number: I use Tomcat, I set the port number to 8086 (Tomcat defaults to 8080) after the timeout definition can not be filled out. Implementation: Here we record the default fill in the Java protocol is filled with: HTTP method is: GET Content encoding: Encoding can not fill in the path: that is, the path of the page, the following redirection and other options can be checked as required,  Here we keep recording without modification.  Parameters parameter: That is, the parameters sent along with the path and the proxy server under the file can be ignored, fill in as required.  C, parameterized as follows, we parameterize the parameters sent by the request.  The above example is the login use case, login has two parameters: email and Developer_password, in the actual test, when we need to use different users to log in, we can use the parameterization. 1), we create a new file, here I created a txt file, named C.txt, the contents of [email protected],111111 [email protected],111111 [email]  protected],111111 2), select "Function Assistant dialog" in "Options" in JMeter, the following dialog will pop up: CSV file to get the values from | *alias: File path to read, absolute path CSV file column number | Next| *alias: Start reading from the first column, note that the number one is 0 as shown, we read the first column of the user name in C.txt (if you want to read the second column of the password, just change 0 to 1, and so on), click the "Generate" button to generate the function, we use the copy generated function string: ${  __csvread (e:\c.txt,0)}.  Other functions are described later.  D, assertion validation in the Web test, sometimes, even if we test the return of response code 200, there is no guarantee that the test is correct, at this time, we can use the response assertion, by comparing the content of the response to determine whether the returned page is we are determined to return the page. Select the page we want to judge, click AddAssert----response assertion, which will appear as: Name: Random, we don't make changes here. Comment: Random Apply to: Here we choose the default value to test the response field: Here we select the response text, that is, the returned page information pattern matching rule: Here we choose to include, that is, the response text includes our  Verify the pattern of the information to be tested: The developer name, that is, we need to verify that the developer name exists in the response text, or you can add more fields to verify.  Other assertions, such as file size and response time, are described later.  E, add listeners when we do performance testing, often need a variety of data to verify our test results, JMeter also provides the relevant functions, here is the main aggregate report aggregation reports. Click Add---Listener, select: View results tree, and aggregate report, if you need to see the assertion information can also choose the assertion results, will set everything after saving, then click Start, the system will run, the results will be displayed in the listener. Iv. Analysis Results1. Look at the result tree: The success is green, and the failure is shown in red. If the result of the test is too much, you only need to see the wrong page, then tick "log error only" 2, aggregated report (Aggregate) Where: Label: Label, which is the name of the request above US #Samples: How many requests are issued in this scenario Average: flat Average response time Median: The median, which is 50% of the user's response time 90%line: 90% of the user's response time, if the minimum and maximum difference is very large, we generally choose this as the final test results min: Minimum response time Max: Maximum response time error% : Error rate, number of requests that have failed in this test/total number of requests throughput: Throughput Kb/sec: Amount of data received per second from server side Five, monitoring memory and CPU, etc.Many times, we test performance needs to look at memory and CPU and other information to determine the system bottleneck, about the CPU and memory monitoring, jmeter is not very good support, many times, we can only through the system's resource Monitor to observe, a flash will not be recorded, very inconvenient.  Fortunately, Google developed a special monitoring of the JMeter plug-in, make up for jmeter this aspect of the shortcomings, the following to introduce some of this plug-in--jmeterplugins, I am using 0.5.6 version.  1, jmeterplugins Address: http://code.google.com/p/jmeter-plugins/downloads/list, select the desired version, download 2, jmeterplugins configuration use Unzip the downloaded file, get the following directory: Copy the Jmeterplugins.jar package to the JMeter Lib directory under the Ext directory, restart the JMeter, we click Add to see a lot of [email protected] The beginning of the file  . Here we monitor the memory we use: [email protected]-PerfMon Metrics Collectot before use, we need to run/serveragent/  Startagent.bat This file, we need to copy the ServerAgent directory and the following files to our test server, and then click on the open (I here is this machine, directly on this computer to open the application system), its default port is 4444. When everything is ready, click Start to get the following: You can get the common performance value you need when the system is running. VI, monitoring memory and CPU (Jconsole)Recently visited the forum, found a better monitoring of memory CPU and other gadgets, based on the principle of the more open source gadgets, record. The steps to open this gadget are simple, if you have already configured the JMeter running environment, then you do not have to do other configuration, direct click: Start-"run-" input cmd--"and then enter" Jconsole "in the command line interface that appears to pop up a"  Java Monitoring and Management console, the following screen will appear: Here we choose the local process, and click on the Sun.tools.jconsole.JConsole line, and then click on the connection, you can see our memory and CPU usage. Of course, we need information such as memory usage of the server, or we can select the remote process under the local process, enter the IP address of the server we need to test in the text box: port, then enter the username and password below, click Connect, see what happens.

"Turn" JMeter tutorial installation and specific operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.