reintroduction of the code coverage leveraging EMMA
| | |
| | | ANT_LIB=$OPENDS_LIB/mail.jar:$OPENDS_LIB/activation.jar |
| | | ANT_HOME=`cd ../..;pwd`/ext/ant |
| | | export ANT_HOME |
| | | ANT_OPTS="-Xmx1g" |
| | | export ANT_OPTS |
| | | # Execute the ant script and pass it any additional command-line arguments. |
| | | $ANT_HOME/bin/ant -lib ${ANT_LIB} -f shared/ant/build.xml ${*} |
| | |
| | | <ant antfile="${antfile.dir}/tests.xml" target="run"/> |
| | | </target> |
| | | |
| | | <target name="tests-func-coverage" |
| | | depends="set-func-type,global-init,opends-build,staf-start"> |
| | | <ant antfile="${antfile.dir}/tests.xml" target="testwithcoverage"/> |
| | | </target> |
| | | |
| | | <!-- Run stress tests --> |
| | | <target name="tests-stress-run" |
| | | depends="set-stress-type,global-init,opends-build,staf-start"> |
| | |
| | | <mkdir dir="${tests.run.dir}/${tests.run.time}/config"/> |
| | | <!-- these will serve for after-the-fact archiving the logs --> |
| | | <mkdir dir="${tests.run.dir}/${tests.run.time}/staf-logs"/> |
| | | <mkdir dir="${tests.run.dir}/${tests.run.time}/coverage"/> |
| | | |
| | | <if> |
| | | <equals arg1="${test.plan.custom}" arg2=""/> |
| | |
| | | <target name="coverage-instrument" if="coverage.on"> |
| | | <delete dir="${tests.tmp.dir}/coverage-instr" /> |
| | | <mkdir dir="${tests.tmp.dir}/coverage-instr" /> |
| | | <mkdir dir="${tests.run.dir}/${tests.run.time}/coverage" /> |
| | | <!-- unzip the original package in a temporary location to make the |
| | | changes necessary so that the coverage tool is called |
| | | --> |
| | | <unzip src="${product.package}" |
| | | <unzip src="${opends.dir}/${opends.name}.zip" |
| | | dest="${tests.tmp.dir}/coverage-instr"/> |
| | | |
| | | <!-- Add emma in the package along with the other librairies |
| | | this has the advantage of being automatically picked up by the scripts |
| | | --> |
| | | <copy file="${project.home}/ext/emma/lib/emma.jar" |
| | | tofile="${tests.tmp.dir}/coverage-instr/${product.name}/lib/emma.jar"/> |
| | | tofile="${tests.tmp.dir}/coverage-instr/${opends.name}/lib/emma.jar"/> |
| | | |
| | | <!-- move the original product package to make room for the coverage |
| | | enabled package |
| | | --> |
| | | <move file="${product.package}" tofile="${product.package}.nocov"/> |
| | | <move file="${opends.dir}/${opends.name}.zip" tofile="${opends.dir}/${opends.name}.zip.nocov"/> |
| | | |
| | | <!-- intrument the OpenDS java archive to gather coverage --> |
| | | <java classpath="${tests.tmp.dir}/coverage-instr/${product.name}/lib$/emma.jar" |
| | | <java classpath="${tests.tmp.dir}/coverage-instr/${opends.name}/lib/emma.jar" |
| | | classname="emma" fork="true"> |
| | | <jvmarg value="-Demma.metadata.out.file=${tests.tmp.dir}/coverage-instr/${product.name}/coverage.em" /> |
| | | <arg value="instr" /> |
| | | <arg value="-m" /> |
| | | <arg value="overwrite" /> |
| | | <arg value="-ip" /> |
| | | <arg value="${tests.tmp.dir}/coverage-instr/${product.name}/lib/OpenDS.jar:${tests.tmp.dir}/coverage-instr/${product.name}/lib/extensions/snmp-mib2605.jar" /> |
| | | <jvmarg value="-Demma.metadata.out.file=${tests.tmp.dir}/coverage-instr/${opends.name}/coverage.em" /> |
| | | <arg value="instr" /> |
| | | <arg value="-m" /> |
| | | <arg value="overwrite" /> |
| | | <arg value="-ix" /> |
| | | <arg value="-org.opends.guitools.*" /> |
| | | <arg value="-ix" /> |
| | | <arg value="-org.opends.quicksetup.*" /> |
| | | <arg value="-ix" /> |
| | | <arg value="org.*" /> |
| | | <arg value="-ix" /> |
| | | <arg value="com.*" /> |
| | | <arg value="-ip" /> |
| | | <arg value="${tests.tmp.dir}/coverage-instr/${opends.name}/lib/OpenDS.jar:${tests.tmp.dir}/coverage-instr/${opends.name}/lib/extensions/snmp-mib2605.jar" /> |
| | | </java> |
| | | <echo>Writing properties file</echo> |
| | | <echo file="${tests.tmp.dir}/coverage-instr/${product.name}/classes/emma.properties">coverage.out.file=${tests.tmp.dir}/emma.coverage |
| | | </echo> |
| | | <copy file="${tests.tmp.dir}/coverage-instr/${opends.name}/coverage.em" |
| | | tofile="${tests.run.dir}/${tests.run.time}/coverage/coverage.em"/> |
| | | |
| | | <!-- Repackage the product with coverage enabled scripts --> |
| | | <zip basedir="${tests.tmp.dir}/coverage-instr" destfile="${product.package}"> |
| | | <zipfileset dir="${tests.tmp.dir}/coverage-instr" |
| | | includes="${product.name}/setup,${product.name}/uninstall,${product.name}/upgrade,${product.name}/bin/*,${product.name}/lib/*.sh" |
| | | filemode="755" dirmode="755" /> |
| | | <zip basedir="${tests.tmp.dir}/coverage-instr" destfile="${opends.dir}/${opends.name}.zip"> |
| | | <zipfileset dir="${tests.tmp.dir}/coverage-instr" |
| | | includes="${opends.name}/setup,${opends.name}/uninstall,${opends.name}/upgrade,${opends.name}/bin/*,${opends.name}/lib/*.sh" |
| | | filemode="755" dirmode="755" /> |
| | | </zip> |
| | | <!-- <delete dir="${tests.tmp.dir}/coverage-instr"/> --> |
| | | </target> |
| | | <target name="coverage-report" if="coverage.on"> |
| | | <delete dir="${tests.tmp.dir}/coverage/all" /> |
| | | <mkdir dir="${tests.tmp.dir}/coverage/all" /> |
| | | <emma enabled="${coverage.on}" > |
| | | <report > |
| | | <infileset dir="${tests.tmp.dir}" includes="**/*.em,**/*.ec" /> |
| | | <sourcepath> |
| | | <dirset dir="${project.home}" > |
| | | <include name="src" /> |
| | | </dirset> |
| | | </sourcepath> |
| | | <html outfile="${tests.tmp.dir}/coverage/all/index.html" |
| | | columns="name, method, line" |
| | | sort="+line, +name" |
| | | metrics="line:80" |
| | | /> |
| | | </report> |
| | | </emma> |
| | | </target> |
| | | <target name="restore-pkg" if="coverage.on"> |
| | | <delete file="${product.package}"/> |
| | | <move file="${product.package}.nocov" tofile="${product.package}"/> |
| | | <delete file="${opends.dir}/${opends.name}.zip"/> |
| | | <move file="${opends.dir}/${opends.name}.zip.nocov" tofile="${opends.dir}/${opends.name}.zip"/> |
| | | </target> |
| | | <target name="testwithcoverage" depends="coverage-on,coverage-instrument,restore-pkg,coverage-report"/> |
| | | <target name="testwithcoverage" depends="coverage-on,coverage-instrument,run,restore-pkg"/> |
| | | |
| | | </project> |
| | |
| | | tests-stress-configure : configure the stress tests |
| | | tests-run : run the functional tests |
| | | tests-func-run : run the functional tests |
| | | tests-func-coverage : run the functional tests with code coverage |
| | | tests-stress-run : run the stress tests |
| | | </echo> |
| | | </target> |
| | |
| | | |
| | | <!-- configure the coverage dump file --> |
| | | <script> |
| | | mylog="::coverage - checking for %s/%s/lib/emma.jar\n" % (DIRECTORY_INSTANCE_DIR,OPENDSNAME) |
| | | if os.path.exists('%s/%s/lib/emma.jar' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)): |
| | | mylog+=" ::coverage on\n" |
| | | if not os.path.exists('%s/coverage' % TMPDIR): |
| | | os.mkdir('%s/coverage' % TMPDIR) |
| | | mylog+=" ::mkdir %s/coverage on\n" % TMPDIR |
| | | if not os.path.exists('%s/coverage/%s' |
| | | % (TMPDIR,CurrentTestPath['group'])): |
| | | os.mkdir('%s/coverage/%s' % (TMPDIR,CurrentTestPath['group'])) |
| | | mylog+=" ::mkdir %s/coverage/%s on\n" \ |
| | | % (TMPDIR,CurrentTestPath['group']) |
| | | mylog+=" ::writing to %s/%s/classes/emma.properties" \ |
| | | % (DIRECTORY_INSTANCE_DIR,OPENDSNAME) |
| | | coveragefh = open( '%s/%s/classes/emma.properties' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME), 'w' ) |
| | | coveragefh.write( 'coverage.out.file=%s/coverage/%s/coverage.ec\n' \ |
| | | % (TMPDIR,CurrentTestPath['group']) ) |
| | | mylog="::coverage - checking for %s/%s/lib/emma.jar\n" % (dsDir,OPENDSNAME) |
| | | if os.path.exists(os.path.join(dsDir,OPENDSNAME,'lib','emma.jar')): |
| | | mylog+=" ::coverage on\n" |
| | | coveragePath = os.path.join(LOGS_ROOT,'coverage') |
| | | if not os.path.exists(coveragePath): |
| | | os.mkdir(coveragePath) |
| | | mylog+=" ::mkdir %s on\n" % coveragePath |
| | | # copying coverage.em in coveragePath |
| | | import shutil |
| | | shutil.copy(os.path.join(dsDir,OPENDSNAME,'coverage.em'),coveragePath) |
| | | coverageGroupPath=os.path.join(coveragePath,CurrentTestPath['group']) |
| | | if not os.path.exists(coverageGroupPath): |
| | | os.mkdir(coverageGroupPath) |
| | | mylog+=" ::mkdir %s on\n" % (coverageGroupPath) |
| | | mylog+=" ::writing to %s/%s/classes/emma.properties" % (dsDir,OPENDSNAME) |
| | | existingECs=[cf for cf in os.listdir(coverageGroupPath) if cf.startswith('coverage') and cf.endswith('.ec')] |
| | | newCoverageEC=os.path.join(coverageGroupPath,'coverage%s.ec' % len(existingECs)) |
| | | coveragefh = open( '%s/%s/classes/emma.properties' % (dsDir,OPENDSNAME), 'w' ) |
| | | coveragefh.write( 'coverage.out.file=%s\n' % (newCoverageEC) ) |
| | | coveragefh.write( 'verbosity.level=silent\n') |
| | | coveragefh.write( 'coverage.out.merge=true\n') |
| | | coveragefh.close() |
| | | |
| | | </script> |
| | | |
| | | <message>mylog</message> |
| | | <!--- Set up DS --> |
| | | <message> |
| | |
| | | CurrentTestPath['group']='unknown-group' |
| | | |
| | | ThisGroupName=CurrentTestPath['group'] |
| | | |
| | | # NOTE: the same code lives in topology.xml |
| | | # the reason for that is that the topology is created AFTER the |
| | | # first test group has started (as part of the first setup) |
| | | # the following groups are going to use the same topology |
| | | mylog="::coverage - checking for %s/%s/lib/emma.jar\n" % (DIRECTORY_INSTANCE_DIR,OPENDSNAME) |
| | | if os.path.exists('%s/%s/lib/emma.jar' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)): |
| | | mylog+=" ::coverage on\n" |
| | | if not os.path.exists('%s/coverage' % TMPDIR): |
| | | os.mkdir('%s/coverage' % TMPDIR) |
| | | mylog+=" ::mkdir %s/coverage on\n" % TMPDIR |
| | | if not os.path.exists('%s/coverage/%s' % (TMPDIR,CurrentTestPath['group'])): |
| | | os.mkdir('%s/coverage/%s' % (TMPDIR,CurrentTestPath['group'])) |
| | | mylog+=" ::mkdir %s/coverage/%s on\n" % (TMPDIR,CurrentTestPath['group']) |
| | | mylog+=" ::writing to %s/%s/classes/emma.properties" % (DIRECTORY_INSTANCE_DIR,OPENDSNAME) |
| | | coveragefh = open( '%s/%s/classes/emma.properties' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME), 'w' ) |
| | | coveragefh.write( 'coverage.out.file=%s/coverage/%s/coverage.ec\n' % (TMPDIR,CurrentTestPath['group']) ) |
| | | coveragefh.close() |
| | | </script> |
| | | <message> |
| | | mylog |
| | | </message> |
| | | <message>'##### %s group preamble #####' % ThisGroupName</message> |
| | | </sequence> |
| | | </function> |
| | |
| | | <message>'##### %s group postamble #####' % ThisGroupName</message> |
| | | |
| | | <script> |
| | | coveragePath=os.path.join(LOGS_ROOT,'coverage') |
| | | emmaJar='%s/%s/lib/emma.jar' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME) |
| | | coverageEm='%s/%s/coverage.em' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME) |
| | | coverageEc='%s/coverage/%s/coverage.ec' % (TMPDIR,CurrentTestPath['group']) |
| | | coverageXml='%s/coverage/%s/coverage.xml' % (TMPDIR,CurrentTestPath['group']) |
| | | coverageHtml='%s/coverage/%s/coverage.html' % (TMPDIR,CurrentTestPath['group']) |
| | | coverageEm=os.path.join(coveragePath,'coverage.em') |
| | | ecPath=os.path.join(coveragePath,CurrentTestPath['group']) |
| | | coverageEcs=[ os.path.join(ecPath,ec) for ec in os.listdir(ecPath) if ec.startswith('coverage') and ec.endswith('.ec')] |
| | | coverageFiles=','.join(coverageEcs) |
| | | coverageXml=os.path.join(ecPath,'coverage.xml') |
| | | coverageHtml=os.path.join(ecPath,'coverage.html') |
| | | </script> |
| | | |
| | | <if expr="os.path.exists(emmaJar)"> |
| | | <sequence> |
| | | <script> |
| | | srcPathPrefix = os.path.join(TMPDIR,"..","..","..","..","..","..","src") |
| | | srcPaths = [ os.path.join(srcPathPrefix,"server"), |
| | | os.path.join(srcPathPrefix,"ads"), |
| | | os.path.join(srcPathPrefix,"server","org"), |
| | | os.path.join(srcPathPrefix,"admin","defn","org"), |
| | | os.path.join(srcPathPrefix,"snmp","src","org"), |
| | | os.path.join(srcPathPrefix,"ads","org"), |
| | | os.path.join(srcPathPrefix,"dsml","org"), |
| | | os.path.join(srcPathPrefix,"messages","src","org") |
| | | ] |
| | | srcArgs = " -sp ".join(srcPaths) |
| | | </script> |
| | | <call function="'runCommand'"> |
| | | { 'name' : 'Generate coverage xml report for test group %s' % CurrentTestPath['group'], |
| | | 'command' : 'java', |
| | | 'arguments' : ' -Xms64M -Xmx512M -cp %s emma report -r xml,html -in %s,%s -Dreport.xml.out.file=%s -Dreport.html.out.file=%s -sp %s/../../../src' % (emmaJar,coverageEm,coverageEc,coverageXml,coverageHtml,TMPDIR), |
| | | 'path' : TMPDIR |
| | | { 'name' : 'Generate coverage xml report for test group %s' % CurrentTestPath['group'], |
| | | 'command' : 'java', |
| | | 'arguments' : ' -Xms64M -Xmx1G -cp %s emma report -r html -in %s,%s -Dreport.html.out.file=%s -sp %s' % (emmaJar, coverageEm, coverageFiles, coverageHtml, srcArgs), |
| | | 'path' : TMPDIR |
| | | } |
| | | </call> |
| | | <script> |
| | |
| | | <sequence> |
| | | <script> |
| | | coverageFiles='' |
| | | for group in os.listdir('%s/coverage/' % TMPDIR): |
| | | coverageFiles+='%s/coverage/%s/coverage.ec' % (TMPDIR,group) |
| | | coveragePath=os.path.join(LOGS_ROOT,'coverage') |
| | | srcPathPrefix = os.path.join(TMPDIR,"..","..","..","..","..","..","src") |
| | | srcPaths = [ os.path.join(srcPathPrefix,"server"), |
| | | os.path.join(srcPathPrefix,"ads"), |
| | | os.path.join(srcPathPrefix,"server","org"), |
| | | os.path.join(srcPathPrefix,"admin","defn","org"), |
| | | os.path.join(srcPathPrefix,"snmp","src","org"), |
| | | os.path.join(srcPathPrefix,"ads","org"), |
| | | os.path.join(srcPathPrefix,"dsml","org"), |
| | | os.path.join(srcPathPrefix,"messages","src","org") |
| | | ] |
| | | srcArgs = " -sp ".join(srcPaths) |
| | | for group in os.listdir(coveragePath): |
| | | coverageGroupPath=os.path.join(coveragePath,group) |
| | | coverageECs=[os.path.join(coverageGroupPath,ec) for ec in os.listdir(coverageGroupPath) if ec.startswith('coverage') and ec.endswith('.ec')] |
| | | coverageFiles=','.join(coverageECs) |
| | | </script> |
| | | <call function="'runCommand'"> |
| | | { 'name' : 'Generate global coverage xml report', |
| | | 'command' : 'java', |
| | | 'arguments' : ' -Xms64M -Xmx1024M -cp %s emma report -r xml,html -in %s/coverage.em,%s -Dreport.xml.out.file=%s/coverage/coverage.xml -Dreport.html.out.file=%s/coverage/coverage.html -sp %s/../../../src' % (emmaJar,dsPath,coverageFiles,TMPDIR,TMPDIR,TMPDIR), |
| | | 'arguments' : '-Xms64M -Xmx2048m -cp %s emma report -r xml,html -in %s/coverage.em,%s -Dreport.xml.out.file=%s/coverage.xml -Dreport.html.out.file=%s/coverage.html -sp %s' % (emmaJar,coveragePath,coverageFiles,coveragePath,coveragePath,srcArgs), |
| | | 'path' : TMPDIR |
| | | } |
| | | </call> |