need a lot of space for stress tests; need to bind for searches to avoid size limits and so; log failure reason

This commit is contained in:
Pierangelo Masarati 2004-09-04 18:31:43 +00:00
parent 9545fe8953
commit 06b023c766
6 changed files with 42 additions and 28 deletions

View File

@ -255,6 +255,7 @@ do_addel(
LDAP *ld = NULL;
int i;
pid_t pid = getpid();
int rc = LDAP_SUCCESS;
if ( uri ) {
ldap_initialize( &ld, uri );
@ -285,8 +286,8 @@ do_addel(
for ( i = 0; i < maxloop; i++ ) {
/* add the entry */
if ( ldap_add_s( ld, entry, attrs ) != LDAP_SUCCESS ) {
rc = ldap_add_s( ld, entry, attrs );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_add" );
break;
@ -299,8 +300,8 @@ do_addel(
#endif
/* now delete the entry again */
if ( ldap_delete_s( ld, entry ) != LDAP_SUCCESS ) {
rc = ldap_delete_s( ld, entry );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_delete" );
break;
@ -308,7 +309,7 @@ do_addel(
}
fprintf( stderr, " PID=%ld - Add/Delete done.\n", (long) pid );
fprintf( stderr, " PID=%ld - Add/Delete done (%d).\n", (long) pid, rc );
ldap_unbind( ld );
}

View File

@ -130,6 +130,7 @@ do_modify( char *uri, char *host, int port, char *manager,
LDAP *ld = NULL;
int i;
pid_t pid;
int rc = LDAP_SUCCESS;
struct ldapmod mod;
struct ldapmod *mods[2];
@ -170,8 +171,6 @@ do_modify( char *uri, char *host, int port, char *manager,
(long) pid, maxloop, entry );
for ( i = 0; i < maxloop; i++ ) {
int rc;
mod.mod_op = LDAP_MOD_ADD;
if (( rc = ldap_modify_s( ld, entry, mods )) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_modify" );
@ -188,7 +187,7 @@ do_modify( char *uri, char *host, int port, char *manager,
}
fprintf( stderr, " PID=%ld - Modify done.\n", (long) pid );
fprintf( stderr, " PID=%ld - Modify done (%d).\n", (long) pid, rc );
ldap_unbind( ld );
}

View File

@ -116,6 +116,8 @@ do_modrdn( char *uri, char *host, int port, char *manager,
pid_t pid;
char *DNs[2];
char *rdns[2];
int rc = LDAP_SUCCESS;
pid = getpid();
DNs[0] = entry;
@ -166,8 +168,6 @@ do_modrdn( char *uri, char *host, int port, char *manager,
(long) pid, maxloop, entry );
for ( i = 0; i < maxloop; i++ ) {
int rc;
if (( rc = ldap_modrdn2_s( ld, DNs[0], rdns[0], 0 ))
!= LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_modrdn" );
@ -182,7 +182,7 @@ do_modrdn( char *uri, char *host, int port, char *manager,
}
}
fprintf( stderr, " PID=%ld - Modrdn done.\n", (long) pid );
fprintf( stderr, " PID=%ld - Modrdn done (%d).\n", (long) pid, rc );
ldap_unbind( ld );
}

View File

@ -106,6 +106,7 @@ do_read( char *uri, char *host, int port, char *entry, int maxloop )
int i;
char *attrs[] = { "1.1", NULL };
pid_t pid = getpid();
int rc = LDAP_SUCCESS;
if ( uri ) {
ldap_initialize( &ld, uri );
@ -134,11 +135,10 @@ do_read( char *uri, char *host, int port, char *entry, int maxloop )
for ( i = 0; i < maxloop; i++ ) {
LDAPMessage *res;
int rc;
if (( rc = ldap_search_s( ld, entry, LDAP_SCOPE_BASE,
NULL, attrs, 1, &res )) != LDAP_SUCCESS ) {
rc = ldap_search_s( ld, entry, LDAP_SCOPE_BASE,
NULL, attrs, 1, &res );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_read" );
if ( rc != LDAP_NO_SUCH_OBJECT ) break;
continue;
@ -148,7 +148,7 @@ do_read( char *uri, char *host, int port, char *entry, int maxloop )
ldap_msgfree( res );
}
fprintf( stderr, " PID=%ld - Read done.\n", (long) pid );
fprintf( stderr, " PID=%ld - Read done (%d).\n", (long) pid, rc );
ldap_unbind( ld );
}

View File

@ -36,7 +36,7 @@
#define LOOPS 100
static void
do_search( char *uri, char *host, int port, char *sbase, char *filter, int maxloop );
do_search( char *uri, char *host, int port, char *manager, char *passwd, char *sbase, char *filter, int maxloop );
static void
usage( char *name )
@ -53,11 +53,13 @@ main( int argc, char **argv )
char *uri = NULL;
char *host = "localhost";
int port = -1;
char *manager = NULL;
char *passwd = NULL;
char *sbase = NULL;
char *filter = NULL;
int loops = LOOPS;
while ( (i = getopt( argc, argv, "H:h:p:b:f:l:" )) != EOF ) {
while ( (i = getopt( argc, argv, "b:D:f:H:h:l:p:w:" )) != EOF ) {
switch( i ) {
case 'H': /* the server uri */
uri = strdup( optarg );
@ -70,6 +72,14 @@ main( int argc, char **argv )
port = atoi( optarg );
break;
case 'D': /* the servers manager */
manager = strdup( optarg );
break;
case 'w': /* the server managers password */
passwd = strdup( optarg );
break;
case 'b': /* file with search base */
sbase = strdup( optarg );
break;
@ -99,18 +109,19 @@ main( int argc, char **argv )
}
do_search( uri, host, port, sbase, filter, ( 10 * loops ));
do_search( uri, host, port, manager, passwd, sbase, filter, ( 10 * loops ));
exit( EXIT_SUCCESS );
}
static void
do_search( char *uri, char *host, int port, char *sbase, char *filter, int maxloop )
do_search( char *uri, char *host, int port, char *manager, char *passwd, char *sbase, char *filter, int maxloop )
{
LDAP *ld = NULL;
int i;
char *attrs[] = { "cn", "sn", NULL };
pid_t pid = getpid();
int rc = LDAP_SUCCESS;
if ( uri ) {
ldap_initialize( &ld, uri );
@ -128,7 +139,7 @@ do_search( char *uri, char *host, int port, char *sbase, char *filter, int maxlo
&version );
}
if ( ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
if ( ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_bind" );
exit( EXIT_FAILURE );
}
@ -139,11 +150,10 @@ do_search( char *uri, char *host, int port, char *sbase, char *filter, int maxlo
for ( i = 0; i < maxloop; i++ ) {
LDAPMessage *res;
int rc;
if (( rc = ldap_search_s( ld, sbase, LDAP_SCOPE_SUBTREE,
filter, attrs, 0, &res )) != LDAP_SUCCESS ) {
rc = ldap_search_s( ld, sbase, LDAP_SCOPE_SUBTREE,
filter, attrs, 0, &res );
if ( rc != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search" );
if ( rc != LDAP_NO_SUCH_OBJECT ) break;
continue;
@ -153,7 +163,7 @@ do_search( char *uri, char *host, int port, char *sbase, char *filter, int maxlo
ldap_msgfree( res );
}
fprintf( stderr, " PID=%ld - Search done.\n", (long) pid );
fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc );
ldap_unbind( ld );
}

View File

@ -41,7 +41,7 @@
#define MODRDNCMD "slapd-modrdn"
#define MODIFYCMD "slapd-modify"
#define MAXARGS 100
#define MAXREQS 20
#define MAXREQS 5000
#define LOOPS "100"
#define TSEARCHFILE "do_search.0"
@ -240,6 +240,10 @@ main( int argc, char **argv )
sargs[sanum++] = "-p";
sargs[sanum++] = port;
}
sargs[sanum++] = "-D";
sargs[sanum++] = manager;
sargs[sanum++] = "-w";
sargs[sanum++] = passwd;
sargs[sanum++] = "-l";
sargs[sanum++] = loops;
sargs[sanum++] = "-b";