fix related to code coverage with EMMA
- serialize the startDS in the tools function startservers to avoid emma.properties generated file to overwrite each other
- skip the kill on OpenDS processes to avoid potential unexpected behaviour with code coverage
- generating a new Emma coverage.ec statistics file for each start of any given OpenDS instance
| | |
| | | <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> |
| | | <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="${opends.dir}/${opends.name}.zip"> |
| | |
| | | <message> |
| | | '%s %s' % (STAFCmd, STAFCmdParams) |
| | | </message> |
| | | |
| | | <!-- configure the coverage dump file --> |
| | | <script> |
| | | mylog = "Didn't find the emma.jar file : '%s'\n" % os.path.join(dsPath,'lib','emma.jar') |
| | | if os.path.exists(os.path.join(dsPath,'lib','emma.jar')): |
| | | mylog= '' |
| | | 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 |
| | | mylog+=" ::copying %s to %s\n" % (os.path.join(dsPath,'coverage.em'),coveragePath) |
| | | if not os.path.exists(os.path.join(dsPath,'coverage.em')): |
| | | mylog+= " Didn't find %s to copy to %s\n" % (os.path.join(dsPath,'coverage.em'),coveragePath) |
| | | else: |
| | | shutil.copy(os.path.join(dsPath,'coverage.em'),coveragePath) |
| | | coverageGroupPath=os.path.join(coveragePath,CurrentTestPath['group']) |
| | | if not os.path.exists(coverageGroupPath): |
| | | mylog+=" ::mkdir %s on\n" % (coverageGroupPath) |
| | | os.mkdir(coverageGroupPath) |
| | | 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/classes/emma.properties' % (dsPath), 'w' ) |
| | | coveragefh.write( 'coverage.out.file=%s\n' % (newCoverageEC) ) |
| | | coveragefh.write( 'verbosity.level=silent\n') |
| | | coveragefh.write( 'coverage.out.merge=true\n') |
| | | coveragefh.close() |
| | | mylog+=" ::writing %s to %s/%s/classes/emma.properties\n" % (newCoverageEC, dsPath,OPENDSNAME) |
| | | </script> |
| | | <message>'%s' % mylog</message> |
| | | <call function="'runCommand'"> |
| | | { 'location' : location, |
| | | 'command' : STAFCmd, |
| | |
| | | |
| | | <sequence> |
| | | <!-- Start the servers in the list --> |
| | | <paralleliterate var="server" in="serverList"> |
| | | <script> |
| | | # check if using coverage in which case we'll avoid doing parallele iterate |
| | | coverage = False |
| | | if os.path.exists(os.path.join(serverList[0].getDir(),OPENDSNAME,'lib','emma.jar')): |
| | | coverage = True |
| | | print 'tools.xml - coverage=%s' % coverage |
| | | </script> |
| | | <if expr="coverage == True"> |
| | | <sequence> |
| | | <message> |
| | | 'Start DS on host %s to run on port %s' % (server.getHostname(),server.getPort()) |
| | | </message> |
| | | |
| | | <!--- Start DS --> |
| | | <call function="'StartDsWithScript'"> |
| | | { 'location' : server.getHostname(), |
| | | 'dsPath' : '%s/%s' % (server.getDir(),OPENDSNAME) |
| | | } |
| | | </call> |
| | | |
| | | <!--- Check that DS started --> |
| | | <call function="'isAlive'"> |
| | | { 'location' : server.getHostname(), |
| | | 'dsPath' : '%s/%s' % (server.getDir(),OPENDSNAME), |
| | | 'dsInstanceHost' : server.getHostname(), |
| | | 'dsInstancePort' : server.getPort(), |
| | | 'dsInstanceDn' : server.getRootDn(), |
| | | 'dsInstancePswd' : server.getRootPwd(), |
| | | 'noOfLoops' : 10 , |
| | | 'noOfMilliSeconds' : 2000 |
| | | } |
| | | </call> |
| | | <message>'starting servers in sequence using "iterate"'</message> |
| | | <iterate var="server" in="serverList"> |
| | | <sequence> |
| | | <message> |
| | | 'Start DS on host %s to run on port %s' % (server.getHostname(),server.getPort()) |
| | | </message> |
| | | |
| | | <!--- Start DS --> |
| | | <call function="'StartDsWithScript'"> |
| | | { 'location' : server.getHostname(), |
| | | 'dsPath' : '%s/%s' % (server.getDir(),OPENDSNAME) |
| | | } |
| | | </call> |
| | | |
| | | <!--- Check that DS started --> |
| | | <call function="'isAlive'"> |
| | | { 'location' : server.getHostname(), |
| | | 'dsPath' : '%s/%s' % (server.getDir(),OPENDSNAME), |
| | | 'dsInstanceHost' : server.getHostname(), |
| | | 'dsInstancePort' : server.getPort(), |
| | | 'dsInstanceDn' : server.getRootDn(), |
| | | 'dsInstancePswd' : server.getRootPwd(), |
| | | 'noOfLoops' : 10 , |
| | | 'noOfMilliSeconds' : 2000 |
| | | } |
| | | </call> |
| | | </sequence> |
| | | </iterate> |
| | | </sequence> |
| | | </paralleliterate> |
| | | <else> |
| | | <sequence> |
| | | <message>'starting servers in parallel using "paralleliterate"'</message> |
| | | <paralleliterate var="server" in="serverList"> |
| | | <sequence> |
| | | <message> |
| | | 'Start DS on host %s to run on port %s' % (server.getHostname(),server.getPort()) |
| | | </message> |
| | | |
| | | <!--- Start DS --> |
| | | <call function="'StartDsWithScript'"> |
| | | { 'location' : server.getHostname(), |
| | | 'dsPath' : '%s/%s' % (server.getDir(),OPENDSNAME) |
| | | } |
| | | </call> |
| | | |
| | | <!--- Check that DS started --> |
| | | <call function="'isAlive'"> |
| | | { 'location' : server.getHostname(), |
| | | 'dsPath' : '%s/%s' % (server.getDir(),OPENDSNAME), |
| | | 'dsInstanceHost' : server.getHostname(), |
| | | 'dsInstancePort' : server.getPort(), |
| | | 'dsInstanceDn' : server.getRootDn(), |
| | | 'dsInstancePswd' : server.getRootPwd(), |
| | | 'noOfLoops' : 10 , |
| | | 'noOfMilliSeconds' : 2000 |
| | | } |
| | | </call> |
| | | </sequence> |
| | | </paralleliterate> |
| | | </sequence> |
| | | </else> |
| | | </if> |
| | | </sequence> |
| | | </function> |
| | | |
| | |
| | | </else> |
| | | </if> |
| | | |
| | | <!-- configure the coverage dump file --> |
| | | <script> |
| | | 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> |
| | | 'Set up DS on %s : %s/%s' % (dsHost,dsDir,OPENDSNAME) |
| | |
| | | <sequence> |
| | | <script> |
| | | coveragePath=os.path.join(LOGS_ROOT,'coverage') |
| | | coverageEm=os.path.join(coveragePath,'coverage.em') |
| | | coverageEm=os.path.join(DIRECTORY_INSTANCE_DIR,OPENDSNAME,'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) |
| | |
| | | pid = STAXResult[:-1] |
| | | _args = '-9 %s' % pid |
| | | </script> |
| | | <call function="'runCommand'"> |
| | | { 'name' : 'Kill DS server', |
| | | 'location' : location, |
| | | 'command' : _cmd, |
| | | 'arguments' : _args |
| | | } |
| | | </call> |
| | | <if expr="os.path.exists(os.path.join(dsPath,'lib','emma.jar')) == False"> |
| | | <call function="'runCommand'"> |
| | | { 'name' : 'Kill DS server', |
| | | 'location' : location, |
| | | 'command' : _cmd, |
| | | 'arguments' : _args |
| | | } |
| | | </call> |
| | | <else> |
| | | <message>'skip the killing of process when running with coverage to avoid data corruption'</message> |
| | | </else> |
| | | </if> |
| | | <return>STAXResult</return> |
| | | </sequence> |
| | | </function> |
| | |
| | | <call function="'runCommand'"> |
| | | { 'name' : 'Generate global coverage xml report', |
| | | 'command' : 'java', |
| | | '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), |
| | | 'arguments' : '-Xms64M -Xmx2048m -cp %s emma report -r xml,html -in %s/%s/coverage.em,%s -Dreport.xml.out.file=%s/coverage.xml -Dreport.html.out.file=%s/coverage.html -sp %s' % (emmaJar,DIRECTORY_INSTANCE_DIR,OPENDSNAME,coverageFiles,coveragePath,coveragePath,srcArgs), |
| | | 'path' : TMPDIR |
| | | } |
| | | </call> |