]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Create 11.natgw.sh
authorMartin Schwenke <martin@meltin.net>
Mon, 19 Mar 2018 09:38:28 +0000 (20:38 +1100)
committerAmitay Isaacs <amitay@samba.org>
Wed, 28 Mar 2018 00:57:17 +0000 (02:57 +0200)
Contains testing support used only by tests for 11.natgw event script.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/eventscripts/scripts/11.natgw.sh [new file with mode: 0644]
ctdb/tests/eventscripts/scripts/local.sh

diff --git a/ctdb/tests/eventscripts/scripts/11.natgw.sh b/ctdb/tests/eventscripts/scripts/11.natgw.sh
new file mode 100644 (file)
index 0000000..162d5b5
--- /dev/null
@@ -0,0 +1,109 @@
+setup_ctdb_natgw ()
+{
+       debug "Setting up NAT gateway"
+
+       natgw_config_dir="${TEST_VAR_DIR}/natgw_config"
+       mkdir -p "$natgw_config_dir"
+
+       export CTDB_NATGW_NODES="${natgw_config_dir}/natgw_nodes"
+
+       # Read from stdin
+       while read _ip _opts ; do
+               case "$_opts" in
+               master)
+                       export FAKE_CTDB_NATGW_MASTER="$_ip"
+                       echo "$_ip"
+                       ;;
+               slave-only)
+                       printf "%s\tslave-only\n" "$_ip"
+                       ;;
+               *)
+                       echo "$_ip"
+                       ;;
+               esac
+       done >"$CTDB_NATGW_NODES"
+
+       # Assume all of the nodes are on a /24 network and have IPv4
+       # addresses:
+       read _ip <"$CTDB_NATGW_NODES"
+       export CTDB_NATGW_PRIVATE_NETWORK="${_ip%.*}.0/24"
+
+       # These are fixed.  Probably don't use the same network for the
+       # private node IPs.  To unset the default gateway just set it to
+       # "".  :-)
+       export CTDB_NATGW_PUBLIC_IP="10.1.1.121/24"
+       export CTDB_NATGW_PUBLIC_IFACE="eth1"
+       export CTDB_NATGW_DEFAULT_GATEWAY="10.1.1.254"
+       export CTDB_NATGW_SLAVE_ONLY=""
+}
+
+ok_natgw_master_ip_addr_show ()
+{
+       _mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" | md5sum | sed -r -e 's@(..)(..)(..)(..)(..)(..).*@\1:\2:\3:\4:\5:\6@')
+
+       # This is based on CTDB_NATGW_PUBLIC_IP
+       _brd="10.1.1.255"
+
+       ok <<EOF
+1: ${CTDB_NATGW_PUBLIC_IFACE}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
+    link/ether ${_mac} brd ff:ff:ff:ff:ff:ff
+    inet ${CTDB_NATGW_PUBLIC_IP} brd ${_brd} scope global ${CTDB_NATGW_PUBLIC_IFACE}
+       valid_lft forever preferred_lft forever
+EOF
+}
+
+ok_natgw_slave_ip_addr_show ()
+{
+       _mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" | md5sum | sed -r -e 's@(..)(..)(..)(..)(..)(..).*@\1:\2:\3:\4:\5:\6@')
+
+       ok <<EOF
+1: ${CTDB_NATGW_PUBLIC_IFACE}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
+    link/ether ${_mac} brd ff:ff:ff:ff:ff:ff
+EOF
+}
+
+ok_natgw_master_static_routes ()
+{
+       _nl="
+"
+       _t=""
+       for _i in $CTDB_NATGW_STATIC_ROUTES ; do
+               # This is intentionally different to the code in 11.natgw ;-)
+               case "$_i" in
+               *@*)
+                       _net=$(echo "$_i" | sed -e 's|@.*||')
+                       _gw=$(echo "$_i" | sed -e 's|.*@||')
+                       ;;
+               *)
+                       _net="$_i"
+                       _gw="$CTDB_NATGW_DEFAULT_GATEWAY"
+               esac
+
+               [ -n "$_gw" ] || continue
+               _t="${_t}${_t:+${_nl}}"
+               _t="${_t}${_net} via ${_gw} dev ethXXX  metric 10 "
+       done
+       _t=$(echo "$_t" | sort)
+       ok "$_t"
+}
+
+ok_natgw_slave_static_routes ()
+{
+       _nl="
+"
+       _t=""
+       for _i in $CTDB_NATGW_STATIC_ROUTES ; do
+               # This is intentionally different to the code in 11.natgw ;-)
+               _net=$(echo "$_i" | sed -e 's|@.*||')
+
+               # The interface for the private network isn't
+               # specified as part of the NATGW configuration and
+               # isn't part of the command to add the route.  It is
+               # implicitly added by "ip route" but our stub doesn't
+               # do this and adds "ethXXX".
+               _t="${_t}${_t:+${_nl}}"
+               _t="${_t}${_net} via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX  metric 10 "
+       done
+       _t=$(echo "$_t" | sort)
+       ok "$_t"
+}
index c0f1b26fca1b617da6da633c3d178f83362dab91..ae0d3f88a50318d480c46cea088930cf0b38f629 100644 (file)
@@ -586,116 +586,6 @@ EOF
 
 ######################################################################
 
-setup_ctdb_natgw ()
-{
-       debug "Setting up NAT gateway"
-
-       natgw_config_dir="${TEST_VAR_DIR}/natgw_config"
-       mkdir -p "$natgw_config_dir"
-
-       export CTDB_NATGW_NODES="${natgw_config_dir}/natgw_nodes"
-
-       # Read from stdin
-       while read _ip _opts ; do
-               case "$_opts" in
-               master)
-                       export FAKE_CTDB_NATGW_MASTER="$_ip"
-                       echo "$_ip"
-                       ;;
-               slave-only)
-                       printf "%s\tslave-only\n" "$_ip"
-                       ;;
-               *)
-                       echo "$_ip"
-                       ;;
-               esac
-       done >"$CTDB_NATGW_NODES"
-
-       # Assume all of the nodes are on a /24 network and have IPv4
-       # addresses:
-       read _ip <"$CTDB_NATGW_NODES"
-       export CTDB_NATGW_PRIVATE_NETWORK="${_ip%.*}.0/24"
-
-       # These are fixed.  Probably don't use the same network for the
-       # private node IPs.  To unset the default gateway just set it to
-       # "".  :-)
-       export CTDB_NATGW_PUBLIC_IP="10.1.1.121/24"
-       export CTDB_NATGW_PUBLIC_IFACE="eth1"
-       export CTDB_NATGW_DEFAULT_GATEWAY="10.1.1.254"
-       export CTDB_NATGW_SLAVE_ONLY=""
-}
-
-ok_natgw_master_ip_addr_show ()
-{
-    _mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" | md5sum | sed -r -e 's@(..)(..)(..)(..)(..)(..).*@\1:\2:\3:\4:\5:\6@')
-
-    # This is based on CTDB_NATGW_PUBLIC_IP
-    _brd="10.1.1.255"
-
-ok <<EOF
-1: ${CTDB_NATGW_PUBLIC_IFACE}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
-    link/ether ${_mac} brd ff:ff:ff:ff:ff:ff
-    inet ${CTDB_NATGW_PUBLIC_IP} brd ${_brd} scope global ${CTDB_NATGW_PUBLIC_IFACE}
-       valid_lft forever preferred_lft forever
-EOF
-}
-
-ok_natgw_slave_ip_addr_show ()
-{
-    _mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" | md5sum | sed -r -e 's@(..)(..)(..)(..)(..)(..).*@\1:\2:\3:\4:\5:\6@')
-ok <<EOF
-1: ${CTDB_NATGW_PUBLIC_IFACE}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
-    link/ether ${_mac} brd ff:ff:ff:ff:ff:ff
-EOF
-}
-
-ok_natgw_master_static_routes ()
-{
-    _nl="
-"
-    _t=""
-    for _i in $CTDB_NATGW_STATIC_ROUTES ; do
-       # This is intentionally different to the code in 11.natgw ;-)
-       case "$_i" in
-           *@*)
-               _net=$(echo "$_i" | sed -e 's|@.*||')
-               _gw=$(echo "$_i" | sed -e 's|.*@||')
-               ;;
-           *)
-               _net="$_i"
-               _gw="$CTDB_NATGW_DEFAULT_GATEWAY"
-       esac
-
-       [ -n "$_gw" ] || continue
-       _t="${_t}${_t:+${_nl}}"
-       _t="${_t}${_net} via ${_gw} dev ethXXX  metric 10 "
-    done
-    _t=$(echo "$_t" | sort)
-    ok "$_t"
-}
-
-ok_natgw_slave_static_routes ()
-{
-    _nl="
-"
-    _t=""
-    for _i in $CTDB_NATGW_STATIC_ROUTES ; do
-       # This is intentionally different to the code in 11.natgw ;-)
-       _net=$(echo "$_i" | sed -e 's|@.*||')
-
-       # The interface for the private network isn't specified as
-       # part of the NATGW configuration and isn't part of the
-       # command to add the route.  It is implicitly added by "ip
-       # route" but our stub doesn't do this and adds "ethXXX".
-       _t="${_t}${_t:+${_nl}}"
-       _t="${_t}${_net} via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX  metric 10 "
-    done
-    _t=$(echo "$_t" | sort)
-    ok "$_t"
-}
-
-######################################################################
-
 # Samba/winbind fakery
 
 setup_samba ()