test007-transformed-replication revision 1.1.1.1
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,cn=config 33changetype: add 34objectClass: olcModuleList 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 46mkdir $DBDIR4 $TESTDIR/confdir-consumer 47 48echo "Starting consumer slapd on TCP/IP port $PORT4..." 49. $CONFFILTER $BACKEND $MONITORDB < $P1SRCONSUMERCONF > $CONF4 50 51echo "database config" >>$CONF4 52echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >>$CONF4 53 54$SLAPD -f $CONF4 -F $TESTDIR/confdir-consumer -h $URI4 -d $LVL > $LOG4 2>&1 & 55CONSUMERPID=$! 56if test $WAIT != 0 ; then 57 echo CONSUMERPID $CONSUMERPID 58 read foo 59fi 60KILLPIDS="$KILLPIDS $CONSUMERPID" 61 62sleep $SLEEP0 63 64echo "Setting up overlay on consumer..." 65$LDAPMODIFY -v -D cn=config -H $URI4 -y $CONFIGPWF \ 66 > $TESTOUT 2>&1 <<EOMOD 67dn: cn=module,cn=config 68changetype: add 69objectClass: olcModuleList 70olcModuleLoad: `pwd`/../datamorph.la 71EOMOD 72RC=$? 73if test $RC != 0 ; then 74 echo "ldapmodify failed ($RC)!" 75 test $KILLSERVERS != no && kill -HUP $KILLPIDS 76 exit $RC 77fi 78 79echo "Configuring syncprov on provider..." 80$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 81 > $TESTOUT 2>&1 <<EOMOD 82dn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config 83changetype: add 84objectclass: olcSyncProvConfig 85EOMOD 86RC=$? 87if test $RC != 0 ; then 88 echo "ldapmodify failed ($RC)!" 89 test $KILLSERVERS != no && kill -HUP $KILLPIDS 90 exit $RC 91fi 92 93. $CONFFILTER $BACKEND $MONITORDB < $OVERLAY_CONFIG | \ 94$LDAPMODIFY -v -D cn=config -H $URI4 -y $CONFIGPWF \ 95 > $TESTOUT 2>&1 96RC=$? 97if test $RC != 0 ; then 98 echo "ldapmodify failed ($RC)!" 99 test $KILLSERVERS != no && kill -HUP $KILLPIDS 100 exit $RC 101fi 102 103for i in 0 1 2 3 4 5; do 104 $LDAPSEARCH -s base -b "$BASEDN" -H $URI4 \ 105 'objectclass=*' > /dev/null 2>&1 106 RC=$? 107 if test $RC = 0 ; then 108 break 109 fi 110 echo "Waiting ${SLEEP1} seconds for consumer to start replication..." 111 sleep ${SLEEP1} 112done 113 114echo "Waiting ${SLEEP1} seconds for consumer to finish replicating..." 115sleep ${SLEEP1} 116 117echo "Testing searches against regular replicated entries..." 118echo "# Testing searches against regular replicated entries..." >> $SEARCHOUT 119$LDAPSEARCH -b "$BASEDN" -H $URI4 "(|(ou=Groups)(st=*))" \ 120 >> $SEARCHOUT 2>&1 121RC=$? 122if test $RC != 0 ; then 123 echo "ldapsearch failed ($RC)!" 124 test $KILLSERVERS != no && kill -HUP $KILLPIDS 125 exit $RC 126fi 127 128echo "Testing searches listing replicated transformed attributes..." 129echo >> $SEARCHOUT 130echo "# Testing searches listing replicated transformed attributes..." >> $SEARCHOUT 131$LDAPSEARCH -b "ou=Information Technology Division,ou=People,$BASEDN" \ 132 -s one -H $URI4 \ 133 >> $SEARCHOUT 2>&1 134RC=$? 135if test $RC != 0 ; then 136 echo "ldapsearch failed ($RC)!" 137 test $KILLSERVERS != no && kill -HUP $KILLPIDS 138 exit $RC 139fi 140 141echo "Testing searches filtering on replicated transformed attributes..." 142echo >> $SEARCHOUT 143echo "# Testing searches filtering on replicated transformed attributes..." >> $SEARCHOUT 144$LDAPSEARCH -b "$BASEDN" -H $URI4 \ 145 "(|(enumerated=bjensen)(&(signed=-19858)(signed<=0)(signed>=-20000)))" \ 146 enumerated signed \ 147 >> $SEARCHOUT 2>&1 148RC=$? 149if test $RC != 0 ; then 150 echo "ldapsearch failed ($RC)!" 151 test $KILLSERVERS != no && kill -HUP $KILLPIDS 152 exit $RC 153fi 154 155echo "Reconfiguring transformation definition..." 156. $CONFFILTER $BACKEND $MONITORDB < data/test003-config.ldif | \ 157$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 158 >> $TESTOUT 2>&1 159RC=$? 160if test $RC != 0 ; then 161 echo "ldapmodify failed ($RC)!" 162 test $KILLSERVERS != no && kill -HUP $KILLPIDS 163 exit $RC 164fi 165 166. $CONFFILTER $BACKEND $MONITORDB < data/test003-config.ldif | \ 167$LDAPMODIFY -v -D cn=config -H $URI4 -y $CONFIGPWF \ 168 >> $TESTOUT 2>&1 169RC=$? 170if test $RC != 0 ; then 171 echo "ldapmodify failed ($RC)!" 172 test $KILLSERVERS != no && kill -HUP $KILLPIDS 173 exit $RC 174fi 175 176echo "Testing searches filtering on the new replicated values..." 177echo >> $SEARCHOUT 178echo "# Testing searches filtering on the new replicated values..." >> $SEARCHOUT 179$LDAPSEARCH -b "$BASEDN" -H $URI4 \ 180 "(|(enumerated=not a value)(enumerated=jaj)(&(signed=45678)(!(signed>=50000))(signed>=44444)))" \ 181 enumerated signed \ 182 >> $SEARCHOUT 2>&1 183RC=$? 184if test $RC != 0 ; then 185 echo "ldapsearch failed ($RC)!" 186 test $KILLSERVERS != no && kill -HUP $KILLPIDS 187 exit $RC 188fi 189 190LDIF=data/test003-out.ldif 191 192echo "Filtering ldapsearch results..." 193$LDIFFILTER -s e < $SEARCHOUT > $SEARCHFLT 194echo "Filtering expected entries..." 195$LDIFFILTER -s e < $LDIF > $LDIFFLT 196echo "Comparing filter output..." 197$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 198 199if test $? != 0 ; then 200 echo "Comparison failed" 201 test $KILLSERVERS != no && kill -HUP $KILLPIDS 202 exit 1 203fi 204 205rm $SEARCHOUT 206 207echo "Reverting part of the above configuration for remainder of the test..." 208. $CONFFILTER $BACKEND $MONITORDB < data/test007-config.ldif | \ 209$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 210 >> $TESTOUT 2>&1 211RC=$? 212if test $RC != 0 ; then 213 echo "ldapmodify failed ($RC)!" 214 test $KILLSERVERS != no && kill -HUP $KILLPIDS 215 exit $RC 216fi 217 218. $CONFFILTER $BACKEND $MONITORDB < data/test007-config.ldif | \ 219$LDAPMODIFY -v -D cn=config -H $URI4 -y $CONFIGPWF \ 220 >> $TESTOUT 2>&1 221RC=$? 222if test $RC != 0 ; then 223 echo "ldapmodify failed ($RC)!" 224 test $KILLSERVERS != no && kill -HUP $KILLPIDS 225 exit $RC 226fi 227 228echo "Modifying entry..." 229$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 230 -f data/test005-changes.ldif >> $TESTOUT 2>&1 231RC=$? 232if test $RC != 0 ; then 233 echo "ldapmodify failed ($RC)!" 234 test $KILLSERVERS != no && kill -HUP $KILLPIDS 235 exit $RC 236fi 237 238echo "Applying invalid changes (should fail)..." 239for CHANGE in data/test005-*fail.ldif; do 240 echo "... $CHANGE" 241 $LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 242 -f $CHANGE >> $TESTOUT 2>&1 243 RC=$? 244 case $RC in 245 0) 246 echo "ldapmodify should have failed ($RC)!" 247 test $KILLSERVERS != no && kill -HUP $KILLPIDS 248 exit 1 249 ;; 250 16|19) 251 echo "ldapmodify failed ($RC)" 252 ;; 253 *) 254 echo "ldapmodify failed ($RC)!" 255 test $KILLSERVERS != no && kill -HUP $KILLPIDS 256 exit $RC 257 ;; 258 esac 259done 260 261echo "Waiting ${SLEEP1} seconds for consumer to finish replicating..." 262sleep ${SLEEP1} 263 264echo "Reading affected entries back..." 265echo "# Reading affected entries back..." >> $SEARCHOUT 266$LDAPSEARCH -b "$BASEDN" -H $URI1 \ 267 '(|(objectClass=OpenLDAPperson)(ou=people))' \ 268 >> $SEARCHOUT 2>&1 269RC=$? 270if test $RC != 0 ; then 271 echo "ldapsearch failed ($RC)!" 272 test $KILLSERVERS != no && kill -HUP $KILLPIDS 273 exit $RC 274fi 275 276test $KILLSERVERS != no && kill -HUP $KILLPIDS 277 278LDIF=data/test005-out.ldif 279 280echo "Filtering ldapsearch results..." 281$LDIFFILTER -s e < $SEARCHOUT > $SEARCHFLT 282echo "Filtering expected entries..." 283$LDIFFILTER -s e < $LDIF > $LDIFFLT 284echo "Comparing filter output..." 285$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 286 287if test $? != 0 ; then 288 echo "Comparison failed" 289 exit 1 290fi 291 292echo ">>>>> Test succeeded" 293 294test $KILLSERVERS != no && wait 295 296exit 0 297