Wednesday, March 12, 2014

SoftwareTesting: Converting Jmeter JTL File To CSV File

SoftwareTesting: Converting Jmeter JTL File To CSV File: JtlToCsv Converter :-By using this utility we convert Jmeter jtl file to CSV file. Prerequisites: 1)Python 2.7 Steps: Step1:...

Monday, November 18, 2013

Beanshell Script Examples (Random string & logging to external file)

Beanshell script examples for generating random string & logging data to external file
Add the BeanShell Post Processor to the required request
Copy the below code to the Script window
Modify the script as per the requirement (assign the parameters to the variables)

Generate Random string:

// Generates a random string
import java.util.Random;

chars = "0123456789-ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
int string_length = 32;
randomstring ="";
    for (int i=0; i<string_length; i++) {
        Random randomGenerator = new Random();
      int randomInt = randomGenerator.nextInt(chars.length());
        randomstring += chars.substring(randomInt,randomInt+1);               
    }
vars.put("uniqueStr",randomstring);

Logging JMeter data to external file:

//Assign to the variables
randomstr1 = vars.get("uniqueStr");
dtime11 = vars.get("dtime1");
rnd1 = vars.get("rnd");
regpass1 = vars.get("regpass");

//logs the information to jmeter.log
log.info(randomstr1);
log.info(dtime11);
log.info(rnd1);
log.info(regpass1);

//Creating an file object and writing to a csv file
FileWriter fstream = new FileWriter("C:\\apache-jmeter-2.9\\beanshell_log\\detail_log.csv",true);
BufferedWriter out = new BufferedWriter(fstream);
out.write(randomstr1+dtime11+rnd1+","+regpass1+"\n");
out.close();

JMeter to load test WebSphere MQ server

How to build test plan & load test any MQ server using JMS Samplers

     
Common Errors:
JMeter2.9 with IBM MQ Not Connecting

JMS Point-to-point - MQ and JMeter .NameNotFoundException.
     
External Plugins:
IBM WebSphere MQ Sampler for JMeter (I didn't find the download link)
     
References:

Thursday, October 31, 2013

Executing Linux commands from Windows Command Prompt using Putty/Plink



Download PUTTY : http://the.earth.li/~sgtatham/putty/latest/x86/putty-0.63-installer.exe

  1. Install PuTTY
  2. Set the environment variables path for PuTTY: {install dir}/PuTTY
    • My Computer --> Right Click --> Properties --> Advanced System Settings --> Environment Variables
  3. Auto login command:
    • plink.exe -ssh <username>@<ip address> -pw <password>
    • plink.exe -ssh root@xxx.xxx.xx.xx -pw password
  4. Auto login and invoke a terminal command: 
    • plink.exe -ssh <username>@<ip address> -pw <password> "<terminal command>"
    • plink.exe -ssh root@xxx.xxx.xx.xx -pw password "nmon -f -s10 -c 360"


Thursday, October 24, 2013

JMeter - Creating date time string using javaScript & Beanshell


For MM/DD/YYYY date string use the below functions

1. using javaScript function:
${__javaScript(var d=new Date(); var date=d.getDate(); var
month=d.getMonth()+1; $DATE=(month<10?"0"+month:month) + "/" +
(date<10?"0"+date:date) + "/" + d.getFullYear();,DATE)}

Thus __javaScript() allows multiple lines of code as long as they are
separated by ";"

2. or using BeanShell
${__BeanShell(new java.text.SimpleDateFormat("MM/dd/yyyy").format(new
Date()))}



For MM/DD/YYYY date time string use the below functions

1. or using BeanShell
${__BeanShell(new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(new
Date()))}

Reference:http://osdir.com/ml/jakarta.jmeter.user/2004-11/msg00024.html

Monday, June 10, 2013

JMeter Random String [A-Z,a-z,0-9]


Random String


Generate a random string using [A-Z,a-z,0-9]



For generating a random string length of 5 then use the below function


Name: randomstr5

${__RandomString(5,ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,)}

For generating a random string length of 10 then use the below function


Name: randomstr10

${__RandomString(10,ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,)}

BeanShell script for Date Time format yyyyMMdd HH:mm:ss.SSS



Add the below code in User Parameters to generate the date time format like 


yyyyMMdd HH:mm:ss.SSS



Name: DateTime

Variable: ${__BeanShell(new java.text.SimpleDateFormat("yyyyMMdd HH:mm:ss.SSS").format(new Date()))}