VU Final Year Project

I am studying for MIT from Virtual University Pakistan. When this semester started, I also had to take a final year project, which would span on two semester. VU proposed 4 projects and also encouraged students to submit their custom proposal. I took the opportunity and discussed a possible custom project with my colleagues and friends. We came up with the idea of an Education CRM, which we could develop on top of existing open source software like Sugar CRM and Moodle. Some of the functional requirements, I proposed were:

  1. Extract customer data from LMS which can be used to effectively manage customers in CRM.
  2. Use CRM to document interaction with LMS users. Interaction includes activities, leads, opportunities, cases, bugs and reporting.
  3. Auto-update customer information from LMS in CRM.
  4. Synchronization of student contact information between the two systems.
  5. In CRM display the list of enrolled courses for every student along with grades in those courses.
  6. Customize CRM to make it ‘Education CRM’ (instead of a generic CRM). For example, instead of calling it “customers”, we may want to call them students.
  7. Auto creation of student account in LMS, when in CRM the lead is “converted” and the status is changed to “Student” from “Lead/opportunity”.

I was very excited about this and was very confident that I would be able to make this by writing a plugin for Sugar CRM and Moodle but unfortunately this project proposal was rejected. I asked our teachers for the reasons but they didn’t like to comment on rejection. I tried to follow all their rules for submitting project proposal but somehow they didn’t like this idea and rejected it. I still believe this is a very good idea but due to lack of time this year, I won’t be able to give it time. However, I will look forward for this and see whenever I get sometime I will start working on it. If anyone has any further ideas and time to take on this project, I would be glad to help in any capacity I could.

Now I am supposed to work on one of the project they proposed. The four projects they proposed are:

  1. Production Rejection Assessment System
  2. Macro Recording System
  3. Robotic Simulation To Detect Explosive Material
  4. Email Moderation Engine

I have now selected ‘Email Moderation Engine’ as my final year project. I am now looking for some good partner and will then start working on this. I will try to keep this space updated about this. I hope to learn quite a few things as I would be trying a few new things.

Starting Android Development

I was looking into Android development. I googled for this and noted it is more popular among the developer communities than the iPhone development. Reason? Android apps could be developed in Java and for iPhone one has to get used to a totally new environment. In my view, it is a huge plus point for Android.

When studying, I noted the best source for beginners would be to study at android development. However, I would also recommend the book Android Application Development: Programming with the Google SDK
. This is an excellent book and would greatly help any one starting Adnroid development.

Presentation about web testing automation

When I was automating testing our first project, it was a web based administration app. For that, I did some research and we chose to go with Sahi. I was able to achieve about 60-70% automation with Sahi and very happy with its result. During that time, one day I also gave a presentation at my office about what and how is web testing automation with Sahi. The presentation I created for this is the following:

This presentation gives a very brief idea about web testing automation in general and with Sahi. In the coming posts, I will try to share the issues I faced both with automating testing for desktop and web apps.

Automating with TestComplete

Recently we purchased TestComplete license. After some initial phase of learning the tool, I have now started automating our actual test cases using TestComplete. Before going to start this I did the following:

  1. Studied Software Test Automation book by Mark Fewster & Dorothy Graham (highly recommended for those who are starting automating tests)
  2. Studied and watched different webinars on Automated QA’s website.

Overall, it is going smooth and good. But obviously, it is taking sometime to get used to this. In some of my next posts, I will share how I am doing with this.

So for now we are using TestComplete for desktop and Sahi for web app testing automation.

Backtrace in PHP

I have been developing in PHP from the last 4-5 years. Since the introduction of OOP concepts in PHP5, the language is getting matured and more ready for large applications.

While working with large projects, one can not avoid logging for error / debug to later diagnose the issues one might face in production. So beside logging some general information and simple errors which PHP throws and we could get from PHP we could also capture the whole backtrace for the code we are running in such case.

It could be easily incorporated in your application. Follow are some modified examples from PHP’s documentation debug_print_backtrace:

//This is backtrace_include.php

//This function modifies the output which PHP provides for debug_print_backtrace
//by dany dot dylan at gmail dot com
function debug_string_backtrace()
{
	ob_start();
	debug_print_backtrace();
	$trace = ob_get_contents();
	ob_end_clean();

	// Remove first item from backtrace as it's this function which
	// is redundant.
	$trace = preg_replace ('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1);

	// Renumber backtrace items.
	$trace = preg_replace ('/^#(\d+)/me', '\'#\' . ($1 - 1)', $trace);

	return $trace;
}

function a()
{
    return b();
}

function b()
{
    return c();
}

function c()
{
    return debug_string_backtrace();
}

$trace = a();
echo $trace;

Save the above file as backtrace_include.php and call in the following file:

//This is backtrace_test.php
include 'backtrace_include.php';

This will print the following:

#0  c() called at [/home/www/backtrace_include.php:29]
#1  b() called at [/home/www/backtrace_include.php:24]
#2  a() called at [/home/www/backtrace_include.php:37]
#3  include(/home/www/backtrace_include.php) called at [/home/www/backtrace_test.php:3]

Usually in production websites, we don’t print such trace on screen and log this in a file. We will also log such information only in a situation when an error occurs while executing the code.

Array comparison in PHP

While working on a recent project, I had to do some array comparison. I did array comparison by doing the following:

$firstArr = array(2,4,8);
$secondArr = array(2,8,4);

According to my requirements the above two arrays are same but if we compare it in PHP, it would not think so due to the presence of value on different indexes. To solve that, I first sorted and then compared these arrays, which gave me the required result.

//sort the arrays using php's sort function
sort($firstArr);
sort($secondArr);

//compare the arrays
if ( $firstArr === $secondArr)
{
	echo "Yes. They are equal";
}
else
{
	echo "No. They are not.";
}

Incremental backup using Rdiff-Backup

Backup. No one can deny the fact that it is a very core requirement of IT businesses. We had been using a script to backup data to a specified folder on our Linux server and then from Linux server we used to write CD weekly or bi weekly basis. Due to lack of time, we couldn’t improve this for quite sometime.

Recently, when due to some extremely busy schedule I couldn’t take backups on CDs, I thought to improve our backup process. Our requirements were really simple, we needed a backup process which could copy our required folders to a remote server and then later on keep doing some incremental backups there. Upon some research, I found two software being used for this purpose one is rsync, the other one rdiff-backup, I chose to go with rdiff-backup software as it was purely written for this purpose of backup and it also uses the libraries of rsync.

I studied and evaluated it and found it worth trying. After a few days of trying on this on my local machine, I installed this both on our local server and online server to start backup using this. Following are some of the steps which would help anyone setup this on their machines:

  • To use rdiff-backup for remote backup of local servers. Both servers need to have rdiff-backup installed. rdiff-backup is available from apt-get on a debian system and for Redhat based systems it could be downloaded from http://rdiff-backup.nongnu.org/
  • After installing rdiff-backup on both servers to start taking backup issue the following command:
    rdiff-backup /home/www/ root@192.168.0.103::/home/meraj/backup/ (whhere /home/www/ is my local source folder to taken backup of and root@192.168.0.103::/home/meraj/backup/ is server address and destination folder)

Now my next step is to automate this stuff. I don’t want do this every day manually so now will try to get some time and automate this by writing a shell script and then run it through crontab.

While setting up and running rdiff-backup, I noticed the following issues:

  1. To make sure that rdiff-backup is working correctly, before trying to start backup run ‘rdiff-backup –version‘ on both servers and make sure that it returns version correctly, which would mean that rdiff-backup is correctly configured and running.
  2. Make sure that on the destination server we have SE (on redhat machines) not running or if running, then make it permissive mode.
  3. In case running SE in permissive mode also doesn’t help then try to relabel the _librsync.s using ‘chcon -t texrel_shlib_t /usr/lib/python2.4/site-packages/rdiff_backup/_librsync.s

Mysql backup and delete older files

We were taking mysql backups using a very simple shell script which was using mysqldump as below.

#!/bin/sh
#echo "Starting the script";
HOST=localhost
USER=myDBUser
PASSWD='myPassword';

# create directory if it doesn't exist
OLDBACKUP=/home/my_backup/sql_files
if [ ! -d "$OLDBACKUP" ]; then
# create direcotry
mkdir /home/my_backup/sql_files
fi

# set file names by appending date to each file
dbName=dbName-`date -I`.sql;

# take db backups
mysqldump -u $USER -p$PASSWD -n -c myDbName >  $dbName;

# move the file to sql_files directory
mv $dbName $OLDBACKUP

We were keeping old backup files but we knew that we would need to remove the backup files older than two weeks or a month. I was thinking what to do and after some studying I found the following one line, would help us remove files older than x number of days.

find /home/my_backup/sql_files -type f -mtime +15 | xargs rm

Where 15 could be changed to any number of days and it will remove all the files older than that number of days recursively, using this command. This command won’t delete any special files or sub directories.

Testing Tools

For our testing automation and testing environment, some time ago I did some research on the available tools and also evaluated some of them.

I thought, that the tools of list I found during the research (though I didn’t try all of them) would be worth sharing with readers:

I will try to add a small description for each of the testing tool in the above list.