Jenkins service restart issue

Issue:

If Jenkins fails to restart with error “System error 1067 has occurred.

Solution:

  • Download latest Jenkins war from https://jenkins-ci.org/
  • Keep it program files folder (e.g. C:\Program Files (x86)\Jenkins)
  • Start Jenkins (java -jar jenkins.war)
  • Check console, olf jobs would not be there.
  • Now stop this Jenkins instace (Cntrl +C)
  • Now start old instance through service, it should start normally and old jobs should appear at console.

Shell custom log colorizer

How to run

./logScript.sh (Default tail parameter = 50)

./logScript 1000 (User defined tail parameter)

 

log_colorizer.properties

LOG_FILE=”/<PathToLogDir>/<LogFileName>”;
LOG_TAIL_PARAM=50

DIR_TEMP=”tmp”;

OLD_FILE_TIMER=”5″;


Script:

#source property file
. log_colorizer.properties

#Getting tail parameter as argument
TEMP_LOG_TAIL_PARAM=$1

#Checking if passed argument is null
if [ "$TEMP_LOG_TAIL_PARAM" != '' ]; then
 LOG_TAIL_PARAM="$1"
fi


#Clearning old temp files
find $DIR_TEMP/ -name 'tmp*' -type f -mmin +$OLD_FILE_TIMER -delete

#Creating temp file to keep track of what is printed
TEMP_FILE=`mktemp $DIR_TEMP/tmp.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`

#Infinite loop
while :
do
 TEMP=`tail -$LOG_TAIL_PARAM $LOG_FILE`

#File separator
IFS='
'
 for item in $TEMP
 do

#Checking if current line is already printed
 if ! grep -qF "$item" $TEMP_FILE ; then
 #Appending colors in front of various key parameters
 echo $item | perl -pe 's/.*info.*/\e[1;32m$&\e[0m/g;s/.*debug.*/\e[1;33m$&\e[0m/g;s/.*\*\*\*\*\ Error.*/\e[1;31m$&\e[0m/g;s/.*Warning.*/\e[1;36m$&\e[0m/g;s/.*HTTP request.*/\e[1;35m$&\e[0m/g;s/.*<?xml.*/\e[1;35m$&\e[0m/g'
 fi

 done

#Redirect currently read tail content to a temp file
 echo $TEMP > $TEMP_FILE
 sleep 1
done

Jenkins GUI tasks

Tools:

  • Jenkins
  • Windows

Issue:

If your script invokes some GUI on windows and Jenkins is installed as window service, it would not have access to desktop tools.

Resolution:

Open windows service manager

  • Windows+R -> services.msc

Look for Jenkins services

  • Right click on service, open properties

Open “Log on” tab.

Check “Allow service to interact with desktop.”

Restart service.

Now when your script will invoke, GUI, it should go fine.

Firefox Selenium IDE Installation

Tools:

1: Firefox

I will suggest firefox 20.0 version as i had trouble with version 28. You may download old firefox version from here.

2: Selenium IDE

http://docs.seleniumhq.org/download/

3: Selenium IDE button

https://addons.mozilla.org/en-us/firefox/addon/selenium-ide-button/

Installation:

Visit http://docs.seleniumhq.org/download/ and download latest selenium IDE.

Continue reading

How to automate web services testing/perfromance-testing on *nix – Approach

JMeter

Its a tool used for performance testing but as its freely available we can use it for normal testing.

Jenkins

Its a tool which can be used to automate tasks.

Integrate Jenkins and JMeter

JMeter comes with many *unix command, We should be hitting a shell scripts from Jenkins which in turn should invoke JMeter, get and display results on Jenkins console.

Looks simple?

Idea

You can create one JMX per web service or for multiple web services depending upon requirement, now the main problem which we usually face in automation tasks is parameterisation, we want to keep some parameters save for the run time, parameters which we can not hard code, this actually makes the automation the automation. Now first identify those parameters which you want to keep for the run time.

Now when you hit button from Jenkins, it should prepare those parameters in the form its required by the Jenkins, you can write a *nix script for that for example if required.

Now once the parameters are ready you invoke JMeter from your script, now there is a turn here, JMeter JMX file can accept input at run time from two ways:

  1. CSV files
  2. -J[prop name]=[value]

Which ever way you choose, make sure you have prepared your JMX file accordingly in advance before doing this.

For example, if you want to use option-1, you can create CSVs at the run time from scripts but in JMX make sure you provide correct path and name.

And in case you want to go with option-2 there is a different syntax you will have to provide in JMX in order to read variables passed at run time.

 

Now point is you can customize it the way you want, you can use these ways to provide parameters at run because thats what i think matters one of the most in any automation. GUI we have got from Jenkins, scripts and prepration and invoke we can do from shell, testing will be done by JMeter, and parameters well written much about it.

 

Output

Well, written much about how to test a thing, here is, how to get the result, use JMeter result tree option to create as many result CSV files as you want with different name and read these files through your script and display it on Jenkins. You can even keep name and location of files dynamic using two options explained above.

 

Performance testing

Well jenkins even support performance output, great, isnt it? you need to install and configure plugin for that. Find more details here.

https://wiki.jenkins-ci.org/display/JENKINS/Performance+Plugin