Backend Java application testing using jmeter - jmeter

I have a Java program which works on backend .It's a kind of batch processing type where I will have a text file that contains messages.The Java program will fetch message from text file and will load in to DB or Mainframe.Instead of sequential fetching we need to try parallel fetching .How can I do through Jmeter?
I tried my converting the program to a Jar file and calling it through class name.
Also tried by pasting code and in argument place we kept the CSV (the text file converted to .CSV).
Both of this giving Sampler client exception..
Can you please help me how to proceed or is there something we are missing or other way to do it.

The easiest way to kick off multiple instances of your program is running it via JMeter's OS Process Sampler which can run arbitrary commands and print their output + measure execution time.
If you have your program as an executable jar you can kick it off like:
See How to Run External Commands and Programs Locally and Remotely from JMeter article for more information on the approach

Related

Spring batch unit testing job with external input and db output

If I understand it correctly normal way of spring batch testing is to basically run my application and let JobLauncherTestUtils run my normal jobs. However my application reads input from external service and writes it to my database. I don't want my tests to write to my production database and I'd like to specify test input to be read rather from the files I'd provide than from external service.
Can anyone direct me to some example how I could do it? I'd like to feed a job with a file then when job has finished check in the database that what I expect is there. I guess I could specify h2 db in application-test.properties but I have no clue about the input.
Docs from https://docs.spring.io/spring-batch/4.1.x/reference/html/testing.html#testing don't really cover it for me.
Are you reading input files from disk? If so you can edit the input file source directory only for tests to be within the src/test/resources/input_dir/your_test_file.xml for example.
If the input file directory is configured with properties, you could create properties file only for tests with something like classpath:input_dir/your_test_file.xml (which would be in your project as src/test/resources/input_dir/your_test_file.xml).
If the input file directory is configured within execution context you can provide that in the jobExecutionContext parameter of JobLauncherTestUtils.launchStep

Is there a way to call a VBS fuction inside Post processor Beanshell - Jmeter

Hi I've a piece of code in VBS file and a function is associated with that
code. I want to call that vbscript function inside a beanshell after Jmeter
execute all its sampler .Is there a way to call a vbs function inside a
beanshell? Please suggest...
It should be as simple as
Runtime.getRuntime().exec("wscript c:/jmeter/bin/yourscript.vbs);
See Runtime class JavaDoc for more details on the approach.
However if your script produces some console output it might be easier to use OS Process Sampler configured like:
See How to Run External Commands and Programs Locally and Remotely from JMeter article to learn how to execute 3rd-party applications from JMeter tests.

JMeter - saving results to both CSV and XML

What I try to achieve is to get JMeter results in 2 formats, for the same test execution. CSV is the one I'm mostly interested in, unless there are failures - then I may need to use data which can be saved only to XML. I can't use XML for most occasions, due to misc reasons.
I was looking at jmeter.save.saveservice.output_format cfg entry, it doesn't seem to accept both as valid entry. I was also looking at JMeter code itself, it also clearly separates both options.
Did anyone invent a hack to get both JMeter outputs at the same time?
Solution for both standalone JMeter and jmeter-maven-plugin is welcome.
If you use JMeter Maven plugin, as per Five Ways To Launch a JMeter Test without Using the JMeter GUI guide the default output has to be XML.
If you need CSV output as well - just add Simple Data Writer listener. If you looking for CSV data to be in line with JMeter default CSV values configure it as follows:

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.

How do I write a Jmeter script without using the GUI?

Is there a way to create a JMeter test plan without going through the GUI?
I.E. can you create a script with pure code?
In a way - yes. You can create the JMX file in a text editor, but it would require knowing what every component needs.
You're better off creating in GUI mode and modifying the JMX file manually as needed.
Yes it's possible to write a test plan just by writing JAVA code.
The key classes to look into are:
StandardJMeterEngine - the main class which configures the Test Plan and executes it
HashTree - a special collection which holds Test Plan elements
A minimum of JMeter Controllers necessary to run the test.
Reference: http://blazemeter.com/blog/5-ways-launch-jmeter-test-without-using-jmeter-gui
I can write and run JMeter without GUI. JMeter use JMX file, as you can here.
Not entirely sure why you would want to write a JMX in this way? ... But yes, entirely possible if you understand the structure of the document.
You could use any basic text editor to achieve this (notepad / notepad++ for example).
A JMX file is a saved JMeter project in XML format. ~ Ref
Depending on your needs you could the browser editor from the JMeter Plugins website.
jmeter-plugins.org/editor/
Or simply save a basic JMX as a template and spend loads of time learning the structure, syntax and namings etc.

Resources