ctdb-tests: 50.samba event script setup modularisation
authorMartin Schwenke <martin@meltin.net>
Mon, 12 Feb 2018 05:25:15 +0000 (16:25 +1100)
committerAmitay Isaacs <amitay@samba.org>
Wed, 28 Mar 2018 00:57:19 +0000 (02:57 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
17 files changed:
ctdb/tests/eventscripts/50.samba.monitor.001.sh
ctdb/tests/eventscripts/50.samba.monitor.101.sh
ctdb/tests/eventscripts/50.samba.monitor.103.sh
ctdb/tests/eventscripts/50.samba.monitor.104.sh
ctdb/tests/eventscripts/50.samba.monitor.105.sh
ctdb/tests/eventscripts/50.samba.monitor.106.sh
ctdb/tests/eventscripts/50.samba.monitor.110.sh
ctdb/tests/eventscripts/50.samba.monitor.111.sh
ctdb/tests/eventscripts/50.samba.monitor.112.sh
ctdb/tests/eventscripts/50.samba.monitor.113.sh
ctdb/tests/eventscripts/50.samba.shutdown.001.sh
ctdb/tests/eventscripts/50.samba.shutdown.002.sh
ctdb/tests/eventscripts/50.samba.shutdown.011.sh
ctdb/tests/eventscripts/50.samba.startup.011.sh
ctdb/tests/eventscripts/scripts/50.samba.sh
ctdb/tests/eventscripts/scripts/local.sh
ctdb/tests/eventscripts/stubs/ctdb

index ac3708f5fd498849b653c20d761ae5432672b689..00f8180901f98a972c5f8aa28fa3a813549fc1fa 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "not managed, check no-op"
 
-setup_samba "down"
+setup "down"
 
 ok_null
 
index cf3b53a8f17eb54e03aa14c5498bbecdbff03e6f..3884a33a986d8f970dade83ffd0bdca2505cb297 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "all OK"
 
-setup_samba
+setup
 
 ok_null
 
index ae953c2d3e5f871512ec790a4fcafed2648615d8..e9232a65117b0ef266ec4f133842fa60342ac389 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "port 445 down"
 
-setup_samba
+setup
+
 tcp_port_down 445
 
 required_result 1 "samba not listening on TCP port 445"
index dca2af517c3cde92e12ed90b759f28d003e40534..8e9d7896d576235d813237950dbe3b61b6ed7e38 100755 (executable)
@@ -4,7 +4,8 @@
 
 define_test "port 139 down"
 
-setup_samba
+setup
+
 tcp_port_down 139
 
 required_result 1 "samba not listening on TCP port 139"
index c6e7dcc8d288442532ac722346c27dad74729e9c..1f2fa1e9068b03dcaa2d6bf1fc9514b39256f326 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "non-existent share path"
 
-setup_samba
+setup
 
 out=$(shares_missing "ERROR: samba directory \"%s\" not available" 2)
 
index 6090961e556319a12376b8f1fff768ca2bdd7811..1dce06d8e241ebbfcfb7c55462ea64e2c4984a47 100755 (executable)
@@ -4,9 +4,9 @@
 
 define_test "non-existent share - not checked"
 
-setup_samba
+setup
 
-export CTDB_SAMBA_SKIP_SHARE_CHECK="yes"
+CTDB_SAMBA_SKIP_SHARE_CHECK="yes"
 
 ok_null
 
index 3c2081af0e9b8106644d1a256230783da9519aac..9645c5a4d79345e459f46e6ce9d773a2d87600e6 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "testparm fails"
 
-setup_samba
+setup
 
 export FAKE_TESTPARM_FAIL="yes"
 required_result 1 <<EOF
index df6662f3a101f7ffaeaacab53ff3bbe891926f50..55df6da807ed23667de92e620756ef492b7e317a 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "testparm fails on 2nd time through"
 
-setup_samba
+setup
 
 ok_null
 simple_test
index a7a487f8fd2895ab27eb627039eb5bda998748a6..f71447206f262fb1e879e677ece8ecbc3a3211f1 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "testparm times out"
 
-setup_samba
+setup
 
 export FAKE_TIMEOUT="yes"
 required_result 1 <<EOF
index 56bd86dc1e3f55f8e19f14750d0a433d44649313..faadda1a0b154b4f8e8eb388c170e3797c8cc255 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "testparm times out on 2nd time through"
 
-setup_samba
+setup
 
 ok_null
 simple_test
index 8c0be7c190f4f10172605a85019bc60a3e0ea8b4..76ac985ff7e22587db3c96d6362a37b387dedbb0 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "shutdown, simple"
 
-setup_samba
+setup
 
 ok <<EOF
 Stopping smb: OK
index 7ead53caf229f422a5f87f38200e2768b2baeac1..f6920267fe0d762c6ffdbae1c63d8bd6ef127716 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "shutdown, simple"
 
-setup_samba
+setup
 
 samba_setup_fake_threads 1 2 3 4 5 6
 
index f225e8f311e5b9c18870af412f060cdd44bbd00a..a64696bf7230a6bf65ce650266ad49cb3003387c 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "shutdown, Debian init style"
 
-setup_samba
+setup
 
 export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
 
index 320549785da5f7bc6035dc0412e9e97097684717..ce79767fb366a6bafcf4e38259a92cac43d14557 100755 (executable)
@@ -4,7 +4,7 @@
 
 define_test "shutdown, Debian init style"
 
-setup_samba
+setup
 
 export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
 
index 21aa66f7234f913bd8dac13edff2631a850879bb..4e7e146b4519653a926d123cad68ff005dc3d8b2 100644 (file)
@@ -1,7 +1,5 @@
-setup_samba ()
+setup ()
 {
-       setup_ctdb
-
        service_name="samba"
 
        if [ "$1" != "down" ] ; then
@@ -13,11 +11,9 @@ setup_samba ()
                        service "$i" force-started
                done
 
-               export CTDB_SAMBA_SKIP_SHARE_CHECK="no"
                export CTDB_MANAGES_SAMBA="yes"
 
-               export FAKE_TCP_LISTEN="0.0.0.0:445 0.0.0.0:139"
-               export FAKE_WBINFO_FAIL="no"
+               setup_tcp_listen 445 139
 
                # Some things in 50.samba are backgrounded and waited
                # for.  If we don't sleep at all then timeouts can
@@ -31,12 +27,15 @@ setup_samba ()
                        service "$i" force-stopped
                done
 
-               export CTDB_SAMBA_SKIP_SHARE_CHECK="no"
                export CTDB_MANAGES_SAMBA=""
 
-               export FAKE_TCP_LISTEN=""
-               export FAKE_WBINFO_FAIL="yes"
+               setup_tcp_listen
        fi
+
+       export CTDB_SAMBA_SKIP_SHARE_CHECK="no"
+
+       setup_shares
+
 }
 
 samba_setup_fake_threads ()
index b29f976e1ed0cb1a4ef7fd737439038eb86d662e..472f5c500d55587069fb3ca68717c81e93c67d6d 100644 (file)
@@ -90,16 +90,34 @@ setup_generic ()
     setup_shares
     setup_dbdir
     setup_date
+}
+
+setup_tcp_listen ()
+{
+       export FAKE_TCP_LISTEN="$*"
+}
 
-    export FAKE_TCP_LISTEN
+tcp_port_listening ()
+{
+       for _i ; do
+                  FAKE_TCP_LISTEN="${FAKE_TCP_LISTEN} ${_i}"
+       done
 }
 
 tcp_port_down ()
 {
-    for _i ; do
-       debug "Marking TCP port \"${_i}\" as not listening"
-       FAKE_TCP_LISTEN=$(echo "$FAKE_TCP_LISTEN" | sed -r -e "s@[[:space:]]*[\.0-9]+:${_i}@@g")
-    done
+       _port="$1"
+       debug "Marking TCP port \"${_port}\" as not listening"
+
+       _t=""
+       for _i in $FAKE_TCP_LISTEN ; do
+               if [ "$_i" = "$_port" ] ; then
+                       continue
+               fi
+               _t="${_t} ${_i}"
+       done
+
+       FAKE_TCP_LISTEN="$_t"
 }
 
 setup_unix_listen ()
index ad71b2738b75e4a39f1accc03c0e327d59e50f5e..c5a6ceecce0a9efa13f3f3f864fde6ebc112f65f 100755 (executable)
@@ -458,7 +458,7 @@ ctdb_checktcpport ()
        _port="$1"
 
        for _i in $FAKE_TCP_LISTEN ; do
-               if [ "$_port" = "${_i##*:}" ] ; then
+               if [ "$_port" = "$_i" ] ; then
                        exit 98
                fi
        done