Home | History | Annotate | Line # | Download | only in scripts
test054-syncreplication-parallel-load revision 1.1
      1  1.1  lukem #! /bin/sh
      2  1.1  lukem # OpenLDAP: pkg/ldap/tests/scripts/test054-syncreplication-parallel-load,v 1.1.2.3 2009/03/05 22:19:39 quanah Exp
      3  1.1  lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
      4  1.1  lukem ##
      5  1.1  lukem ## Copyright 1998-2009 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 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
     17  1.1  lukem 	echo "Test does not support $BACKEND"
     18  1.1  lukem 	exit 0
     19  1.1  lukem fi
     20  1.1  lukem 
     21  1.1  lukem echo "running defines.sh"
     22  1.1  lukem . $SRCDIR/scripts/defines.sh
     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 $DBDIR4
     30  1.1  lukem 
     31  1.1  lukem #
     32  1.1  lukem # Test replication:
     33  1.1  lukem # - start producer
     34  1.1  lukem # - start consumer
     35  1.1  lukem # - populate over ldap
     36  1.1  lukem # - perform some modifies and deleted
     37  1.1  lukem # - 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  lukem echo "Starting producer slapd on TCP/IP port $PORT1..."
     42  1.1  lukem . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
     43  1.1  lukem $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
     44  1.1  lukem PID=$!
     45  1.1  lukem if test $WAIT != 0 ; then
     46  1.1  lukem     echo PID $PID
     47  1.1  lukem     read foo
     48  1.1  lukem fi
     49  1.1  lukem KILLPIDS="$PID"
     50  1.1  lukem 
     51  1.1  lukem sleep 1
     52  1.1  lukem 
     53  1.1  lukem echo "Using ldapsearch to check that producer slapd is running..."
     54  1.1  lukem for i in 0 1 2 3 4 5; do
     55  1.1  lukem 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
     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  lukem echo "Using ldapadd to create the context prefix entry in the producer..."
     72  1.1  lukem $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -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  lukem echo "Starting consumer slapd on TCP/IP port $PORT4..."
     82  1.1  lukem . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
     83  1.1  lukem $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
     84  1.1  lukem SLAVEPID=$!
     85  1.1  lukem if test $WAIT != 0 ; then
     86  1.1  lukem     echo SLAVEPID $SLAVEPID
     87  1.1  lukem     read foo
     88  1.1  lukem fi
     89  1.1  lukem KILLPIDS="$KILLPIDS $SLAVEPID"
     90  1.1  lukem 
     91  1.1  lukem sleep 1
     92  1.1  lukem 
     93  1.1  lukem echo "Using ldapsearch to check that consumer slapd is running..."
     94  1.1  lukem for i in 0 1 2 3 4 5; do
     95  1.1  lukem 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
     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  lukem MORELDIF=$TESTDIR/more.ldif
    112  1.1  lukem TESTOUT1=$TESTDIR/testout1.out
    113  1.1  lukem TESTOUT2=$TESTDIR/testout2.out
    114  1.1  lukem sed -e 's/[Oo][Uu]=/ou=More /g' -e 's/^[Oo][Uu]: /ou: More /' \
    115  1.1  lukem 	-e 's/cn=Manager/cn=More Manager/g' \
    116  1.1  lukem 	-e 's/^cn: Manager/cn: More Manager/' \
    117  1.1  lukem 	$LDIFORDEREDNOCP > $MORELDIF
    118  1.1  lukem 
    119  1.1  lukem echo "Using ldapadd to populate the producer directory..."
    120  1.1  lukem $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
    121  1.1  lukem 	$LDIFORDEREDNOCP > $TESTOUT1 2>&1  &
    122  1.1  lukem C1PID=$!
    123  1.1  lukem $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
    124  1.1  lukem 	$MORELDIF > $TESTOUT2 2>&1 &
    125  1.1  lukem C2PID=$!
    126  1.1  lukem wait $C1PID $C2PID
    127  1.1  lukem 
    128  1.1  lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    129  1.1  lukem sleep $SLEEP1
    130  1.1  lukem 
    131  1.1  lukem echo "Stopping the provider, sleeping 10 seconds and restarting it..."
    132  1.1  lukem kill -HUP "$PID"
    133  1.1  lukem wait $PID
    134  1.1  lukem sleep 10
    135  1.1  lukem echo "RESTART" >> $LOG1
    136  1.1  lukem $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
    137  1.1  lukem PID=$!
    138  1.1  lukem if test $WAIT != 0 ; then
    139  1.1  lukem     echo PID $PID
    140  1.1  lukem     read foo
    141  1.1  lukem fi
    142  1.1  lukem KILLPIDS="$PID $SLAVEPID"
    143  1.1  lukem 
    144  1.1  lukem sleep 1
    145  1.1  lukem 
    146  1.1  lukem echo "Using ldapsearch to check that producer slapd is running..."
    147  1.1  lukem for i in 0 1 2 3 4 5; do
    148  1.1  lukem 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
    149  1.1  lukem 		'objectclass=*' > /dev/null 2>&1
    150  1.1  lukem 	RC=$?
    151  1.1  lukem 	if test $RC = 0 ; then
    152  1.1  lukem 		break
    153  1.1  lukem 	fi
    154  1.1  lukem 	echo "Waiting 5 seconds for slapd to start..."
    155  1.1  lukem 	sleep 5
    156  1.1  lukem done
    157  1.1  lukem 
    158  1.1  lukem if test $RC != 0 ; then
    159  1.1  lukem 	echo "ldapsearch failed ($RC)!"
    160  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    161  1.1  lukem 	exit $RC
    162  1.1  lukem fi
    163  1.1  lukem 
    164  1.1  lukem echo "Waiting 10 seconds to let the system catch up"
    165  1.1  lukem sleep 10
    166  1.1  lukem 
    167  1.1  lukem echo "Using ldapmodify to modify producer directory..."
    168  1.1  lukem 
    169  1.1  lukem #
    170  1.1  lukem # Do some modifications
    171  1.1  lukem #
    172  1.1  lukem 
    173  1.1  lukem $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
    174  1.1  lukem 	$TESTOUT 2>&1 << EOMODS
    175  1.1  lukem dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
    176  1.1  lukem changetype: modify
    177  1.1  lukem add: drink
    178  1.1  lukem drink: Orange Juice
    179  1.1  lukem -
    180  1.1  lukem delete: sn
    181  1.1  lukem sn: Jones
    182  1.1  lukem -
    183  1.1  lukem add: sn
    184  1.1  lukem sn: Jones
    185  1.1  lukem 
    186  1.1  lukem dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    187  1.1  lukem changetype: modify
    188  1.1  lukem replace: drink
    189  1.1  lukem drink: Iced Tea
    190  1.1  lukem 
    191  1.1  lukem dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
    192  1.1  lukem changetype: modify
    193  1.1  lukem delete: uniquemember
    194  1.1  lukem uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
    195  1.1  lukem uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    196  1.1  lukem -
    197  1.1  lukem add: uniquemember
    198  1.1  lukem uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
    199  1.1  lukem uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
    200  1.1  lukem 
    201  1.1  lukem dn: cn=All Staff,ou=Groups,dc=example,dc=com
    202  1.1  lukem changetype: modify
    203  1.1  lukem delete: description
    204  1.1  lukem 
    205  1.1  lukem dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    206  1.1  lukem changetype: add
    207  1.1  lukem objectclass: OpenLDAPperson
    208  1.1  lukem cn: Gern Jensen
    209  1.1  lukem sn: Jensen
    210  1.1  lukem uid: gjensen
    211  1.1  lukem title: Chief Investigator, ITD
    212  1.1  lukem postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
    213  1.1  lukem seealso: cn=All Staff, ou=Groups, dc=example,dc=com
    214  1.1  lukem drink: Coffee
    215  1.1  lukem homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
    216  1.1  lukem description: Very odd
    217  1.1  lukem facsimiletelephonenumber: +1 313 555 7557
    218  1.1  lukem telephonenumber: +1 313 555 8343
    219  1.1  lukem mail: gjensen@mailgw.example.com
    220  1.1  lukem homephone: +1 313 555 8844
    221  1.1  lukem 
    222  1.1  lukem dn: ou=Retired, ou=People, dc=example,dc=com
    223  1.1  lukem changetype: add
    224  1.1  lukem objectclass: organizationalUnit
    225  1.1  lukem ou: Retired
    226  1.1  lukem 
    227  1.1  lukem dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
    228  1.1  lukem changetype: add
    229  1.1  lukem objectclass: OpenLDAPperson
    230  1.1  lukem cn: Rosco P. Coltrane
    231  1.1  lukem sn: Coltrane
    232  1.1  lukem uid: rosco
    233  1.1  lukem description: Fat tycoon
    234  1.1  lukem 
    235  1.1  lukem dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
    236  1.1  lukem changetype: modrdn
    237  1.1  lukem newrdn: cn=Rosco P. Coltrane
    238  1.1  lukem deleteoldrdn: 1
    239  1.1  lukem newsuperior: ou=Retired, ou=People, dc=example,dc=com
    240  1.1  lukem 
    241  1.1  lukem dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
    242  1.1  lukem changetype: delete
    243  1.1  lukem 
    244  1.1  lukem EOMODS
    245  1.1  lukem 
    246  1.1  lukem RC=$?
    247  1.1  lukem if test $RC != 0 ; then
    248  1.1  lukem 	echo "ldapmodify failed ($RC)!"
    249  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    250  1.1  lukem 	exit $RC
    251  1.1  lukem fi
    252  1.1  lukem 
    253  1.1  lukem echo "Using ldappasswd to change some passwords..."
    254  1.1  lukem $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
    255  1.1  lukem 	'cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
    256  1.1  lukem 	> $TESTOUT 2>&1
    257  1.1  lukem RC=$?
    258  1.1  lukem if test $RC != 0 ; then
    259  1.1  lukem 	echo "ldapmodify failed ($RC)!"
    260  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    261  1.1  lukem 	exit $RC
    262  1.1  lukem fi
    263  1.1  lukem 
    264  1.1  lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    265  1.1  lukem sleep $SLEEP1
    266  1.1  lukem 
    267  1.1  lukem echo "Stopping consumer to test recovery..."
    268  1.1  lukem kill -HUP $SLAVEPID
    269  1.1  lukem wait $SLAVEPID
    270  1.1  lukem 
    271  1.1  lukem echo "Modifying more entries on the producer..."
    272  1.1  lukem $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
    273  1.1  lukem 	$TESTOUT 2>&1 << EOMODS
    274  1.1  lukem dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
    275  1.1  lukem changetype: delete
    276  1.1  lukem 
    277  1.1  lukem dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    278  1.1  lukem changetype: modify
    279  1.1  lukem add: drink
    280  1.1  lukem drink: Mad Dog 20/20
    281  1.1  lukem 
    282  1.1  lukem dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
    283  1.1  lukem changetype: add
    284  1.1  lukem objectclass: OpenLDAPperson
    285  1.1  lukem sn: Coltrane
    286  1.1  lukem uid: rosco
    287  1.1  lukem cn: Rosco P. Coltrane
    288  1.1  lukem 
    289  1.1  lukem EOMODS
    290  1.1  lukem 
    291  1.1  lukem echo "Restarting consumer..."
    292  1.1  lukem echo "RESTART" >> $LOG4
    293  1.1  lukem $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
    294  1.1  lukem SLAVEPID=$!
    295  1.1  lukem if test $WAIT != 0 ; then
    296  1.1  lukem     echo SLAVEPID $SLAVEPID
    297  1.1  lukem     read foo
    298  1.1  lukem fi
    299  1.1  lukem KILLPIDS="$PID $SLAVEPID"
    300  1.1  lukem 
    301  1.1  lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    302  1.1  lukem sleep $SLEEP1
    303  1.1  lukem 
    304  1.1  lukem if test ! $BACKLDAP = "ldapno" ; then
    305  1.1  lukem 	echo "Try updating the consumer slapd..."
    306  1.1  lukem 	$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
    307  1.1  lukem 		$TESTOUT 2>&1 << EOMODS
    308  1.1  lukem dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
    309  1.1  lukem changetype: modify
    310  1.1  lukem add: description
    311  1.1  lukem description: This write must fail because directed to a shadow context,
    312  1.1  lukem description: unless the chain overlay is configured appropriately ;)
    313  1.1  lukem 
    314  1.1  lukem EOMODS
    315  1.1  lukem 
    316  1.1  lukem 	RC=$?
    317  1.1  lukem 	if test $RC != 0 ; then
    318  1.1  lukem 		echo "ldapmodify failed ($RC)!"
    319  1.1  lukem 		test $KILLSERVERS != no && kill -HUP $KILLPIDS
    320  1.1  lukem 		exit $RC
    321  1.1  lukem 	fi
    322  1.1  lukem 
    323  1.1  lukem 	# ITS#4964
    324  1.1  lukem 	echo "Trying to change some passwords on the consumer..."
    325  1.1  lukem 	$LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD \
    326  1.1  lukem 		'cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
    327  1.1  lukem 		> $TESTOUT 2>&1
    328  1.1  lukem 	RC=$?
    329  1.1  lukem 	if test $RC != 0 ; then
    330  1.1  lukem 		echo "ldapmodify failed ($RC)!"
    331  1.1  lukem 		test $KILLSERVERS != no && kill -HUP $KILLPIDS
    332  1.1  lukem 		exit $RC
    333  1.1  lukem 	fi
    334  1.1  lukem 
    335  1.1  lukem 	echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    336  1.1  lukem 	sleep $SLEEP1
    337  1.1  lukem fi
    338  1.1  lukem 
    339  1.1  lukem OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
    340  1.1  lukem 
    341  1.1  lukem echo "Using ldapsearch to read all the entries from the producer..."
    342  1.1  lukem $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
    343  1.1  lukem 	'(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
    344  1.1  lukem RC=$?
    345  1.1  lukem 
    346  1.1  lukem if test $RC != 0 ; then
    347  1.1  lukem 	echo "ldapsearch failed at producer ($RC)!"
    348  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    349  1.1  lukem 	exit $RC
    350  1.1  lukem fi
    351  1.1  lukem 
    352  1.1  lukem echo "Using ldapsearch to read all the entries from the consumer..."
    353  1.1  lukem $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
    354  1.1  lukem 	'(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
    355  1.1  lukem RC=$?
    356  1.1  lukem 
    357  1.1  lukem if test $RC != 0 ; then
    358  1.1  lukem 	echo "ldapsearch failed at consumer ($RC)!"
    359  1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    360  1.1  lukem 	exit $RC
    361  1.1  lukem fi
    362  1.1  lukem 
    363  1.1  lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
    364  1.1  lukem 
    365  1.1  lukem echo "Filtering producer results..."
    366  1.1  lukem . $LDIFFILTER < $MASTEROUT > $MASTERFLT
    367  1.1  lukem echo "Filtering consumer results..."
    368  1.1  lukem . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
    369  1.1  lukem 
    370  1.1  lukem echo "Comparing retrieved entries from producer and consumer..."
    371  1.1  lukem $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
    372  1.1  lukem 
    373  1.1  lukem if test $? != 0 ; then
    374  1.1  lukem 	echo "test failed - producer and consumer databases differ"
    375  1.1  lukem 	exit 1
    376  1.1  lukem fi
    377  1.1  lukem 
    378  1.1  lukem echo ">>>>> Test succeeded"
    379  1.1  lukem 
    380  1.1  lukem test $KILLSERVERS != no && wait
    381  1.1  lukem 
    382  1.1  lukem exit 0
    383