From 105207b85c7d7182f29e8941d30342dac5c4468f Mon Sep 17 00:00:00 2001
From: madiot <madiot@localhost>
Date: Wed, 27 Jan 2010 09:14:32 +0000
Subject: [PATCH] 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
---
opendj-sdk/opends/tests/staf-tests/shared/functions/dsadm.xml | 32 ++++++++++
opendj-sdk/opends/tests/staf-tests/shared/ant/tests.xml | 2
opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml | 21 ++++--
opendj-sdk/opends/tests/staf-tests/shared/functions/tools.xml | 94 +++++++++++++++++++++++--------
opendj-sdk/opends/tests/staf-tests/shared/functions/topology.xml | 26 --------
opendj-sdk/opends/tests/staf-tests/shared/tests/runTests.xml | 2
6 files changed, 114 insertions(+), 63 deletions(-)
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/ant/tests.xml b/opendj-sdk/opends/tests/staf-tests/shared/ant/tests.xml
index b6acd93..3a82c78 100644
--- a/opendj-sdk/opends/tests/staf-tests/shared/ant/tests.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/ant/tests.xml
@@ -421,8 +421,6 @@
<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">
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/dsadm.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/dsadm.xml
index e0fcf30..900a366 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/dsadm.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/dsadm.xml
@@ -304,7 +304,37 @@
<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,
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/tools.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/tools.xml
index 7ea7014..870a1e5 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/tools.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/tools.xml
@@ -1043,33 +1043,77 @@
<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>
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/topology.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/topology.xml
index c79d82e..2155274 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/topology.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/topology.xml
@@ -782,32 +782,6 @@
</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)
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml
index d19f160..933bd79 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml
@@ -1145,7 +1145,7 @@
<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)
@@ -1969,13 +1969,18 @@
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>
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/tests/runTests.xml b/opendj-sdk/opends/tests/staf-tests/shared/tests/runTests.xml
index eeb5945..46ecd35 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/tests/runTests.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/tests/runTests.xml
@@ -139,7 +139,7 @@
<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>
--
Gitblit v1.10.0