mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

andrug
28.38.2008 5942df14cc3ada177a9e5aa7bada64ddb4f2c3ae
suffix can now import ldif file
4 files modified
117 ■■■■■ changed files
opends/tests/system-tests/phases/generateLdif/generateLdif.xml 84 ●●●●● patch | view | raw | blame | history
opends/tests/system-tests/phases/log/topology.xml 13 ●●●●● patch | view | raw | blame | history
opends/tests/system-tests/phases/parser/parser.py 17 ●●●● patch | view | raw | blame | history
opends/tests/system-tests/scenario/conf.dtd 3 ●●●● patch | view | raw | blame | history
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('&lt;/instance&gt;\n')</script>
          
opends/tests/system-tests/phases/log/topology.xml
@@ -263,9 +263,14 @@
        topoMsg = '%s\n&lt;/topology&gt;\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 \
&lt;numberOfEntries&gt;%s&lt;/numberOfEntries&gt;\n \
%s \n \
' % (topoMsg,suffix.getNbOfEntries(),suffixDataForXml)
' % (topoMsg,nbOfEntries,suffixDataForXml)
      }
      </call>
      <call function="'writeEndTag'">
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)]
  
  
  
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>