petek, 11. december 2015

Powershell execute Jmeter tests nonGUI remote

Powershell give a performance team a great opportunity to automate complete test execution run.
In this blog i will show you how easy is to set up and run jmeter file with  local and global properties.


Jmeter is run from powershell where parameters can be read and data can be prepared for test execution.
Parameters when jmeter test is run:
  •  --nongui; jmeter is run in non gui to save memory and CPU usage
  • --runremote; gives a possibility to run on remote host on which jmeter_server is running
  • --testfile; which jmx file will be used in test, i usually copy original file to .bkp and used it for testing
  • --logfile; where to write a log file
  • --jmeterlogfile; all data shown on the screen are saved in file with name
  • --globalproperty: is used to share properties along remote hosts
  • --jmeterpoperty: is used on this machine and is not send to remote hosts
More information can be found in jmeter home page.

Option --rurmote can be used also on same machine from which jmeter test are started, with running jmeter_server.bat in background. This sometimes have impact on performance of machine when a lot of machines are included in remote.

Most of my test are run on different sets of remote hosts, depends what i need to identify of artifacts from the tests. For example, how many stored procedures was executed, check duration of each API call, etc.....

Example of code in  powershell to run jmeter test:

cmd.exe /c jmeter.bat --nongui -JforcePerfmonFile=true  --runremote --testfile "$global:TestName.jmx.bkp" `
--logfile "$JMeterReportFileFolder\$($global:TestName)-output.jtl" `
--jmeterlogfile "$JMeterReportFileFolder\$($global:TestName)-jmeter.log" `
--globalproperty LogDir="$($JMeterReportFileFolder)\" `
--globalproperty "Jmeter\$global:TestCaseName\$($global:TestCaseName) -" `
--globalproperty "Jmeter\$global:TestCaseName\$($global:TestScenario).properties" `
--globalproperty "Jmeter\$global:TestCaseName\$($global:TestScenario)" `
--globalproperty "Jmeter\$global:TestCaseName\$($global:TestScenario)" `
--globalproperty "Jmeter\$global:TestCaseName\$($global:TestScenario)" `
--globalproperty "" `
--jmeterproperty "remote_hosts=$($global:Remote_Hosts)" `
--globalproperty "ServerRun=$($global:Remote_Hosts)"


When a tests are running on remote host is good to define which properties are global properties and which are local properties, because incorrect decision may have impact that test are not executed in expected way. Enjoy preparing test cases with single .jmx file and more test cases.

Ni komentarjev:

Objavite komentar