Migration testing framework

1,083 views

Published on

Session Presented at 2nd IndicThreads.com Conference On Software Quality held on 25-26 March 2011 in Pune, India. WEB: http://Q11.IndicThreads.com

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,083
On SlideShare
0
From Embeds
0
Number of Embeds
32
Actions
Shares
0
Downloads
24
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Migration testing framework

  1. 1. Developing Platform Independent Migration Testing Framework – Approaches using ANT Vishal Harane SAS R&D, India
  2. 2. Agenda <ul><li>Takeaways </li></ul><ul><li>What is Product Migration </li></ul><ul><li>Different types of product architecture </li></ul><ul><li>Problem area </li></ul><ul><li>Automation process flow </li></ul><ul><li>Why ANT? </li></ul><ul><li>Framework Architecture </li></ul><ul><li>Sample scripts with examples </li></ul><ul><li>Test execution report </li></ul><ul><li>Schedule Automation Script </li></ul>
  3. 3. Takeaways <ul><li>To automate different complex tasks (Non GUI tasks) </li></ul><ul><li>To develop platform independent framework </li></ul><ul><li>Automate to maximum </li></ul><ul><ul><li>(Manual tasks + GUI tasks) </li></ul></ul>
  4. 4. What Is Product Migration? <ul><li>Migration is the process of moving product from </li></ul><ul><ul><li>Smaller machine to bigger </li></ul></ul><ul><ul><li>One platform to another </li></ul></ul><ul><ul><li>One application to another </li></ul></ul><ul><ul><li>One version to another </li></ul></ul><ul><li>It is not just a copy, it is more than that </li></ul>
  5. 5. Single Machine Architecture Grid Architecture
  6. 6. Multi Machine Architecture
  7. 7. Problem Area
  8. 8. Solution? Develop a framework which automate different tasks
  9. 9. Automation Process Flow
  10. 10. Why ANT? <ul><li>Ease of use </li></ul><ul><li>Platform independent </li></ul><ul><li>Is not only a build tool; it can do much more… </li></ul><ul><li>Can invoke third party plug-ins tasks </li></ul><ul><li>Can handle dependencies between targets </li></ul><ul><li>Custom tasks – Java, Groovy, etc. </li></ul>
  11. 11. Framework Architecture ANT Script Property Files
  12. 12. ANT Script To Check OS <target name=&quot;checkBuild&quot; depends=&quot; checkOS &quot;> <if> <isset property=&quot; i sWindows &quot;/> <then> < exec executable=&quot;${build.location} setup.exe &quot; > <arg line=&quot;-quiet -responsefile ${responsefile}&quot; /> </exec> </then> <else> < exec executable=&quot;${build.location}/ setup.sh &quot; > <arg line=&quot;-quiet -responsefile ${responsefile}&quot; /> </exec> </else> </if> </target> <target name=&quot;checkOS&quot; > <condition property=&quot; isWindows &quot;> <os family =&quot;windows&quot;/> </condition> <condition property=&quot;isUnix&quot;> <os family=&quot;unix&quot;/> </condition> </target> Run Executable Check OS
  13. 13. ANT Script With Java Integration <ul><li><project name=&quot;testProject&quot; default=&quot;checkBuild&quot; > </li></ul><ul><li><target name=&quot;checkBuild” > </li></ul><ul><li><echo message=&quot;Checking availability of build&quot;/> </li></ul><ul><li><getBuild/> </li></ul><ul><li><echo message=&quot;Build to be tested = ${ getBuild.name }&quot;/> </li></ul><ul><li></target> </li></ul><ul><li><!-- Script to generate last weekly build name --> </li></ul><ul><li>< scriptdef name=&quot; getBuild &quot; language=&quot;beanshell&quot;> </li></ul><ul><li><![CDATA[ </li></ul><ul><li>final String BUILD_INITIALS = “product.&quot;; </li></ul><ul><li>final String DATE_FORMAT = &quot;yyyyMMdd&quot;; </li></ul><ul><li>final long DAY_MILLIS = 86400000; </li></ul><ul><li>Calendar cal = new GregorianCalendar(); </li></ul><ul><li>int day = cal.getTime().getDay(); </li></ul><ul><li>if(day > 3) { </li></ul><ul><li>cal.setTimeInMillis(cal.getTimeInMillis() - ((day - 3) * DAY_MILLIS)); </li></ul><ul><li>} else if (day < 3) { </li></ul><ul><li>cal.setTimeInMillis(cal.getTimeInMillis() - ((4 + day) * DAY_MILLIS)); </li></ul><ul><li>} </li></ul><ul><li>java.text.DateFormat df = new java.text.SimpleDateFormat(DATE_FORMAT); </li></ul><ul><li>project.setProperty(&quot; getBuild.name &quot;, BUILD_INITIALS + df.format(cal.getTime())); </li></ul><ul><li>]]> </li></ul><ul><li></scriptdef> </li></ul><ul><li></project> </li></ul>Code To Generate product.20110101 Pattern
  14. 14. Configuration Task <ul><li><target name=&quot;checkConfig&quot; > </li></ul><ul><li>Windows </li></ul><ul><li><property file=&quot;${config.dir}Servers.ini&quot;/> </li></ul><ul><li><echo message=&quot;Stopping the Product Services if they are running.&quot;/> </li></ul><ul><li><!-- Stopping the Product Services --> </li></ul><ul><li><exec executable=&quot; net &quot; > </li></ul><ul><li><arg value=&quot; stop &quot;/> </li></ul><ul><li><arg value=&quot; ${ServiceName} &quot;/> </li></ul><ul><li><arg value=&quot; /y &quot;/> </li></ul><ul><li></exec> </li></ul><ul><li>UNIX </li></ul><ul><li><echo message=&quot;Stopping the Product Services if they are running.&quot;/> </li></ul><ul><li><!-- Stopping the Product Services --> </li></ul><ul><li><exec executable=&quot; ${config.dir}servers &quot; > </li></ul><ul><li><arg value=&quot; stop &quot;/> </li></ul><ul><li></exec> </li></ul><ul><li><echo message=&quot;Deleting product configuration directory.&quot;/> </li></ul><ul><li>< delete dir=&quot;${config.dir}&quot;/> </li></ul><ul><li></target> </li></ul>
  15. 15. Install, Log And Response File Tasks <ul><li><target name=&quot; checkInstall &quot; > </li></ul><ul><li>< delete dir=&quot;${install.dir}&quot;/> </li></ul><ul><li></target> </li></ul><ul><li><target name=&quot; checkLog &quot; > </li></ul><ul><li>< delete dir=&quot;${logdir}&quot;/> </li></ul><ul><li></target> </li></ul><ul><li><target name=&quot; checkResponsefile &quot; > </li></ul><ul><li><echo message=&quot;Editing the response file to use the correct license file from current weekly build.&quot;/> </li></ul><ul><li>< replaceregexp file=&quot;${responsefile}&quot; match=“ product.([0-9]*) &quot; replace=&quot; ${ build.name } &quot; flags=&quot;ig&quot;/> </li></ul><ul><li></target> </li></ul>
  16. 16. Main ANT Task <ul><li><target name=&quot;runBuild&quot; depends=&quot; checkConfig , checkInstall , checkLogs , checkResponsefile &quot; > </li></ul><ul><li><parallel> </li></ul><ul><li><exec executable=&quot;${build.location}/${build.name}/ setup.sh &quot; > </li></ul><ul><li><arg line=&quot;-quiet -responsefile ${responsefile}&quot; /> </li></ul><ul><li></exec> </li></ul><ul><li><sequential> </li></ul><ul><li><waitfor maxwait=&quot;120&quot; maxwaitunit=&quot;minute&quot; checkevery=&quot;1&quot; checkeveryunit=&quot;minute&quot;> </li></ul><ul><li><available file=&quot;${install.dir}installs.txt&quot; /> </li></ul><ul><li></waitfor> </li></ul><ul><li><echo message=&quot; Setting up the root permissions .... &quot;/> </li></ul><ul><li><exec executable=&quot;/usr/bin/sudo&quot; dir=&quot;${install.dir}/utilities/bin&quot;> </li></ul><ul><li><arg line=&quot; chown root testauth testperm&quot; /> </li></ul><ul><li></exec> </li></ul><ul><li><exec executable=&quot;/usr/bin/sudo&quot; dir=&quot;${install.dir}/utilities/bin&quot;> </li></ul><ul><li><arg line=&quot; chmod 4755 testauth testperm&quot; /> </li></ul><ul><li></exec> </li></ul><ul><li></sequential> </li></ul><ul><li></parallel> </li></ul>
  17. 17. Main ANT Task - Continue <ul><li>< waitfor maxwait=&quot;120&quot; maxwaitunit=&quot;minute&quot; checkevery=&quot;1&quot; checkeveryunit=&quot;minute&quot;> </li></ul><ul><li><not><available file=&quot; ${logfile}.lck &quot;/></not> </li></ul><ul><li></waitfor> </li></ul><ul><li><!-- Is Product ran successfully? --> </li></ul><ul><li><loadfile srcFile=&quot;${logfile}&quot; property=&quot;product.Error&quot;> </li></ul><ul><li><filterchain> </li></ul><ul><li><containsregex pattern=&quot; Exit Code = -1 &quot; flags=&quot;gi&quot;/> </li></ul><ul><li></filterchain> </li></ul><ul><li></loadfile> </li></ul><ul><li><if> </li></ul><ul><li><isset property=&quot; product.Error &quot;/> </li></ul><ul><li><then> </li></ul><ul><li><!– Code to send mail --> </li></ul><ul><li></then> </li></ul><ul><li><else> </li></ul><ul><li><echo message=&quot;Product installed successfully&quot;/> </li></ul><ul><li><antcall target=&quot; validateServers &quot; /> </li></ul><ul><li><antcall target=&quot; checkData &quot; /> </li></ul><ul><li></else> </li></ul><ul><li></if> </li></ul><ul><li></target> </li></ul>
  18. 18. Services/Servers Validation <ul><li>Server.xml file contains information related to all services present for a Product </li></ul><ul><li>< GetObjects > </li></ul><ul><li>< Servers > </li></ul><ul><li><Server Name =&quot;Authentication Service&quot; /> </li></ul><ul><li><Server Name=&quot;File Service&quot; /> </li></ul><ul><li><Server Name=&quot;RPC Service&quot; /> </li></ul><ul><li><Server Name=&quot;WorkAllocation Service&quot; /> </li></ul><ul><li><Server Name=&quot;Console Service&quot; /> </li></ul><ul><li></Servers> </li></ul><ul><li></GetObjects> </li></ul><ul><li><target name=&quot;validateServers&quot; > </li></ul><ul><li><xmlproperty file=&quot;${serverxml}&quot; collapseAttributes=&quot;true&quot;/> </li></ul><ul><li><property name=&quot;getobjects.servers.name&quot; value=&quot;${ GetObjects.Servers.Name }&quot;/> </li></ul><ul><li><echo message=&quot;${ getobjects.servers.name }&quot; /> </li></ul><ul><li><for list=&quot;${getobjects.servers.name} &quot; delimiter=&quot;,&quot; param=&quot;currentval&quot;> </li></ul><ul><li><sequential> </li></ul><ul><li><exec executable=&quot;${install.dir}UtilitiesValidateServer.exe&quot; LogError=&quot;true&quot; > </li></ul><ul><li><arg value=&quot;host=${host} port=${port} username=${username} password=${password}&quot;/> </li></ul><ul><li><arg value=&quot;-servername&quot;/> </li></ul><ul><li><arg value=&quot;@{currentval}&quot;/> </li></ul><ul><li></exec> </li></ul>Sample XML Containing Server Names
  19. 19. Services/Servers Validation - Cont... <ul><li><loadfile srcFile=&quot;${validatelog}&quot; property=&quot; validate.Success &quot;> </li></ul><ul><li><filterchain> </li></ul><ul><li><containsregex pattern=&quot; Return code: 0 ” /> </li></ul><ul><li></filterchain> </li></ul><ul><li></loadfile> </li></ul><ul><li><if> </li></ul><ul><li><isset property=&quot;validate.Success&quot;/> </li></ul><ul><li><then> </li></ul><ul><li><echo message=&quot;@{currentval} = Successful ” /> </li></ul><ul><li></then> </li></ul><ul><li><else> </li></ul><ul><li><echo message=&quot;@{currentval} = Failed ” /> </li></ul><ul><li></else> </li></ul><ul><li></if> </li></ul><ul><li><unset name=&quot;validate.Success&quot;/> </li></ul><ul><li></sequential> </li></ul><ul><li></for> </li></ul><ul><li></target> </li></ul>
  20. 20. Web Server Validation Task <ul><li><!-- Check whether Tomcat is running --> </li></ul><ul><li><target name=&quot;check-port&quot; description=&quot;Check whether Tomcat is running&quot;> </li></ul><ul><li><echo message=&quot;Checking whether Tomcat is running&quot;/> </li></ul><ul><li><condition property=&quot;tomcat.running&quot;> </li></ul><ul><li> < socket server=&quot;${tomcat.host}&quot; port=&quot;${tomcat.port}&quot; /> </li></ul><ul><li></condition> </li></ul><ul><li></target> </li></ul><ul><li><!-- Start Tomcat if it isn't running --> </li></ul><ul><li><target name=&quot;start-tomcat&quot; depends=&quot;check-port&quot; description=&quot;Start Tomcat if it isn't running&quot; unless=&quot;tomcat.running&quot;> </li></ul><ul><li><echo message=&quot;Starting Tomcat&quot;/> </li></ul><ul><li><property environment=&quot;env&quot;/> </li></ul><ul><li><exec executable=&quot; ${env.CATALINA_HOME}/bin/${tomcat.executableName} &quot; </li></ul><ul><li> spawn=&quot;true&quot; vmlauncher=&quot;false&quot;/> </li></ul><ul><li><sleep seconds=&quot;15&quot;/> </li></ul><ul><li></target> </li></ul>
  21. 21. Database Schema Validation Task
  22. 22. Database Schema Validation Task <ul><li>#!/usr/bin/perl (Perl Script) </li></ul><ul><li>use DBI; </li></ul><ul><li>my $temp_table=0; </li></ul><ul><li>my $g_dbh = DBI-> connect ( $test_database, $test_user, $test_password) </li></ul><ul><li>or die &quot;Can't connect to database $test_database: $DBI::errstr&quot;; </li></ul><ul><li>my $g_sth = $g_dbh-> prepare (q{ select tabname from syscat.tables where tabschema='DB2INST1'}) </li></ul><ul><li>or die &quot;Can't prepare Select statement for getting list of tables: $DBI::errstr&quot;; </li></ul><ul><li>my $g_rc = $g_sth-> execute </li></ul><ul><li>or die &quot;Can't execute Select statement for getting list of tables: $DBI::errstr&quot;; </li></ul><ul><li>open(TEMP,&quot;>/temp/tables.txt&quot;) #get list to tables before migration </li></ul><ul><li>or die &quot;Can't open file: $!&quot;; </li></ul><ul><li>while (($tabname) = $g_sth-> fetchrow ()) { </li></ul><ul><li>print TEMP &quot;$tabnamen&quot;; </li></ul><ul><li>$temp_table++; </li></ul><ul><li>} </li></ul><ul><li>close TEMP; </li></ul>
  23. 23. Database Schema Task – Cont… <ul><li>open(PRODUCT,&quot;</temp/tables.txt&quot;) or die &quot;$!&quot;; #get list to tables before migration </li></ul><ul><li>open(FILE,&quot;>/temp/schema_before_mig.txt&quot;) or die &quot;$!&quot;; #get schema details before migration </li></ul><ul><li>while ($product_tables = <PRODUCT>) { </li></ul><ul><li>chomp($product_tables); </li></ul><ul><li>my $g_sth = $g_dbh-> prepare (qq{ select COLNAME, TYPENAME, LENGTH, DEFAULT, NULLS from syscat.columns where TABNAME='$product_tables' order by COLNAME}) </li></ul><ul><li>or die &quot;Can't prepare Select product describe table statement: $DBI::errstr&quot;; </li></ul><ul><li>my $g_rc = $g_sth-> execute </li></ul><ul><li>or die &quot;Can't execute Select product describe table statement: $DBI::errstr&quot;; </li></ul><ul><li>while (($g_Column,$g_Type,$g_Length,$g_default,$g_nulls) = $g_sth->fetchrow()) { </li></ul><ul><li>print FILE &quot;n$product_tables:$g_Column:$g_Type:$g_Length:$g_default:$g_nulls&quot;; </li></ul><ul><li>} </li></ul><ul><li>$g_sth->finish; </li></ul><ul><li>} </li></ul><ul><li>print FILE &quot;n&quot;; </li></ul><ul><li>close FILE; </li></ul><ul><li>close PRODUCT; </li></ul><ul><li>$g_dbh->disconnect; </li></ul>
  24. 24. Physical Data Files Validation Task
  25. 25. Physical Data Files Task – Cont… <ul><li><target name=&quot; checkData &quot; > </li></ul><ul><li><echo message=&quot;Comparing the data files present on source machine with the target machine. “/> </li></ul><ul><li>< resourcecount property=&quot;file.lines&quot;> </li></ul><ul><li><tokens> </li></ul><ul><li> <concat> </li></ul><ul><li><filterchain> </li></ul><ul><li> <tokenfilter> </li></ul><ul><li>< linetokenizer /> </li></ul><ul><li> </tokenfilter> </li></ul><ul><li></filterchain> </li></ul><ul><li><fileset file=&quot;${source.datafile}&quot;/> </li></ul><ul><li> </concat> </li></ul><ul><li></tokens> </li></ul><ul><li></resourcecount> </li></ul><ul><li><echo message=&quot;Total number of Product Data files present on Source machine are :” /> </li></ul><ul><li>< loadfile srcFile=&quot;${datacompare.file}&quot; property=&quot;file.input&quot;/> </li></ul><ul><li><for list=&quot;${file.input}&quot; delimiter=&quot;${line.separator}&quot; param=&quot;currentval&quot;> </li></ul><ul><li>< sequential > </li></ul><ul><li><echo>@{currentval}</echo> </li></ul><ul><li><exec executable=&quot; C:Program FilesGnuWin32binfind.exe &quot; dir=&quot;${config.dir}&quot; output=&quot;${tmp.target.file}&quot; append=&quot;true&quot;> </li></ul><ul><li><arg line=&quot;'@{currentval}' -name '*. sas *' -type f&quot;/> </li></ul><ul><li></exec> </li></ul><ul><li></sequential> </li></ul><ul><li></for> </li></ul>
  26. 26. Physical Data Files Task – Cont… <ul><li><exec executable=&quot; sort &quot; output=&quot;${target.datafile}&quot;> </li></ul><ul><li><arg line=&quot;${tmp.target.file}&quot;/> </li></ul><ul><li></exec> </li></ul><ul><li><!– Code to calculate number of product Data file present on Target machine --> </li></ul><ul><li><echo message=&quot;Total number of Product Data files present on Target machine are : “/> </li></ul><ul><li><echo message=&quot;Following files are not present in the target environment:”/> </li></ul><ul><li><exec executable=&quot; diff &quot; output=&quot;${tmp.target.file}&quot; > </li></ul><ul><li><arg line=&quot;${source.datafile} ${target.datafile}&quot;/> </li></ul><ul><li></exec> </li></ul><ul><li><exec executable=&quot; grep &quot; output=&quot;${tmp.target.file}&quot;> </li></ul><ul><li><arg line=&quot;&quot;&lt;&quot; ${tmp.target.file}&quot;/> </li></ul><ul><li></exec> </li></ul><ul><li><exec executable=&quot; sed &quot; output=&quot;${datafile}&quot; append=&quot;true&quot;> </li></ul><ul><li><arg line=&quot;-e &quot;s/&lt; //g&quot; ${tmp.target.file}&quot;/> </li></ul><ul><li></exec> </li></ul><ul><li></target> </li></ul>
  27. 27. Job Submission & Result Validation <ul><li>Software Development Kit (SDK) </li></ul><ul><li>Product utilities </li></ul>
  28. 28. Job Submission & Result – Cont… <ul><li><exec executable=&quot;${install.dir}/Utilities/ submitJob &quot; LogError=&quot;true&quot; > </li></ul><ul><li><arg value=&quot;-inputfile ${input_file} -outputfile ${output_file} -comparefile ${compare_file} -log ${ result_log }&quot;/> </li></ul><ul><li></exec> </li></ul><ul><li><loadfile srcFile=&quot;${ result_log }&quot; property=&quot;result.Success&quot;> </li></ul><ul><li><filterchain> </li></ul><ul><li><containsregex pattern=&quot; Return code: 0 ” /> </li></ul><ul><li></filterchain> </li></ul><ul><li></loadfile> </li></ul><ul><li><if> </li></ul><ul><li><isset property=&quot;result.Success&quot;/> </li></ul><ul><li><then> </li></ul><ul><li><echo message=&quot;Test job result is Successful&quot; /> </li></ul><ul><li></then> </li></ul><ul><li><else> </li></ul><ul><li><echo message=&quot;Test job failed, please check ${result_log} file for more information&quot; /> </li></ul><ul><li></else> </li></ul><ul><li></if> </li></ul>
  29. 29. Reporting
  30. 30. Schedule Automation Script <ul><li>Schedule these scripts </li></ul><ul><ul><li>Daily </li></ul></ul><ul><ul><li>Weekly </li></ul></ul><ul><li>Utilities </li></ul><ul><ul><li>Windows scheduler </li></ul></ul><ul><ul><li>Unix’s crontab </li></ul></ul>
  31. 31. Questions
  32. 32. References <ul><li>Explore ANT </li></ul><ul><ul><li>http://ant.apache.org/ </li></ul></ul><ul><li>ANT Manual </li></ul><ul><ul><li>http://ant.apache.org/manual/ </li></ul></ul>
  33. 33. Thank You !!! Contact: vishal.harane@gmail.com

×