From bbc9d70ed184ba880afc3c03a1bba10bf4e5dc6d Mon Sep 17 00:00:00 2001
From: andrug <andrug@localhost>
Date: Fri, 28 Mar 2008 11:47:03 +0000
Subject: [PATCH] add new local client for example

---
 opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/run.sh               |   28 +
 opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Server.java      |   46 +++
 opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/build.sh             |   36 ++
 opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Client.java      |  355 +++++++++++++++++++++++
 opends/tests/system-tests/scenario/conf.dtd                                              |    2 
 opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/sampleSearchLoad.xml |  286 +++++++++++++++++++
 opends/tests/system-tests/scenario/sample2/conf.xml                                      |    2 
 opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Worker.java      |  127 ++++++++
 8 files changed, 880 insertions(+), 2 deletions(-)

diff --git a/opends/tests/system-tests/scenario/conf.dtd b/opends/tests/system-tests/scenario/conf.dtd
index e002e11..caf820b 100755
--- a/opends/tests/system-tests/scenario/conf.dtd
+++ b/opends/tests/system-tests/scenario/conf.dtd
@@ -98,7 +98,7 @@
     <!ELEMENT client ANY>
     <!ATTLIST client
       id NMTOKEN #IMPLIED
-      name ( searchLoad | modifyLoad | restartDs) "searchLoad"
+      name ( searchLoad | modifyLoad | restartDs | sampleSearchLoad) "searchLoad"
       host NMTOKEN #IMPLIED
       start NMTOKEN #IMPLIED
       stop NMTOKEN #IMPLIED
diff --git a/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/build.sh b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/build.sh
new file mode 100755
index 0000000..bc9e44d
--- /dev/null
+++ b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/build.sh
@@ -0,0 +1,36 @@
+#!/bin/ksh
+
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE
+# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+# add the following below this CDDL HEADER, with the fields enclosed
+# information:
+#      Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#      Copyright 2008 Sun Microsystems, Inc.
+
+export CLASSPATH=$CLASSPATH:../../../../clients/LDAPjdk/ldapjdk.jar
+echo "Compiling classes..."
+javac src/*.java -d .
+[ $? -ne 0 ] && return 1
+echo "Creating jarfile"
+jar cvf search.jar *.class
+[ $? -ne 0 ] && return 1
+echo "Cleanup"
+rm -f *.class
diff --git a/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/run.sh b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/run.sh
new file mode 100755
index 0000000..1b22fab
--- /dev/null
+++ b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/run.sh
@@ -0,0 +1,28 @@
+#!/bin/ksh
+
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE
+# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+# add the following below this CDDL HEADER, with the fields enclosed
+# information:
+#      Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#      Copyright 2008 Sun Microsystems, Inc.
+
+java -client -Xmx1G -Xms1G -XX:NewRatio=1 -XX:SurvivorRatio=100 -cp ../LDAPjdk/ldapjdk.jar:search.jar Client $@
diff --git a/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/sampleSearchLoad.xml b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/sampleSearchLoad.xml
new file mode 100755
index 0000000..911af7d
--- /dev/null
+++ b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/sampleSearchLoad.xml
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE stax SYSTEM "../../../../../shared/stax.dtd">
+<!--
+ ! CDDL HEADER START
+ !
+ ! The contents of this file are subject to the terms of the
+ ! Common Development and Distribution License, Version 1.0 only
+ ! (the "License").  You may not use this file except in compliance
+ ! with the License.
+ !
+ ! You can obtain a copy of the license at
+ ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ ! See the License for the specific language governing permissions
+ ! and limitations under the License.
+ !
+ ! When distributing Covered Code, include this CDDL HEADER in each
+ ! file and include the License file at
+ ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+ ! add the following below this CDDL HEADER, with the fields enclosed
+ ! by brackets "[]" replaced with your own identifying information:
+ !      Portions Copyright [yyyy] [name of copyright owner]
+ !
+ ! CDDL HEADER END
+ !
+ !      Copyright 2008 Sun Microsystems, Inc.
+ ! -->
+<stax>
+
+  <defaultcall function="sampleSearchLoad"/>
+
+
+
+  <!-- ************************************************************ -->
+  <function name="sampleSearchLoad" scope="local">
+    <function-map-args>
+      <function-arg-def name="workingDir" type="required">
+      </function-arg-def>
+      <function-arg-def name="client" type="required">
+      </function-arg-def>
+      <function-arg-def name="instances" type="required">
+      </function-arg-def>
+      <function-arg-def name="duration" type="required">
+      </function-arg-def>
+      <function-arg-def name="fileFd" type="required">
+      </function-arg-def>
+    </function-map-args>
+    
+    <sequence>
+      <!-- ===================   Comments   =================== -->
+      <!-- client is run under paralleliterate tag              -->
+      <!-- each variables defined are internal                  -->
+      <!-- client should have its own err_num variable in order -->
+      <!-- to inform scheduler if it has pass/fail status       -->
+      <script>
+        errNum = 0
+      </script>
+      
+      <!-- ==================    Preamble   =================== -->
+      <!-- parse the client parameters :                        -->
+      <!-- params is [[param1,val1],[param2,val2],...]          -->
+      <!-- get the ldap instance parameters                     -->
+      
+      <script>
+        outFile = '%s/client_sampleSearchLoad_%s.txt' % (LOG_DIR,client.getId())
+        cParams = client.getParams()
+        serverInstanceFromClient = cParams[0][1]
+        baseDn = cParams[1][1]
+        nbCnx = cParams[2][1]
+        nbMaxSearch = cParams[3][1]
+        attributeName = cParams[4][1]
+        
+        sys.path.append("%s/phases/scheduler" % TESTS_DIR )
+        from scheduler import getInstance
+        serverInstance = getInstance(serverInstanceFromClient,instances)
+        if (serverInstance == 'ERROR'):
+          msg = 'ERROR: cant find client instance named'
+          msg = '%s %s in server instance list' %(msg,serverInstanceFromClient)
+          
+        else:
+          # remove sec, try to finish before timer kill -9 the client
+          duration = duration - 10
+          
+          parms=[]
+          parms.append('-h %s -p %s' % \
+                      (serverInstance.getHost(),serverInstance.getLDAPPort()))
+          parms.append('-b "%s"' % baseDn)
+          parms.append('-D "%s" -w "%s"' % \
+                      (DIRECTORY_INSTANCE_DN,DIRECTORY_INSTANCE_PSWD))
+          parms.append('-t %s -M %s -a %s -d %s' % \
+                      (nbCnx,nbMaxSearch,attributeName,duration))
+          parms = ' '.join(parms)
+      </script>
+      
+      <if expr="msg.find('ERROR') != -1">
+        <sequence>
+          <message>'%s' % msg</message>
+          <call function="'writeOperationResult'">
+            {
+              'returncode' : '1',
+              'expected'   : '0',
+              'result'     : msg,
+              'status'     : 'ERROR',
+              'fileFd'     : fileFd
+            }
+          </call>
+          <script>
+            errNum += 1
+          </script>
+        </sequence>
+      <else>
+        <sequence>
+          
+          <!-- ==== Add execute permission to build.sh file ==== -->
+          <call function="'writeStartTagOperation'">
+          { 'tagName' : 'chmod',
+            'fileFd'  : fileFd }
+          </call>
+          <call function="'writeMessage'">
+          {'content' : 'Add execute permission to build.sh file',
+           'fileFd'  : fileFd}
+          </call>
+          
+          
+          <process name="'%s: chmod +x build.sh' % client.getHost()">
+            <location>client.getHost()</location>
+            <command mode="'shell'">'chmod +x build.sh'</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.sh file ==== -->
+          <call function="'writeStartTagOperation'">
+          { 'tagName' : 'build',
+            'fileFd'  : fileFd }
+          </call>
+          <call function="'writeMessage'">
+          {'content' : 'Build client',
+           'fileFd'  : fileFd}
+          </call>
+          
+          
+          <process name="'%s: build %s' % (client.getHost(),client.getName())">
+            <location>client.getHost()</location>
+            <command mode="'shell'">'./build.sh'</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>
+          <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',
+            'fileFd'  : fileFd }
+          </call>
+          <call function="'writeMessage'">
+          { 'fileFd'  : fileFd,
+            'content' : 'Do ldapsearchs on %s:%s' % \
+                        (serverInstance.getHost(),serverInstance.getLDAPPort())
+          }
+          </call>
+          
+          <script>
+            cParam = '-client -Xmx1G -Xms1G'
+            cParam = '%s -XX:NewRatio=1 -XX:SurvivorRatio=100' % cParam
+            cParam = '%s -cp %s/clients/LDAPjdk/ldapjdk.jar' % \
+                     (cParam,LOCAL_TESTS_DIR)
+            cParam = '%s:%s/search.jar' % (cParam,workingDir)
+            cParam = '%s Client %s' % (cParam,parms)
+            
+            titleName = '%s: run %s on %s' % \
+                        (client.getHost(),client.getName(),
+                         serverInstance.getName())
+          </script>
+          <process name="'%s' % titleName">
+            <location>client.getHost()</location>
+            <command>'java'</command>
+            <parms>cParam </parms>
+            <workdir>workingDir</workdir>
+            <envs>['PATH=/bin:/usr/bin']</envs>
+            <stderr mode="'stdout'"/>
+            <stdout>outFile</stdout>
+            <returnstdout/>
+          </process>
+          <!-- TBD : result should be STAXResult[0][1] : problem when
+                     javaexception, with carac " and < >-->
+          <call function="'checkRC'">
+            { 'returncode' : RC ,
+              'result'     : '',
+              'fileFd'     : fileFd }
+          </call>
+          <script>
+            errNum += STAXResult
+          </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),
+           'fileFd'  : fileFd}
+          </call>
+          
+          <!-- ==== Copy output file in main log directory ==== -->
+          <script>
+            clientHostFullName = '%s%s' % (client.getHost(),DOMAIN[0])
+          </script>
+          <if expr="clientHostFullName != STAXServiceMachine">
+            <sequence>
+              <call function="'copyFile'">
+                {
+                  'location'   : client.getHost(),
+                  'remoteHost' : STAXServiceMachine,
+                  'srcFile'    : outFile,
+                  'destFile'   : outFile,
+                  'fileFd'     : fileFd
+                }
+              </call>
+              <script>
+                errNum += STAXResult[0]
+              </script>
+            </sequence>
+          </if>
+        </sequence>
+      </else>
+      </if>
+      
+      <return> errNum </return>
+      
+    </sequence>
+    
+  </function>
+  
+  
+  
+</stax>
+
diff --git a/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Client.java b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Client.java
new file mode 100755
index 0000000..96804a6
--- /dev/null
+++ b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Client.java
@@ -0,0 +1,355 @@
+// CDDL HEADER START
+//
+// The contents of this file are subject to the terms of the
+// Common Development and Distribution License, Version 1.0 only
+// (the "License").  You may not use this file except in compliance
+// with the License.
+//
+// You can obtain a copy of the license at
+// trunk/opends/resource/legal-notices/OpenDS.LICENSE
+// or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+// See the License for the specific language governing permissions
+// and limitations under the License.
+//
+// When distributing Covered Code, include this CDDL HEADER in each
+// file and include the License file at
+// trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+// add the following below this CDDL HEADER, with the fields enclosed
+// information:
+//      Portions Copyright [yyyy] [name of copyright owner]
+//
+// CDDL HEADER END
+//
+//
+//      Copyright 2008 Sun Microsystems, Inc.
+import netscape.ldap.*;
+import netscape.ldap.util.*;
+
+import java.util.*;
+import java.io.*;
+import java.lang.Thread;
+
+
+
+public class Client {
+    
+    
+//    static String dn="cn=Directory Manager";
+//    static String password="secret12";
+    static int NB_MAX_srchs=100;
+    static Object lock;
+    static int nb_srchs_started=0;
+    static int nb_srchs_done=0;
+    static int total_nb_srchs=0;
+    static int nb_threads=3;
+    public ArrayList<String> ValueList;
+    // String dn="cn=admin,dc=com";
+//    String dn="cn=Directory Manager";
+//    String password="secret12";
+    Random random;   
+    static String attr="cn";
+    public String attribute;
+    
+    static String hostname ;
+    static int portnumber;
+    static String bindDN;
+    static String bindPW;
+    static String suffix;
+    static Server server;
+    static String time= new String ("0 sec.");;
+    static long duration=0;
+    static long maxDuration=0;
+    static long startup=System.currentTimeMillis();
+    
+    public Client()
+    {
+            
+        attribute=attr;
+        random=new Random();
+        lock = new Object();
+        
+        ValueList=new ArrayList<String>();
+        // println("INFO", "Getting DN from file " + DNFileName);
+        try {
+            println ("INFO", "Get the DNs on suffix \"" + suffix + "\" from server " + server );
+            LDAPConnection  c = new LDAPConnection();
+            // no bind
+            c.connect( server.host, server.port);
+            println ("INFO", "Connected to server " + server );
+            
+            // bind if needed
+            if ( bindDN != null ) {
+                println ("INFO", "Binding as \"" + bindDN + "\"");
+                c.bind(bindDN, bindPW);
+            }
+            else {
+                println ("INFO", "Anonymous mode (no bind)");
+            }
+            
+            
+            // no limit for nb of entries returned by a search
+            Integer sizeLimit = new Integer( 0 );
+            c.setOption( LDAPv3.SIZELIMIT, sizeLimit );
+            LDAPSearchResults results = c.search( suffix, LDAPv3.SCOPE_SUB, "(objectclass=*)" , new String[] {attr} , false );
+            while ( results.hasMoreElements() ) {
+                Object o=null;
+                try {
+                    o=results.nextElement();
+                    LDAPEntry entry=(LDAPEntry) o;
+                    //  hack for oracle
+                    if ( entry == null ) {
+                        break;
+                    }
+                    // println("DEBUG", "DN="+entry.getDN());
+                    LDAPAttribute a = entry.getAttribute(attr);
+                    if ( a == null ) {
+                        continue;
+                    }
+                    for ( String value: a.getStringValueArray()) {
+                        ValueList.add( value );
+                    }
+                }
+                catch (java.lang.ClassCastException e) {
+                    e.printStackTrace();
+                    println ("ERROR", o.toString() );
+                }
+            }
+            ValueList.trimToSize();
+            if ( ValueList.size() == 0) {
+                println ("ERROR", "No values found for attribute  " + attr + " in suffix \"" + suffix + "\"");
+                System.exit(1);
+            }
+            println("INFO", "Found " + ValueList.size() + " values for attribute " + attr + " in \"" + suffix + "\" on " + server.toString() );
+            c.disconnect();
+        } catch (LDAPException e) {
+            int errorCode = e.getLDAPResultCode(); 
+            if ( errorCode == 32) {
+                println ("ERROR", "Base dn \"" + suffix + "\" not found");
+            }
+            else {
+                e.printStackTrace();
+            }
+            System.exit(1);
+        }
+        /* try {
+            File DNFile= new File(DNFileName);
+            LineNumberReader in=new LineNumberReader (new FileReader(DNFile) );
+            while ( in.ready() ) {
+                ValueList.add(in.readLine());
+            }
+        } catch (IOException e) {
+            println ("ERROR", e.toString());
+            System.exit(1);
+        }*/
+        // ValueList.trimToSize();
+        //println("INFO", "Found " + ValueList.size() + " DNs");
+        
+        
+        try {
+            // reinitialize startup
+            startup=System.currentTimeMillis();
+            long t1=System.currentTimeMillis();
+            
+            if ( maxDuration != 0 ) {
+                maxDuration= t1 + maxDuration * 1000;
+            }
+            
+            for (int i=0; i < nb_threads; i++ ) {
+                Worker w=new Worker(this, server);
+            }
+            println ("INFO", nb_threads + " threads connected to server " + server );
+            println ("INFO", "Will search using filter \"(" + attr + " = <value> )\" (MAX =" + NB_MAX_srchs + ")" );
+            synchronized (lock) {    
+                lock.notifyAll();
+            }
+            int seconds=0;
+            while (true) {
+                    
+                long new_t1=System.currentTimeMillis();
+                
+                if ( ( maxDuration != 0 ) && ( new_t1 > maxDuration ) ) { break; }
+                
+                if ( (new_t1 - t1) >= 1000 ) {
+                    
+                    
+                    println("INFO",  nb_srchs_done + " srchs/sec."); // (time = "+(new_t1-t1) + "ms)");
+                    // println("DEBUG",  nb_srchs_started + " srchs/sec started"); 
+                    
+                    total_nb_srchs+=nb_srchs_done;
+                    nb_srchs_started=0;
+                    nb_srchs_done=0;
+                    synchronized (lock) {    
+                        lock.notifyAll();
+                    } 
+                    
+                    if ( (seconds++) >= 9 ) {
+                        
+                        duration=((new_t1-startup)/1000);
+                        
+                        println("INFO",  "Avg rate: " + (total_nb_srchs/duration) + " srchs/sec. after " + getTime(duration));
+                        seconds=0;
+                    }
+                    t1=new_t1;
+                    
+                }
+            }
+            
+            System.exit(0);
+            
+        }
+        catch( Exception e ) {
+
+            e.printStackTrace();
+            System.exit(1);
+        }
+        
+        
+    }
+    
+    public static String getTime(long d) {
+        String time=new String (d + " sec.");
+        if ( d > 10000 ) {
+            time=new String ((d/3600) + " hours");
+        } else if ( d > 300 ) {
+            time=new String ((d/60) + " min.");
+        }
+        return time;
+    }
+    
+    public static void main( String[] args )
+
+    {
+        String usage = "Usage: java Main [-h <host>] [-p <port>]  -b <base_dn> "
+                        + "[-D <bindDN> ] [-w <bindPW> ] [-t <nb_threads>] [-M <nb_max_srchs>] [-a <attribute>] [-d duration (seconds)]";
+        int portnumber = LDAPv2.DEFAULT_PORT;
+        // Check for these options. -H means to print out a usage message.
+        GetOpt options = new GetOpt( "h:p:b:d:D:w:H:t:M:a:", args );
+        // Get the arguments specified for each option.
+        hostname = options.getOptionParam( 'h' );
+        String port = options.getOptionParam( 'p' );
+        bindDN = options.getOptionParam( 'D' );
+        bindPW = options.getOptionParam( 'w' );
+        suffix = options.getOptionParam( 'b' );
+
+        if ( options.hasOption( 't' ) ) {
+            nb_threads=Integer.parseInt(options.getOptionParam( 't' ));
+        }
+        
+        if ( options.hasOption( 'M' ) ) {
+            NB_MAX_srchs=Integer.parseInt(options.getOptionParam( 'M' ));
+        }
+        
+        if ( options.hasOption( 'a' ) ) {
+            attr=options.getOptionParam( 'a' );
+        }
+        
+        if ( options.hasOption( 'd' ) ) {
+            String sMaxDuration=options.getOptionParam( 'd' );
+            maxDuration = Long.parseLong(sMaxDuration);
+        }
+
+        //  option -DM to use default QA settings for Directory manager
+        if ( bindDN != null && bindDN.equals("M") ) {
+            bindDN="cn=Directory Manager";
+            bindPW="secret12";
+        }
+
+        // Check to see if the hostname (which is mandatory)
+        // is not specified or if the user simply wants to
+        // see the usage message (-H).
+        if ( options.hasOption( 'H' ) || ( suffix == null ) ) {
+            System.out.println( usage );
+            System.exit( 1 );
+        }
+
+
+        if ( hostname == null ) hostname="localhost";
+        // If a port number was specified, convert the port value
+        //  to an integer.
+        if ( port != null ) {
+            try {
+                portnumber = java.lang.Integer.parseInt( port );
+            } catch ( java.lang.Exception e ) {
+                System.out.println( "Invalid port number: " + port );
+                System.out.println( usage );
+                System.exit( 1 );
+            }
+        }
+        else {
+            portnumber=1389;
+        }
+        server=new Server(hostname,portnumber);
+        
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            public void run() {
+                duration=((System.currentTimeMillis()-startup)/1000);
+                if ( duration != 0 ) 
+                    println("INFO", "TOTAL: " + total_nb_srchs + " srchs (Avg rate: " + (total_nb_srchs/duration) + " srchs/sec.) after " + getTime(duration));
+            }
+        });
+        
+        
+        Client c = new Client();
+    }
+
+
+   public static void inc_srchs_started() {
+        check_srchs_started();
+        nb_srchs_started++;
+   }
+
+   
+   public static void inc_srchs_done() {
+        nb_srchs_done++;
+   }
+   
+   public static void check_srchs_started() {
+        if ( nb_srchs_started>=NB_MAX_srchs ) {
+            // println("DEBUG", "srchs=" + nb_srchs_started );
+            try {
+                synchronized (lock) {
+                    lock.wait();
+                }
+            } catch ( InterruptedException e ) {
+                e.printStackTrace();
+            }  
+        }
+    }
+    
+    public static void wait_after_error() {
+        try {
+            synchronized (lock) {
+                lock.wait();
+            }
+        } catch ( InterruptedException e ) {
+            e.printStackTrace();
+        }  
+   }
+    
+   public static void sleep(int time) {
+        try {  
+            Thread.sleep(time);
+        }
+        catch ( InterruptedException e )
+        {
+             println( "ERROR" ,  e.toString() );
+        }
+    }
+    
+   
+    public static String getDate() {
+    
+        // Initialize the today's date string
+        String DATE_FORMAT = "yyyy/MM/dd:HH:mm:ss";
+        java.text.SimpleDateFormat sdf = 
+            new java.text.SimpleDateFormat(DATE_FORMAT);
+        Calendar c1 = Calendar.getInstance(); // today
+        return("[" + sdf.format(c1.getTime()) + "]");
+   }
+   
+   public static void println(String level, String msg) {
+        System.out.println (getDate() + " - " + level + ": " + msg );
+   }
+
+}
+
diff --git a/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Server.java b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Server.java
new file mode 100755
index 0000000..dbf2405
--- /dev/null
+++ b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Server.java
@@ -0,0 +1,46 @@
+// CDDL HEADER START
+//
+// The contents of this file are subject to the terms of the
+// Common Development and Distribution License, Version 1.0 only
+// (the "License").  You may not use this file except in compliance
+// with the License.
+//
+// You can obtain a copy of the license at
+// trunk/opends/resource/legal-notices/OpenDS.LICENSE
+// or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+// See the License for the specific language governing permissions
+// and limitations under the License.
+//
+// When distributing Covered Code, include this CDDL HEADER in each
+// file and include the License file at
+// trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+// add the following below this CDDL HEADER, with the fields enclosed
+// information:
+//      Portions Copyright [yyyy] [name of copyright owner]
+//
+// CDDL HEADER END
+//
+//
+//      Copyright 2008 Sun Microsystems, Inc.
+import java.util.*;
+
+
+public class Server {
+    public String host;
+    public int port;
+    
+    public Server (String host, int port) {
+        this.host=host;
+        this.port=port;
+    }
+    
+    public Server (String hostPort) {
+        StringTokenizer st = new StringTokenizer(hostPort, ":");
+        this.host=st.nextToken();
+        this.port=Integer.parseInt(st.nextToken());
+    }
+    
+    public String toString() {
+        return (host + ":" + port);
+    }
+}
diff --git a/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Worker.java b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Worker.java
new file mode 100755
index 0000000..dced41a
--- /dev/null
+++ b/opends/tests/system-tests/scenario/sample2/clients/sampleSearchLoad/src/Worker.java
@@ -0,0 +1,127 @@
+// CDDL HEADER START
+//
+// The contents of this file are subject to the terms of the
+// Common Development and Distribution License, Version 1.0 only
+// (the "License").  You may not use this file except in compliance
+// with the License.
+//
+// You can obtain a copy of the license at
+// trunk/opends/resource/legal-notices/OpenDS.LICENSE
+// or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+// See the License for the specific language governing permissions
+// and limitations under the License.
+//
+// When distributing Covered Code, include this CDDL HEADER in each
+// file and include the License file at
+// trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+// add the following below this CDDL HEADER, with the fields enclosed
+// information:
+//      Portions Copyright [yyyy] [name of copyright owner]
+//
+// CDDL HEADER END
+//
+//
+//      Copyright 2008 Sun Microsystems, Inc.
+import netscape.ldap.*;
+import netscape.ldap.util.*;
+
+import java.util.*;
+import java.io.*;
+import java.lang.Thread;
+
+public class Worker extends Thread {
+ 
+    Server server;
+    Client client;
+    
+    public Worker (Client client, Server server) {
+        super();
+        try {
+            this.server = server;
+            this.client = client;
+            this.start();	
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
+
+
+    public void run () {
+        
+        String value="";
+        String[] attributes =  new String []{client.attr};
+        LDAPConnection connection = new LDAPConnection();
+        while (true) {
+            try {
+
+                connection.connect( server.host, server.port);
+                // bind if needed
+                if ( client.bindDN != null ) {
+                    // println ("INFO", "Binding as \"" + client.bindDN + "\"");
+                    connection.bind(client.bindDN, client.bindPW);
+                }
+                /* try {
+                    synchronized (client.lock) {
+                        client.lock.wait();
+                    }
+                } catch ( InterruptedException ie ) {
+                    ie.printStackTrace();
+                }*/
+            while (true) {
+                    //try {
+                        client.inc_srchs_started();
+                        value=(String) client.ValueList.get(client.random.nextInt(client.ValueList.size()));
+                        //println ("INFO", "Modifying \""+myDN+"\" (replace "+ attribute + ":" + value + ") on master " + master.toString());
+                        //connection.search(client.suffix, LDAPv3.SCOPE_SUB, new String (client.attr + "=" + value ), new String []{}, false );
+                        //connection.search(client.suffix, LDAPv3.SCOPE_SUB, new String (client.attr + "=" + value ), new String []{client.attr}, false );
+                        LDAPSearchResults results=connection.search(client.suffix, LDAPv3.SCOPE_SUB, new String (client.attr + "=" + value ), attributes, false );
+                        while ( results.hasMoreElements() ) {
+                            LDAPEntry entry=results.next();
+                        }
+                        client.inc_srchs_done();
+                        results=null;
+                        
+                    //} catch (LDAPException e) {
+                    //        println("ERROR", e.toString());
+                            // Client.wait_after_error();
+                    /*        try {
+                                synchronized (client.lock) {
+                                    client.lock.wait();
+                                }
+                            } catch ( InterruptedException ie ) {
+                                ie.printStackTrace();
+                            }  */
+                    //}
+
+                }
+            }
+            catch( LDAPException e ) {
+                println( "ERROR" , e.toString() );
+                // make sure we are disconnected
+                try {
+                    connection.disconnect();
+                }
+                catch( LDAPException e2 ) {
+                    println( "ERROR" , e2.toString() );
+                }
+//                System.exit(1);
+            }
+        }
+    }
+
+    private String getDate() {
+    
+        // Initialize the today's date string
+        String DATE_FORMAT = "yyyy/MM/dd:HH:mm:ss";
+        java.text.SimpleDateFormat sdf = 
+            new java.text.SimpleDateFormat(DATE_FORMAT);
+        Calendar c1 = Calendar.getInstance(); // today
+        return("[" + sdf.format(c1.getTime()) + "]");
+   }
+   
+   private void println(String level, String msg) {
+        System.out.println (getDate() + " - " + level + ": (" + server + ") " + msg );
+   }
+	
+}
diff --git a/opends/tests/system-tests/scenario/sample2/conf.xml b/opends/tests/system-tests/scenario/sample2/conf.xml
index 920f9df..c0d0f21 100755
--- a/opends/tests/system-tests/scenario/sample2/conf.xml
+++ b/opends/tests/system-tests/scenario/sample2/conf.xml
@@ -109,7 +109,7 @@
     <!--== Module 1 ==-->
     <module name="search" enabled="true">
     
-      <client id="1" name="searchLoad" host="localhost" start="t30"
+      <client id="1" name="sampleSearchLoad" host="localhost" start="t30"
                                                          stop="t60">
         <serverInstance>I1</serverInstance>
         <baseDn>dc=com</baseDn>

--
Gitblit v1.10.0