arbitrary sleeps. Should hopefully make these tests more stable.
#!/bin/ksh
-# $OpenBSD: carp_1.sh,v 1.2 2023/10/19 18:36:41 anton Exp $
+# $OpenBSD: carp_1.sh,v 1.3 2024/01/05 10:37:54 anton Exp $
cleanup()
#
# IFNO1 must become master
-sleep 3.1 # need 3 seconds to become master
+wait_until "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'"
# carpdemote must work
ifconfig -g ${IFGPREFIX}a carpdemote
-sleep 0.1
+wait_until "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'"
#!/bin/ksh
-# $OpenBSD: carp_2.sh,v 1.2 2023/10/19 18:36:41 anton Exp $
+# $OpenBSD: carp_2.sh,v 1.3 2024/01/05 10:37:54 anton Exp $
cleanup()
#
# IFNO1 must become master
-sleep 3.1 # need 3 seconds to become master
+wait_until "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'"
# carpdemote must work
ifconfig -g ${IFGPREFIX}a carpdemote
-sleep 0.1
+wait_until "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'"
#!/bin/ksh
-# $OpenBSD: carp_3.sh,v 1.2 2023/10/19 18:36:41 anton Exp $
+# $OpenBSD: carp_3.sh,v 1.3 2024/01/05 10:37:54 anton Exp $
cleanup()
#
# IFNO1 must become master
-sleep 3.1 # need 3 seconds to become master
+wait_until "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'"
# carpdemote must work
ifconfig -g ${IFGPREFIX}a carpdemote
-sleep 0.1
+wait_until "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'"
#!/bin/ksh
-# $OpenBSD: carp_4.sh,v 1.2 2023/10/19 18:36:41 anton Exp $
+# $OpenBSD: carp_4.sh,v 1.3 2024/01/05 10:37:54 anton Exp $
cleanup()
#
# IFNO1 must become master
-sleep 3.1 # need 3 seconds to become master
+wait_until "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'"
# carpdemote must work
ifconfig -g ${IFGPREFIX}a carpdemote
-sleep 0.1
+wait_until "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'"
fi
}
+wait_until() {
+ local _i=0
+
+ while [ "$_i" -lt 8 ]; do
+ sh -c "$@" && return 0
+ sleep 0.5
+ _i="$((_i + 1))"
+ done
+ echo timeout
+ return 1
+}
+
+
RDOMAINS=""
IFACE_NUMS=""
while getopts 'cvR:I:' ch "$@"; do