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 DSADM=`command -v dsadm`
     20      1.1  christos if test -z "$DSADM"; then
     21      1.1  christos 	echo "DSEE dsadm not in path, test skipped"
     22      1.1  christos 	exit 0
     23      1.1  christos fi 
     24      1.1  christos 
     25      1.1  christos mkdir -p $TESTDIR $DBDIR2
     26      1.1  christos 
     27      1.1  christos #
     28      1.1  christos # Test replication:
     29      1.1  christos # - start provider
     30      1.1  christos # - start consumer
     31      1.1  christos # - populate over ldap
     32      1.1  christos # - perform some modifies and deleted
     33      1.1  christos # - attempt to modify the consumer (referral)
     34      1.1  christos # - retrieve database over ldap and compare against expected results
     35      1.1  christos #
     36      1.1  christos 
     37      1.1  christos DSEEPW=secret21
     38      1.1  christos DSEEDN="cn=Directory Manager"
     39      1.1  christos DSEEPWF=$TESTDIR/dseepw
     40      1.1  christos 
     41      1.1  christos echo "secret21" > $DSEEPWF
     42      1.1  christos 
     43      1.1  christos echo "Setting up DSEE provider slapd on TCP/IP port $PORT1..."
     44      1.1  christos dsadm create -p $PORT1 -w $DSEEPWF $DBDIR1
     45      1.1  christos dsadm start $DBDIR1
     46      1.1  christos dsconf create-suffix -c -p $PORT1 -w $DSEEPWF $BASEDN
     47      1.1  christos dsconf set-server-prop -p $PORT1 -w $DSEEPWF moddn-enabled:on
     48      1.1  christos dsconf set-server-prop -p $PORT1 -w $DSEEPWF retro-cl-enabled:on
     49      1.1  christos dsadm restart $DBDIR1
     50      1.1  christos KILLPIDS=`basename $DBDIR1/locks/server/*`
     51      1.1  christos 
     52      1.1  christos sleep 1
     53      1.1  christos 
     54      1.1  christos echo "Using ldapsearch to check that provider slapd is running..."
     55      1.1  christos for i in 0 1 2 3 4 5; do
     56      1.1  christos 	$LDAPSEARCH -s base -b "$BASEDN" -H $URI1 \
     57      1.1  christos 		'objectclass=*' > /dev/null 2>&1
     58      1.1  christos 	RC=$?
     59      1.1  christos 	if test $RC = 0 ; then
     60      1.1  christos 		break
     61      1.1  christos 	fi
     62      1.1  christos 	echo "Waiting 5 seconds for slapd to start..."
     63      1.1  christos 	sleep 5
     64      1.1  christos done
     65      1.1  christos 
     66      1.1  christos if test $RC != 0 ; then
     67      1.1  christos 	echo "ldapsearch failed ($RC)!"
     68      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     69      1.1  christos 	exit $RC
     70      1.1  christos fi
     71      1.1  christos 
     72      1.1  christos echo "Starting consumer slapd on TCP/IP port $PORT2..."
     73      1.1  christos . $CONFFILTER $BACKEND < $DSEESYNC1CONF > $CONF2
     74      1.1  christos $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
     75      1.1  christos CONSUMERPID=$!
     76      1.1  christos if test $WAIT != 0 ; then
     77      1.1  christos     echo CONSUMERPID $CONSUMERPID
     78      1.1  christos     read foo
     79      1.1  christos fi
     80      1.1  christos KILLPIDS="$KILLPIDS $CONSUMERPID"
     81      1.1  christos 
     82      1.1  christos sleep 1
     83      1.1  christos 
     84      1.1  christos echo "Using ldapsearch to check that consumer slapd is running..."
     85      1.1  christos for i in 0 1 2 3 4 5; do
     86      1.1  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
     87      1.1  christos 		'objectclass=*' > /dev/null 2>&1
     88      1.1  christos 	RC=$?
     89      1.1  christos 	if test $RC = 0 ; then
     90      1.1  christos 		break
     91      1.1  christos 	fi
     92      1.1  christos 	echo "Waiting 5 seconds for slapd to start..."
     93      1.1  christos 	sleep 5
     94      1.1  christos done
     95      1.1  christos 
     96      1.1  christos if test $RC != 0 ; then
     97      1.1  christos 	echo "ldapsearch failed ($RC)!"
     98      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     99      1.1  christos 	exit $RC
    100      1.1  christos fi
    101      1.1  christos 
    102      1.1  christos # using LDIFDIRSYNCNOCP to avoid custom OpenLDAP schema
    103      1.1  christos echo "Using ldapadd to populate the provider directory..."
    104      1.1  christos $LDAPADD -D "$DSEEDN" -H $URI1 -w $DSEEPW < \
    105      1.1  christos 	$LDIFDIRSYNCNOCP > /dev/null 2>&1
    106      1.1  christos RC=$?
    107      1.1  christos if test $RC != 0 ; then
    108      1.1  christos 	echo "ldapadd failed ($RC)!"
    109      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    110      1.1  christos 	exit $RC
    111      1.1  christos fi
    112      1.1  christos 
    113      1.1  christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    114      1.1  christos sleep $SLEEP1
    115      1.1  christos 
    116      1.1  christos echo "Using ldapmodify to modify provider directory..."
    117      1.1  christos 
    118      1.1  christos #
    119      1.1  christos # Do some modifications
    120      1.1  christos #
    121      1.1  christos 
    122      1.1  christos $LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW > \
    123      1.1  christos 	$TESTOUT 2>&1 << EOMODS
    124      1.1  christos dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
    125      1.1  christos changetype: modify
    126      1.1  christos add: carLicense
    127      1.1  christos carLicense: Orange Juice
    128      1.1  christos -
    129      1.1  christos delete: sn
    130      1.1  christos sn: Jones
    131      1.1  christos -
    132      1.1  christos add: sn
    133      1.1  christos sn: Jones
    134      1.1  christos 
    135      1.1  christos dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    136      1.1  christos changetype: modify
    137      1.1  christos replace: carLicense
    138      1.1  christos carLicense: Iced Tea
    139      1.1  christos carLicense: Mad Dog 20/20
    140      1.1  christos 
    141      1.1  christos dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
    142      1.1  christos changetype: modify
    143      1.1  christos delete: uniquemember
    144      1.1  christos uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
    145      1.1  christos uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
    146      1.1  christos -
    147      1.1  christos add: uniquemember
    148      1.1  christos uniquemember: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
    149      1.1  christos uniquemember: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
    150      1.1  christos 
    151      1.1  christos dn: cn=All Staff,ou=Groups,dc=example,dc=com
    152      1.1  christos changetype: modify
    153      1.1  christos delete: description
    154      1.1  christos 
    155      1.1  christos dn: cn=Gern Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
    156      1.1  christos changetype: add
    157      1.1  christos objectclass: inetOrgPerson
    158      1.1  christos cn: Gern Jensen
    159      1.1  christos sn: Jensen
    160      1.1  christos uid: gjensen
    161      1.1  christos title: Chief Investigator, ITD
    162      1.1  christos postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
    163      1.1  christos seealso: cn=All Staff,ou=Groups,dc=example,dc=com
    164      1.1  christos carLicense: Coffee
    165      1.1  christos homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
    166      1.1  christos description: Very odd
    167      1.1  christos facsimiletelephonenumber: +1 313 555 7557
    168      1.1  christos telephonenumber: +1 313 555 8343
    169      1.1  christos mail: gjensen@mailgw.example.com
    170      1.1  christos homephone: +1 313 555 8844
    171      1.1  christos 
    172      1.1  christos dn: ou=Retired,ou=People,dc=example,dc=com
    173      1.1  christos changetype: add
    174      1.1  christos objectclass: organizationalUnit
    175      1.1  christos ou: Retired
    176      1.1  christos 
    177      1.1  christos dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
    178      1.1  christos changetype: add
    179      1.1  christos objectclass: inetOrgPerson
    180      1.1  christos cn: Rosco P. Coltrane
    181      1.1  christos sn: Coltrane
    182      1.1  christos uid: rosco
    183      1.1  christos 
    184      1.1  christos dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
    185      1.1  christos changetype: modrdn
    186      1.1  christos newrdn: cn=Rosco P. Coltrane
    187      1.1  christos deleteoldrdn: 1
    188      1.1  christos newsuperior: ou=Retired,ou=People,dc=example,dc=com
    189      1.1  christos 
    190      1.1  christos dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
    191      1.1  christos changetype: delete
    192      1.1  christos 
    193      1.1  christos dn: ou=testdomain1,dc=example,dc=com
    194      1.1  christos changetype: modrdn
    195      1.1  christos newrdn: ou=itsdomain1
    196      1.1  christos deleteoldrdn: 1
    197      1.1  christos 
    198      1.1  christos dn: ou=itsdomain1,dc=example,dc=com
    199      1.1  christos changetype: modify
    200      1.1  christos replace: description
    201      1.1  christos description: Example, Inc. ITS test domain
    202      1.1  christos 
    203      1.1  christos EOMODS
    204      1.1  christos 
    205      1.1  christos RC=$?
    206      1.1  christos if test $RC != 0 ; then
    207      1.1  christos 	echo "ldapmodify failed ($RC)!"
    208      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    209      1.1  christos 	exit $RC
    210      1.1  christos fi
    211      1.1  christos 
    212      1.1  christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    213      1.1  christos sleep $SLEEP1
    214      1.1  christos 
    215      1.1  christos echo "Performing modrdn alone on the provider..."
    216      1.1  christos $LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW > \
    217      1.1  christos 	$TESTOUT 2>&1 << EOMODS
    218      1.1  christos dn: ou=testdomain2,dc=example,dc=com
    219      1.1  christos changetype: modrdn
    220      1.1  christos newrdn: ou=itsdomain2
    221      1.1  christos deleteoldrdn: 1
    222      1.1  christos 
    223      1.1  christos EOMODS
    224      1.1  christos 
    225      1.1  christos RC=$?
    226      1.1  christos if test $RC != 0 ; then
    227      1.1  christos 	echo "ldapmodify failed ($RC)!"
    228      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    229      1.1  christos 	exit $RC
    230      1.1  christos fi
    231      1.1  christos 
    232      1.1  christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    233      1.1  christos sleep $SLEEP1
    234      1.1  christos 
    235      1.1  christos echo "Performing modify alone on the provider..."
    236      1.1  christos $LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW > \
    237      1.1  christos 	$TESTOUT 2>&1 << EOMODS
    238      1.1  christos dn: ou=itsdomain2,dc=example,dc=com
    239      1.1  christos changetype: modify
    240      1.1  christos replace: description
    241      1.1  christos description: Example, Inc. itsdomain2 test domain
    242      1.1  christos 
    243      1.1  christos EOMODS
    244      1.1  christos 
    245      1.1  christos RC=$?
    246      1.1  christos if test $RC != 0 ; then
    247      1.1  christos 	echo "ldapmodify failed ($RC)!"
    248      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    249      1.1  christos 	exit $RC
    250      1.1  christos fi
    251      1.1  christos 
    252      1.1  christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    253      1.1  christos sleep $SLEEP1
    254      1.1  christos 
    255      1.1  christos echo "Performing larger modify on the provider..."
    256      1.1  christos $LDAPMODIFY -v -D "$DSEEDN" -H $URI1 -w $DSEEPW > \
    257      1.1  christos 	$TESTOUT 2>&1 << EOMODS
    258      1.1  christos dn: cn=Alumni Assoc Staff,ou=Groups,dc=example,dc=com
    259      1.1  christos changetype: modify
    260      1.1  christos replace: cn
    261      1.1  christos cn: Alumni Assoc Staff
    262      1.1  christos -
    263      1.1  christos replace: description
    264      1.1  christos description: blablabla
    265      1.1  christos -
    266      1.1  christos replace: member
    267      1.1  christos member: cn=Manager,dc=example,dc=com
    268      1.1  christos member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
    269      1.1  christos member: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
    270      1.1  christos member: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com
    271      1.1  christos member: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
    272      1.1  christos member: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
    273      1.1  christos member: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
    274      1.1  christos 
    275      1.1  christos EOMODS
    276      1.1  christos 
    277      1.1  christos RC=$?
    278      1.1  christos if test $RC != 0 ; then
    279      1.1  christos 	echo "ldapmodify failed ($RC)!"
    280      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    281      1.1  christos 	exit $RC
    282      1.1  christos fi
    283      1.1  christos 
    284      1.1  christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    285      1.1  christos sleep $SLEEP1
    286      1.1  christos 
    287      1.1  christos OPATTRS="creatorsName createTimestamp modifiersName modifyTimestamp"
    288      1.1  christos 
    289      1.1  christos echo "Using ldapsearch to read all the entries from the provider..."
    290      1.1  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    291      1.1  christos 	-D "$DSEEDN" -w $DSEEPW \
    292      1.1  christos 	'(objectclass=*)' '*' $OPATTRS > $PROVIDEROUT 2>&1
    293      1.1  christos RC=$?
    294      1.1  christos 
    295      1.1  christos if test $RC != 0 ; then
    296      1.1  christos 	echo "ldapsearch failed at provider ($RC)!"
    297      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    298      1.1  christos 	exit $RC
    299      1.1  christos fi
    300      1.1  christos 
    301      1.1  christos echo "Using ldapsearch to read all the entries from the consumer..."
    302      1.1  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
    303      1.1  christos 	'(objectclass=*)' '*' $OPATTRS > $CONSUMEROUT 2>&1
    304      1.1  christos RC=$?
    305      1.1  christos 
    306      1.1  christos if test $RC != 0 ; then
    307      1.1  christos 	echo "ldapsearch failed at consumer ($RC)!"
    308      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    309      1.1  christos 	exit $RC
    310      1.1  christos fi
    311      1.1  christos 
    312      1.1  christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
    313      1.1  christos 
    314      1.1  christos echo "Filtering provider results..."
    315      1.1  christos $LDIFFILTER -s a < $PROVIDEROUT > $PROVIDERFLT
    316      1.1  christos echo "Filtering consumer results..."
    317      1.1  christos $LDIFFILTER -s a < $CONSUMEROUT > $CONSUMERFLT
    318      1.1  christos 
    319      1.1  christos echo "Comparing retrieved entries from provider and consumer..."
    320      1.1  christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
    321      1.1  christos 
    322      1.1  christos if test $? != 0 ; then
    323      1.1  christos 	echo "test failed - provider and consumer databases differ"
    324      1.1  christos 	exit 1
    325      1.1  christos fi
    326      1.1  christos 
    327      1.1  christos echo ">>>>> Test succeeded"
    328      1.1  christos 
    329      1.1  christos test $KILLSERVERS != no && wait
    330      1.1  christos 
    331      1.1  christos exit 0
    332