Home | History | Annotate | Line # | Download | only in scripts
      1       1.1     lukem #! /bin/sh
      2   1.1.1.5      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.11  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 $BACKLDAP = ldapno; then 
     20       1.1     lukem 	echo "LDAP backend not available, test skipped"
     21       1.1     lukem 	exit 0
     22       1.1     lukem fi 
     23       1.1     lukem 
     24       1.1     lukem if test $SYNCPROV = syncprovno; then 
     25       1.1     lukem 	echo "Syncrepl provider overlay not available, test skipped"
     26       1.1     lukem 	exit 0
     27       1.1     lukem fi 
     28       1.1     lukem 
     29       1.1     lukem mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3
     30       1.1     lukem 
     31       1.1     lukem #
     32       1.1     lukem # Test replication:
     33  1.1.1.10  christos # - start provider
     34  1.1.1.10  christos # - start consumer
     35       1.1     lukem # - populate over ldap
     36       1.1     lukem # - perform some modifies and deleted
     37  1.1.1.10  christos # - attempt to modify the consumer (referral or chain)
     38       1.1     lukem # - retrieve database over ldap and compare against expected results
     39       1.1     lukem #
     40       1.1     lukem 
     41  1.1.1.10  christos echo "Starting provider slapd on TCP/IP port $PORT1..."
     42  1.1.1.10  christos . $CONFFILTER $BACKEND < $PLSRPROVIDERCONF > $CONF1
     43  1.1.1.10  christos $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
     44  1.1.1.10  christos PROVIDERPID=$!
     45       1.1     lukem if test $WAIT != 0 ; then
     46  1.1.1.10  christos     echo PROVIDERPID $PROVIDERPID
     47       1.1     lukem     read foo
     48       1.1     lukem fi
     49  1.1.1.10  christos KILLPIDS="$PROVIDERPID"
     50       1.1     lukem 
     51       1.1     lukem sleep 1
     52       1.1     lukem 
     53  1.1.1.10  christos echo "Using ldapsearch to check that provider slapd is running..."
     54       1.1     lukem for i in 0 1 2 3 4 5; do
     55  1.1.1.10  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
     56       1.1     lukem 		'(objectClass=*)' > /dev/null 2>&1
     57       1.1     lukem 	RC=$?
     58       1.1     lukem 	if test $RC = 0 ; then
     59       1.1     lukem 		break
     60       1.1     lukem 	fi
     61       1.1     lukem 	echo "Waiting 5 seconds for slapd to start..."
     62       1.1     lukem 	sleep 5
     63       1.1     lukem done
     64       1.1     lukem 
     65       1.1     lukem if test $RC != 0 ; then
     66       1.1     lukem 	echo "ldapsearch failed ($RC)!"
     67       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     68       1.1     lukem 	exit $RC
     69       1.1     lukem fi
     70       1.1     lukem 
     71  1.1.1.10  christos echo "Using ldapadd to create the context prefix entry in the provider..."
     72  1.1.1.10  christos $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD < \
     73       1.1     lukem 	$LDIFORDEREDCP > /dev/null 2>&1
     74       1.1     lukem RC=$?
     75       1.1     lukem if test $RC != 0 ; then
     76       1.1     lukem 	echo "ldapadd failed ($RC)!"
     77       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     78       1.1     lukem 	exit $RC
     79       1.1     lukem fi
     80       1.1     lukem 
     81  1.1.1.10  christos echo "Starting P1 consumer slapd on TCP/IP port $PORT2..."
     82  1.1.1.10  christos . $CONFFILTER $BACKEND < $RCONSUMERCONF > $CONF2
     83  1.1.1.10  christos $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
     84  1.1.1.10  christos P1CONSUMERPID=$!
     85       1.1     lukem if test $WAIT != 0 ; then
     86  1.1.1.10  christos     echo P1CONSUMERPID $P1CONSUMERPID
     87       1.1     lukem     read foo
     88       1.1     lukem fi
     89  1.1.1.10  christos KILLPIDS="$PROVIDERPID $P1CONSUMERPID"
     90       1.1     lukem 
     91       1.1     lukem sleep 1
     92       1.1     lukem 
     93  1.1.1.10  christos echo "Using ldapsearch to check that P1 consumer slapd is running..."
     94       1.1     lukem for i in 0 1 2 3 4 5; do
     95  1.1.1.10  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
     96       1.1     lukem 		'(objectClass=*)' > /dev/null 2>&1
     97       1.1     lukem 	RC=$?
     98       1.1     lukem 	if test $RC = 0 ; then
     99       1.1     lukem 		break
    100       1.1     lukem 	fi
    101       1.1     lukem 	echo "Waiting 5 seconds for slapd to start..."
    102       1.1     lukem 	sleep 5
    103       1.1     lukem done
    104       1.1     lukem 
    105       1.1     lukem if test $RC != 0 ; then
    106       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    107       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    108       1.1     lukem 	exit $RC
    109       1.1     lukem fi
    110       1.1     lukem 
    111  1.1.1.10  christos echo "Starting R1 consumer slapd on TCP/IP port $PORT3..."
    112  1.1.1.10  christos . $CONFFILTER $BACKEND < $RCONSUMERCONF | sed -e 's;\.2\.\([^/]*\)$;.3.\1;' > $CONF3
    113  1.1.1.10  christos $SLAPD -f $CONF3 -h $URI3 -d $LVL > $LOG3 2>&1 &
    114  1.1.1.10  christos R1CONSUMERPID=$!
    115       1.1     lukem if test $WAIT != 0 ; then
    116  1.1.1.10  christos     echo R1CONSUMERPID $R1CONSUMERPID
    117       1.1     lukem     read foo
    118       1.1     lukem fi
    119  1.1.1.10  christos KILLPIDS="$PROVIDERPID $P1CONSUMERPID $R1CONSUMERPID"
    120       1.1     lukem 
    121       1.1     lukem sleep 1
    122       1.1     lukem 
    123  1.1.1.10  christos echo "Using ldapsearch to check that R1 consumer slapd is running..."
    124       1.1     lukem for i in 0 1 2 3 4 5; do
    125  1.1.1.10  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI3 \
    126       1.1     lukem 		'(objectClass=*)' > /dev/null 2>&1
    127       1.1     lukem 	RC=$?
    128       1.1     lukem 	if test $RC = 0; then
    129       1.1     lukem 		break
    130       1.1     lukem 	fi
    131       1.1     lukem 	echo "Waiting 5 seconds for slapd to start..."
    132       1.1     lukem 	sleep 5
    133       1.1     lukem done
    134       1.1     lukem 
    135       1.1     lukem if test $RC != 0 ; then
    136       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    137       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    138       1.1     lukem 	exit $RC
    139       1.1     lukem fi
    140       1.1     lukem 
    141       1.1     lukem CHECK=1
    142  1.1.1.10  christos echo "$CHECK > Using ldapadd to populate the provider directory..."
    143  1.1.1.10  christos $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD < \
    144       1.1     lukem 	$LDIFORDEREDNOCP > /dev/null 2>&1
    145       1.1     lukem RC=$?
    146       1.1     lukem if test $RC != 0 ; then
    147       1.1     lukem 	echo "ldapadd failed ($RC)!"
    148       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    149       1.1     lukem 	exit $RC
    150       1.1     lukem fi
    151       1.1     lukem 
    152   1.1.1.3     lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    153   1.1.1.3     lukem sleep $SLEEP1
    154       1.1     lukem 
    155  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the provider..."
    156  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    157  1.1.1.10  christos 	'(objectClass=*)' > "${PROVIDEROUT}.1" 2>&1
    158       1.1     lukem RC=$?
    159       1.1     lukem 
    160       1.1     lukem if test $RC != 0 ; then
    161  1.1.1.10  christos 	echo "ldapsearch failed at provider ($RC)!"
    162       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    163       1.1     lukem 	exit $RC
    164       1.1     lukem fi
    165       1.1     lukem 
    166  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the P1 consumer..."
    167  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
    168  1.1.1.10  christos 	'(objectClass=*)' > "${CONSUMEROUT}.1" 2>&1
    169       1.1     lukem RC=$?
    170       1.1     lukem 
    171       1.1     lukem if test $RC != 0 ; then
    172  1.1.1.10  christos 	echo "ldapsearch failed at P1 consumer ($RC)!"
    173       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    174       1.1     lukem 	exit $RC
    175       1.1     lukem fi
    176       1.1     lukem 
    177  1.1.1.10  christos #echo "Filtering provider results..."
    178  1.1.1.10  christos $LDIFFILTER < "${PROVIDEROUT}.1" > $PROVIDERFLT
    179  1.1.1.10  christos #echo "Filtering consumer results..."
    180  1.1.1.10  christos $LDIFFILTER < "${CONSUMEROUT}.1" > $CONSUMERFLT
    181       1.1     lukem 
    182  1.1.1.10  christos echo "$CHECK < Comparing retrieved entries from provider and P1 consumer..."
    183  1.1.1.10  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    184       1.1     lukem 
    185       1.1     lukem if test $? != 0 ; then
    186  1.1.1.10  christos 	echo "test failed - provider and P1 consumer databases differ"
    187       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    188       1.1     lukem 	exit 1
    189       1.1     lukem fi
    190       1.1     lukem 
    191  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the R1 consumer..."
    192  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI3 \
    193  1.1.1.10  christos 	'(objectClass=*)' > "${CONSUMEROUT}.1" 2>&1
    194       1.1     lukem RC=$?
    195       1.1     lukem 
    196       1.1     lukem if test $RC != 0 ; then
    197  1.1.1.10  christos 	echo "ldapsearch failed at R1 consumer ($RC)!"
    198       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    199       1.1     lukem 	exit $RC
    200       1.1     lukem fi
    201       1.1     lukem 
    202  1.1.1.10  christos #echo "Filtering consumer results..."
    203  1.1.1.10  christos $LDIFFILTER < "${CONSUMEROUT}.1" > $CONSUMERFLT
    204       1.1     lukem 
    205  1.1.1.10  christos echo "$CHECK < Comparing retrieved entries from provider and R1 consumer..."
    206  1.1.1.10  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    207       1.1     lukem 
    208       1.1     lukem if test $? != 0 ; then
    209  1.1.1.10  christos 	echo "test failed - provider and R1 consumer databases differ"
    210       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    211       1.1     lukem 	exit 1
    212       1.1     lukem fi
    213       1.1     lukem 
    214       1.1     lukem CHECK=`expr $CHECK + 1`
    215   1.1.1.3     lukem echo "$CHECK > Stopping the provider, sleeping $SLEEP2 seconds and restarting it..."
    216  1.1.1.10  christos kill -HUP "$PROVIDERPID"
    217  1.1.1.10  christos wait $PROVIDERPID
    218   1.1.1.3     lukem sleep $SLEEP2
    219       1.1     lukem 
    220       1.1     lukem echo "======================= RESTART =======================" >> $LOG1
    221  1.1.1.10  christos $SLAPD -f $CONF1 -h $URI1 -d $LVL >> $LOG1 2>&1 &
    222  1.1.1.10  christos PROVIDERPID=$!
    223       1.1     lukem if test $WAIT != 0 ; then
    224  1.1.1.10  christos     echo PROVIDERPID $PROVIDERPID
    225       1.1     lukem     read foo
    226       1.1     lukem fi
    227  1.1.1.10  christos KILLPIDS="$PROVIDERPID $P1CONSUMERPID $R1CONSUMERPID"
    228       1.1     lukem 
    229       1.1     lukem sleep 1
    230       1.1     lukem 
    231  1.1.1.10  christos echo "Using ldapsearch to check that provider slapd is running..."
    232       1.1     lukem for i in 0 1 2 3 4 5; do
    233  1.1.1.10  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
    234       1.1     lukem 		'(objectClass=*)' > /dev/null 2>&1
    235       1.1     lukem 	RC=$?
    236       1.1     lukem 	if test $RC = 0 ; then
    237       1.1     lukem 		break
    238       1.1     lukem 	fi
    239       1.1     lukem 	echo "Waiting 5 seconds for slapd to start..."
    240       1.1     lukem 	sleep 5
    241       1.1     lukem done
    242       1.1     lukem 
    243       1.1     lukem if test $RC != 0 ; then
    244       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    245       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    246       1.1     lukem 	exit $RC
    247       1.1     lukem fi
    248       1.1     lukem 
    249  1.1.1.10  christos echo "Using ldapmodify to modify provider directory..."
    250       1.1     lukem 
    251       1.1     lukem #
    252       1.1     lukem # Do some modifications
    253       1.1     lukem #
    254       1.1     lukem 
    255  1.1.1.10  christos $LDAPMODIFY -v -D "$MANAGERDN" -H $URI1 -w $PASSWD > \
    256       1.1     lukem 	$TESTOUT 2>&1 << EOMODS
    257       1.1     lukem dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
    258       1.1     lukem changetype: modify
    259       1.1     lukem add: drink
    260       1.1     lukem drink: Orange Juice
    261       1.1     lukem -
    262       1.1     lukem delete: sn
    263       1.1     lukem sn: Jones
    264       1.1     lukem -
    265       1.1     lukem add: sn
    266       1.1     lukem sn: Jones
    267       1.1     lukem 
    268       1.1     lukem dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    269       1.1     lukem changetype: modify
    270       1.1     lukem replace: drink
    271       1.1     lukem drink: Iced Tea
    272       1.1     lukem 
    273       1.1     lukem dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
    274       1.1     lukem changetype: modify
    275       1.1     lukem delete: uniquemember
    276       1.1     lukem uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
    277       1.1     lukem uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    278       1.1     lukem -
    279       1.1     lukem add: uniquemember
    280       1.1     lukem uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
    281       1.1     lukem uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
    282       1.1     lukem 
    283       1.1     lukem dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
    284       1.1     lukem  =com
    285       1.1     lukem changetype: modify
    286       1.1     lukem delete: cn
    287       1.1     lukem cn: Biiff Jensen
    288       1.1     lukem 
    289       1.1     lukem dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    290       1.1     lukem changetype: add
    291       1.1     lukem objectclass: OpenLDAPperson
    292       1.1     lukem cn: Gern Jensen
    293       1.1     lukem sn: Jensen
    294       1.1     lukem uid: gjensen
    295       1.1     lukem title: Chief Investigator, ITD
    296       1.1     lukem postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
    297       1.1     lukem seealso: cn=All Staff, ou=Groups, dc=example,dc=com
    298       1.1     lukem drink: Coffee
    299       1.1     lukem homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
    300       1.1     lukem description: Very odd
    301       1.1     lukem facsimiletelephonenumber: +1 313 555 7557
    302       1.1     lukem telephonenumber: +1 313 555 8343
    303       1.1     lukem mail: gjensen@mailgw.example.com
    304       1.1     lukem homephone: +1 313 555 8844
    305       1.1     lukem 
    306       1.1     lukem dn: ou=Retired, ou=People, dc=example,dc=com
    307       1.1     lukem changetype: add
    308       1.1     lukem objectclass: organizationalUnit
    309       1.1     lukem ou: Retired
    310       1.1     lukem 
    311       1.1     lukem dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
    312       1.1     lukem changetype: add
    313       1.1     lukem objectclass: OpenLDAPperson
    314       1.1     lukem cn: Rosco P. Coltrane
    315       1.1     lukem sn: Coltrane
    316       1.1     lukem uid: rosco
    317       1.1     lukem description: Fat tycoon
    318       1.1     lukem 
    319       1.1     lukem dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
    320       1.1     lukem changetype: modrdn
    321       1.1     lukem newrdn: cn=Rosco P. Coltrane
    322       1.1     lukem deleteoldrdn: 1
    323       1.1     lukem newsuperior: ou=Retired, ou=People, dc=example,dc=com
    324       1.1     lukem 
    325       1.1     lukem dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
    326       1.1     lukem changetype: delete
    327       1.1     lukem EOMODS
    328       1.1     lukem 
    329       1.1     lukem RC=$?
    330       1.1     lukem if test $RC != 0 ; then
    331       1.1     lukem 	echo "ldapmodify failed ($RC)!"
    332       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    333       1.1     lukem 	exit $RC
    334       1.1     lukem fi
    335       1.1     lukem 
    336   1.1.1.3     lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    337   1.1.1.3     lukem sleep $SLEEP1
    338       1.1     lukem 
    339  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the provider..."
    340  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    341  1.1.1.10  christos 	'(objectClass=*)' > "${PROVIDEROUT}.2" 2>&1
    342       1.1     lukem RC=$?
    343       1.1     lukem 
    344       1.1     lukem if test $RC != 0 ; then
    345  1.1.1.10  christos 	echo "ldapsearch failed at provider ($RC)!"
    346       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    347       1.1     lukem 	exit $RC
    348       1.1     lukem fi
    349       1.1     lukem 
    350  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the P1 consumer..."
    351  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
    352  1.1.1.10  christos 	'(objectClass=*)' > "${CONSUMEROUT}.2" 2>&1
    353       1.1     lukem RC=$?
    354       1.1     lukem 
    355       1.1     lukem if test $RC != 0 ; then
    356  1.1.1.10  christos 	echo "ldapsearch failed at P1 consumer ($RC)!"
    357       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    358       1.1     lukem 	exit $RC
    359       1.1     lukem fi
    360       1.1     lukem 
    361  1.1.1.10  christos #echo "Filtering provider results..."
    362  1.1.1.10  christos $LDIFFILTER < "${PROVIDEROUT}.2" > $PROVIDERFLT
    363  1.1.1.10  christos #echo "Filtering P1 consumer results..."
    364  1.1.1.10  christos $LDIFFILTER < "${CONSUMEROUT}.2" > $CONSUMERFLT
    365       1.1     lukem 
    366  1.1.1.10  christos echo "$CHECK < Comparing retrieved entries from provider and P1 consumer..."
    367  1.1.1.10  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    368       1.1     lukem 
    369       1.1     lukem if test $? != 0 ; then
    370  1.1.1.10  christos 	echo "test failed - provider and P1 consumer databases differ"
    371       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    372       1.1     lukem 	exit 1
    373       1.1     lukem fi
    374       1.1     lukem 
    375  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the R1 consumer..."
    376  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI3 \
    377  1.1.1.10  christos 	'(objectClass=*)' > "${CONSUMEROUT}.2" 2>&1
    378       1.1     lukem RC=$?
    379       1.1     lukem 
    380       1.1     lukem if test $RC != 0 ; then
    381  1.1.1.10  christos 	echo "ldapsearch failed at R1 consumer ($RC)!"
    382       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    383       1.1     lukem 	exit $RC
    384       1.1     lukem fi
    385       1.1     lukem 
    386  1.1.1.10  christos #echo "Filtering consumer results..."
    387  1.1.1.10  christos $LDIFFILTER < "${CONSUMEROUT}.2" > $CONSUMERFLT
    388       1.1     lukem 
    389  1.1.1.10  christos echo "$CHECK < Comparing retrieved entries from provider and R1 consumer..."
    390  1.1.1.10  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    391       1.1     lukem 
    392       1.1     lukem if test $? != 0 ; then
    393  1.1.1.10  christos 	echo "test failed - provider and R1 consumer databases differ"
    394       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    395       1.1     lukem 	exit 1
    396       1.1     lukem fi
    397       1.1     lukem 
    398       1.1     lukem CHECK=`expr $CHECK + 1`
    399  1.1.1.10  christos echo "$CHECK > Stopping consumer to test recovery..."
    400  1.1.1.10  christos kill -HUP $P1CONSUMERPID $R1CONSUMERPID
    401  1.1.1.10  christos wait $P1CONSUMERPID
    402  1.1.1.10  christos wait $R1CONSUMERPID
    403       1.1     lukem 
    404  1.1.1.10  christos echo "Modifying more entries on the provider..."
    405  1.1.1.10  christos $LDAPMODIFY -v -D "$MANAGERDN" -H $URI1 -w $PASSWD >> \
    406       1.1     lukem 	$TESTOUT 2>&1 << EOMODS
    407       1.1     lukem dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    408       1.1     lukem changetype: modify
    409       1.1     lukem add: description
    410  1.1.1.10  christos description: r1 consumer is down...
    411       1.1     lukem 
    412       1.1     lukem dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
    413       1.1     lukem changetype: add
    414       1.1     lukem objectclass: OpenLDAPperson
    415       1.1     lukem sn: Kirk
    416       1.1     lukem uid: jtk
    417       1.1     lukem cn: James T. Kirk
    418       1.1     lukem 
    419       1.1     lukem dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
    420       1.1     lukem changetype: add
    421       1.1     lukem objectclass: OpenLDAPperson
    422       1.1     lukem sn: Hooker
    423       1.1     lukem uid: tjh
    424       1.1     lukem cn: Tiberius J. Hooker
    425       1.1     lukem 
    426       1.1     lukem EOMODS
    427       1.1     lukem 
    428  1.1.1.10  christos echo "Restarting P1 consumer..."
    429       1.1     lukem echo "======================= RESTART =======================" >> $LOG3
    430  1.1.1.10  christos $SLAPD -f $CONF2 -h $URI2 -d $LVL >> $LOG2 2>&1 &
    431  1.1.1.10  christos P1CONSUMERPID=$!
    432       1.1     lukem if test $WAIT != 0 ; then
    433  1.1.1.10  christos     echo P1CONSUMERPID $P1CONSUMERPID
    434       1.1     lukem     read foo
    435       1.1     lukem fi
    436       1.1     lukem 
    437  1.1.1.10  christos echo "Restarting R1 consumer..."
    438       1.1     lukem echo "======================= RESTART =======================" >> $LOG3
    439  1.1.1.10  christos $SLAPD -f $CONF3 -h $URI3 -d $LVL >> $LOG3 2>&1 &
    440  1.1.1.10  christos R1CONSUMERPID=$!
    441       1.1     lukem if test $WAIT != 0 ; then
    442  1.1.1.10  christos     echo R1CONSUMERPID $R1CONSUMERPID
    443       1.1     lukem     read foo
    444       1.1     lukem fi
    445  1.1.1.10  christos KILLPIDS="$PROVIDERPID $P1CONSUMERPID $R1CONSUMERPID"
    446       1.1     lukem 
    447   1.1.1.3     lukem echo "Waiting $SLEEP2 seconds for syncrepl to receive changes..."
    448   1.1.1.3     lukem sleep $SLEEP2
    449       1.1     lukem 
    450  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the provider..."
    451  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    452  1.1.1.10  christos 	'(objectClass=*)' > "${PROVIDEROUT}.3" 2>&1
    453       1.1     lukem RC=$?
    454       1.1     lukem 
    455       1.1     lukem if test $RC != 0 ; then
    456  1.1.1.10  christos 	echo "ldapsearch failed at provider ($RC)!"
    457       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    458       1.1     lukem 	exit $RC
    459       1.1     lukem fi
    460       1.1     lukem 
    461  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the P1 consumer..."
    462  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
    463  1.1.1.10  christos 	'(objectClass=*)' > "${CONSUMEROUT}.3" 2>&1
    464       1.1     lukem RC=$?
    465       1.1     lukem 
    466       1.1     lukem if test $RC != 0 ; then
    467  1.1.1.10  christos 	echo "ldapsearch failed at consumer ($RC)!"
    468       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    469       1.1     lukem 	exit $RC
    470       1.1     lukem fi
    471       1.1     lukem 
    472  1.1.1.10  christos #echo "Filtering provider results..."
    473  1.1.1.10  christos $LDIFFILTER < "${PROVIDEROUT}.3" > $PROVIDERFLT
    474  1.1.1.10  christos #echo "Filtering consumer results..."
    475  1.1.1.10  christos $LDIFFILTER < "${CONSUMEROUT}.3" > $CONSUMERFLT
    476       1.1     lukem 
    477  1.1.1.10  christos echo "$CHECK < Comparing retrieved entries from provider and P1 consumer..."
    478  1.1.1.10  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    479       1.1     lukem 
    480       1.1     lukem if test $? != 0 ; then
    481  1.1.1.10  christos 	echo "test failed - provider and consumer databases differ"
    482       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    483       1.1     lukem 	exit 1
    484       1.1     lukem fi
    485       1.1     lukem 
    486  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the R1 consumer..."
    487  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI3 \
    488  1.1.1.10  christos 	'(objectClass=*)' > "${CONSUMEROUT}.3" 2>&1
    489       1.1     lukem RC=$?
    490       1.1     lukem 
    491       1.1     lukem if test $RC != 0 ; then
    492  1.1.1.10  christos 	echo "ldapsearch failed at consumer ($RC)!"
    493       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    494       1.1     lukem 	exit $RC
    495       1.1     lukem fi
    496       1.1     lukem 
    497  1.1.1.10  christos #echo "Filtering consumer results..."
    498  1.1.1.10  christos $LDIFFILTER < "${CONSUMEROUT}.3" > $CONSUMERFLT
    499       1.1     lukem 
    500  1.1.1.10  christos echo "$CHECK < Comparing retrieved entries from provider and R1 consumer..."
    501  1.1.1.10  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    502       1.1     lukem 
    503       1.1     lukem if test $? != 0 ; then
    504  1.1.1.10  christos 	echo "test failed - provider and consumer databases differ"
    505       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    506       1.1     lukem 	exit 1
    507       1.1     lukem fi
    508       1.1     lukem 
    509       1.1     lukem CHECK=`expr $CHECK + 1`
    510  1.1.1.10  christos echo "$CHECK > Try updating the P1 consumer slapd..."
    511  1.1.1.10  christos $LDAPMODIFY -v -D "$MANAGERDN" -H $URI2 -w $PASSWD > \
    512       1.1     lukem 	$TESTOUT 2>&1 << EOMODS
    513       1.1     lukem dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
    514       1.1     lukem changetype: modify
    515       1.1     lukem add: description
    516       1.1     lukem description: This write must fail because directed to a shadow context,
    517       1.1     lukem description: unless the chain overlay is configured appropriately ;)
    518       1.1     lukem 
    519       1.1     lukem EOMODS
    520       1.1     lukem 
    521       1.1     lukem RC=$?
    522       1.1     lukem if test $RC != 0 ; then
    523       1.1     lukem 	echo "ldapmodify failed ($RC)!"
    524       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    525       1.1     lukem 	exit $RC
    526       1.1     lukem fi
    527       1.1     lukem 
    528   1.1.1.3     lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    529   1.1.1.3     lukem sleep $SLEEP1
    530       1.1     lukem 
    531  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the provider..."
    532  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    533  1.1.1.10  christos 	'(objectClass=*)' > "${PROVIDEROUT}.4" 2>&1
    534       1.1     lukem RC=$?
    535       1.1     lukem 
    536       1.1     lukem if test $RC != 0 ; then
    537  1.1.1.10  christos 	echo "ldapsearch failed at provider ($RC)!"
    538       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    539       1.1     lukem 	exit $RC
    540       1.1     lukem fi
    541       1.1     lukem 
    542  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the P1 consumer..."
    543  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
    544  1.1.1.10  christos '(objectClass=*)' > "${CONSUMEROUT}.4" 2>&1
    545       1.1     lukem RC=$?
    546       1.1     lukem 
    547       1.1     lukem if test $RC != 0 ; then
    548  1.1.1.10  christos 	echo "ldapsearch failed at consumer ($RC)!"
    549       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    550       1.1     lukem 	exit $RC
    551       1.1     lukem fi
    552       1.1     lukem 
    553  1.1.1.10  christos #echo "Filtering provider results..."
    554  1.1.1.10  christos $LDIFFILTER < "${PROVIDEROUT}.4" > $PROVIDERFLT
    555  1.1.1.10  christos #echo "Filtering consumer results..."
    556  1.1.1.10  christos $LDIFFILTER < "${CONSUMEROUT}.4" > $CONSUMERFLT
    557       1.1     lukem 
    558  1.1.1.10  christos echo "$CHECK < Comparing retrieved entries from provider and P1 consumer..."
    559  1.1.1.10  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    560       1.1     lukem 
    561       1.1     lukem if test $? != 0 ; then
    562  1.1.1.10  christos 	echo "test failed - provider and P1 consumer databases differ"
    563       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    564       1.1     lukem 	exit 1
    565       1.1     lukem fi
    566       1.1     lukem 
    567  1.1.1.10  christos #echo "Using ldapsearch to read all the entries from the R1 consumer..."
    568  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI3 \
    569  1.1.1.10  christos '(objectClass=*)' > "${CONSUMEROUT}.4" 2>&1
    570       1.1     lukem RC=$?
    571       1.1     lukem 
    572       1.1     lukem if test $RC != 0 ; then
    573  1.1.1.10  christos 	echo "ldapsearch failed at consumer ($RC)!"
    574       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    575       1.1     lukem 	exit $RC
    576       1.1     lukem fi
    577       1.1     lukem 
    578  1.1.1.10  christos #echo "Filtering consumer results..."
    579  1.1.1.10  christos $LDIFFILTER < "${CONSUMEROUT}.4" > $CONSUMERFLT
    580       1.1     lukem 
    581  1.1.1.10  christos echo "$CHECK < Comparing retrieved entries from provider and R1 consumer..."
    582  1.1.1.10  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    583       1.1     lukem 
    584       1.1     lukem if test $? != 0 ; then
    585  1.1.1.10  christos 	echo "test failed - provider and R1 consumer databases differ"
    586       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    587       1.1     lukem 	exit 1
    588       1.1     lukem fi
    589       1.1     lukem 
    590       1.1     lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
    591       1.1     lukem 
    592       1.1     lukem echo ">>>>> Test succeeded"
    593       1.1     lukem 
    594       1.1     lukem test $KILLSERVERS != no && wait
    595       1.1     lukem 
    596       1.1     lukem exit 0
    597