From 7c846b4cc9b41e621ffc05fdf85f5e80dd2253c1 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 3 Nov 2001 16:59:06 +0000 Subject: [PATCH] more meaningful subtree replication test --- tests/data/slapd-repl-submaster.conf | 4 +- tests/data/slapd-repl-subslave.conf | 32 ++++++++++++++ tests/data/test-base.ldif | 16 ------- tests/data/test-ordered.ldif | 3 +- tests/scripts/defines.sh | 6 +++ tests/scripts/subfilter.sh | 10 +++++ tests/scripts/test011-subtree-repl | 62 ++++++++++++++-------------- tests/scripts/undiff.sh | 9 ++++ 8 files changed, 92 insertions(+), 50 deletions(-) create mode 100644 tests/data/slapd-repl-subslave.conf delete mode 100644 tests/data/test-base.ldif create mode 100755 tests/scripts/subfilter.sh create mode 100755 tests/scripts/undiff.sh diff --git a/tests/data/slapd-repl-submaster.conf b/tests/data/slapd-repl-submaster.conf index 9836e28c87..8e4e420e04 100644 --- a/tests/data/slapd-repl-submaster.conf +++ b/tests/data/slapd-repl-submaster.conf @@ -31,7 +31,7 @@ lastmod on replogfile ./test-db/slapd.replog replica host=localhost:9010 - suffix="ou=People, o=University of Michigan, c=US" - binddn="cn=Replica, o=University of Michigan, c=US" + suffix="ou=Groups, o=University of Michigan, c=US" + binddn="cn=Replica, ou=Groups, o=University of Michigan, c=US" bindmethod=simple credentials=secret diff --git a/tests/data/slapd-repl-subslave.conf b/tests/data/slapd-repl-subslave.conf new file mode 100644 index 0000000000..adfaed0fd7 --- /dev/null +++ b/tests/data/slapd-repl-subslave.conf @@ -0,0 +1,32 @@ +# $OpenLDAP$ +# +# slave slapd config -- for testing of replication +# +ucdata-path ./ucdata +include ./schema/core.schema +include ./schema/cosine.schema +include ./schema/inetorgperson.schema +# +schemacheck off +pidfile ./test-repl/slapd.pid +argsfile ./test-repl/slapd.args + +#referral "ldap://localhost:9009/" + +####################################################################### +# ldbm database definitions +####################################################################### + +database @BACKEND@ +cachesize 0 +suffix "ou=Groups, o=University of Michigan, c=US" +directory ./test-repl +rootdn "cn=Replica, ou=Groups, o=University of Michigan, c=US" +rootpw secret +updatedn "cn=Replica, ou=Groups, o=University of Michigan, c=US" +updateref "ldap://localhost:9009" +#ldbm#index objectClass eq +#ldbm#index cn,sn,uid pres,eq,sub +#bdb#index objectClass eq +#bdb#index cn,sn,uid pres,eq,sub +lastmod on diff --git a/tests/data/test-base.ldif b/tests/data/test-base.ldif deleted file mode 100644 index 1c551194cd..0000000000 --- a/tests/data/test-base.ldif +++ /dev/null @@ -1,16 +0,0 @@ -dn: o=University of Michigan, c=US -objectclass: top -objectclass: organization -objectclass: domainRelatedObject -l: Ann Arbor, Michigan -st: Michigan -o: University of Michigan -o: UMICH -o: UM -o: U-M -o: U of M -description: The University of Michigan at Ann Arbor -postaladdress: University of Michigan $ 535 W. William St. $ Ann Arbor, MI 481 - 09 $ US -telephonenumber: +1 313 764-1817 -associateddomain: umich.edu diff --git a/tests/data/test-ordered.ldif b/tests/data/test-ordered.ldif index fdaab5d03c..59690d7af3 100644 --- a/tests/data/test-ordered.ldif +++ b/tests/data/test-ordered.ldif @@ -34,7 +34,7 @@ dn: ou=Information Technology Division, ou=People, o=University of Michigan, c =US objectclass: top objectclass: organizationalUnit -ou: Information Technology Divisio +ou: Information Technology Division dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US member: cn=Manager, o=University of Michigan, c=US @@ -311,3 +311,4 @@ homephone: +1 313 555 8421 pager: +1 313 555 2844 facsimiletelephonenumber: +1 313 555 9700 telephonenumber: +1 313 555 5331 + diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh index 2793900fd2..e532a043a7 100755 --- a/tests/scripts/defines.sh +++ b/tests/scripts/defines.sh @@ -14,6 +14,7 @@ MASTERCONF=$DATADIR/slapd-repl-master.conf SLAVECONF=$DATADIR/slapd-repl-slave.conf REFSLAVECONF=$DATADIR/slapd-ref-slave.conf SUBMASTERCONF=$DATADIR/slapd-repl-submaster.conf +SUBSLAVECONF=$DATADIR/slapd-repl-subslave.conf SCHEMACONF=$DATADIR/slapd-schema.conf DBCONF=$DBDIR/slapd.conf @@ -29,6 +30,8 @@ CLIENTDIR=../clients/tools #CLIENTDIR=/usr/local/bin LDIFFILTER=$SRCDIR/scripts/acfilter.sh +SUBFILTER=$SRCDIR/scripts/subfilter.sh +UNDIFFFILTER=$SRCDIR/scripts/undiff.sh CONFFILTER=$SRCDIR/scripts/conf.sh SLAPADD="../servers/slapd/tools/slapadd $LDAP_VERBOSE" @@ -70,8 +73,11 @@ SLURPLOG=$DBDIR/slurp.log SEARCHOUT=$DBDIR/ldapsearch.out SEARCHFLT=$DBDIR/ldapsearch.flt LDIFFLT=$DBDIR/ldif.flt +SUBFLT=$DBDIR/sub.flt +SUBFLT2=$DBDIR/sub2.flt MASTEROUT=$DBDIR/master.out SLAVEOUT=$DBDIR/slave.out +SUBMASTEROUT=$DBDIR/submaster.out TESTOUT=$DBDIR/test.out INITOUT=$DBDIR/init.out SEARCHOUTMASTER=$DATADIR/search.out.master diff --git a/tests/scripts/subfilter.sh b/tests/scripts/subfilter.sh new file mode 100755 index 0000000000..ebc4978ad1 --- /dev/null +++ b/tests/scripts/subfilter.sh @@ -0,0 +1,10 @@ +#! /bin/sh +# +# Strip entries that belong to subtree $2 (if any) +# +if test $# == 0 ; then + exit 1 +else + awk "/^dn:/&&!/$1\$/ {while (\$1!=\"\") {print \$0;getline} print \"\"}" +fi + diff --git a/tests/scripts/test011-subtree-repl b/tests/scripts/test011-subtree-repl index 84011badcd..6fa1de066d 100755 --- a/tests/scripts/test011-subtree-repl +++ b/tests/scripts/test011-subtree-repl @@ -38,6 +38,7 @@ echo "Cleaning up in $DBDIR..." rm -f $DBDIR/[!C]* echo "Cleaning up in $REPLDIR..." rm -f $REPLDIR/[!C]* +rm -f $REPLDIR/replica/[!C]* echo "Starting master slapd on TCP/IP port $PORT..." . $CONFFILTER $BACKEND < $SUBMASTERCONF > $DBCONF @@ -49,7 +50,7 @@ if test $WAIT != 0 ; then fi echo "Starting slave slapd on TCP/IP port $SLAVEPORT..." -. $CONFFILTER $BACKEND < $SLAVECONF > $REPLCONF +. $CONFFILTER $BACKEND < $SUBSLAVECONF > $REPLCONF $SLAPD -f $REPLCONF -h $SLAVEURI -d $LVL $TIMING > $SLAVELOG 2>&1 & SLAVEPID=$! if test $WAIT != 0 ; then @@ -79,17 +80,6 @@ for i in 0 1 2 3 4 5; do fi done -echo "Creating base in subtree slave" -$LDAPADD -D "$UPDATEDN" -h localhost -p $SLAVEPORT -w $PASSWD < \ - $LDIFBASE > /dev/null 2>&1 -RC=$? -if test $RC != 0 ; then - echo "ldapadd failed ($RC)!" - kill -INT $PID $SLAVEPID - kill -KILL $SLURPPID - exit $RC -fi - echo "Starting slurpd..." $SLURPD -f $SUBMASTERCONF -d ${SLURPD_DEBUG-5} -t $REPLDIR > $SLURPLOG 2>&1 & SLURPPID=$! @@ -186,8 +176,8 @@ EOMODS echo "Waiting 15 seconds for slurpd to send changes..." sleep 15 -echo "Using ldapsearch to read the subtree entries from the master..." -$LDAPSEARCH -S "" -b "$BASEDN" -s base -h localhost -p $PORT \ +echo "Using ldapsearch to read all the entries from the master..." +$LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \ 'objectclass=*' > $MASTEROUT 2>&1 if test $RC != 0 ; then @@ -197,8 +187,9 @@ if test $RC != 0 ; then exit $RC fi -$LDAPSEARCH -S "" -b "ou=People, $BASEDN" -h localhost -p $PORT \ - 'objectclass=*' >> $MASTEROUT 2>&1 +echo "Using ldapsearch to read the subtree entries from the master..." +$LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h localhost -p $PORT \ + 'objectclass=*' > $SUBMASTEROUT 2>&1 if test $RC != 0 ; then echo "ldapsearch failed ($RC)!" @@ -208,7 +199,7 @@ if test $RC != 0 ; then fi echo "Using ldapsearch to read all the entries from the slave..." -$LDAPSEARCH -S "" -b "$BASEDN" -s base -h localhost -p $SLAVEPORT \ +$LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h localhost -p $SLAVEPORT \ 'objectclass=*' > $SLAVEOUT 2>&1 if test $RC != 0 ; then @@ -218,25 +209,15 @@ if test $RC != 0 ; then exit $RC fi -$LDAPSEARCH -S "" -b "ou=People, $BASEDN" -h localhost -p $SLAVEPORT \ - 'objectclass=*' >> $SLAVEOUT 2>&1 - -if test $RC != 0 ; then - echo "ldapsearch failed ($RC)!" - kill -INT $PID $SLAVEPID - kill -KILL $SLURPPID - exit $RC -fi - kill -INT $PID $SLAVEPID kill -KILL $SLURPPID -SEARCHOUT=$MASTEROUT +SEARCHOUT=$SUBMASTEROUT LDIF=$SLAVEOUT -echo "Filtering ldapsearch results..." +echo "Filtering master ldapsearch results..." . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT -echo "Filtering original ldif used to create database..." +echo "Filtering slave ldapsearch results..." . $LDIFFILTER < $LDIF > $LDIFFLT echo "Comparing retrieved entries from master and slave..." @@ -247,7 +228,26 @@ if test $? != 0 ; then exit 1 fi -echo ">>>>> Test succeeded" +SEARCHOUT=$MASTEROUT + +echo "Filtering remaining data" +. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT + +echo "Stripping slave entries from master output..." +$CMP $SEARCHFLT $LDIFFLT | $UNDIFFFILTER > $SUBFLT +echo "Stripping subtree entries from master output..." +. $SUBFILTER 'ou=Groups,[ ]?o=University of Michigan,[ ]?c=US' < $SEARCHOUT \ + | $UNDIFFFILTER > $SUBFLT2 + +echo "Comparing master minus subtree and master minus slave..." +$CMP $SUBFLT $SUBFLT2 > $CMPOUT + +if test $? != 0 ; then + echo "test failed - master and slave databases differ" + exit 1 +fi + +echo ">>>>> Test succeeded" exit 0 diff --git a/tests/scripts/undiff.sh b/tests/scripts/undiff.sh new file mode 100755 index 0000000000..09c898a190 --- /dev/null +++ b/tests/scripts/undiff.sh @@ -0,0 +1,9 @@ +#! /bin/sh +# +# Expunge "< " and "> " resulting from diff +# +awk '!/^[0-9]/ {print $0}' | \ + sed "s/^< //" | \ + sed "s/> //" | \ + awk '/.+/ {print $0}' + -- 2.39.5