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 29$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 30 > $TESTOUT 2>&1 <<EOMOD 31dn: olcOverlay={0}variant,olcDatabase={1}$BACKEND,cn=config 32changetype: modify 33replace: olcVariantPassReplication 34olcVariantPassReplication: FALSE 35EOMOD 36RC=$? 37if test $RC != 0 ; then 38 echo "ldapmodify failed ($RC)!" 39 test $KILLSERVERS != no && kill -HUP $KILLPIDS 40 exit $RC 41fi 42 43if test "$SYNCPROV" = syncprovmod; then 44 $LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 45 > $TESTOUT 2>&1 <<EOMOD 46dn: cn=module{0},cn=config 47changetype: modify 48add: olcModuleLoad 49olcModuleLoad: $LDAP_BUILD/servers/slapd/overlays/syncprov.la 50EOMOD 51 52 RC=$? 53 if test $RC != 0 ; then 54 echo "ldapmodify failed ($RC)!" 55 test $KILLSERVERS != no && kill -HUP $KILLPIDS 56 exit $RC 57 fi 58fi 59 60echo "Configuring syncprov on the provider..." 61$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 62 > $TESTOUT 2>&1 <<EOMOD 63dn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config 64changetype: add 65objectclass: olcSyncProvConfig 66EOMOD 67RC=$? 68if test $RC != 0 ; then 69 echo "ldapmodify failed ($RC)!" 70 test $KILLSERVERS != no && kill -HUP $KILLPIDS 71 exit $RC 72fi 73 74mkdir $DBDIR4 75 76echo "Starting consumer slapd on TCP/IP port $PORT4..." 77. $CONFFILTER $BACKEND $MONITORDB < $P1SRCONSUMERCONF > $CONF4 78$SLAPD -f $CONF4 -h $URI4 -d $LVL > $LOG4 2>&1 & 79CONSUMERPID=$! 80if test $WAIT != 0 ; then 81 echo CONSUMERPID $CONSUMERPID 82 read foo 83fi 84KILLPIDS="$KILLPIDS $CONSUMERPID" 85 86sleep $SLEEP0 87 88for i in 0 1 2 3 4 5; do 89 $LDAPSEARCH -s base -b "$BASEDN" -H $URI4 \ 90 'objectclass=*' > /dev/null 2>&1 91 RC=$? 92 if test $RC = 0 ; then 93 break 94 fi 95 echo "Waiting ${SLEEP1} seconds for consumer to start replication..." 96 sleep ${SLEEP1} 97done 98 99echo "Waiting ${SLEEP1} seconds for consumer to finish replicating..." 100sleep ${SLEEP1} 101 102echo "Testing searches against regular entries..." 103echo "# Testing searches against regular entries..." >> $SEARCHOUT 104$LDAPSEARCH -b "$BASEDN" -H $URI4 \ 105 "(|(name=Elliot)(description=*hiker*))" \ 106 >> $SEARCHOUT 2>&1 107RC=$? 108if test $RC != 0 ; then 109 echo "ldapsearch failed ($RC)!" 110 test $KILLSERVERS != no && kill -HUP $KILLPIDS 111 exit $RC 112fi 113 114echo "Testing searches listing replicated variants..." 115echo >> $SEARCHOUT 116echo "# Testing searches listing replicated variants..." >> $SEARCHOUT 117$LDAPSEARCH -b "$BASEDN" -s one -H $URI4 \ 118 >> $SEARCHOUT 2>&1 119RC=$? 120if test $RC != 0 ; then 121 echo "ldapsearch failed ($RC)!" 122 test $KILLSERVERS != no && kill -HUP $KILLPIDS 123 exit $RC 124fi 125 126# regex variants do not replicate correctly and this is documented 127echo >> $SEARCHOUT 128$LDAPSEARCH -b "$BASEDN" -s base -H $URI1 \ 129 >> $SEARCHOUT 2>&1 130RC=$? 131if test $RC != 0 ; then 132 echo "ldapsearch failed ($RC)!" 133 test $KILLSERVERS != no && kill -HUP $KILLPIDS 134 exit $RC 135fi 136 137# regex variants do not replicate correctly and this is documented 138echo >> $SEARCHOUT 139$LDAPSEARCH -s base -H $URI1 \ 140 -b "cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN" \ 141 '(ou=Information Technology Division)' \ 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 150# regex variants do not replicate correctly and this is documented 151echo >> $SEARCHOUT 152$LDAPSEARCH -b "cn=ITD Staff,ou=Groups,$BASEDN" -s base -H $URI1 \ 153 >> $SEARCHOUT 2>&1 154RC=$? 155if test $RC != 0 ; then 156 echo "ldapsearch failed ($RC)!" 157 test $KILLSERVERS != no && kill -HUP $KILLPIDS 158 exit $RC 159fi 160 161echo "Testing searches filtering on replicated variants..." 162echo >> $SEARCHOUT 163echo "# Testing searches filtering on replicated variants..." >> $SEARCHOUT 164$LDAPSEARCH -b "$BASEDN" -H $URI4 \ 165 "(st=Alumni Association)" st \ 166 >> $SEARCHOUT 2>&1 167RC=$? 168if test $RC != 0 ; then 169 echo "ldapsearch failed ($RC)!" 170 test $KILLSERVERS != no && kill -HUP $KILLPIDS 171 exit $RC 172fi 173 174test $KILLSERVERS != no && kill -HUP $KILLPIDS 175 176LDIF=data/test003-out.ldif 177 178echo "Filtering ldapsearch results..." 179$LDIFFILTER -s e < $SEARCHOUT > $SEARCHFLT 180echo "Filtering expected entries..." 181$LDIFFILTER -s e < $LDIF > $LDIFFLT 182echo "Comparing filter output..." 183$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 184 185if test $? != 0 ; then 186 echo "Comparison failed" 187 exit 1 188fi 189 190echo ">>>>> Test succeeded" 191 192test $KILLSERVERS != no && wait 193 194exit 0 195