Thursday, 3 October 2013

MTR test Automation Techniques

In this blog i am going to talk about couple of techniques how to automate certain MTR testcases,

these techniques are really underlying inside the suites and they never got exposed much to the test members. In case he/she wants to make use of these techniques for writing MTR testcase. One should really invest time and search from the existing suites.

My effort here is to bring up such techniques and consolidate them as a single reference for the end user.I will also keep updating this blog whenever i find something interesting.

The Viewers also can keep posting to this blog.

Technique 1:

The following sample code describes how to pass a value from MTR to perl

#Set the value of the variable in MTR
let  x=100;

#Get the value into perl & print

my $var1 = $ENV{'x'};
print "var1 = $var1 \n";


Technique 2:

The following sample code describes how to pass a value vice versa (Perl to MTR).Here it is not straight forward like above mentioned, hence store the value into a temp file and use source command to bring into MTR, and finally cleanup the temp file.

#Set the value of variable in the perl
 my $dir = $ENV{'MYSQLTEST_VARDIR'};
 open ( OUTPUT, ">$dir/tmp/") ;
 print OUTPUT "let \$stat = 100;\n";
 close (OUTPUT);

#Get the value of the variable from to MTR, from perl
--source  $MYSQLTEST_VARDIR/tmp/

#Print the value in MTR
--echo $stat

#Remove the temp file
--remove_file $MYSQLTEST_VARDIR/tmp/

Technique 3:

Assume that, there are 2 DATADIR locations old and new are existing, in case user wants to star the DB server with new DATADIR location and do some testing during MTR test execution. Here is the sample code

1. Stop the server which was running with old DATADIR
2. Restrat the DB server with new DATADIR

Following sample code describes how to start from new location.

#Stop server with old location
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- shutdown_server 30
-- source include/

#Restart the DB server from new location
-- exec echo "restart: --datadir=$MYSQL_TMP_DIR/ " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- enable_reconnect
-- source include/

Note: all DATA files should exist under new location otherwise DB startup will fail.

No comments:

Post a Comment