Sending test result mail through jmeter - email

I have incorporated a simple HTTP Request sampler in a test plan. And, viewing the result through "View Result Tree" and writing the same results to a file. I want this file to send through mail Sampler.
Issue is, once I execute the test-case, it sends mail first and then append new test results to the file. So, in mail I got the previous run results instead of the new one.
How can I incorporate this?

Reference Article - Send JMeter Test Reports Automatically in Email
If you use 'View Results Tree' or 'Summary Report' Listeners, you won't be able to send the current report, through mail via SMTP Sampler, even if you use tearDown Thread Group.
Reason : JMeter writes the data to these report files, only after the test is finished completely. You can verify this by adding a tearDown Thread Group and adding a delay before running the SMTP Sampler. Keep an eye on the file size, it is created once the test is started, but data is written when the last thread (SMTP Sampler, in this case) is finished execution.
Hence, only an empty file would be attached with your email.
Solution -
1. Find and modify (or add, if not present) the following section in the 'user.properties' file, setting the autoflush parameter to true:
# AutoFlush on each line written in XML or CSV output
# Setting this to true will result in less test results data loss in case of Crash
# but with impact on performances, particularly for intensive tests (low or no pauses)
# Since JMeter 2.10, this is false by default
jmeter.save.saveservice.autoflush=true
Use a batch script, and send the mail using some other utility after your JMeter Test, as suggested by Ashish.
Problem with this approach is, there is a dependency on another utility. Also, we would require to write different scripts for different platforms (Windows/Linux).
Instead of using default in-built JMeter plugins, we can use jp#gc JMeter Plugins, which provides very powerful reporting elements.
In this case, what we need is a 'Flexible File Writer' Plugin. It provides you powerful customization to configure what data you want to write to your report file, and also it would allow you to include complete report file to be sent via SMTP Sampler.
I was able to achieve this using Flexible File Writer Listener, and tearDown Thread Group. Here is the structure of my Test Plan -
Test Plan
--- Thread Group
-------Sampler
-------jp#gc- Flexible Filw Writer
---tearDown Thread Group
------SMTP Sampler
Here is a snapshot of my File Writer Plugin's configuration :
You may want to add some delay before sending the mail from tearDown Thread Group.
You can download the Flexible File Writer plugin using in-built Jmeter's Plugin Manager, or from JMeter Plugins Site - jp#gc Flexible File Writer Plugin

I observe that JMeter first sends the Email with either blank or old run report when doing it using the SMTP Sampler.
To overvome it, this is what I tried:
I created a batch file to call the Jmeter from command line as:
call jmeter -n -t "script path" -l "JTL report path"
I used a utility called sendEmail which is available in below location:
http://caspian.dotconf.net/menu/Software/SendEmail/
as:
sendEmail -f Sender_Email -t Receiver_Email -cc CC_Email -s Mail_Server -u "Subject" -m "Email body" -a "Path of JTL Report attachment"
What it is doing that it executes the JMeter script, generate the report in path specified in first step and then send Email with the report using step 2.
It might help.

I would suggest sending your email in tearDown Thread Group which is designed for post processing purposes and seems to be exactly what you're looking for.
Also make sure that you wait for reasonable amount of time via Test Action sampler as JMeter doesn't update results file on the fly, it periodically flushes chunks of results.
If you don't want "old" data you can use setUp Thread Group with i.e. OS Process Sampler to delete old results file or move it somewhere else.
For more JMeter email tips and tricks see Load Testing Your Email Server: How to Send and Receive E-mails with JMeter

Related

How to Send same file/different file multiple times to server with "form data" using Postman or Jmeter?

For Example, I want to send a file multiple times to the server concurrently/Sequentially with "form data" request.
I can able to send single file at once which reflects in the server.
**-**I want to send this file for 10000 times concurrently/Sequentially to the server.
**-**If possible, i want to know send different files at once.
Jmeter or POSTMAN anything is fine. I just want it to be done.
Thanks in advance.
screenshot for one file upload at oncePlease find the screenshot.
For JMeter:
Record your file upload request using JMeter's HTTP(S) Test Script Recorder.
Start JMeter's proxy server
Configure your browser (or Postman) to use JMeter as a proxy
Copy the file you will be uploading to "bin" folder of your JMeter installation
Perform the upload in browser (or Postman) - JMeter will record the request
In order to execute 10k concurrent uploads:
Set "Number of Threads" in Thread Group to 10000
Add Synchronizing Timer as a child of the HTTP Request which performs the upload and set "Number of Simultaneous Users to Group by" to 10000
To upload different files you can substitute hard-coded recorded file name with the JMeter Variable originating from i.e. Directory Listing Config Plugin

How to send the Assersion failure emails and end of test results via email in Jmeter?

link for jmeteri am using jmeter for my testing. I am finding it hard to find a way to send an email to my account when an assertion fails. Or when the job is complete, i want the results sent to my email. How can i do that?
You can send an email with JMeter using SMTP Sampler. Something like:
If Controller, condition ${JMeterThread.last_sample_ok}==false
SMTP Sampler
See Load Testing Your Email Server: How to Send and Receive E-mails with JMeter article for details on how to configure SMTP Sampler
Results can be send in the similar way.
Add the following line to user.properties file (lives in JMeter's "bin" folder)
jmeter.save.saveservice.autoflush=true
This is required to configure JMeter to save results into a file as soon as they're available in order to ensure you won't miss a single request results
Add tearDown Thread Group to your Test Plan. tearDown Thread group is being executed after all other Thread Groups
Add SMTP Sampler as a child of the tearDown Thread Group and configure it to send .jtl results file to the specified email(s)

BIRT Reports - How to schedule them and send by email?

I am currently creating reports with Eclipse embedded Report Designer for BIRT reports. In my next step, I would like to schedule this reports in such a way:
It will run once per day on a set time.
It will be produced as PDF.
It will be sent by email to a concrete email address.
I am working on Windows. Is it possible to do all of that by running bash script as a scheduled task in Windows Task Scheduler?
Thanks.
You can either do this yourself with the free BIRT runtime or download the free BIRT iHub F-Type server at http://www.actuate.com/resources/product-downloads/.
How to use the BIRT runtime:
Download the BIRT runtime and install it.
http://download.eclipse.org/birt/downloads/#runtime
Test the runtime installation (if you use Windows it will look like the following)
C:\birt\ReportEngine>echo %BIRT_HOME%
C:\birt
C:\birt\ReportEngine>genReport.bat
C:\birt\ReportEngine>ECHO off
Help for ReportRunner
--mode/-m [run|render|runrender] [options] [rptdesign|rptdocument]
The default mode is runrender.
To see options for run mode, use:
--help/-h run
To see options for render mode, use:
--help/-h render
To see options for runrender mode, use:
--help/-h runrender
Print current message, use --help/-h
Test the runtime in console with a job like
C:\birt\ReportEngine>genReport.bat -o test.pdf -f PDF new_report.rptdesign
Create a batch file for your job (the sample you ran earlier).
In Windows Task Scheduler, make a task to run the batch file for your job.
Run your task on demand to make sure it runs correctly.
Windows task scheduler does have a simple email function but you will probably have to find a better program to send the generated file as email. Then add the script to run this program to your batch file. Make sure you read up on how to configure a task for Windows task scheduler correctly.
It sounds like you need a way of
running the a BIRT report, through the BIRT reporting engine,
using scheduler to control execution of the report a on a particular schedule
specifying output format
and specifying how the output should be delivered in the scheduled job.
You could role your own or you could use a Reporting/BI server that already has all of those capabilities. Depending on your other needs, this may be overkill or exactly right. I am using SpagoBI for that exact purpose. SpagoBI supports BIRT as one of the reporting formats and engines. It uses the quartz scheduler, and does support emailing a PDF version of a report to a specific email address (or list). You might also look into iHub or other products.
http://www.spagobi.org/
http://birt.actuate.com/products/birt-ihub
In SpagoBI, you would deploy your BIRT report to the SpagoBI server from SpagoBI Studio. Then, in SpagoBI Server you would setup the parameters on the report document and create a schedule for the report. On the schedule, you would specify the parameters (if other than default), a schedule, output format, and how you want the output stored/sent.

How to send email within an NSIS installer?

Background:
For our software product (web application) clients will need to request a license from us before installing it.
We would need to check if they are a paying client (a manual process at the moment).
I need the ability for one of the initial steps of my installer to be let user request license via a custom page in the NSIS installer.
They would put in some mandatory fields and then this would get fired off in an email.
Ideally, NSIS would let them know that the email had successfully been sent.
They would then exit the wizard, but when we verify who they are and send them a serial (few days later), they can run installer again, and there would be an option to enter the serial, allowing them to progress to the next screen.
Ideally, the custom page will look something like this.
Question:
It is the emailing bit that I am currently stumped on.
I have not seen any plugins to do this.
How can I send an email from a custom page in NSIS?
- I imagine there might be a couple of approaches?
Probably best way to send emails is to use external application.
You can develop simple application in C/C++/C# if you have some programming skills, but there exist many apps for this purpose, e.g try this one called bmail:
http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm
C:\>mail -s smtp.server -t cpeacock#max -f root#neptune -h -a "Subject e.g. Fatal Error"
-b "Body of message e.g. Fatal Error occurred in cgi script, secure.cgi"
Simply use nsExec plugin to call this .exe with your desired parameters.
Alternatively create.bat file with appropriate parameters, unpack it to $PLUGINS directory together with bmail.exe and launch the .bat using ExecWait command from NSIS.
For creating custom page try this tool for NSIS: http://www.graphical-installer.com - it allows you to create skinned installer with custom page you need.

Recorded test plan does not work

I use jmeter to record the requests and then perform a performance test.
After I've recorded all the requests with proxy server and they contain post form,
I run these test-cases, but I found the post form not work: it can not create a record in website's database automatically.
But before that i used webload and everything was ok.
What's the problem? What can i do to solve it?
Does your JMeter test contain an HTTP cookie manager?
The built in proxy recorder of JMeter may create problems in case your application requires cookies and/or sessions to allow access to content.
You might want to try Blazemeter. Blazemeter has an extension in Google Chrome. You can record your test script using this extension as you browse through your application. Once you are done, export the test script in .JMX format from the extension (you will have to be logged in to Blazemeter for this). Open that as test plan in JMeter. Make any changes required in the test plan and run your test!