Saturday, October 15, 2011

Server side monitoring in JMeter with JMeter Plugins

Like may I needed some server side statistics while running load tests earlier I had couple of Ruby scripts which were gathering my required information on server as CSV file I do have webmin configured on the server but I was still looking for something which is bit more tightly coupled with one of the most famous (easy to use) tool for load testing JMeter.

Here is how to do it:
We just needed one thing JMeter Plugins
 Prerequisite: JMeter 2.4+ or above with a JRE 1.6+
 Download JMeter Plugins 
  • Unzip it and (refer
    • Copy JMeterPlugins.jar to  JMETER_HOME/lib/ext. 
    • Copy zip files content to the Server(s) you need to monitor
  • On each server run JMeterPlugins-HOME/serverAgent/startAgent.sh PORT_NUMBER (refer)
  • Run JMeter (create your test plan as usual)
  • You will see bunch of extra items in Add context menue's item beginning with jp@..  these are the extra plugins we just added via JMeterPlugins.jar
  • Add jp@gc - PerfMon Metrics Collector (refer)
  • Configure your parameters (refer)
  • Run your tests and see server side info
I have use it on Mac and Linux, it should be able to work with most of the systems since its server side agent is build on top of SIGAR - System Information Gatherer And Reporter

Sunday, July 10, 2011

Run Sikuli in (J)Ruby - (J)IRB

I use irb for composing and debugging scripts. Following is what you might need to do inorder to run Sikuli in  IRB:
  1. Install JRuby or via rvm
  2. Copy sikuli-script.jar to  jruby lib
    • cp /Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar $JRUBY_HOME/lib
    • For RVM:
      • rvm list (to list currently installed rubies)
      • rvm use jruby-1.x.x (to use jruby as the ruby implementation)
      • rvm info (to print information about the ruby currently being used)
      • cp /Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar $MY_RUBY_HOME/lib ($MY_RUBY_HOME points to the current ruby home, in this case jruby)
  3. run irb (the irb prompt should list jruby as the ruby implementation, something like jruby-1.x.x :001 >  )
  4. jruby-1.x.x :001 > require 'java'                                                                                      
    •  => true 
  5. jruby-1.x.x :002 > java_import 'org.sikuli.script.Screen'                                                              
    •  => Java::OrgSikuliScript::Screen 
  6. jruby-1.x.x :003 > screen = Screen.new                                                                             
    •  => #<Java::OrgSikuliScript::Screen:0x1dc2dad7>
  7. jruby-1.6.0 :004 > image_path='/Users/mubbashir/Desktop'                                                             
    •  => "/Users/mubbashir/Desktop"
  8. screen.hover("#{image_path}/apple.png") 
    • [info] Sikuli vision engine loaded.
    •  => 1 
 You will see mouse pointer to be moved to apple icon.

With Auto Completion IRB is just a blessing, specially when you want to try some new library or need to run some snippets:

Similarly in script it would be something like:


to run the script ruby script_file_name.rb Just be sure that you are using JRuby ;)

Saturday, July 9, 2011

Sikuli on Selenium- A demonstration of automation using selenium and Sikuli (such as flash uploader)

Selenium 2.0 is just launched, and the excitement remind me that there are tons of selenium related things I need to share with the world.

One of those things is File Upload. File uploads have always been a real pain to automate using selenium.
People have used AutoIt (so have I) to upload on windows only environment. On windows, beside AutoIt, native events  (of webdriver) have worked a great deal for me in the past. 

It becomes a real challenge  when file upload is done via some flash components (components which don't provides hooks from java script to play with files to upload).  

I had tired couple of things but the thing which worked really well was to have type="file"  and send keys but flash uploader and *nix remains challenging.  

Then I stumble across Sikuli. From there web site "Sikuli is a visual technology to automate and test graphical user interfaces (GUI) using images (screenshots)".

Below is what I have done to use it to automat file upload via flash components on MacOS X. With few image changes we should be able to port it for Linux.


Source code is available at: https://github.com/mubbashir/Sikuli-on-Selenium

See it pretty smoothly uploads the file, but .. It works like a real user and real human user i.e. a real user can only interact with what is being displayed on the Screen. If the browser window dosen't have the focus Sikuli will not be able to find images.

Did I mention that test are written using TestNG, so this can slightly work as demonstration of TestNG on Selenium as well. 

Note: I haven't tried this in head-less mode.

Monday, September 27, 2010

Disk Usage on a Remote host: Enable X11 Forwarding for ssh and run x11 application

Lately I was in the of analyze analyze disk space on a remote server, when you are on *nix you can do such things quite easliy.
ssh into your remote host and Enable ForwardX11
  1. For  enabling it for sshd (ssh deamon):
    •   sudo vi /etc/ssh/sshd_config 
    • and modify X11Forwarding no to X11Forwarding yes
  2. Restart sshd:
    • sudo /etc/init.d/ssh 
  3. Exit from current session
  4. ssh into remote host again with -X flag
    • ssh -X username@hostname
  5. Run your application in my case $ baobab
Disk Usage Utility
Have Look at JDiskReport for a cross platform app.
For Macs Edit  sshd_config  located in /etc
  1. sudo vim /etc/sshd_config 
  2. ssh to your mac
  3. Run the app $ java -jar jdiskreport-1.3.2.jar 
JDiskReport


Ruby IRB Auto Completion and Highlight - Linux

Install wirble

laptop:~$ sudo gem install wirble
Successfully installed wirble-0.1.3
1 gem installed
Installing ri documentation for wirble-0.1.3...
Installing RDoc documentation for wirble-0.1.3...

vim ~/.irbrc
Put the following in this file:

require "rubygems"
require "wirble"
Wirble.init
Wirble.colorize

IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:LOAD_MODULES] = [] unless IRB.conf.key?(:LOAD_MODULES)
unless IRB.conf[:LOAD_MODULES].include?('irb/completion')
IRB.conf[:LOAD_MODULES] << 'irb/completion'
end


type
:wq

Thats it on irb prompt use tab for auto completion

Example:

Install random_data

laptop:~$ sudo gem install random_data
Successfully installed random_data-1.5.1
1 gem installed
Installing ri documentation for random_data-1.5.1...
Installing RDoc documentation for random_data-1.5.1...

-laptop:~$ irb
>> require 'rubygems'
=> false
>> require 'random_data'
=> true
>> Random.al
Random.allocate Random.alphanumeric
>> Random.alphanumeric 11
=> "w1KbPVLzE2l"

Sunday, September 6, 2009

It is Fixed, or Just Fixed

The first thing you tell a Tester is "How to write Test Cases", Then you tell him how to write the Better one, and How can you make them Effective. Then you throw IEEE guide lines on Tester to make even Lengthy. Even the gurus have told us what is a good Test Case.

And Once I follow all these guide lines (not matter I want to follow or not) and find some Bug then you kill me by Telling me how to write bugs and how to report bugs how to use the Bug Tracking system and how to use it Effectively. Even the gurus have told us about writing Effective Bug reports.

And few Sr Tester/ Test Manager believes, always write how to replicate the bug and If you can't replicate its not a Bug.

Asking the tester to follow this (instead of letting him Test) is done in the Name of Communication. Communication with Developers, communication with Product owners and Communication with rest of the Team. And then there comes the advocacy part.

Once I have spent this much time on ( things helping ) Testing, I follow the guide lines for creating Test Case, I follow the Guide Line of Bug Reporting and I advocate my Bug well. Then the developer acknowledge the bug and submits it patch and changes the State in the Bug Tracking System (or an Email thread) and puts his comments. "It is Fixed" or Just "Fixed".

Ohh Come on, I deserve more then that, show some courtesy You ask me to write and write and your response is "Fixed". You think I don't need to know

What was causing the Bug?
How have you fixed it?
What other Areas might have effected with the fix?
(during the earlier cycles of Testing) You don't want me to tell that you have been real Lame in deploying the application (For Testing) you haven't updated the config file you haven't deployed all components, you were using wrong code from wrong Source Code Tag.
You don't want me to tell you can't use regular Expression to handle Input fields.
Or there was a logical Error, You were Assuming it is to be done some other way (and I wan't to know the other way)
......

Knowing the application help me a lot to Test it, What was causing it help me a lot to Understand the Bug Pattern and Help to find similar things in other parts of the Application. What you have done to fix it Help me a lot to investigate Impact of the Fix and How can I make sure it hasn't effected any other area...

Why Test Managers Keep Telling his Testers How to write Test Case/Bug Report and Its dos and don't. Why Can't They Developers to shade some light on the Bug and Its fix.

Why Development Manager Can't Tell developers to write few lines when changing the state of the Bug.

Why It is just "Fixed"?

BTW, you can avoid all this, but for that you need to have good relations with developers you can get all that information on Informal communication channels.