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