1#! /bin/sh 2## $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 2016-2021 The OpenLDAP Foundation. 6## All rights reserved. 7## 8## Redistribution and use in source and binary forms, with or without 9## modification, are permitted only as authorized by the OpenLDAP 10## Public License. 11## 12## A copy of this license is available in the file LICENSE in the 13## top-level directory of the distribution or, alternatively, at 14## <http://www.OpenLDAP.org/license.html>. 15## 16## ACKNOWLEDGEMENTS: 17## This module was written in 2016 by Ond��ej Kuzn��k for Symas Corp. 18 19echo "running defines.sh" 20. $SRCDIR/scripts/defines.sh 21 22if test "$SYNCPROV" = syncprovno; then 23 echo "Syncrepl provider overlay not available, test skipped" 24 exit 0 25fi 26 27. ${SCRIPTDIR}/common.sh 28 29if test "$SYNCPROV" = syncprovmod; then 30 $LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 31 > $TESTOUT 2>&1 <<EOMOD 32dn: cn=module{0},cn=config 33changetype: modify 34add: olcModuleLoad 35olcModuleLoad: $LDAP_BUILD/servers/slapd/overlays/syncprov.la 36EOMOD 37 38 RC=$? 39 if test $RC != 0 ; then 40 echo "ldapmodify failed ($RC)!" 41 test $KILLSERVERS != no && kill -HUP $KILLPIDS 42 exit $RC 43 fi 44fi 45 46echo "Configuring syncprov on the provider..." 47$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 48 > $TESTOUT 2>&1 <<EOMOD 49dn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config 50changetype: add 51objectclass: olcSyncProvConfig 52EOMOD 53RC=$? 54if test $RC != 0 ; then 55 echo "ldapmodify failed ($RC)!" 56 test $KILLSERVERS != no && kill -HUP $KILLPIDS 57 exit $RC 58fi 59 60mkdir $DBDIR4 $TESTDIR/confdir-consumer 61 62echo "Starting consumer slapd on TCP/IP port $PORT4..." 63. $CONFFILTER $BACKEND $MONITORDB < $P1SRCONSUMERCONF > $CONF4 64 65echo "database config" >>$CONF4 66echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >>$CONF4 67 68$SLAPD -f $CONF4 -F $TESTDIR/confdir-consumer -h $URI4 -d $LVL > $LOG4 2>&1 & 69CONSUMERPID=$! 70if test $WAIT != 0 ; then 71 echo CONSUMERPID $CONSUMERPID 72 read foo 73fi 74KILLPIDS="$KILLPIDS $CONSUMERPID" 75 76sleep $SLEEP0 77 78echo "Setting up variant overlay on consumer..." 79$LDAPSEARCH -D cn=config -H $URI4 -y $CONFIGPWF \ 80 -s base -b 'cn=module{0},cn=config' 1.1 >$TESTOUT 2>&1 81RC=$? 82case $RC in 830) 84 $LDAPMODIFY -v -D cn=config -H $URI4 -y $CONFIGPWF \ 85 >> $TESTOUT 2>&1 <<EOMOD 86dn: cn=module{0},cn=config 87changetype: modify 88add: olcModuleLoad 89olcModuleLoad: `pwd`/../variant.la 90EOMOD 91 ;; 9232) 93 $LDAPMODIFY -v -D cn=config -H $URI4 -y $CONFIGPWF \ 94 >> $TESTOUT 2>&1 <<EOMOD 95dn: cn=module,cn=config 96changetype: add 97objectClass: olcModuleList 98olcModuleLoad: `pwd`/../variant.la 99EOMOD 100 ;; 101*) 102 echo "Failed testing for module load entry" 103 exit $RC; 104 ;; 105esac 106 107RC=$? 108if test $RC != 0 ; then 109 echo "ldapmodify failed ($RC)!" 110 test $KILLSERVERS != no && kill -HUP $KILLPIDS 111 exit $RC 112fi 113 114. $CONFFILTER $BACKEND $MONITORDB < $OVERLAY_CONFIG | \ 115$LDAPMODIFY -v -D cn=config -H $URI4 -y $CONFIGPWF \ 116 > $TESTOUT 2>&1 117RC=$? 118if test $RC != 0 ; then 119 echo "ldapmodify failed ($RC)!" 120 test $KILLSERVERS != no && kill -HUP $KILLPIDS 121 exit $RC 122fi 123 124for i in 0 1 2 3 4 5; do 125 $LDAPSEARCH -s base -b "$BASEDN" -H $URI4 \ 126 'objectclass=*' > /dev/null 2>&1 127 RC=$? 128 if test $RC = 0 ; then 129 break 130 fi 131 echo "Waiting ${SLEEP1} seconds for consumer to start replication..." 132 sleep ${SLEEP1} 133done 134 135echo "Waiting ${SLEEP1} seconds for consumer to finish replicating..." 136sleep ${SLEEP1} 137 138echo "Testing searches against regular entries..." 139echo "# Testing searches against regular entries..." >> $SEARCHOUT 140$LDAPSEARCH -b "$BASEDN" -H $URI4 \ 141 "(|(name=Elliot)(description=*hiker*))" \ 142 >> $SEARCHOUT 2>&1 143RC=$? 144if test $RC != 0 ; then 145 echo "ldapsearch failed ($RC)!" 146 test $KILLSERVERS != no && kill -HUP $KILLPIDS 147 exit $RC 148fi 149 150echo "Testing searches listing replicated variants..." 151echo >> $SEARCHOUT 152echo "# Testing searches listing replicated variants..." >> $SEARCHOUT 153$LDAPSEARCH -b "$BASEDN" -s one -H $URI4 \ 154 >> $SEARCHOUT 2>&1 155RC=$? 156if test $RC != 0 ; then 157 echo "ldapsearch failed ($RC)!" 158 test $KILLSERVERS != no && kill -HUP $KILLPIDS 159 exit $RC 160fi 161 162echo >> $SEARCHOUT 163$LDAPSEARCH -b "$BASEDN" -s base -H $URI4 \ 164 >> $SEARCHOUT 2>&1 165RC=$? 166if test $RC != 0 ; then 167 echo "ldapsearch failed ($RC)!" 168 test $KILLSERVERS != no && kill -HUP $KILLPIDS 169 exit $RC 170fi 171 172echo >> $SEARCHOUT 173$LDAPSEARCH -s base -H $URI4 \ 174 -b "cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN" \ 175 '(ou=Information Technology Division)' \ 176 >> $SEARCHOUT 2>&1 177RC=$? 178if test $RC != 0 ; then 179 echo "ldapsearch failed ($RC)!" 180 test $KILLSERVERS != no && kill -HUP $KILLPIDS 181 exit $RC 182fi 183 184echo >> $SEARCHOUT 185$LDAPSEARCH -b "cn=ITD Staff,ou=Groups,$BASEDN" -s base -H $URI4 \ 186 >> $SEARCHOUT 2>&1 187RC=$? 188if test $RC != 0 ; then 189 echo "ldapsearch failed ($RC)!" 190 test $KILLSERVERS != no && kill -HUP $KILLPIDS 191 exit $RC 192fi 193 194echo "Testing searches filtering on replicated variants..." 195echo >> $SEARCHOUT 196echo "# Testing searches filtering on replicated variants..." >> $SEARCHOUT 197$LDAPSEARCH -b "$BASEDN" -H $URI4 \ 198 "(st=Alumni Association)" st \ 199 >> $SEARCHOUT 2>&1 200RC=$? 201if test $RC != 0 ; then 202 echo "ldapsearch failed ($RC)!" 203 test $KILLSERVERS != no && kill -HUP $KILLPIDS 204 exit $RC 205fi 206 207test $KILLSERVERS != no && kill -HUP $KILLPIDS 208 209LDIF=data/test003-out.ldif 210 211echo "Filtering ldapsearch results..." 212$LDIFFILTER -s e < $SEARCHOUT > $SEARCHFLT 213echo "Filtering expected entries..." 214$LDIFFILTER -s e < $LDIF > $LDIFFLT 215echo "Comparing filter output..." 216$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 217 218if test $? != 0 ; then 219 echo "Comparison failed" 220 exit 1 221fi 222 223echo ">>>>> Test succeeded" 224 225test $KILLSERVERS != no && wait 226 227exit 0 228