# JMeter Instructions Installation/Running A Test

## Installing JMeter on your local Machine

**You can use the current Product API scripts from 02/03/2020 in the following file path**:
`delphi-api-qa-automation/jmeter/Full Products API Test Suite.jmx`

### Prerequisites:
* Must have admin access to machine.
* Check your Java Version by running `java -version` in your terminal/command prompt, if empty you need to install Java.
* Must have Java JDK installed, [JDK Site](https://www.oracle.com/technetwork/java/javase/downloads/index.html).

### Installation Instructions (Terminal | CMD)

#### Mac
1. First check to see if you have brew installed on your machine by opening up your terminal and running `brew info`.
If your computer has brew installed something similar will appear:
``15 kegs, 47,679 files, 1.1GB``.
2. If `brew` is  **NOT** installed on  your machine you have to go to [brew.sh](https://brew.sh/) and run the following command on your terminal: `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`.
3. Next run `brew upgrade`, this will update all of brew's dependencies and current kegs.
4. Next install JMeter by running `brew install jmeter` in your terminal. This will install jmeter into your keg directory. An example of the file path is `
/usr/local/Cellar`.
5. Lastly run  `brew upgrade jmeter`, this will pull the latest version of JMeter into your machine.

#### Windows
1. Navigate to the [Apache Downloads site](http://jmeter.apache.org/download_jmeter.cgi).
2. Download the .tgz or .zip file under Binaries.
3. Unzip the file after downloaded, and navigate to the following file path: `Wherever You Downloaded JMeter/apache-jmeter-[version]/bin/`.

### Running JMeter (GUI Mode/Non-GUI Mode)
**DO NOT RUN YOUR PERFORMANCE TEST USING GUI MODE**

#### Mac
1. After you have installed jmeter, in the terminal type in `jmeter` or `./jmeter` to start JMeter in the GUI mode.
2. After verifying your test are working you can kick off your test using Non-GUI mode by navigating to wherever you saved your test in your terminal.
3. Kick off the Non-GUI test by running the following `jmeter -n -t Whatever_Your_Test_Is_Named.jmx`.
4. This will kick off your test based on the settings you applied in the Thread Group.
5. To kick off a test using a proxy server run the following command: `jmeter -n -t Whatever_Your_Test_Is_Named.jmx - l log.jtl -H 127.0.0.1 -P 8000`.
    * `-n` = Tells JMeter to run in command line mode.
    * `-t Whatever_Your_Test_Is_Named.jmx` = Tells JMeter which test plan to run.
    * `-l log.jtl`= Log file stores test results.
    * `-H 127.0.0.1` = Proxy server Host Name, (replace the 127.0.0.1 with your host name).
    * `-P 8000` = Port Name (replace 8000 with the specified port number).

#### Windows
1. After navigating to `Wherever You Downloaded JMeter/apache-jmeter-(numbered version of JMeter)/bin/` now click on the jmeter.bat file.
2. This will open up the JMeter GUI.
3. When you are ready to kick off the Non-GUI version of jmeter you have to open up the command prompt and navigate to the bin folder and run the follow command: `jmeter -n -t Whatever_Your_Test_Is_Named.jmx`.
4. This will kick off your test based on the settings you applied in the Thread Group.
5. To kick off a test using a proxy server run the following command: `jmeter -n -t Whatever_Your_Test_Is_Named.jmx - l log.jtl -H 127.0.0.1 -P 8000`.
    * `-n` = Tells JMeter to run in command line mode.
    * `-t Whatever_Your_Test_Is_Named.jmx` = Tells JMeter which test plan to run.
    * `-l log.jtl`= Log file stores test results.
    * `-H 127.0.0.1` = Proxy server Host Name, (replace the 127.0.0.1 with your host name).
    * `-P 8000` = Port Name (replace 8000 with the specified port number).

## Listeners [Reference](https://www.blazemeter.com/blog/jmeter-listeners-part-1-basic-display-formats/)
* View Results Tree - A listener that displays the request and response of the call.
* Summary Report - A simple summary of the test that was running, you can use this to display the errors in XML or have it display the summarized results of the test in CSV.
* Aggregate Report - Similar to the Summary Report but displays aggregated data such as top 90 percentile, etc.
* jp@gc - Response Times Over Time - A listener that displays the response times for each call and time stamps of each call in Epoch time. Within the GUI you can see a display of the graph on where your response times are landing.
* jp@gc - Hits Per Second - Records the amount of hits per second to the server and displays on the graph.
* jp@gc - Response Times Distribution - Records and aggregate's the amount of times the response times hit a certain number. This will also display in a graph on the GUI.

## References
Some reading material that may apply to your tests and can give you more context:

* [Apache Getting Started site](https://jmeter.apache.org/usermanual/get-started.html) - Documentation from Apache.
* [How to create your first test](https://www.guru99.com/jmeter-performance-testing.html) - Example on  how to create your first test.
* [Explanation on JMeter Listeners](https://www.blazemeter.com/blog/jmeter-listeners-part-1-basic-display-formats/) - An introduction to JMeter's listeners.
* [Breakdown of some GUI Listeners](https://octoperf.com/blog/2017/10/19/how-to-analyze-jmeter-results/) - How to use/configure certain listeners in JMeter's GUI.
* [Remote Host Setup](https://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.html)- How to configure remote hosts for your test.