From 5942df14cc3ada177a9e5aa7bada64ddb4f2c3ae Mon Sep 17 00:00:00 2001
From: andrug <andrug@localhost>
Date: Fri, 28 Mar 2008 09:38:22 +0000
Subject: [PATCH] suffix can now import ldif file
---
opends/tests/system-tests/phases/generateLdif/generateLdif.xml | 84 +++++++++++++++++++++++++++++-------------
opends/tests/system-tests/phases/parser/parser.py | 17 ++++++--
opends/tests/system-tests/scenario/conf.dtd | 3 +
opends/tests/system-tests/phases/log/topology.xml | 13 ++++--
4 files changed, 81 insertions(+), 36 deletions(-)
diff --git a/opends/tests/system-tests/phases/generateLdif/generateLdif.xml b/opends/tests/system-tests/phases/generateLdif/generateLdif.xml
index a3d06ac..d68f570 100755
--- a/opends/tests/system-tests/phases/generateLdif/generateLdif.xml
+++ b/opends/tests/system-tests/phases/generateLdif/generateLdif.xml
@@ -85,15 +85,6 @@
<else>
<sequence>
- <!--=========== Generate template ==========-->
- <script>
- sys.path.append("%s/phases/parser" % TESTS_DIR )
- from parser import *
- localTemplateFile = '%s/template.ldif' % (LOG_DIR)
- </script>
- <call function="'generateTemplate'">
- { 'templateFile' : localTemplateFile }
- </call>
<!--=========== For the first host, copy and run makeldif ======-->
<script>
@@ -108,22 +99,63 @@
ldifFile = '%s/data.ldif' % \
topoElements[0].getInstanceRef().getInstallDir()
</script>
- <call function="'copyFile'">
- { 'location' : topoElements[0].getInstanceRef().getHost(),
- 'srcFile' : localTemplateFile,
- 'destFile' : templateFile,
- 'remoteHost' : topoElements[0].getInstanceRef().getHost(),
- 'fileFd' : LOG_MAIN_FD
- }
- </call>
- <call function="'makeLdif'">
- { 'location' : topoElements[0].getInstanceRef().getHost(),
- 'dsPath' : topoElements[0].getInstanceRef().getInstallDir(),
- 'templateFile' : templateFile,
- 'ldifFile' : ldifFile,
- 'fileFd' : LOG_MAIN_FD
- }
- </call>
+
+
+ <!--=== If suffix has already a generated ldif file, copy it ====-->
+ <if expr="suffix.getLdifFile() != NOT_DEFINED">
+ <sequence>
+ <call function="'copyFile'">
+ { 'location' : STAXServiceMachine,
+ 'srcFile' : suffix.getLdifFile(),
+ 'destFile' : ldifFile,
+ 'remoteHost' : topoElements[0].getInstanceRef().getHost(),
+ 'fileFd' : LOG_MAIN_FD
+ }
+ </call>
+ <message>
+ '%s : copy ldif file done' % topoElements[0].getInstanceRef().getHost()
+ </message>
+ </sequence>
+
+
+ <!--=== No ldif file provided, Generate it ===-->
+ <else>
+ <sequence>
+ <!--== Generate and copy the template ==-->
+ <script>
+ sys.path.append("%s/phases/parser" % TESTS_DIR )
+ from parser import *
+ localTemplateFile = '%s/template.ldif' % (LOG_DIR)
+ </script>
+ <call function="'generateTemplate'">
+ { 'templateFile' : localTemplateFile }
+ </call>
+ <call function="'copyFile'">
+ { 'location' : STAXServiceMachine,
+ 'srcFile' : localTemplateFile,
+ 'destFile' : templateFile,
+ 'remoteHost' : topoElements[0].getInstanceRef().getHost(),
+ 'fileFd' : LOG_MAIN_FD
+ }
+ </call>
+ <!--== Run make ldif ==-->
+ <call function="'makeLdif'">
+ { 'location' : topoElements[0].getInstanceRef().getHost(),
+ 'dsPath' : topoElements[0].getInstanceRef().getInstallDir(),
+ 'templateFile' : templateFile,
+ 'ldifFile' : ldifFile,
+ 'fileFd' : LOG_MAIN_FD
+ }
+ </call>
+ <message>
+ '%s : makeLDIF done' % topoElements[0].getInstanceRef().getHost()
+ </message>
+ </sequence>
+ </else>
+ </if>
+
+
+ <!--================== Import ldif file =======================-->
<call function="'ImportLdifWithScript'">
{
'location' : topoElements[0].getInstanceRef().getHost(),
@@ -134,7 +166,7 @@
}
</call>
<message>
- '%s : makeLDIF done' % topoElements[0].getInstanceRef().getHost()
+ '%s : importLDIF done' % topoElements[0].getInstanceRef().getHost()
</message>
<script>LOG_MAIN_FD.write('</instance>\n')</script>
diff --git a/opends/tests/system-tests/phases/log/topology.xml b/opends/tests/system-tests/phases/log/topology.xml
index e2f4238..9b13dbd 100644
--- a/opends/tests/system-tests/phases/log/topology.xml
+++ b/opends/tests/system-tests/phases/log/topology.xml
@@ -263,9 +263,14 @@
topoMsg = '%s\n</topology>\n' % topoMsg
# SUFFIX DATA
- suffixDataForXml = NOT_DEFINED
- root = suffix.getTree()
- suffixDataForXml = getSuffixDataForXML(suffix.getSuffixDn(),root)
+ # Get ldif file if specified in conf.xml
+ suffixDataForXml = suffix.getLdifFile()
+ nbOfEntries = 'unknown'
+ # if ldif file is not specified in conf.xml, get the tree data
+ if suffixDataForXml == NOT_DEFINED:
+ root = suffix.getTree()
+ suffixDataForXml = getSuffixDataForXML(suffix.getSuffixDn(),root)
+ nbOfEntries = suffix.getNbOfEntries()
</script>
<call function="'writeStartTag'">
{
@@ -281,7 +286,7 @@
'content' : '\n %s \
<numberOfEntries>%s</numberOfEntries>\n \
%s \n \
-' % (topoMsg,suffix.getNbOfEntries(),suffixDataForXml)
+' % (topoMsg,nbOfEntries,suffixDataForXml)
}
</call>
<call function="'writeEndTag'">
diff --git a/opends/tests/system-tests/phases/parser/parser.py b/opends/tests/system-tests/phases/parser/parser.py
index 9d1f546..7580e99 100755
--- a/opends/tests/system-tests/phases/parser/parser.py
+++ b/opends/tests/system-tests/phases/parser/parser.py
@@ -148,12 +148,13 @@
"""Describes suffix information,
tree is a list of Branch objectclasses
topology is a list of SuffixTopology objectclasses"""
- def __init__(self, sid, dn, topology, nbOfEntries, tree):
+ def __init__(self, sid, dn, topology, nbOfEntries, tree, ldifFile):
self.sid = sid
self.dn = dn
self.topology = topology
self.nbOfEntries = nbOfEntries
self.tree = tree
+ self.ldifFile = ldifFile
def getId(self):
return self.sid
@@ -181,7 +182,9 @@
def getTree(self):
return self.tree
-
+
+ def getLdifFile(self):
+ return self.ldifFile
#
# Class for instance
@@ -642,6 +645,8 @@
msg = ''
cSuffixReplServers = NOT_DEFINED
cNbOfEntries = NOT_DEFINED
+ cBranches = NOT_DEFINED
+ cLdifFile = NOT_DEFINED
#
# Parsing second level : instanceList,numberOfEntries,...
@@ -695,8 +700,9 @@
(msg,thisSubChild.getNodeName())
elif (thisSubChild.getNodeType() == Node.ELEMENT_NODE and
- thisSubChild.getNodeName() == 'numberOfEntries'):
- cNbOfEntries = _getPropValue(thisSubChild)
+ thisSubChild.getNodeName() == 'ldifFile'):
+ cLdifFile = _getPropValue(thisSubChild)
+ cLdifFile = cLdifFile.strip()
# parsing suffix TREE
elif (thisSubChild.getNodeType() == Node.ELEMENT_NODE and
@@ -728,7 +734,8 @@
else:
msg = '%s\n ERROR: parseSuffix() : no children for suffix node' % msg
- return [msg,Suffix(cId,cSuffixName,cSuffixReplServers,cNbOfEntries,cBranches)]
+ return [msg,Suffix(cId,cSuffixName,cSuffixReplServers,\
+ cNbOfEntries,cBranches,cLdifFile)]
diff --git a/opends/tests/system-tests/scenario/conf.dtd b/opends/tests/system-tests/scenario/conf.dtd
index 2d63ccf..e002e11 100755
--- a/opends/tests/system-tests/scenario/conf.dtd
+++ b/opends/tests/system-tests/scenario/conf.dtd
@@ -56,7 +56,7 @@
<!-- ========== SUFFIX NODE ========================= -->
-<!ELEMENT suffix (topology,tree)>
+<!ELEMENT suffix (topology,ldifFile?,tree?)>
<!ATTLIST suffix
dn CDATA #REQUIRED>
@@ -67,6 +67,7 @@
initRule ( importLdif | totalUpdate ) "importLdif"
instanceSourceName NMTOKEN #IMPLIED>
+ <!ELEMENT ldifFile (#PCDATA)>
<!ELEMENT tree (branch+,subordinateTemplate*)>
<!ATTLIST tree nbOfEntries CDATA #REQUIRED>
--
Gitblit v1.10.0