Home | History | Annotate | Line # | Download | only in scripts
      1      1.1  christos #! /bin/sh
      2      1.1  christos # $OpenLDAP$
      3      1.1  christos ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
      4      1.1  christos ##
      5  1.1.1.2  christos ## Copyright 1998-2024 The OpenLDAP Foundation.
      6      1.1  christos ## All rights reserved.
      7      1.1  christos ##
      8      1.1  christos ## Redistribution and use in source and binary forms, with or without
      9      1.1  christos ## modification, are permitted only as authorized by the OpenLDAP
     10      1.1  christos ## Public License.
     11      1.1  christos ##
     12      1.1  christos ## A copy of this license is available in the file LICENSE in the
     13      1.1  christos ## top-level directory of the distribution or, alternatively, at
     14      1.1  christos ## <http://www.OpenLDAP.org/license.html>.
     15      1.1  christos 
     16      1.1  christos echo "running defines.sh"
     17      1.1  christos . $SRCDIR/scripts/defines.sh
     18      1.1  christos 
     19      1.1  christos OPATTRS="creatorsName createTimestamp modifiersName modifyTimestamp"
     20      1.1  christos 
     21      1.1  christos DSADM=`command -v dsadm`
     22      1.1  christos if test -z "$DSADM"; then
     23      1.1  christos 	echo "DSEE dsadm not in path, test skipped"
     24      1.1  christos 	exit 0
     25      1.1  christos fi
     26      1.1  christos 
     27      1.1  christos mkdir -p $TESTDIR $DBDIR4
     28      1.1  christos 
     29      1.1  christos #
     30      1.1  christos # Test replication:
     31      1.1  christos # - start provider
     32      1.1  christos # - start consumer
     33      1.1  christos # - populate over ldap
     34      1.1  christos # - perform some modifies and deleted
     35      1.1  christos # - attempt to modify the consumer (referral or chain)
     36      1.1  christos # - retrieve database over ldap and compare against expected results
     37      1.1  christos #
     38      1.1  christos 
     39      1.1  christos DSEEPW=secret21
     40      1.1  christos DSEEDN="cn=Directory Manager"
     41      1.1  christos DSEEPWF=$TESTDIR/dseepw
     42      1.1  christos 
     43      1.1  christos echo "secret21" > $DSEEPWF
     44      1.1  christos 
     45      1.1  christos echo "Setting up DSEE provider slapd on TCP/IP port $PORT1..."
     46      1.1  christos dsadm create -p $PORT1 -w $DSEEPWF $DBDIR1
     47      1.1  christos dsadm start $DBDIR1
     48      1.1  christos dsconf create-suffix -c -p $PORT1 -w $DSEEPWF $BASEDN
     49      1.1  christos dsconf set-server-prop -p $PORT1 -w $DSEEPWF moddn-enabled:on
     50      1.1  christos dsconf set-server-prop -p $PORT1 -w $DSEEPWF retro-cl-enabled:on
     51      1.1  christos dsadm restart $DBDIR1
     52      1.1  christos PID=`basename $DBDIR1/locks/server/*`
     53      1.1  christos KILLPIDS="$PID"
     54      1.1  christos 
     55      1.1  christos sleep 1
     56      1.1  christos 
     57      1.1  christos echo "Using ldapsearch to check that provider slapd is running..."
     58      1.1  christos for i in 0 1 2 3 4 5; do
     59      1.1  christos 	$LDAPSEARCH -s base -b "$BASEDN" -H $URI1 \
     60      1.1  christos 		'objectclass=*' > /dev/null 2>&1
     61      1.1  christos 	RC=$?
     62      1.1  christos 	if test $RC = 0 ; then
     63      1.1  christos 		break
     64      1.1  christos 	fi
     65      1.1  christos 	echo "Waiting 5 seconds for slapd to start..."
     66      1.1  christos 	sleep 5
     67      1.1  christos done
     68      1.1  christos 
     69      1.1  christos if test $RC != 0 ; then
     70      1.1  christos 	echo "ldapsearch failed ($RC)!"
     71      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     72      1.1  christos 	exit $RC
     73      1.1  christos fi
     74      1.1  christos 
     75      1.1  christos echo "Starting consumer slapd on TCP/IP port $PORT4..."
     76      1.1  christos . $CONFFILTER $BACKEND < $DSEESYNC2CONF > $CONF4
     77      1.1  christos $SLAPD -f $CONF4 -h $URI4 -d $LVL > $LOG4 2>&1 &
     78      1.1  christos CONSUMERPID=$!
     79      1.1  christos if test $WAIT != 0 ; then
     80      1.1  christos     echo CONSUMERPID $CONSUMERPID
     81      1.1  christos     read foo
     82      1.1  christos fi
     83      1.1  christos KILLPIDS="$KILLPIDS $CONSUMERPID"
     84      1.1  christos 
     85      1.1  christos sleep 1
     86      1.1  christos 
     87      1.1  christos echo "Using ldapsearch to check that consumer slapd is running..."
     88      1.1  christos for i in 0 1 2 3 4 5; do
     89      1.1  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI4 \
     90      1.1  christos 		'objectclass=*' > /dev/null 2>&1
     91      1.1  christos 	RC=$?
     92      1.1  christos 	if test $RC = 0 ; then
     93      1.1  christos 		break
     94      1.1  christos 	fi
     95      1.1  christos 	echo "Waiting 5 seconds for slapd to start..."
     96      1.1  christos 	sleep 5
     97      1.1  christos done
     98      1.1  christos 
     99      1.1  christos if test $RC != 0 ; then
    100      1.1  christos 	echo "ldapsearch failed ($RC)!"
    101      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    102      1.1  christos 	exit $RC
    103      1.1  christos fi
    104      1.1  christos 
    105      1.1  christos # using LDIFDIRSYNCNOCP to avoid custom OpenLDAP schema
    106      1.1  christos echo "Using ldapadd to populate the provider directory..."
    107      1.1  christos $LDAPADD -D "$DSEEDN" -H $URI1 -w $DSEEPW < \
    108      1.1  christos 	$LDIFDIRSYNCNOCP > /dev/null 2>&1
    109      1.1  christos RC=$?
    110      1.1  christos if test $RC != 0 ; then
    111      1.1  christos 	echo "ldapadd failed ($RC)!"
    112      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    113      1.1  christos 	exit $RC
    114      1.1  christos fi
    115      1.1  christos 
    116      1.1  christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    117      1.1  christos sleep $SLEEP1
    118      1.1  christos 
    119      1.1  christos echo "Using ldapsearch to read all the entries from the provider..."
    120      1.1  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    121      1.1  christos 	-D "$DSEEDN" -w "$DSEEPW" \
    122      1.1  christos 	'(objectclass=*)' '*' $OPATTRS > $PROVIDEROUT 2>&1
    123      1.1  christos RC=$?
    124      1.1  christos 
    125      1.1  christos if test $RC != 0 ; then
    126      1.1  christos 	echo "ldapsearch failed at provider ($RC)!"
    127      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    128      1.1  christos 	exit $RC
    129      1.1  christos fi
    130      1.1  christos 
    131      1.1  christos echo "Using ldapsearch to read all the entries from the consumer..."
    132      1.1  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI4 \
    133      1.1  christos 	'(objectclass=*)' '*' $OPATTRS > $CONSUMEROUT 2>&1
    134      1.1  christos RC=$?
    135      1.1  christos 
    136      1.1  christos if test $RC != 0 ; then
    137      1.1  christos 	echo "ldapsearch failed at consumer ($RC)!"
    138      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    139      1.1  christos 	exit $RC
    140      1.1  christos fi
    141      1.1  christos 
    142      1.1  christos echo "Filtering provider results..."
    143      1.1  christos $LDIFFILTER -s a < $PROVIDEROUT > $PROVIDERFLT
    144      1.1  christos echo "Filtering consumer results..."
    145      1.1  christos $LDIFFILTER -s a < $CONSUMEROUT > $CONSUMERFLT
    146      1.1  christos 
    147      1.1  christos echo "Comparing retrieved entries from provider and consumer..."
    148      1.1  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    149      1.1  christos 
    150      1.1  christos if test $? != 0 ; then
    151      1.1  christos 	echo "test failed - provider and consumer databases differ"
    152      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    153      1.1  christos 	exit 1
    154      1.1  christos fi
    155      1.1  christos 
    156      1.1  christos echo "Stopping the provider, sleeping 10 seconds and restarting it..."
    157      1.1  christos kill -HUP "$PID"
    158      1.1  christos wait $PID
    159      1.1  christos sleep 10
    160      1.1  christos echo "RESTART" >> $LOG1
    161      1.1  christos dsadm start $DBDIR1
    162      1.1  christos PID=`basename $DBDIR1/locks/server/*`
    163      1.1  christos if test $WAIT != 0 ; then
    164      1.1  christos     echo PID $PID
    165      1.1  christos     read foo
    166      1.1  christos fi
    167      1.1  christos KILLPIDS="$PID $CONSUMERPID"
    168      1.1  christos 
    169      1.1  christos sleep 1
    170      1.1  christos 
    171      1.1  christos echo "Using ldapsearch to check that provider slapd is running..."
    172      1.1  christos for i in 0 1 2 3 4 5; do
    173      1.1  christos 	$LDAPSEARCH -s base -b "$BASEDN" -H $URI1 \
    174      1.1  christos 		'objectclass=*' > /dev/null 2>&1
    175      1.1  christos 	RC=$?
    176      1.1  christos 	if test $RC = 0 ; then
    177      1.1  christos 		break
    178      1.1  christos 	fi
    179      1.1  christos 	echo "Waiting 5 seconds for slapd to start..."
    180      1.1  christos 	sleep 5
    181      1.1  christos done
    182      1.1  christos 
    183      1.1  christos echo "Waiting $SLEEP1 seconds for consumer to reconnect..."
    184      1.1  christos sleep $SLEEP1
    185      1.1  christos 
    186      1.1  christos if test $RC != 0 ; then
    187      1.1  christos 	echo "ldapsearch failed ($RC)!"
    188      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    189      1.1  christos 	exit $RC
    190      1.1  christos fi
    191      1.1  christos 
    192      1.1  christos echo "Using ldapmodify to modify provider directory..."
    193      1.1  christos 
    194      1.1  christos #
    195      1.1  christos # Do some modifications
    196      1.1  christos #
    197      1.1  christos 
    198      1.1  christos $LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW > \
    199      1.1  christos 	$TESTOUT 2>&1 << EOMODS
    200      1.1  christos dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
    201      1.1  christos changetype: modify
    202      1.1  christos add: carLicense
    203      1.1  christos carLicense: Orange Juice
    204      1.1  christos -
    205      1.1  christos delete: sn
    206      1.1  christos sn: Jones
    207      1.1  christos -
    208      1.1  christos add: sn
    209      1.1  christos sn: Jones
    210      1.1  christos 
    211      1.1  christos dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    212      1.1  christos changetype: modify
    213      1.1  christos replace: carLicense
    214      1.1  christos carLicense: Iced Tea
    215      1.1  christos 
    216      1.1  christos dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
    217      1.1  christos changetype: modify
    218      1.1  christos delete: uniquemember
    219      1.1  christos uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
    220      1.1  christos uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    221      1.1  christos -
    222      1.1  christos add: uniquemember
    223      1.1  christos uniquemember: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
    224      1.1  christos uniquemember: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
    225      1.1  christos 
    226      1.1  christos dn: cn=All Staff,ou=Groups,dc=example,dc=com
    227      1.1  christos changetype: modify
    228      1.1  christos delete: description
    229      1.1  christos 
    230      1.1  christos dn: cn=Gern Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
    231      1.1  christos changetype: add
    232      1.1  christos objectclass: inetOrgPerson
    233      1.1  christos cn: Gern Jensen
    234      1.1  christos sn: Jensen
    235      1.1  christos uid: gjensen
    236      1.1  christos title: Chief Investigator, ITD
    237      1.1  christos postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
    238      1.1  christos seealso: cn=All Staff,ou=Groups,dc=example,dc=com
    239      1.1  christos carLicense: Coffee
    240      1.1  christos homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
    241      1.1  christos description: Very odd
    242      1.1  christos facsimiletelephonenumber: +1 313 555 7557
    243      1.1  christos facsimiletelephonenumber: +1 313 555 9998
    244      1.1  christos facsimiletelephonenumber: +1 313 555 9999
    245      1.1  christos telephonenumber: +1 313 555 8343
    246      1.1  christos mail: gjensen@mailgw.example.com
    247      1.1  christos homephone: +1 313 555 8844
    248      1.1  christos 
    249      1.1  christos # modify attribute with no matching rule (ITS#6458)
    250      1.1  christos dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    251      1.1  christos changetype: modify
    252      1.1  christos replace: facsimiletelephonenumber
    253      1.1  christos facsimiletelephonenumber: +1 313 555 9998
    254      1.1  christos facsimiletelephonenumber: +1 313 555 9999
    255      1.1  christos 
    256      1.1  christos dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    257      1.1  christos changetype: modify
    258      1.1  christos replace: facsimiletelephonenumber
    259      1.1  christos facsimiletelephonenumber: +1 313 555 9998
    260      1.1  christos facsimiletelephonenumber: +1 313 555 9999
    261      1.1  christos facsimiletelephonenumber: +1 313 555 7557
    262      1.1  christos 
    263      1.1  christos dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    264      1.1  christos changetype: modify
    265      1.1  christos replace: facsimiletelephonenumber
    266      1.1  christos facsimiletelephonenumber: +1 313 555 9998
    267      1.1  christos facsimiletelephonenumber: +1 313 555 9999
    268      1.1  christos 
    269      1.1  christos dn: ou=Retired,ou=People,dc=example,dc=com
    270      1.1  christos changetype: add
    271      1.1  christos objectclass: organizationalUnit
    272      1.1  christos ou: Retired
    273      1.1  christos 
    274      1.1  christos dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
    275      1.1  christos changetype: add
    276      1.1  christos objectclass: inetOrgPerson
    277      1.1  christos cn: Rosco P. Coltrane
    278      1.1  christos sn: Coltrane
    279      1.1  christos uid: rosco
    280      1.1  christos description: Fat tycoon
    281      1.1  christos 
    282      1.1  christos dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
    283      1.1  christos changetype: modrdn
    284      1.1  christos newrdn: cn=Rosco P. Coltrane
    285      1.1  christos deleteoldrdn: 1
    286      1.1  christos newsuperior: ou=Retired,ou=People,dc=example,dc=com
    287      1.1  christos 
    288      1.1  christos dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
    289      1.1  christos changetype: delete
    290      1.1  christos 
    291      1.1  christos dn: ou=testdomain1,dc=example,dc=com
    292      1.1  christos changetype: modrdn
    293      1.1  christos newrdn: ou=itsdomain1
    294      1.1  christos deleteoldrdn: 1
    295      1.1  christos 
    296      1.1  christos dn: ou=itsdomain1,dc=example,dc=com
    297      1.1  christos changetype: modify
    298      1.1  christos replace: description
    299      1.1  christos description: Example, Inc. ITS test domain
    300      1.1  christos 
    301      1.1  christos dn: ou=testdomain2,dc=example,dc=com
    302      1.1  christos changetype: modrdn
    303      1.1  christos newrdn: ou=itsdomain2
    304      1.1  christos deleteoldrdn: 1
    305      1.1  christos 
    306      1.1  christos EOMODS
    307      1.1  christos 
    308      1.1  christos RC=$?
    309      1.1  christos if test $RC != 0 ; then
    310      1.1  christos 	echo "ldapmodify failed ($RC)!"
    311      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    312      1.1  christos 	exit $RC
    313      1.1  christos fi
    314      1.1  christos 
    315      1.1  christos ## ldappasswd test removed, not supported on DSEE
    316      1.1  christos 
    317      1.1  christos echo "Stopping consumer to test recovery..."
    318      1.1  christos kill -HUP $CONSUMERPID
    319      1.1  christos wait $CONSUMERPID
    320      1.1  christos 
    321      1.1  christos echo "Modifying more entries on the provider..."
    322      1.1  christos $LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW >> \
    323      1.1  christos 	$TESTOUT 2>&1 << EOMODS
    324      1.1  christos dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
    325      1.1  christos changetype: delete
    326      1.1  christos 
    327      1.1  christos dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    328      1.1  christos changetype: modify
    329      1.1  christos add: carLicense
    330      1.1  christos carLicense: Mad Dog 20/20
    331      1.1  christos 
    332      1.1  christos dn: cn=Rosco P. Coltrane,ou=Retired,ou=People,dc=example,dc=com
    333      1.1  christos changetype: add
    334      1.1  christos objectclass: inetOrgPerson
    335      1.1  christos sn: Coltrane
    336      1.1  christos uid: rosco
    337      1.1  christos cn: Rosco P. Coltrane
    338      1.1  christos 
    339      1.1  christos dn: ou=itsdomain2,dc=example,dc=com
    340      1.1  christos changetype: modify
    341      1.1  christos replace: description
    342      1.1  christos description: Example, Inc. itsdomain2 test domain
    343      1.1  christos 
    344      1.1  christos # rename with a newly added newSuperior while the consumer is down (ITS#6472)
    345      1.1  christos dn: ou=New Branch,dc=example,dc=com
    346      1.1  christos changetype: add
    347      1.1  christos objectClass: organizationalUnit
    348      1.1  christos ou: New Branch
    349      1.1  christos 
    350      1.1  christos dn: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
    351      1.1  christos changetype: modrdn
    352      1.1  christos newrdn: cn=Dorothy Stevens
    353      1.1  christos deleteoldrdn: 0
    354      1.1  christos newsuperior: ou=New Branch,dc=example,dc=com
    355      1.1  christos 
    356      1.1  christos EOMODS
    357      1.1  christos 
    358      1.1  christos RC=$?
    359      1.1  christos if test $RC != 0 ; then
    360      1.1  christos 	echo "ldapmodify failed ($RC)!"
    361      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    362      1.1  christos 	exit $RC
    363      1.1  christos fi
    364      1.1  christos 
    365      1.1  christos echo "Restarting consumer..."
    366      1.1  christos echo "RESTART" >> $LOG4
    367      1.1  christos $SLAPD -f $CONF4 -h $URI4 -d $LVL >> $LOG4 2>&1 &
    368      1.1  christos CONSUMERPID=$!
    369      1.1  christos if test $WAIT != 0 ; then
    370      1.1  christos     echo CONSUMERPID $CONSUMERPID
    371      1.1  christos     read foo
    372      1.1  christos fi
    373      1.1  christos KILLPIDS="$PID $CONSUMERPID"
    374      1.1  christos 
    375      1.1  christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    376      1.1  christos sleep $SLEEP1
    377      1.1  christos 
    378      1.1  christos echo "Using ldapsearch to read all the entries from the provider..."
    379      1.1  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    380      1.1  christos 	-D "$DSEEDN" -w "$DSEEPW" \
    381      1.1  christos 	'(objectclass=*)' '*' $OPATTRS > $PROVIDEROUT 2>&1
    382      1.1  christos RC=$?
    383      1.1  christos 
    384      1.1  christos if test $RC != 0 ; then
    385      1.1  christos 	echo "ldapsearch failed at provider ($RC)!"
    386      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    387      1.1  christos 	exit $RC
    388      1.1  christos fi
    389      1.1  christos 
    390      1.1  christos echo "Using ldapsearch to read all the entries from the consumer..."
    391      1.1  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI4 \
    392      1.1  christos 	'(objectclass=*)' '*' $OPATTRS > $CONSUMEROUT 2>&1
    393      1.1  christos RC=$?
    394      1.1  christos 
    395      1.1  christos if test $RC != 0 ; then
    396      1.1  christos 	echo "ldapsearch failed at consumer ($RC)!"
    397      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    398      1.1  christos 	exit $RC
    399      1.1  christos fi
    400      1.1  christos 
    401      1.1  christos echo "Filtering provider results..."
    402      1.1  christos $LDIFFILTER -s a < $PROVIDEROUT > $PROVIDERFLT
    403      1.1  christos echo "Filtering consumer results..."
    404      1.1  christos $LDIFFILTER -s a < $CONSUMEROUT > $CONSUMERFLT
    405      1.1  christos 
    406      1.1  christos echo "Comparing retrieved entries from provider and consumer..."
    407      1.1  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    408      1.1  christos 
    409      1.1  christos if test $? != 0 ; then
    410      1.1  christos 	echo "test failed - provider and consumer databases differ"
    411      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    412      1.1  christos 	exit 1
    413      1.1  christos fi
    414      1.1  christos 
    415      1.1  christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
    416      1.1  christos 
    417      1.1  christos echo ">>>>> Test succeeded"
    418      1.1  christos 
    419      1.1  christos test $KILLSERVERS != no && wait
    420      1.1  christos 
    421      1.1  christos exit 0
    422