From 80631edbe5a925bdc0a453cdbf2a50e3642dfb28 Mon Sep 17 00:00:00 2001
From: smaguin <smaguin@localhost>
Date: Mon, 30 Jun 2008 08:08:03 +0000
Subject: [PATCH] Split clients to have preamble,run,postamble

---
 opends/tests/system-tests/scenario/singleServer/clients/secureSearch/secureSearch.xml |  232 +++++++---------------------------------------------------
 1 files changed, 28 insertions(+), 204 deletions(-)

diff --git a/opends/tests/system-tests/scenario/singleServer/clients/secureSearch/secureSearch.xml b/opends/tests/system-tests/scenario/singleServer/clients/secureSearch/secureSearch.xml
index c839d23..bdac15c 100644
--- a/opends/tests/system-tests/scenario/singleServer/clients/secureSearch/secureSearch.xml
+++ b/opends/tests/system-tests/scenario/singleServer/clients/secureSearch/secureSearch.xml
@@ -28,13 +28,13 @@
 <stax>
 
   <defaultcall function="secureSearch"/>
-
-
-
+  
+  
   <!-- ************************************************************ -->
-  <function name="secureSearch" scope="local">
+  <!-- Client is automatically called by the scheduler and must     -->
+  <!-- always define all the parameters below                       -->
+  <function name="secureSearch">
     <function-map-args>
-      <function-arg-def name="workingDir" type="required"/>
       <function-arg-def name="client"     type="required"/>
       <function-arg-def name="instances"  type="required"/>
       <function-arg-def name="duration"   type="required"/>
@@ -54,111 +54,21 @@
         msg = ''
       </script>
       
-      <!-- ==================    Preamble   =================== -->
+      <!-- ==================    Parser     =================== -->
       <!-- parse the client parameters :                        -->
       <!-- params is [[param1,val1],[param2,val2],...]          -->
       <!-- get the ldap instance parameters                     -->
+      <import machine="'%s' % (client.getHost())"
+              file="'%s/%sLib.xml' % (client.getPath(),client.getName())"/>
+      <call function="'%sParser' % client.getName()">
+      {
+        'client'     : client,
+        'instances'  : instances,
+        'duration'   : duration,
+        'suffix'     : suffix
+      }
+      </call>
       
-      <script>
-        compilDir = '%s/%s_%s' % (workingDir,client.getHost(),client.getId())
-        
-        outFile = '%s/client_secureSearch_id%s.txt' % \
-                  (client.getLogDir(),client.getId())
-        
-        #
-        # Extract client parameters from client.getParams()
-        #
-        cParams = client.getParams()
-        try:
-          serverInstanceFromClient = cParams[0][1]
-        except IndexError:
-          serverInstanceFromClient = NOT_DEFINED
-          msg = '%s\nERROR: serverInstanceFromClient undefined,mandatory' % msg
-        try:
-          baseDn = cParams[1][1]
-        except IndexError:
-          baseDn = NOT_DEFINED
-          msg = '%s\nERROR: baseDn undefined,mandatory' % msg
-        try:
-          nbCnx = cParams[2][1]
-        except IndexError:
-          nbCnx = NOT_DEFINED
-          msg = '%s\nERROR: nbCnx undefined,mandatory' % msg
-        try:
-          nbMaxOp = cParams[3][1]
-        except IndexError:
-          nbMaxOp = NOT_DEFINED
-          msg = '%s\nERROR: nbMaxOperations undefined,mandatory' % msg
-        try:
-          attributeName = cParams[4][1]
-        except IndexError:
-          attributeName = NOT_DEFINED
-        try:
-          protocol = cParams[5][1]
-        except IndexError:
-          protocol = NOT_DEFINED
-        try:
-          authentication = cParams[6][1]
-        except IndexError:
-          authentication = NOT_DEFINED
-        try:
-          certAlias = cParams[7][1]
-        except IndexError:
-          certAlias = NOT_DEFINED
-        try:
-          delaySec = cParams[8][1]
-        except IndexError:
-          delaySec = NOT_DEFINED          
-          
-        #
-        # setup parms to run the client
-        #
-        if serverInstanceFromClient != NOT_DEFINED:
-          sys.path.append("%s/phases/scheduler" % TESTS_DIR )
-          from scheduler import getInstance
-          serverInstance = getInstance(serverInstanceFromClient,instances)
-          if (serverInstance == 'ERROR'):
-            msg = '%s\nERROR: cant find client instance named' % msg
-            msg = '%s %s in server instance list' % \
-                  (msg,serverInstanceFromClient)
-            
-          else:
-            # remove sec, try to finish before timer kill -9 the client
-            duration = duration - 60
-          
-            # keystorePath
-            keystorePath = "%s/CERT_%s_%s/config" % (client.getLogDir(),client.getName(),client.getId())
-            
-            parms=[]
-            if (protocol == 'ssl'):
-              parms.append('-Dhostname=%s -Dport=%s' % \
-                       (serverInstance.getHost(),serverInstance.getLDAPSPort()))
-            else:
-              parms.append('-Dhostname=%s -Dport=%s' % \
-                       (serverInstance.getHost(),serverInstance.getLDAPPort()))
-            
-            parms.append('-Dsuffix="%s"' % baseDn)
-        
-            parms.append('-Dnb_threads=%s -DNB_MAX_srchs=%s -DmaxDuration=%s' % (nbCnx,nbMaxOp,duration))
-
-            parms.append('-Dprotocol="%s"' % protocol)
-            if attributeName != NOT_DEFINED:
-              parms.append('-DattributeName="%s"' % attributeName)
-            parms.append('-Dauthentication="%s"' % authentication)
-            
-
-            parms.append('-DbindDN="%s"' % DIRECTORY_INSTANCE_DN)
-            parms.append('-DbindPW="%s"' % DIRECTORY_INSTANCE_PSWD)
-            
-            if delaySec != NOT_DEFINED:
-              parms.append('-DdelaySec="%s"' % delaySec)             
-            parms = ' '.join(parms)
-      </script>
-     
-        <call function="'writeMessage'">
-          {'content' : 'DEBUG params %s' % parms ,
-           'fileFd'  : fileFd}
-          </call>
       <if expr="msg.find('ERROR') != -1">
         <sequence>
           <message>'%s' % msg</message>
@@ -177,75 +87,6 @@
         </sequence>
       <else>
         <sequence>
-          
-          <!-- ==== Add execute permission to build.ksh file ==== -->
-          <call function="'writeStartTagOperation'">
-          { 'tagName' : 'chmod',
-            'fileFd'  : fileFd }
-          </call>
-          <call function="'writeMessage'">
-          {'content' : 'Add execute permission to build.ksh file',
-           'fileFd'  : fileFd}
-          </call>
-          
-          
-          <process name="'%s: chmod +x build.ksh' % client.getHost()">
-            <location>client.getHost()</location>
-            <command mode="'shell'">'chmod +x build.ksh'</command>
-            <parms/>
-            <workdir>workingDir</workdir>
-            <envs>['PATH=/bin:/usr/bin']</envs>
-            <stderr mode="'stdout'"/>
-            <stdout/>
-            <returnstdout/>
-          </process>
-          <call function="'checkRC'">
-            { 'returncode' : RC,
-              'result'     : STAXResult[0][1],
-              'fileFd'     : fileFd }
-          </call>
-          <script>
-            errNum += STAXResult
-          </script>
-          <call function="'writeEndTagOperation'">{'fileFd'  : fileFd}</call>
-          
-          
-          <!-- ==== Build client : run build.ksh file ==== -->
-          <call function="'writeStartTagOperation'">
-          { 'tagName' : 'build',
-            'fileFd'  : fileFd }
-          </call>
-        
-          
-          <!-- Build Client in unique directory (compilDir), avoid          -->
-          <!-- conflict if same client is run several time at the same time -->
-          <process name="'%s: build %s' % (client.getHost(),client.getName())">
-            <location>client.getHost()</location>
-            <command mode="'shell'">'./build.ksh'</command>
-            <parms/>
-            <workdir>workingDir</workdir>
-            <envs>['PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME,'COMPILDIR=%s' % compilDir ]</envs>
-            <stderr mode="'stdout'"/>
-            <stdout/>
-            <returnstdout/>
-          </process>
-          <call function="'checkRC'">
-            { 'returncode' : RC,
-              'result'     : STAXResult[0][1],
-              'fileFd'     : fileFd }
-          </call>
-          <if expr="RC != 0">
-            <message>
-              'FAILED to build client %s on %s' % \
-              (client.getName(),client.getHost())
-            </message>
-          </if>
-          <script>
-            errNum += STAXResult
-          </script>
-          <call function="'writeEndTagOperation'">{'fileFd'  : fileFd}</call>
-          
-          
           <!-- ========== Run the client ========== -->
           <call function="'writeStartTagOperation'">
           { 'tagName' : 'run',
@@ -253,11 +94,12 @@
           </call>
           <call function="'writeMessage'">
           { 'fileFd'  : fileFd,
-            'content' : 'Do ldapsearchs on %s:%s' % \
-                        (serverInstance.getHost(),serverInstance.getLDAPSPort())
+            'content' : 'Do secure or non secure ldapsearchs on %s:%s' % \
+                        (serverInstance.getHost(),serverInstance.getLDAPPort())
           }
           </call>
-       
+          
+
           <script>
             cParam = '-client -Xmx1G -Xms1G'
             cParam = '%s -XX:NewRatio=1 -XX:SurvivorRatio=100' % cParam
@@ -273,23 +115,24 @@
                         (client.getHost(),client.getName(),
                          serverInstance.getName())
           </script>
-         <call function="'writeMessage'">
+
+          <call function="'writeMessage'">
           { 'fileFd'  : fileFd,
-            'content' : 'DEBUG %s' % cParam
+            'content' : 'cmd : cd %s ; %s/bin/java %s' % \
+                        (client.getPath(),JAVA_HOME,cParam)
           }
           </call>
-          <process name="'%s' % titleName">
+	  <process name="'%s' % titleName">
             <location>client.getHost()</location>
             <command>'%s/bin/java' % JAVA_HOME</command>
             <parms>cParam </parms>
-            <workdir>workingDir</workdir>
+            <workdir>client.getPath()</workdir>
             <envs>['PATH=%s/bin:/bin:/usr/bin' % JAVA_HOME]</envs>
             <stderr mode="'stdout'"/>
             <stdout>outFile</stdout>
             <returnstdout/>
           </process>
-          <!-- java -client -Xmx1G -Xms1G -XX:NewRatio=1 -XX:SurvivorRatio=100 -cp secureSearch.jar -Djavax.net.ssl.keyStore=/tmp/shared/data/CERT_1111/keystore -Djavax.net.ssl.trustStorePassword=password -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=/tmp/shared/data/CERT_1111/keystore  -Djavax.security.sasl.level=FINEST -Dport=1636 -DmaxDuration=$maxDuration -DNB_MAX_srchs=$NB_MAX_srchs -Dsuffix=$suffix -Dnb_threads=$nb_threads -Dhostname=$hostname Client $@
--->
+
           <!-- TBD : result should be STAXResult[0][1] : problem when
                      javaexception, with carac " and < >-->
           <call function="'checkRC'">
@@ -302,27 +145,9 @@
           </script>
           <call function="'writeEndTagOperation'">{'fileFd'  : fileFd}</call>
           
-          <!-- ========== Postamble ========== -->
           <call function="'writeMessage'">
           {'content' : 'Output file %s' % outFile,
-           'fileFd'  : fileFd}
-          </call>
-          
-          <process name="'%s:%s: Grep' % (client.getHost(),client.getName())">
-            <location>client.getHost()</location>
-            <command mode="'shell'">
-              "grep 'TOTAL' %s | cut -d ' ' -f3-" % outFile
-            </command>
-            <envs>['PATH=/bin:/usr/bin']</envs>
-            <stderr mode="'stdout'"/>
-            <stdout/>
-            <returnstdout/>
-          </process>
-          <script>
-            summary = STAXResult[0][1]
-          </script>
-          <call function="'writeMessage'">
-          {'content' : 'Summary %s' % (summary),
+           'xlink'   : outFile,
            'fileFd'  : fileFd}
           </call>
           
@@ -337,6 +162,5 @@
   </function>
   
   
-  
 </stax>
 

--
Gitblit v1.10.0