Testing SAP SMTP service with jMeter
Considering you have set up the SAP SMTP service as described in this document: Configuring SAP SMTP service. As outlined in my blog testing the SMTP service using telnet is not really an option. Telnet is great for checking if the SMTP service is alive, but not feasible for automated testing. Sending attachments is not an easy task, too. In the previous blog I mentioned at the end that jMeter is good, free, fast and easy to use tool to test SMTP. Let’s use jMeter to test the SAP SMTP service.
Testing SMTP with jMeter is straight forward. Compared to testing a web application like WD, it is really easy and fast to create the test case as no HTTP navigation needs to be recorded and adjusted.
Basic configuration
Create a thread group and add an SMTP sampler. The data needed to configure this sampler is the same used in the telnet command:
- Fill in the server configuration parameters of your SAP SMTP server and the sender / recipient information.
- Give a subject and mail message
Add parameters
That’s all it takes to run a successful test run. But jMeter allows for more: send attachments and combining this with parameters. jMeter can use a CSV file to be parametrized, making at a powerful tool for sending data via email. The CSV file helps in having a different subject, mail body, etc.To make use of a CSV file, define a CSV Data Set Config in your jMeter test. The field variable names maps each column of a line as a value to a variable.
Sample input of the file input.txt:
Test Subject 1;lorem ipsum 1;94
Test Subject 2;lorem ipsum 2;95
Test Subject 3;lorem ipsum 3;96
Test Subject 4;lorem ipsum 4;97
These values are used by jMeter by each iteration to fill in the variables. Iteration 1 will read line 1, iteration 2 line 2, and so on. If 4 threads are started, thread 1 will read line 1, thread 2 line 2, etc. The variable names line assignes each variable a value. Here, the variable “subject” will get the value “Test Subject 1” assigned. Variables can be used by ${variablename}. To refer to the value of varialbe subject, use ${subject}. Add the parameters to the mail part
This is all it takes to send emails with an attachment to the SAP SMTP server.
To make it easier to understand the jMeter testplan, I plan to publish the files used. As soon as this is done, I’ll update this blog.
Thanks a lot, Tobias. This was really helpful for me as I constantly have to wait for the administrator of the E-mail server to properly setup the forwarding to SAP server.