2013-01-31

Tips and Tricks Part-1

What is HTTP Request Defaults? Why we use it

In this following article we are going to see what is HTTP Request Defaults in JMeter and why we use it.

HTTP Request Defaults is the default configuration set for each http request in a fragment/thread/plan which are under it. This is one king of Configuration element that controls the HTTP Request .

When we add a  HTTP Request Defaults(Thread group->(right click)add->Config Element-> HTTP Request Defaults) we will find these

Server:Domain name /IP of server [Exclude http:// prefix]
Port: Port of server.
Connect Timeout(ms): Time to wait for a connection to open
Response Timeout(ms):Time to wait for a response.
Implementation:Java/HttpClient3.1/HttpClient4.[If blank, the default will be activated that is in jmeter.properties.]
Protocol :HTTP/HTTPS
Path: The path to resource.
[Note:Path is the default for the full path, not a prefix to be applied to paths specified on the HTTP Request screens.
Send Parameters With the Request -The query string will be generated from Name and Value.The query string will be generated depending on the choice of "Method"(In the http request sampler)
[If we send a file by multipart form, it will be created using the multipart form specification].
Press Add to add row for parameter.  We can enable encoding if we need(spatially for https)
Server (proxy): Hostname/IP [Exclude http:// prefix.]   
Port: Proxy Port
UserName/Password for Proxy
Retrieve All Embedded Resources from HTML Files: Enabling this, Jmeter will parse the HTML file and send HTTP/HTTPS requests for all images/Java applets/JavaScript /CSS etc
Use concurrent pool: Use concurrent connections to get embedded resources.
Size(byte):Pool size for concurrent connection
Embedded URLs must match: Filter option(Perl regular expression)

Why we use HTTP Request Defaults?
1. When we need to categorize http request under single configuration
2. When we need to use a configuration for multiple fragment( test request segments)
3. When we need to dedicate a particular sampler set following a specific http/https request settings.

-It is best practice to use HTTP Request Defaults in test planning so that we can track the configurations and requests easily.

...Thanks....:)

2013-01-30

What is JDBC Connection Configuration? Why we use this.

In this following article we are going to see what is JDBC Connection Configuration in JMeter and why we use it.

By naming, we can understand it is one king of Connection Configuration element that controls the JDBC connection. It will control the the communication to any Data Base used by JDBC. And, it will be present in side a config element.

When we add a  JDBC Connection Configuration(Thread group->(right click)add->Config Element)-> JDBC Connection Configuration) we will find These

Variable Name*: Connection settings will be stored in this variable. Use unique names for Multiple connections Configuration as JDBC Samplers will select any one to use. If two configuration elements using the same name, only one will be saved.
Max Number of Connections* : Number of threads allowed in the pool the connection.
[0=the connection is not shared between thread,
any number = The max count of thread share this connection.(to ensure threads don't wait on each other)[Note: on sharing, thread number = this number]
Pool timeout(m)*: Time to retrieve a Connection Pool (Throws an error when the timeout period is exceeded in the process)
Idle Cleanup Interval (ms)*: Time to Clean a connection pool when it is Idle.( need more experiment on exact functionality)
Auto Commit* Enable/Disable auto commit for connections.
Transaction Isolation* : Transaction Behavior for a connection pool.
Keep-alive*: Logically, connection behavior for validation query( need more experiment on exact functionality). Default true.
Max Connection Age (ms)*: Logically, connection life time for the validation query.( need more experiment on exact functionality). Default 5000.
Validation Query*: A simple query to know the database response.
Database URL*: JDBC DB Connection string
JDBC Driver class*: Fully qualified(including package) name of driver class(Include .jar to \lib)

*= Mandatory

Why we use this ? As it is the configuration for database connection. It will be used for any request that needs a database.Different database's JDBC driver should be located in \lib or should be added to class path(of test plan).
We can see more with the example from my jmeter database related posts.

..Thanks..:)

What is HTTP Header Manager? Why we use it

In this following article we are going to see what is HTTP Header Manager in JMeter and why we use it.

By naming, we can understand it is one king of element that controls the header. And, it will be present in side a config element(as it holds all type of configurable elements)

So, When ever we add a HTTP Header Manager(Thread group->(right click)add->Config Element)->HTTP Header Manager). We can see a section "Headers Stored in the Header Manager". This section contains all header. We can either add or load(previously saved) a header list.
So, When we add a header we have provide type of http header as name and the string of the header as value.
Ex- If we want to add a opera User-Agent in header, we will add a blank row, we will write "User-Agent" in the name section and value "Opera/12.80 (Windows NT 5.1; U; en) Presto/2.10.289 Version/12.02"

Note: When we add headers in the manager, those headers are append to the request. For a whole thread group, one header manager should be present(multiple supported). If one header added to multiple manager , latest one(or specific one) will be use.

Some useful headers are
-Accept  
-Accept-Charset  
-Accept-Encoding  
-Accept-Language  
-Accept-Datetime     
-Cache-Control  
-Connection  
-Cookie    [preciously set cookie, (different from cookie manager)]
-Content-Length  
-Content-Type  
-Date  
-Expect  
-Host        
-Pragma  
-Proxy-Authorization  
-Range  
-Referer     
-Upgrade  
-User-Agent  
-Via  
-Warning



We can see the full list in this here.

Why we use HTTP Header Manager? When we need to send http request with specific header( that may define the http response because of that header). For example,
-when we need specify user agent/browsers
-When we need to specify language
-When we need to specify Date/Time
-When we need to specify Date
-When we need to specify Content Length/type
-When we need to specify conditions of response to server
-When we need to specify proxy

... Thanks..:)