Showing posts with label jmeter. Show all posts
Showing posts with label jmeter. Show all posts

Wednesday, December 19, 2012

jmeter: preparing data or recycling data with JDBC PreProcessor or JDBC PostProcessor

I was doing testing on some records, and to be able to run the test again, the status of the record must be set to specific value

To be able to do that, I thought of doing this by trigger on the DB, but unfortunately, I was working on the client DB and I didn’t have access to create triggers

So I thought of doing that from jmeter, and it worked perfectly

First I added JDBC Connection Configuration as in the image below

2012-12-19_17-35-56

Configured this as below

Variable Name: conn

(Variable name should be any name, that will be used later)

Database URL: jdbc:db2://127.0.0.1:50000/QAT_MOI_DB1T;

(Database URL is the JDBC URL for the database)

JDBC Driver class: com.ibm.db2.jcc.DB2Driver

(Make sure to place the drivers in the lib directory inside jmeter directory. you will need to restart your jmeter to for them to work correctly, in my case I was working with DB2 database, so I copied the files db2jcc.jar and db2jcc_license_cisuz.jar to the lib directory)

Username: user

Password: password

2012-12-19_17-37-27

Then I added JDBC PostProcessor at the first request in the script

2012-12-19_17-39-47

Configured it,

Variable Name: conn

(variable name is same as above in the configuration element)

Query Type: update statement

Query: update records set status=1 where id=${id};

I was able to insert parameters in the query same way I do in the requests

By this way I was able to reset the data before every cycle

You can also add JDBC PostProcessor at the last request, to do some other post processing

Sunday, December 16, 2012

jmeter with spring webflow

I have been using jmeter for a while with spring webflow application, I have some experience with it now that I would to share

Studying the recording of spring webflow application, I noticed the following

There are requests that doesn’t have anything inside, that are followed by requests with execution parameter as in the images below

Request without any parameters, let’s call them initial requests

2012-12-16_09-46-29

Request with the “execution” parameter, let’s call them execution requests

2012-12-16_09-46-38

Or it could be request with execution parameter in the query string, and the view state parameter, execution in query requests

2012-12-16_09-52-47

To be able to replay the scenario,  with multiple iterations, and multiple users, the execution parameters and view state needs to be parameterized, to be extracted and used in next requests to maintain the execution flow correctly

I found out by trials and from the results from the results tree, that initial requests are followed by sub samples that contains the execution parameter for the consequences request

Also found out that new execution is generated at the end of execution in query requests

2012-12-16_16-20-20

But there was a difference in the extraction of the execution parameter in that case, it comes in the body

So for my scenario, in order to work correctly, I added 2 types of extraction rules

One after initial requests, that checks the sub sample URL only with the below settings

Apply To: Sub-samples only

Response Field to Check: URL

Regular Expression: execution=(.+?)$

2012-12-16_16-25-04

Another one at the end of each request with execution in the query string, with the below settings

Apply To: Main sample only

Response Field to Check: Body

Regular Expression: execution=([^"]+)"

2012-12-16_16-30-03

Then in consecutive requests, replace the execution parameter with the extracted parameter, in my case here I named it ${e3s2}

2012-12-16_16-39-15

2012-12-16_16-42-56

Thursday, August 2, 2012

jmeter: Adding the same item for several requests

I wanted to add a regular expression extractor to several requests, I was delighted to discover that the jmeter interface is very smart in a way that it understands when you past an object copied from it..

So all I did was to copy for the regular expression extractor, and did a paste on each request I wanted to add this extractor to it.

You can do copy and paste with right click then selecting copy/paste, or you can do it by the keyboard shortcuts, ctrl+c, ctrl+v

I found also that I can do copy/paste for different things, like the HTTP Requests, Recording Controller, etc…

One more thing also that was nice for me, the test plan is saved as a XML file, so when I wanted to modify some value for all my regular expression extractor, I just opened the plan with a text editor and did a Find and Replace for the value I wanted to change, and did a Replace All command, all values was changed with just couple of steps

Friday, April 20, 2012

jmeter: adding assertions to validate correct response

During my test execution I noticed that some responses are getting the error page, for the jmeter is was http 200, so it marked the request as passed, this is not correct, this request should be failing, so I created assertion rule to identify these errors

In my case the error page has it’s own URL, so I added response assertion to check URL sampled not to contain “error”, steps to do so:

Right click on the thread group or the recording controller

Select add –> Assertions –> Response Assertions

image

Fill the Response Assertion properties:

Apply to: Main samples and sub samples (usually the error page comes as a sub page from the requested page)

Response Field to Test: URL Sampled (In my case the error is identified by the URL of the error page, in other cases the error can be a frame inside the response)

Pattern Matching Rules: Contains, make sure not is checked (This means I am asserting that my response URL is not the error URL)

Pattern to Test: error (in my case the URL to error contained the word error, in other cases it could be a specific text message inside the response)

Screenshot-2012-04-20_15.48.20

Adding the Assertion as above, while running, if any sub sample was the error page, it was marked as failed

Wednesday, April 18, 2012

jmeter: excluding resources while recording

it is better to exclude un-necessary resource while recording so that you don’t end up with hundreds of requests, and removing them later by selecting and deleting, will be exhausting task

Add the following to the HTTP Proxy Server settings

.*\.jpg

.*\.png

.*\.ico

.*\.css

.*\.gif

.*\.js

Screenshot-2012-04-18_17.14.00

Monday, February 13, 2012

jmeter: Reading results from csv or xml files

I run a couple of tests, saved results to CSV/XML  files. later I was trying to open these files by excel or any editor, I was hoping to analyze the results with excel and draw graphs as I need, but it wasn’t very clear to me when  I opened it by excel, what the values represents, as there was no column headers.

I looked online for some tools to do this job, but couldn’t find any simple ones, finally I remembered that there is a browse button inside the Aggregate Graph sampler, so I added one, browsed to the results file, and I was able to display the results and generate graphs also

Screenshot-2012-02-13_14.19.54

The good thing also is that I can copy from the table inside jmeter to excel and I know the label from each column from jmeter

The same also can be applied with summary report, add a summary report sampler to your test, open the csv/xml file, and then you can see the results

Tuesday, February 7, 2012

jmeter: Validate regular expression extractor

I had some extractors in my test, and when I was looking on the request using the extracted values, I noticed that it is not coming correctly. I looked for someway to validate this extractors to see whether I did it correct or not.

First I made sure that I am using the variables correctly in my test

So if the regular expression Reference Name is param1, it should be used as ${param1}

Second, I found that the regular expression can be verified from the “View Results Tree”, so I went to the request, then selected the Response Data tab in the details panel as below

Screenshot-2012-02-07_11.48.58

Then at the bottom, I have entered regular expression in the search box, and checked the Regular exp. check box

at first it wasn’t bringing any results, because there is ? in the regular expression that needs to be escaped

when I changed ? to \?, results was found and highlighted in the response

Screenshot-2012-02-07_11.48.15     Screenshot-2012-02-07_11.48.31

Using this method I was able to verify and correct the regular expressions for the regular expression extractor

Thursday, February 2, 2012

JMETER: using parameters from csv file

I wanted to parameterize my requests, like the login for example, to be able to use different users
looking for some help from the web I found this useful article
http://ivetetecedor.com/192/how-to-use-a-csv-file-with-jmeter
I followed the article, created users.csv file with user names and password like the below
user1, password
user2, password
etc…
Then added CSV Dataset Config to my requests, set it like below
image
Next i went to the request and changed the login info to ${user} and ${password}

JMETER: Extracting values using regular expression extractor

We were trying jmeter to do our performance test, one of the issues we faced is that we needed to extract values from pages to be used in next requests

to do so we need to add Regular Expression Extractor to the request, and to set the extractor properties

The most important part is the Regular Expression property

Getting some help from http://jmeter.apache.org/usermanual/regular_expressions.html

I used a general form like the following, to extract readme.txt from name="file" value="readme.txt"

we use Regular Expression

name="file" value="(.+?)"

OR

name="file" value="([^"]+)"

If there is no double quotes  at the end, then it will be like

login?execution=(.+?)$