From: Dimitar Stoychev Date: Thu, 19 May 2022 13:45:50 +0000 (-0700) Subject: ITS#9823 Update test043 to check deltasync recovery after accesslog has been purged X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69de6c94cd549770b8579d85501c5e41b4cf1c6b;p=thirdparty%2Fopenldap.git ITS#9823 Update test043 to check deltasync recovery after accesslog has been purged --- diff --git a/tests/data/slapd-deltasync-provider.conf b/tests/data/slapd-deltasync-provider.conf index c38b9ef3d0..844eed5d6e 100644 --- a/tests/data/slapd-deltasync-provider.conf +++ b/tests/data/slapd-deltasync-provider.conf @@ -29,6 +29,10 @@ argsfile @TESTDIR@/slapd.1.args #accesslogmod#modulepath ../servers/slapd/overlays/ #accesslogmod#moduleload accesslog.la +database config +include @TESTDIR@/configpw.conf + + ####################################################################### # provider database definitions ####################################################################### diff --git a/tests/scripts/test043-delta-syncrepl b/tests/scripts/test043-delta-syncrepl index c919478459..c5c5a413b2 100755 --- a/tests/scripts/test043-delta-syncrepl +++ b/tests/scripts/test043-delta-syncrepl @@ -34,6 +34,8 @@ mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR2 SPEC="mdb=a" +$SLAPPASSWD -g -n >$CONFIGPWF +echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf # # Test replication: # - start provider @@ -129,6 +131,7 @@ sleep $SLEEP1 echo "Stopping the provider, sleeping 10 seconds and restarting it..." kill -HUP "$PID" +wait $PID sleep 10 echo "RESTART" >> $LOG1 $SLAPD -f $CONF1 -h $URI1 -d $LVL >> $LOG1 2>&1 & @@ -296,7 +299,8 @@ fi echo "Stopping consumer to test recovery..." kill -HUP $CONSUMERPID -sleep 10 +wait $CONSUMERPID +KILLPIDS="$PID" echo "Modifying more entries on the provider..." $LDAPMODIFY -v -D "$BJORNSDN" -H $URI1 -w bjorn >> \ @@ -388,6 +392,131 @@ if test $RC != 0 ; then exit $RC fi +echo "Filtering provider results..." +$LDIFFILTER -b $BACKEND -s $SPEC < $PROVIDEROUT | grep -iv "^auditcontext:" > $PROVIDERFLT +echo "Filtering consumer results..." +$LDIFFILTER -b $BACKEND -s $SPEC < $CONSUMEROUT | grep -iv "^auditcontext:" > $CONSUMERFLT + +echo "Comparing retrieved entries from provider and consumer..." +$CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT + +if test $? != 0 ; then + echo "test failed - provider and consumer databases differ" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + +echo "Stopping consumer to test recovery after logpurge expired..." +kill -HUP $CONSUMERPID +wait $CONSUMERPID +KILLPIDS="$PID" + +echo "Modifying even more entries on the provider..." +$LDAPMODIFY -v -D "$BJORNSDN" -H $URI1 -w bjorn >> \ + $TESTOUT 2>&1 << EOMODS +dn: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com +changetype: delete + +dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com +changetype: modify +add: drink +drink: Sangria + +dn: cn=George D. Stevens, ou=Retired, ou=People, dc=example,dc=com +changetype: add +objectclass: OpenLDAPperson +sn: Stevens +uid: gstevens +cn: George D. Stevens + +dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example, + dc=com +changetype: modify +replace: drink +drink: cold water + +dn: cn=Some Staff,ou=Groups,dc=example,dc=com +changetype: modrdn +newrdn: cn=More Staff +deleteoldrdn: 1 + +EOMODS + +echo "Configuring logpurge of 1 second..." +$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF >> \ + $TESTOUT 2>&1 << EOMODS + +dn: olcOverlay={1}accesslog,olcDatabase={2}$BACKEND,cn=config +changetype: modify +replace: olcAccessLogPurge +olcAccessLogPurge: 0+00:00:02 0+00:00:01 +- + +EOMODS +RC=$? +if test $RC != 0 ; then + echo "ldapmodify failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Waiting 4 seconds for accesslog to be purged..." +sleep 4 + +echo "Using ldapsearch to check if accesslog is empty..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -b "cn=log" -H $URI1 -z 1 \ + > $SEARCHOUT 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 3 seconds for accesslog to be purged..." + sleep 3 +done + +if test $RC != 0; then + echo "Accesslog did not purge in time" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + + +echo "Restarting consumer..." +echo "RESTART" >> $LOG2 +$SLAPD -f $CONF2 -h $URI2 -d $LVL >> $LOG2 2>&1 & +CONSUMERPID=$! +if test $WAIT != 0 ; then + echo CONSUMERPID $CONSUMERPID + read foo +fi +KILLPIDS="$PID $CONSUMERPID" + +echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." +sleep $SLEEP1 + +echo "Using ldapsearch to read all the entries from the provider..." +$LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \ + 'objectclass=*' \* + > $PROVIDEROUT 2>&1 +RC=$? + +if test $RC != 0 ; then + echo "ldapsearch failed at provider ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Using ldapsearch to read all the entries from the consumer..." +$LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \ + 'objectclass=*' \* + > $CONSUMEROUT 2>&1 +RC=$? + +if test $RC != 0 ; then + echo "ldapsearch failed at consumer ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + test $KILLSERVERS != no && kill -HUP $KILLPIDS echo "Filtering provider results..."