Save File and close Jmeter GUI with command line - performance

I am currently trying to automatically record a JMeter script using Selenium. Therefore i start Jmeter in GUI-Mode through Jenkins (using a batch file) with activated Script Recorder.
Then i run a Selenium-test also through Jenkins and a batch file. The requests that this Selenioum script is doing are successfully being recorded.
The only step that i was not able to figure out yet is to save the recorded JMX-Script and close JMeter.
Is there a way to do this through command line, batch file or other? Doing it manually is not an option since JMeter is running on a remote node through Jenkins.
I was able to close JMeter through a system exit/kill command but this way the jmx-file is not being saved.

I don't think it's possible as of JMeter 5.2.1, you will need to automate JMeter GUI separately using Appium or Sikuli or ldtp
However I believe it will make more sense to reconsider your approach and go for one of the following options:
Replay your Selenium test using JMeter's HTTP(S) Test Script Recorder as the proxy
Use Taurus tool which has Proxy2JMX Converter
If above 2 options for some reason cannot be used in your environment you can automate i.e. JMeter Chrome Extension from Selenium (check out 6 Easy Steps to Testing Your Chrome Extension With Selenium for details) so you will be able to start the recording and export resulting .jmx script directly from your browser without having to communicate with the remote Jenkins/JMeter instances.

Related

Run python-selenium script through jmeter

I have a selenium script written in Python, how do I run it through jmeter?
I read it from other posting that you can choose JSR223 sampler, but it really does not have in language portion, a choice of python.
You need to download jython jar and copy it to JMeter's lib folder
I don't think it's possible via JSR223 Sampler, although you can get Python language support in JSR223 test elements by putting Jython jar to the JMeter classpath you won't be able to install selenium module
So the options are in:
Use OS Process Sampler for launching your Python scripts
Convert your Python scripts into "pure" JMeter scripts by running them via JMeter's HTTP(S) Test Script Recorder, see Http proxies Selenium documentation chapter for example code

Read system property from a target server for JMeter GUI tests

I'm running tests on JMeter on a target server. So I start JMeter(GUI) on my Mac but it points to a Linux server and runs tests against it. I need to read a system property on the target server and use that in my If Controller.
System.getProperty("prop_name"); works if the property is defined on my mac. But it doesn't pick it up from the target server.
Any suggestion is much appreciated!
Thanks!
I can suggest 2 options:
If your application under test has JMX enabled - you can read the "interesting" property value in one of JSR223 Test Elements using Groovy code. The properties can be queried from the RuntimeMXBean.
See Java Management Extensions (JMX) Technology Tutorial for more information.
If there is no JMX exposed to the outer world you can still try to get the property value remotely. Be aware that you can run any command or program on remote Linux instance using SSH Sampler. SSH Sampler can be installed using JMeter Plugins Manager.
See How to Run External Commands and Programs Locally and Remotely from JMeter for more information.

Graph Results via Non GUI mode in JMeter

Is there any possibilities to get my below mentioned Graph Results in JMeter test, which is executed in non GUI mode. I can extract its values using csv, but we need to run the test in non GUI mode to get dashboard results also. Any possibilities for this ?
Given you run your JMeter test in command-line non-GUI mode like:
jmeter -n -t test.jmx -l results.jtl
Once test is finished you should be able to open JMeter GUI, add Graph Results listener, locate results.jtl file using "Browse" button and you will see the chart.
Also there is an option to generate some charts in unattended manner using Command-Line Graph Plotting Tool available via JMeter Plugins project, see Automatically generating nice graphs at end of your Load Test with Apache JMeter and JMeter-Plugins guide for details.
I am trying to write web app based on Django to work with test results, do an online monitoring, etc. (kinda dashboard) for load tests which runned in Jmeter console mode (incl. distributive testing).
Maybe you will want to participate in development or so :):
https://github.com/v0devil/JMeter-Control-Center

View result file in Jmeter

Need a help in jmeter. When we run jmeter from GUI mode, we can see the instant results in UI and that gets auto refreshed in milliseconds or lesser.
But when I run jmeter from command line , in non GUI mode it still creates the result file and I can view it by another jmeter and with the adding an aggregate report listener to it. It opens the results with a pop up alert message but does not refresh it. For getting the updated results , need to browse and open it again .
So is there any way/plugin to open the file to view with auto refreshed as we can view while running in GUI mode.
Thanks
It is not recommended to use listeners during test run, even if it is done via another instance of JMeter. Wait for the test to finish and then perform the analysis.
If for some reason looking into interim stats is absolutely required I would recommend running your JMeter test using Taurus tool as a wrapper, you'll be able to see some statistics and graphs this way:

execute jmeter test plan inside cucumber step in ruby

This must be easy but I am struggling so I post it here. I am new to Jmeter, and I have to use it to send messages. I am testing a messaging portal which uses a core messaging application where the portal gets the data from this application. Now there are clients who connect to this messaging application and when they send messages, the application processes it and the portal application displays it. I am using JMeter right now as a test harness simulating the client interface to send these test messages. My colleage who knows JMeter has created the .jmx file which has all the settings, the url, thread count,format of the message. All I have to do is open the .jmx file in GUI or on command line and send it. It works. I wanted this process of JMeter sending the messages automated in my cucumber step. So that when I write a step like:
'Given when clients sends a message'
then the step definition would be a command or script to execute the JMeter test plan.
I tried doing this by giving the line in my step definition:
system('start jmeter.bat -n -t sample.jmx ')
I am using ruby and the system command is the ruby way to execute external commands, in this case it is a windows command. -n is to run the JMeter in non-GUI mode and -t is to mention the .jmx file. The problem I have here is, anytime I run the JMeter in non-GUI mode, it opens a terminal, executes and the control stays there. So when I use this script in my cucumber steps, the control stays there in terminal and my cucumber scenarios fails.
How can I do this in a different way so that the JMeter test plan gets executed in the background or I get the control back to my cucumber step?
Note: I may have a solution using the ruby-jmeter gem : https://github.com/flood-io/ruby-jmeter but I am not finding a way how to simply execute this using the gem. Here in the gem he tells of running the test plan locally or on flood-io but not at a different url. In my case the url is an IP address where the messaging application is listening and I use JMS publisher in JMeter to send messages via GUI. I created the .jmx file using the GUI and the same can be used in command line successfully. Please let me know of any solutions.

Resources