From 2a8b55b1c55cb99c09543f1b5648da98f5d28a8d Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 25 Nov 2011 01:29:34 -0800 Subject: [PATCH] ITS#7090 test unordered slapadd --- tests/data/test-reordered.ldif | 55 ++++++++++++++++++++++++++++++ tests/data/test-unordered.ldif | 55 ++++++++++++++++++++++++++++++ tests/scripts/defines.sh | 2 ++ tests/scripts/test001-slapadd | 62 +++++++++++++++++++++++++++++++++- 4 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 tests/data/test-reordered.ldif create mode 100644 tests/data/test-unordered.ldif diff --git a/tests/data/test-reordered.ldif b/tests/data/test-reordered.ldif new file mode 100644 index 0000000000..76e917752c --- /dev/null +++ b/tests/data/test-reordered.ldif @@ -0,0 +1,55 @@ +dn: ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: test + +dn: ou=Policies,ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: Policies + +dn: ou=slapo-ppolicy,ou=Policies,ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: slapo-ppolicy +ou: Password Policies + +dn: ou=Users,ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: Users + +dn: uid=michael,ou=Users,ou=test,dc=example,dc=com +uid: michael +objectClass: account +objectClass: simpleSecurityObject +userPassword:: dGVzdHNlY3JldA== + +dn: ou=Systemkonten,ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: Systemkonten + +dn: cn=slapd-1,ou=Systemkonten,ou=test,dc=example,dc=com +cn: slapd-1 +objectClass: applicationProcess +objectClass: simpleSecurityObject +userPassword:: cHdfc2xhcGQx + +dn: cn=slapd-2,ou=Systemkonten,ou=test,dc=example,dc=com +cn: slapd-2 +objectClass: applicationProcess +objectClass: simpleSecurityObject +userPassword:: cHdfc2xhcGQy + +dn: ou=Groups,ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: Groups + +dn: cn=Admins,ou=Groups,ou=test,dc=example,dc=com +cn: Admins +cn: Password Admins +objectClass: groupOfNames +member: uid=michael,ou=Users,ou=test,dc=example,dc=com + +dn: cn=Replicas,ou=Groups,ou=test,dc=example,dc=com +member: cn=slapd-1,ou=Systemkonten,ou=test,dc=example,dc=com +member: cn=slapd-2,ou=Systemkonten,ou=test,dc=example,dc=com +cn: Replicas +objectClass: groupOfNames + diff --git a/tests/data/test-unordered.ldif b/tests/data/test-unordered.ldif new file mode 100644 index 0000000000..bdccea2184 --- /dev/null +++ b/tests/data/test-unordered.ldif @@ -0,0 +1,55 @@ +dn: ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: test + +dn: ou=Policies,ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: Policies + +dn: ou=slapo-ppolicy,ou=Policies,ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: slapo-ppolicy +ou: Password Policies + +dn: uid=michael,ou=Users,ou=test,dc=example,dc=com +uid: michael +objectClass: account +objectClass: simpleSecurityObject +userPassword: testsecret + +dn: ou=Users,ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: Users + +dn: cn=slapd-1,ou=Systemkonten,ou=test,dc=example,dc=com +cn: slapd-1 +objectClass: applicationProcess +objectClass: simpleSecurityObject +userPassword: pw_slapd1 + +dn: cn=slapd-2,ou=Systemkonten,ou=test,dc=example,dc=com +cn: slapd-2 +objectClass: applicationProcess +objectClass: simpleSecurityObject +userPassword: pw_slapd2 + +dn: ou=Systemkonten,ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: Systemkonten + +dn: ou=Groups,ou=test,dc=example,dc=com +objectClass: organizationalUnit +ou: Groups + +dn: cn=Admins,ou=Groups,ou=test,dc=example,dc=com +cn: Admins +cn: Password Admins +objectClass: groupOfNames +member: uid=michael,ou=Users,ou=test,dc=example,dc=com + +dn: cn=Replicas,ou=Groups,ou=test,dc=example,dc=com +member: cn=slapd-1,ou=Systemkonten,ou=test,dc=example,dc=com +member: cn=slapd-2,ou=Systemkonten,ou=test,dc=example,dc=com +cn: Replicas +objectClass: groupOfNames + diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh index 6086de52ca..d5b6f3f319 100755 --- a/tests/scripts/defines.sh +++ b/tests/scripts/defines.sh @@ -245,6 +245,8 @@ LDIFTRANSLUCENTMERGED=$DATADIR/test-translucent-merged.ldif LDIFMETA=$DATADIR/test-meta.ldif LDIFVALSORT=$DATADIR/test-valsort.ldif SQLADD=$DATADIR/sql-add.ldif +LDIFUNORDERED=$DATADIR/test-unordered.ldif +LDIFREORDERED=$DATADIR/test-reordered.ldif # strings MONITOR="" diff --git a/tests/scripts/test001-slapadd b/tests/scripts/test001-slapadd index 9c02505f31..7e320fa451 100755 --- a/tests/scripts/test001-slapadd +++ b/tests/scripts/test001-slapadd @@ -50,6 +50,66 @@ for i in 0 1 2 3 4 5; do sleep 5 done +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Filtering ldapsearch results..." +$LDIFFILTER < $SEARCHOUT > $SEARCHFLT +echo "Filtering original ldif used to create database..." +$LDIFFILTER < $LDIF > $LDIFFLT +echo "Comparing filter output..." +$CMP $SEARCHFLT $LDIFFLT > $CMPOUT + +if test $? != 0 ; then + echo "comparison failed - database was not created correctly" + echo $SEARCHFLT $LDIFFLT + $DIFF $SEARCHFLT $LDIFFLT + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + +kill -HUP $KILLPIDS + +rm -f $DBDIR1/* + +BASE2="ou=test,dc=example,dc=com" +sed -e "s;$BASEDN;$BASE2;" $ADDCONF > ${ADDCONF}2 +mv ${ADDCONF}2 $ADDCONF +sed -e "s;$BASEDN;$BASE2;" $CONF1 > ${CONF1}2 +mv ${CONF1}2 $CONF1 +echo "Running slapadd with unordered LDIF..." +$SLAPADD -f $ADDCONF -l $LDIFUNORDERED +RC=$? +if test $RC != 0 ; then + echo "slapadd failed ($RC)!" + exit $RC +fi + +echo "Starting slapd on TCP/IP port $PORT1..." +$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$PID" + +sleep 1 + +echo "Using ldapsearch to retrieve all the entries..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -b "$BASE2" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done + test $KILLSERVERS != no && kill -HUP $KILLPIDS if test $RC != 0 ; then @@ -60,7 +120,7 @@ fi echo "Filtering ldapsearch results..." $LDIFFILTER < $SEARCHOUT > $SEARCHFLT echo "Filtering original ldif used to create database..." -$LDIFFILTER < $LDIF > $LDIFFLT +$LDIFFILTER < $LDIFREORDERED > $LDIFFLT echo "Comparing filter output..." $CMP $SEARCHFLT $LDIFFLT > $CMPOUT -- 2.39.5