• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Migration testing framework
 

Migration testing framework

on

  • 1,034 views

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

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

Statistics

Views

Total Views
1,034
Views on SlideShare
1,003
Embed Views
31

Actions

Likes
0
Downloads
21
Comments
0

1 Embed 31

http://q11.indicthreads.com 31

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Migration testing framework Migration testing framework Presentation Transcript

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