Run JMeter Test on a Linux VM on Azure: Step-by-step guide with Linux commands- Part 2(copy jmx file into VM and run)

Chalindu Kodikara
3 min readJun 20, 2022

If you haven’t set up JMeter on your VM, you have to do it first. Refer first part of this article. Here is the link.

Let’s get started. Here is the summary of this article.
1. How to copy the file from the local machine to VM and run it
2. Useful commands
3. Run the test in the background(Solution for connection reset issue)

1. Run the test using jmx file you created

1. Create a jmx file on your local machine

You have to create a test plan first using JMeter. Then, save the file. Here the test plan name is “test”.

If you want to know more details about how to create a test plan, there are enough tutorials to do that. This article's purpose is to teach you to run this test plan on a Linux VM.

2. Open 2 Powershells (2 terminals in Linux)

From here onwards I call them 1st shell and 2nd shell.

3. Login to your VM(1st shell)

Do this using your 1st shell(terminal).

I will give you the command here. But if you want to know further details, you have to refer to my 1st article on this topic.

>>ssh -i "private_key_name".pem "Username"@"IP"
Example:- (ssh -i test_key.pem azureuser@20.109.104.66)

4. Copy jmx file from local machine to VM(2nd shell)

Use 2nd shell/terminal for this step.
You have to have “” marks for private key path and jmx file path.

>>scp -i "$private_key_path$" "$jmx_file_path$" $username$@$ip_address$:~Example: (>>scp -i "C:\Users\Chalindu Kodikara\Downloads\tests_key.pem" "C:\Users\Chalindu Kodikara\Tests\test.jmx" azureuser@20.109.104.66:~)

5. Go to bin folder(1st shell)

In the 1st article, we installed JMeter version 5.4.2. jmeter_files folder was also created in the previous article. Change these names according to your needs.

>>cd "bin_folder_path"Example: (>>cd jmeter_files/apache-jmeter-5.4.2/bin)

6. Copy jmx file from home to bin folder(1st shell)

>>cp "jmx_file_home_path" "jmx_file_inside_bin_path"Example: (>>cp /home/azureuser/pattern_B_0.jmx /home/azureuser/jmeter/apache-jmeter-5.4.2/bin/pattern_B_0.jmx)

7. Create jtl file and run the test(1st shell)

>>./jmeter -n -t "jmx_file_name" -l "jtl_file_name"Example: (>>./jmeter -n -t test.jmx -l test.jtl)

This command will run your test file in the foreground. But it is not a good option to run it in the foreground. This will lead to plenty of issues.

  • If you don’t interact with the shell/terminal, your connection will be disconnected.

This is not a huge problem if your test doesn’t take a long time to finish. But I recommend you to run this in the background.
You can find the commands required in the 3rd section.

2. Useful commands to use on VM

1. View all processes that are running on the VM
>>ps
2. Filter process name and view
>>ps -aux | grep "name_you_want"
Example: (ps -aux | grep jmeter)
3. Kill a process forcefully
>>kill -9 "processID"
#You can view process ID when you view processes using ps command
4. Read a file
>>cat "file_path"
Example: (>>cat /tmp/output.log)
5. Read the tail of a file
>>tail "file_path"
Example: (>>tail /tmp/output.log)
6. Exit from the vm
>>exit

3. Run the test in the background

This is what happens when you run the test in the foreground using 1st section’s last command.

To avoid this, you have to run the test in the background using the following command.

>>nohup ./jmeter -n -t "jmx_file_name" -l "jtl_file_name" > /tmp/"output_log_file_name" 2>&1 &Example: (>>nohup ./jmeter -n -t test.jmx -l test.jtl > /tmp/output.log 2>&1 &)

— — — — — — — — — — — — — — — — — — — —

Do feel free to comment and give your feedback.

You can connect with me on LinkedIn: https://www.linkedin.com/in/chalindukodikara

— — — — — — — — — — — — — — — — — — — —

References:

How to Run Linux Commands in Background | Linuxize

--

--

Chalindu Kodikara

Computer Science and Engineering Graduate, Software Engineer