Home | History | Annotate | Line # | Download | only in scripts
      1       1.1     lukem #! /bin/sh
      2   1.1.1.4      tron # $OpenLDAP$
      3       1.1     lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
      4       1.1     lukem ##
      5  1.1.1.10  christos ## Copyright 1998-2024 The OpenLDAP Foundation.
      6       1.1     lukem ## All rights reserved.
      7       1.1     lukem ##
      8       1.1     lukem ## Redistribution and use in source and binary forms, with or without
      9       1.1     lukem ## modification, are permitted only as authorized by the OpenLDAP
     10       1.1     lukem ## Public License.
     11       1.1     lukem ##
     12       1.1     lukem ## A copy of this license is available in the file LICENSE in the
     13       1.1     lukem ## top-level directory of the distribution or, alternatively, at
     14       1.1     lukem ## <http://www.OpenLDAP.org/license.html>.
     15       1.1     lukem 
     16       1.1     lukem echo "running defines.sh"
     17       1.1     lukem . $SRCDIR/scripts/defines.sh
     18       1.1     lukem 
     19       1.1     lukem if test $SYNCPROV = syncprovno; then 
     20       1.1     lukem 	echo "Syncrepl provider overlay not available, test skipped"
     21       1.1     lukem 	exit 0
     22       1.1     lukem fi 
     23       1.1     lukem if test $ACCESSLOG = accesslogno; then 
     24       1.1     lukem 	echo "Accesslog overlay not available, test skipped"
     25       1.1     lukem 	exit 0
     26       1.1     lukem fi 
     27   1.1.1.3      adam if test $BACKEND = ldif ; then
     28   1.1.1.3      adam 	# Onelevel search does not return entries in order of creation or CSN.
     29   1.1.1.3      adam 	echo "$BACKEND backend unsuitable for syncprov logdb, test skipped"
     30   1.1.1.3      adam 	exit 0
     31   1.1.1.3      adam fi
     32       1.1     lukem 
     33       1.1     lukem mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR2
     34       1.1     lukem 
     35   1.1.1.9  christos SPEC="mdb=a"
     36   1.1.1.5  christos 
     37  1.1.1.10  christos $SLAPPASSWD -g -n >$CONFIGPWF
     38  1.1.1.10  christos echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
     39       1.1     lukem #
     40       1.1     lukem # Test replication:
     41   1.1.1.4      tron # - start provider
     42       1.1     lukem # - start consumer
     43       1.1     lukem # - populate over ldap
     44       1.1     lukem # - perform some modifies and deleted
     45       1.1     lukem # - attempt to modify the consumer (referral or chain)
     46       1.1     lukem # - retrieve database over ldap and compare against expected results
     47       1.1     lukem #
     48       1.1     lukem 
     49   1.1.1.4      tron echo "Starting provider slapd on TCP/IP port $PORT1..."
     50   1.1.1.9  christos . $CONFFILTER $BACKEND < $DSRPROVIDERCONF > $CONF1
     51   1.1.1.9  christos $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
     52       1.1     lukem PID=$!
     53       1.1     lukem if test $WAIT != 0 ; then
     54       1.1     lukem     echo PID $PID
     55       1.1     lukem     read foo
     56       1.1     lukem fi
     57       1.1     lukem KILLPIDS="$PID"
     58       1.1     lukem 
     59       1.1     lukem sleep 1
     60       1.1     lukem 
     61   1.1.1.4      tron echo "Using ldapsearch to check that provider slapd is running..."
     62       1.1     lukem for i in 0 1 2 3 4 5; do
     63   1.1.1.9  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
     64       1.1     lukem 		'objectclass=*' > /dev/null 2>&1
     65       1.1     lukem 	RC=$?
     66       1.1     lukem 	if test $RC = 0 ; then
     67       1.1     lukem 		break
     68       1.1     lukem 	fi
     69       1.1     lukem 	echo "Waiting 5 seconds for slapd to start..."
     70       1.1     lukem 	sleep 5
     71       1.1     lukem done
     72       1.1     lukem 
     73       1.1     lukem if test $RC != 0 ; then
     74       1.1     lukem 	echo "ldapsearch failed ($RC)!"
     75       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     76       1.1     lukem 	exit $RC
     77       1.1     lukem fi
     78       1.1     lukem 
     79   1.1.1.4      tron echo "Using ldapadd to create the context prefix entries in the provider..."
     80   1.1.1.9  christos $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD < \
     81       1.1     lukem 	$LDIFORDEREDCP > /dev/null 2>&1
     82       1.1     lukem RC=$?
     83       1.1     lukem if test $RC != 0 ; then
     84       1.1     lukem 	echo "ldapadd failed ($RC)!"
     85       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     86       1.1     lukem 	exit $RC
     87       1.1     lukem fi
     88       1.1     lukem 
     89       1.1     lukem echo "Starting consumer slapd on TCP/IP port $PORT2..."
     90   1.1.1.9  christos . $CONFFILTER $BACKEND < $DSRCONSUMERCONF > $CONF2
     91   1.1.1.9  christos $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
     92   1.1.1.9  christos CONSUMERPID=$!
     93       1.1     lukem if test $WAIT != 0 ; then
     94   1.1.1.9  christos     echo CONSUMERPID $CONSUMERPID
     95       1.1     lukem     read foo
     96       1.1     lukem fi
     97   1.1.1.9  christos KILLPIDS="$KILLPIDS $CONSUMERPID"
     98       1.1     lukem 
     99       1.1     lukem sleep 1
    100       1.1     lukem 
    101       1.1     lukem echo "Using ldapsearch to check that consumer slapd is running..."
    102       1.1     lukem for i in 0 1 2 3 4 5; do
    103   1.1.1.9  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
    104       1.1     lukem 		'objectclass=*' > /dev/null 2>&1
    105       1.1     lukem 	RC=$?
    106       1.1     lukem 	if test $RC = 0 ; then
    107       1.1     lukem 		break
    108       1.1     lukem 	fi
    109       1.1     lukem 	echo "Waiting 5 seconds for slapd to start..."
    110       1.1     lukem 	sleep 5
    111       1.1     lukem done
    112       1.1     lukem 
    113       1.1     lukem if test $RC != 0 ; then
    114       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    115       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    116       1.1     lukem 	exit $RC
    117       1.1     lukem fi
    118       1.1     lukem 
    119   1.1.1.4      tron echo "Using ldapadd to populate the provider directory..."
    120   1.1.1.9  christos $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD < \
    121       1.1     lukem 	$LDIFORDEREDNOCP > /dev/null 2>&1
    122       1.1     lukem RC=$?
    123       1.1     lukem if test $RC != 0 ; then
    124       1.1     lukem 	echo "ldapadd failed ($RC)!"
    125       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    126       1.1     lukem 	exit $RC
    127       1.1     lukem fi
    128       1.1     lukem 
    129   1.1.1.2     lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    130   1.1.1.2     lukem sleep $SLEEP1
    131       1.1     lukem 
    132       1.1     lukem echo "Stopping the provider, sleeping 10 seconds and restarting it..."
    133       1.1     lukem kill -HUP "$PID"
    134  1.1.1.10  christos wait $PID
    135       1.1     lukem sleep 10
    136       1.1     lukem echo "RESTART" >> $LOG1
    137   1.1.1.9  christos $SLAPD -f $CONF1 -h $URI1 -d $LVL >> $LOG1 2>&1 &
    138       1.1     lukem PID=$!
    139       1.1     lukem if test $WAIT != 0 ; then
    140       1.1     lukem     echo PID $PID
    141       1.1     lukem     read foo
    142       1.1     lukem fi
    143   1.1.1.9  christos KILLPIDS="$PID $CONSUMERPID"
    144       1.1     lukem 
    145       1.1     lukem sleep 1
    146       1.1     lukem 
    147   1.1.1.4      tron echo "Using ldapsearch to check that provider slapd is running..."
    148       1.1     lukem for i in 0 1 2 3 4 5; do
    149   1.1.1.9  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
    150       1.1     lukem 		'objectclass=*' > /dev/null 2>&1
    151       1.1     lukem 	RC=$?
    152       1.1     lukem 	if test $RC = 0 ; then
    153       1.1     lukem 		break
    154       1.1     lukem 	fi
    155       1.1     lukem 	echo "Waiting 5 seconds for slapd to start..."
    156       1.1     lukem 	sleep 5
    157       1.1     lukem done
    158       1.1     lukem 
    159       1.1     lukem if test $RC != 0 ; then
    160       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    161       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    162       1.1     lukem 	exit $RC
    163       1.1     lukem fi
    164       1.1     lukem 
    165   1.1.1.4      tron echo "Using ldapmodify to modify provider directory..."
    166       1.1     lukem 
    167       1.1     lukem #
    168       1.1     lukem # Do some modifications
    169       1.1     lukem #
    170       1.1     lukem 
    171   1.1.1.9  christos $LDAPMODIFY -v -D "$MANAGERDN" -H $URI1 -w $PASSWD > \
    172       1.1     lukem 	$TESTOUT 2>&1 << EOMODS
    173       1.1     lukem dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
    174       1.1     lukem changetype: modify
    175       1.1     lukem add: drink
    176       1.1     lukem drink: Orange Juice
    177       1.1     lukem -
    178       1.1     lukem delete: sn
    179       1.1     lukem sn: Jones
    180       1.1     lukem -
    181       1.1     lukem add: sn
    182       1.1     lukem sn: Jones
    183   1.1.1.9  christos -
    184   1.1.1.9  christos add: displayName
    185   1.1.1.9  christos displayName: The one
    186   1.1.1.9  christos 
    187   1.1.1.9  christos dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
    188   1.1.1.9  christos changetype: modify
    189   1.1.1.9  christos add: displayName
    190   1.1.1.9  christos displayName: James the First
    191   1.1.1.9  christos -
    192   1.1.1.9  christos delete: displayName
    193   1.1.1.9  christos displayName: The one
    194       1.1     lukem 
    195       1.1     lukem dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    196       1.1     lukem changetype: modify
    197       1.1     lukem replace: drink
    198       1.1     lukem drink: Iced Tea
    199       1.1     lukem 
    200       1.1     lukem dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
    201       1.1     lukem changetype: modify
    202       1.1     lukem delete: uniquemember
    203       1.1     lukem uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
    204       1.1     lukem uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    205       1.1     lukem -
    206       1.1     lukem add: uniquemember
    207       1.1     lukem uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
    208       1.1     lukem uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
    209       1.1     lukem 
    210       1.1     lukem dn: cn=All Staff,ou=Groups,dc=example,dc=com
    211       1.1     lukem changetype: modify
    212       1.1     lukem delete: description
    213       1.1     lukem 
    214       1.1     lukem dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    215       1.1     lukem changetype: add
    216       1.1     lukem objectclass: OpenLDAPperson
    217       1.1     lukem cn: Gern Jensen
    218       1.1     lukem sn: Jensen
    219       1.1     lukem uid: gjensen
    220       1.1     lukem title: Chief Investigator, ITD
    221       1.1     lukem postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
    222       1.1     lukem seealso: cn=All Staff, ou=Groups, dc=example,dc=com
    223       1.1     lukem drink: Coffee
    224       1.1     lukem homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
    225       1.1     lukem description: Very odd
    226       1.1     lukem facsimiletelephonenumber: +1 313 555 7557
    227       1.1     lukem telephonenumber: +1 313 555 8343
    228       1.1     lukem mail: gjensen@mailgw.example.com
    229       1.1     lukem homephone: +1 313 555 8844
    230       1.1     lukem 
    231       1.1     lukem dn: ou=Retired, ou=People, dc=example,dc=com
    232       1.1     lukem changetype: add
    233       1.1     lukem objectclass: organizationalUnit
    234       1.1     lukem ou: Retired
    235       1.1     lukem 
    236       1.1     lukem dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
    237       1.1     lukem changetype: add
    238       1.1     lukem objectclass: OpenLDAPperson
    239       1.1     lukem cn: Rosco P. Coltrane
    240       1.1     lukem sn: Coltrane
    241       1.1     lukem uid: rosco
    242       1.1     lukem description: Fat tycoon
    243       1.1     lukem 
    244       1.1     lukem dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
    245       1.1     lukem changetype: modrdn
    246       1.1     lukem newrdn: cn=Rosco P. Coltrane
    247       1.1     lukem deleteoldrdn: 1
    248       1.1     lukem newsuperior: ou=Retired, ou=People, dc=example,dc=com
    249       1.1     lukem 
    250       1.1     lukem dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
    251       1.1     lukem changetype: delete
    252       1.1     lukem 
    253       1.1     lukem EOMODS
    254       1.1     lukem RC=$?
    255       1.1     lukem if test $RC != 0 ; then
    256       1.1     lukem 	echo "ldapmodify failed ($RC)!"
    257       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    258       1.1     lukem 	exit $RC
    259       1.1     lukem fi
    260       1.1     lukem 
    261   1.1.1.2     lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    262   1.1.1.2     lukem sleep $SLEEP1
    263       1.1     lukem 
    264   1.1.1.4      tron echo "Using ldapsearch to read all the entries from the provider..."
    265   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    266   1.1.1.9  christos 	'objectclass=*' \* + > $PROVIDEROUT 2>&1
    267   1.1.1.4      tron RC=$?
    268   1.1.1.4      tron 
    269   1.1.1.4      tron if test $RC != 0 ; then
    270   1.1.1.4      tron 	echo "ldapsearch failed at provider ($RC)!"
    271   1.1.1.4      tron 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    272   1.1.1.4      tron 	exit $RC
    273   1.1.1.4      tron fi
    274   1.1.1.4      tron 
    275   1.1.1.4      tron echo "Using ldapsearch to read all the entries from the consumer..."
    276   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
    277   1.1.1.9  christos 	'objectclass=*' \* + > $CONSUMEROUT 2>&1
    278   1.1.1.4      tron RC=$?
    279   1.1.1.4      tron 
    280   1.1.1.4      tron if test $RC != 0 ; then
    281   1.1.1.4      tron 	echo "ldapsearch failed at consumer ($RC)!"
    282   1.1.1.4      tron 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    283   1.1.1.4      tron 	exit $RC
    284   1.1.1.4      tron fi
    285   1.1.1.4      tron 
    286   1.1.1.4      tron echo "Filtering provider results..."
    287   1.1.1.9  christos $LDIFFILTER -b $BACKEND -s $SPEC < $PROVIDEROUT | grep -iv "^auditcontext:" > $PROVIDERFLT
    288   1.1.1.4      tron echo "Filtering consumer results..."
    289   1.1.1.9  christos $LDIFFILTER -b $BACKEND -s $SPEC < $CONSUMEROUT | grep -iv "^auditcontext:" > $CONSUMERFLT
    290   1.1.1.4      tron 
    291   1.1.1.4      tron echo "Comparing retrieved entries from provider and consumer..."
    292   1.1.1.9  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    293   1.1.1.4      tron 
    294   1.1.1.4      tron if test $? != 0 ; then
    295   1.1.1.4      tron 	echo "test failed - provider and consumer databases differ"
    296   1.1.1.4      tron 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    297   1.1.1.4      tron 	exit 1
    298   1.1.1.4      tron fi
    299   1.1.1.4      tron 
    300       1.1     lukem echo "Stopping consumer to test recovery..."
    301   1.1.1.9  christos kill -HUP $CONSUMERPID
    302  1.1.1.10  christos wait $CONSUMERPID
    303  1.1.1.10  christos KILLPIDS="$PID"
    304       1.1     lukem 
    305   1.1.1.4      tron echo "Modifying more entries on the provider..."
    306   1.1.1.9  christos $LDAPMODIFY -v -D "$BJORNSDN" -H $URI1 -w bjorn >> \
    307       1.1     lukem 	$TESTOUT 2>&1 << EOMODS
    308       1.1     lukem dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
    309       1.1     lukem changetype: delete
    310       1.1     lukem 
    311       1.1     lukem dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    312       1.1     lukem changetype: modify
    313       1.1     lukem add: drink
    314       1.1     lukem drink: Mad Dog 20/20
    315       1.1     lukem 
    316       1.1     lukem dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
    317       1.1     lukem changetype: add
    318       1.1     lukem objectclass: OpenLDAPperson
    319       1.1     lukem sn: Coltrane
    320       1.1     lukem uid: rosco
    321       1.1     lukem cn: Rosco P. Coltrane
    322       1.1     lukem 
    323       1.1     lukem dn: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
    324       1.1     lukem changetype: modify
    325       1.1     lukem replace: drink
    326   1.1.1.6  christos drink: Red Wine
    327   1.1.1.6  christos -
    328   1.1.1.6  christos replace: drink
    329       1.1     lukem 
    330       1.1     lukem dn: cn=All Staff,ou=Groups,dc=example,dc=com
    331       1.1     lukem changetype: modrdn
    332       1.1     lukem newrdn: cn=Some Staff
    333       1.1     lukem deleteoldrdn: 1
    334       1.1     lukem 
    335       1.1     lukem EOMODS
    336       1.1     lukem 
    337       1.1     lukem echo "Restarting consumer..."
    338       1.1     lukem echo "RESTART" >> $LOG2
    339   1.1.1.9  christos $SLAPD -f $CONF2 -h $URI2 -d $LVL >> $LOG2 2>&1 &
    340   1.1.1.9  christos CONSUMERPID=$!
    341       1.1     lukem if test $WAIT != 0 ; then
    342   1.1.1.9  christos     echo CONSUMERPID $CONSUMERPID
    343       1.1     lukem     read foo
    344       1.1     lukem fi
    345   1.1.1.9  christos KILLPIDS="$PID $CONSUMERPID"
    346       1.1     lukem 
    347   1.1.1.2     lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    348   1.1.1.2     lukem sleep $SLEEP1
    349       1.1     lukem 
    350       1.1     lukem if test ! $BACKLDAP = "ldapno" ; then
    351       1.1     lukem 	echo "Try updating the consumer slapd..."
    352   1.1.1.9  christos 	$LDAPMODIFY -v -D "$MANAGERDN" -H $URI2 -w $PASSWD > \
    353       1.1     lukem 		$TESTOUT 2>&1 << EOMODS
    354       1.1     lukem dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
    355       1.1     lukem changetype: modify
    356       1.1     lukem add: description
    357       1.1     lukem description: This write must fail because directed to a shadow context,
    358       1.1     lukem description: unless the chain overlay is configured appropriately ;)
    359       1.1     lukem 
    360       1.1     lukem EOMODS
    361       1.1     lukem 
    362       1.1     lukem 	RC=$?
    363       1.1     lukem 	if test $RC != 0 ; then
    364       1.1     lukem 		echo "ldapmodify failed ($RC)!"
    365       1.1     lukem 		test $KILLSERVERS != no && kill -HUP $KILLPIDS
    366       1.1     lukem 		exit $RC
    367       1.1     lukem 	fi
    368       1.1     lukem 
    369   1.1.1.2     lukem 	echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    370   1.1.1.2     lukem 	sleep $SLEEP1
    371       1.1     lukem fi
    372       1.1     lukem 
    373   1.1.1.4      tron echo "Using ldapsearch to read all the entries from the provider..."
    374   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    375   1.1.1.9  christos 	'objectclass=*' \* + > $PROVIDEROUT 2>&1
    376       1.1     lukem RC=$?
    377       1.1     lukem 
    378       1.1     lukem if test $RC != 0 ; then
    379   1.1.1.4      tron 	echo "ldapsearch failed at provider ($RC)!"
    380       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    381       1.1     lukem 	exit $RC
    382       1.1     lukem fi
    383       1.1     lukem 
    384       1.1     lukem echo "Using ldapsearch to read all the entries from the consumer..."
    385   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
    386   1.1.1.9  christos 	'objectclass=*' \* + > $CONSUMEROUT 2>&1
    387       1.1     lukem RC=$?
    388       1.1     lukem 
    389       1.1     lukem if test $RC != 0 ; then
    390       1.1     lukem 	echo "ldapsearch failed at consumer ($RC)!"
    391       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    392       1.1     lukem 	exit $RC
    393       1.1     lukem fi
    394       1.1     lukem 
    395  1.1.1.10  christos echo "Filtering provider results..."
    396  1.1.1.10  christos $LDIFFILTER -b $BACKEND -s $SPEC < $PROVIDEROUT | grep -iv "^auditcontext:" > $PROVIDERFLT
    397  1.1.1.10  christos echo "Filtering consumer results..."
    398  1.1.1.10  christos $LDIFFILTER -b $BACKEND -s $SPEC < $CONSUMEROUT | grep -iv "^auditcontext:" > $CONSUMERFLT
    399  1.1.1.10  christos 
    400  1.1.1.10  christos echo "Comparing retrieved entries from provider and consumer..."
    401  1.1.1.10  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    402  1.1.1.10  christos 
    403  1.1.1.10  christos if test $? != 0 ; then
    404  1.1.1.10  christos 	echo "test failed - provider and consumer databases differ"
    405  1.1.1.10  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    406  1.1.1.10  christos 	exit 1
    407  1.1.1.10  christos fi
    408  1.1.1.10  christos 
    409  1.1.1.10  christos echo "Stopping consumer to test recovery after logpurge expired..."
    410  1.1.1.10  christos kill -HUP $CONSUMERPID
    411  1.1.1.10  christos wait $CONSUMERPID
    412  1.1.1.10  christos KILLPIDS="$PID"
    413  1.1.1.10  christos 
    414  1.1.1.10  christos echo "Modifying even more entries on the provider..."
    415  1.1.1.10  christos $LDAPMODIFY -v -D "$BJORNSDN" -H $URI1 -w bjorn >> \
    416  1.1.1.10  christos 	$TESTOUT 2>&1 << EOMODS
    417  1.1.1.10  christos dn: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
    418  1.1.1.10  christos changetype: delete
    419  1.1.1.10  christos 
    420  1.1.1.10  christos dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    421  1.1.1.10  christos changetype: modify
    422  1.1.1.10  christos add: drink
    423  1.1.1.10  christos drink: Sangria
    424  1.1.1.10  christos 
    425  1.1.1.10  christos dn: cn=George D. Stevens, ou=Retired, ou=People, dc=example,dc=com
    426  1.1.1.10  christos changetype: add
    427  1.1.1.10  christos objectclass: OpenLDAPperson
    428  1.1.1.10  christos sn: Stevens
    429  1.1.1.10  christos uid: gstevens
    430  1.1.1.10  christos cn: George D. Stevens
    431  1.1.1.10  christos 
    432  1.1.1.10  christos dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
    433  1.1.1.10  christos  dc=com
    434  1.1.1.10  christos changetype: modify
    435  1.1.1.10  christos replace: drink
    436  1.1.1.10  christos drink: cold water
    437  1.1.1.10  christos 
    438  1.1.1.10  christos dn: cn=Some Staff,ou=Groups,dc=example,dc=com
    439  1.1.1.10  christos changetype: modrdn
    440  1.1.1.10  christos newrdn: cn=More Staff
    441  1.1.1.10  christos deleteoldrdn: 1
    442  1.1.1.10  christos 
    443  1.1.1.10  christos EOMODS
    444  1.1.1.10  christos 
    445  1.1.1.10  christos echo "Configuring logpurge of 1 second..."
    446  1.1.1.10  christos $LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF >> \
    447  1.1.1.10  christos 	$TESTOUT 2>&1 << EOMODS
    448  1.1.1.10  christos 
    449  1.1.1.10  christos dn: olcOverlay={1}accesslog,olcDatabase={2}$BACKEND,cn=config
    450  1.1.1.10  christos changetype: modify
    451  1.1.1.10  christos replace: olcAccessLogPurge
    452  1.1.1.10  christos olcAccessLogPurge: 0+00:00:02 0+00:00:01
    453  1.1.1.10  christos -
    454  1.1.1.10  christos 
    455  1.1.1.10  christos EOMODS
    456  1.1.1.10  christos RC=$?
    457  1.1.1.10  christos if test $RC != 0 ; then
    458  1.1.1.10  christos 	echo "ldapmodify failed ($RC)!"
    459  1.1.1.10  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    460  1.1.1.10  christos 	exit $RC
    461  1.1.1.10  christos fi
    462  1.1.1.10  christos 
    463  1.1.1.10  christos echo "Waiting 4 seconds for accesslog to be purged..."
    464  1.1.1.10  christos sleep 4
    465  1.1.1.10  christos 
    466  1.1.1.10  christos echo "Using ldapsearch to check if accesslog is empty..."
    467  1.1.1.10  christos for i in 0 1 2 3 4 5; do
    468  1.1.1.10  christos 	$LDAPSEARCH -b "cn=log" -H $URI1 -z 1 \
    469  1.1.1.10  christos 		> $SEARCHOUT 2>&1
    470  1.1.1.10  christos 	RC=$?
    471  1.1.1.10  christos 	if test $RC = 0 ; then
    472  1.1.1.10  christos 		break
    473  1.1.1.10  christos 	fi
    474  1.1.1.10  christos 	echo "Waiting 3 seconds for accesslog to be purged..."
    475  1.1.1.10  christos 	sleep 3
    476  1.1.1.10  christos done
    477  1.1.1.10  christos 
    478  1.1.1.10  christos if test $RC != 0; then
    479  1.1.1.10  christos 	echo "Accesslog did not purge in time"
    480  1.1.1.10  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    481  1.1.1.10  christos 	exit 1
    482  1.1.1.10  christos fi
    483  1.1.1.10  christos 
    484  1.1.1.10  christos 
    485  1.1.1.10  christos echo "Restarting consumer..."
    486  1.1.1.10  christos echo "RESTART" >> $LOG2
    487  1.1.1.10  christos $SLAPD -f $CONF2 -h $URI2 -d $LVL >> $LOG2 2>&1 &
    488  1.1.1.10  christos CONSUMERPID=$!
    489  1.1.1.10  christos if test $WAIT != 0 ; then
    490  1.1.1.10  christos 	echo CONSUMERPID $CONSUMERPID
    491  1.1.1.10  christos 	read foo
    492  1.1.1.10  christos fi
    493  1.1.1.10  christos KILLPIDS="$PID $CONSUMERPID"
    494  1.1.1.10  christos 
    495  1.1.1.10  christos echo "Waiting $SLEEP1 seconds for syncrepl to reschedule (ITS#9878) and poking it..."
    496  1.1.1.10  christos sleep $SLEEP1
    497  1.1.1.10  christos 
    498  1.1.1.10  christos $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
    499  1.1.1.10  christos     'objectclass=*' > /dev/null 2>&1
    500  1.1.1.10  christos RC=$?
    501  1.1.1.10  christos 
    502  1.1.1.10  christos if test $RC != 0; then
    503  1.1.1.10  christos 	echo "ldapsearch failed at consumer ($RC)!"
    504  1.1.1.10  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    505  1.1.1.10  christos 	exit 1
    506  1.1.1.10  christos fi
    507  1.1.1.10  christos 
    508  1.1.1.10  christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    509  1.1.1.10  christos sleep $SLEEP1
    510  1.1.1.10  christos 
    511  1.1.1.10  christos echo "Using ldapsearch to read all the entries from the provider..."
    512  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    513  1.1.1.10  christos 	'objectclass=*' \* + > $PROVIDEROUT 2>&1
    514  1.1.1.10  christos RC=$?
    515  1.1.1.10  christos 
    516  1.1.1.10  christos if test $RC != 0 ; then
    517  1.1.1.10  christos 	echo "ldapsearch failed at provider ($RC)!"
    518  1.1.1.10  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    519  1.1.1.10  christos 	exit $RC
    520  1.1.1.10  christos fi
    521  1.1.1.10  christos 
    522  1.1.1.10  christos echo "Using ldapsearch to read all the entries from the consumer..."
    523  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
    524  1.1.1.10  christos 	'objectclass=*' \* + > $CONSUMEROUT 2>&1
    525  1.1.1.10  christos RC=$?
    526  1.1.1.10  christos 
    527  1.1.1.10  christos if test $RC != 0 ; then
    528  1.1.1.10  christos 	echo "ldapsearch failed at consumer ($RC)!"
    529  1.1.1.10  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    530  1.1.1.10  christos 	exit $RC
    531  1.1.1.10  christos fi
    532  1.1.1.10  christos 
    533       1.1     lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
    534       1.1     lukem 
    535   1.1.1.4      tron echo "Filtering provider results..."
    536   1.1.1.9  christos $LDIFFILTER -b $BACKEND -s $SPEC < $PROVIDEROUT | grep -iv "^auditcontext:" > $PROVIDERFLT
    537       1.1     lukem echo "Filtering consumer results..."
    538   1.1.1.9  christos $LDIFFILTER -b $BACKEND -s $SPEC < $CONSUMEROUT | grep -iv "^auditcontext:" > $CONSUMERFLT
    539       1.1     lukem 
    540   1.1.1.4      tron echo "Comparing retrieved entries from provider and consumer..."
    541   1.1.1.9  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    542       1.1     lukem 
    543       1.1     lukem if test $? != 0 ; then
    544   1.1.1.4      tron 	echo "test failed - provider and consumer databases differ"
    545       1.1     lukem 	exit 1
    546       1.1     lukem fi
    547       1.1     lukem 
    548       1.1     lukem echo ">>>>> Test succeeded"
    549       1.1     lukem 
    550       1.1     lukem test $KILLSERVERS != no && wait
    551       1.1     lukem 
    552       1.1     lukem exit 0
    553