Setup Apache JMeter in MacBook(M1)

Performance Testing

Nayomi Edirisinghe
Code道
5 min readFeb 29, 2024

--

Pre-requisites

Install Java : Since JMeter is a Java-based application, need to have SDK/JDK/JRE installed which compatibles with ARM architecture of the Apple M1 chip (java 8+ would do).

Make sure Keytool has been properly setup upon java installation : In order for JMeter to handle embedded resources and certificate creation on fly, it use keytool utility (available on JDK/JRE). Run below command in your terminal. If you see the help output, it means the utility is available in your PATH.

keytool --help

https://cwiki.apache.org/confluence/display/JMETER/TestRecording210

Download and install JMeter :

Initially I installed JMeter via brew. But it blocked me at the step of generating .crt certificate. Continue Reading !!

arch -arm64 brew install jmeter

Launch JMeter

Search for the jmeter executable, which will give you the directory where JMeter is installed. It’s also something that can easily find in brew logs if you still have it !

which jmeter

Use commandopen /<JMeter_Home>/bin/jemeter to launch JMeter application in your computer. Make sure to provide the correct path toJMeter_home


open /opt/homebrew/bin/jmeter

Generate Certificate

After launching JMeter successfully on my mac, and following basic instruction 26.2 > steps from 2- 6, under in the documentation
https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html, I realised that ApacheJMeterTemporaryRootCA.crt certifiacate is not generated in JMETER_HOME/bin folder.The Certificate need to be installed in the browser, before recording and without it, I couldn’t proceed further. So had to take a step backward and do a manual installation of JMeter again.

For Apple Silicon (M1) I’m using apache-jmeter-5.6.3.zip. Download, extract it and move the folder somewhere suitable.

Add the JMETER_HOME to .zshrc file & source

export JMETER_HOME=/Users/ned/apache-jmeter-5.6.3/bin

Launch JMeter again. Use the jmeter.sh file

sh jmeter.sh

Now follow the steps to start the proxy server. This time, it should generate the certificate & should be available in the bin (Note that by default, certificate valid only 7 days)

Following the steps to generate a test plan, it created a HTTP(S) Test Script Recorder by default. It looks like it’s disabled, but I could start it when generating the certificate. Anyways, without taking further risk , I manually created another recorder script. Just Right click on Test Plan > Add > Non-Test Elements > HTTP(S) Test Script Recorder

Install Certificate -FireFox

To import the certificate, pickup a browser (I will be using Firefox) > go to settings > search for certificate > View Certificate. Under the Authorities tab, you will see the option to import certificate. Click it and browse the certificate from your computer.

After importing, you should see the “Add Security Exception” dialog. Click on the “View…” button to review the certificate details. Ensure that the details match the ones displayed by the JMeter Test Script Recorder

If the certificate details match, check the box that says “Trust this CA to identify websites” and click on the “OK” button.

Your JMeter certificate should now be installed and trusted in Firefox. You can now proceed to use JMeter for recording HTTP(S) traffic in your Firefox browser sessions.

Configure JMeter Proxy in Firefox

Open browser, type about:preferences#advanced as URL. Under Network settings > go to settings. Make sure you still have JMerter running in your computer.

Select Manual configuration. Enter localhost or your IP address of your system and port 8888.

Recording your navigation

While HTTP(S) Test Script Recorder is Running, open your browser and navigate to the web application you wish performing load testing. Run the manual test steps you would like to do. Once finished, close your browser and bring up the JMeter window. Expand the Thread Group and there should be several samplers. At this point, the test plan can be saved as is.

Once recorded, validate the script before running the test plan. Save

Run the test on loop

In order to run the script on multiple threads & loops, configure the Thread Properties as you prefer.

While on the View Results Tree , run the test. It will run the script based on the defined threads & loop count. You can see the request flow like you would see in browser developer tools network requests, if you check the scroll automatically checkbox.

AND WE DONE ! So we have recorded a script to perform load testing on a web application.

Additional Notes : use private browsing mode when recording the session. This should ensure that the browser starts with no stored cookies, and prevents certain changes from being saved. For example, Firefox does not allow certificate overrides to be saved permanently.

It was challenging to setup & configure JMeter in MacBook M1, because of the limited/outdated resources available. Hope this helps ! Any comments, thoughts are welcome..

~~ HAPPY TESTING ~~

--

--