[Fuego] [PATCH] Add test cases of service multipathd.

Wang Mingyu wangmy at cn.fujitsu.com
Wed Jan 9 09:45:08 UTC 2019


The multipathd daemon is in charge of checking for failed paths.
This test set is used to check if the ps, pidfile and syslog of the service can be generated successfully.

Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.multipathd/fuego_test.sh   | 18 ++++++
 .../tests/Functional.multipathd/multipathd_test.sh |  4 ++
 engine/tests/Functional.multipathd/parser.py       | 22 +++++++
 engine/tests/Functional.multipathd/spec.json       |  7 ++
 .../tests/multipathd_pidfile.sh                    | 75 ++++++++++++++++++++++
 .../Functional.multipathd/tests/multipathd_ps.sh   | 73 +++++++++++++++++++++
 .../Functional.multipathd/tests/multipathd_show.sh | 55 ++++++++++++++++
 .../tests/multipathd_syslog.sh                     | 73 +++++++++++++++++++++
 8 files changed, 327 insertions(+)
 create mode 100644 engine/tests/Functional.multipathd/fuego_test.sh
 create mode 100755 engine/tests/Functional.multipathd/multipathd_test.sh
 create mode 100644 engine/tests/Functional.multipathd/parser.py
 create mode 100644 engine/tests/Functional.multipathd/spec.json
 create mode 100644 engine/tests/Functional.multipathd/tests/multipathd_pidfile.sh
 create mode 100644 engine/tests/Functional.multipathd/tests/multipathd_ps.sh
 create mode 100644 engine/tests/Functional.multipathd/tests/multipathd_show.sh
 create mode 100644 engine/tests/Functional.multipathd/tests/multipathd_syslog.sh

diff --git a/engine/tests/Functional.multipathd/fuego_test.sh b/engine/tests/Functional.multipathd/fuego_test.sh
new file mode 100644
index 0000000..d1f64e0
--- /dev/null
+++ b/engine/tests/Functional.multipathd/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    assert_has_program multipathd
+}
+
+function test_deploy {
+    put $TEST_HOME/multipathd_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put $FUEGO_CORE/engine/scripts/fuego_board_function_lib.sh $BOARD_TESTDIR/fuego.$TESTDIR
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./multipathd_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.multipathd/multipathd_test.sh b/engine/tests/Functional.multipathd/multipathd_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.multipathd/multipathd_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.multipathd/parser.py b/engine/tests/Functional.multipathd/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.multipathd/parser.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/engine/tests/Functional.multipathd/spec.json b/engine/tests/Functional.multipathd/spec.json
new file mode 100644
index 0000000..e444db0
--- /dev/null
+++ b/engine/tests/Functional.multipathd/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.multipathd",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.multipathd/tests/multipathd_pidfile.sh b/engine/tests/Functional.multipathd/tests/multipathd_pidfile.sh
new file mode 100644
index 0000000..3017e1f
--- /dev/null
+++ b/engine/tests/Functional.multipathd/tests/multipathd_pidfile.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+#  In the target start multipathd, and check if the /var/run/multipathd.pid is exist
+#  check the keyword "multipathd".
+
+test="pidfile"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+service_status=$(exec_service_on_target multipathd is-active)
+
+exec_service_on_target multipathd stop
+
+if [ -f /etc/multipath.conf ]
+then
+    cp /etc/multipath.conf /etc/multipath.conf_bak
+fi
+
+if [ -f /etc/multipath.conf.example ]
+then
+    cp /etc/multipath.conf.example /etc/multipath.conf
+fi
+
+restore_target() {
+    if [ -f /etc/multipath.conf_bak ]
+    then
+        mv /etc/multipath.conf_bak /etc/multipath.conf
+    else
+        rm -f /etc/multipath.conf
+    fi
+}
+
+if exec_service_on_target multipathd start
+then
+    echo " -> start of multipathd succeeded."
+else
+    echo " -> start of multipathd failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+sleep 10
+
+if test -f /var/run/multipathd.pid
+then
+    echo " -> get the pidfile of multipathd."
+else
+    echo " -> can't get the pidfile of multipathd."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target multipathd stop
+    restore_target
+    if [ $multipathd_status = "active" ]
+    then
+        exec_service_on_target multipathd start
+    fi
+    exit
+fi
+
+exec_service_on_target multipathd stop
+
+if test ! -f /var/run/multipathd.pid
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+restore_target
+if [ $multipathd_status = "active" ]
+then
+    exec_service_on_target multipathd start
+fi
diff --git a/engine/tests/Functional.multipathd/tests/multipathd_ps.sh b/engine/tests/Functional.multipathd/tests/multipathd_ps.sh
new file mode 100644
index 0000000..afb9d63
--- /dev/null
+++ b/engine/tests/Functional.multipathd/tests/multipathd_ps.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+#  In the target start multipathd, and confirm the process condition by command ps.
+
+test="ps"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+service_status=$(exec_service_on_target multipathd is-active)
+
+exec_service_on_target multipathd stop
+
+if [ -f /etc/multipath.conf ]
+then
+    cp /etc/multipath.conf /etc/multipath.conf_bak
+fi
+
+if [ -f /etc/multipath.conf.example ]
+then
+    cp /etc/multipath.conf.example /etc/multipath.conf
+fi
+
+restore_target() {
+    if [ -f /etc/multipath.conf_bak ]
+    then
+        mv /etc/multipath.conf_bak /etc/multipath.conf
+    else
+        rm -f /etc/multipath.conf
+    fi
+}
+
+if exec_service_on_target multipathd start
+then
+    echo " -> start of multipathd succeeded."
+else
+    echo " -> start of multipathd failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if ps aux | grep "[/]sbin/multipathd"
+then
+    echo " -> get the process of multipathd."
+else
+    echo " -> can't get the process of multipathd."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target multipathd stop
+    restore_target
+    if [ $service_status = "active" ]
+    then
+        exec_service_on_target multipathd start
+    fi
+    exit
+fi
+
+exec_service_on_target multipathd stop
+
+if ps aux | grep "[/]sbin/multipathd"
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
+restore_target
+if [ $service_status = "active" ]
+then
+    exec_service_on_target multipathd start
+fi
diff --git a/engine/tests/Functional.multipathd/tests/multipathd_show.sh b/engine/tests/Functional.multipathd/tests/multipathd_show.sh
new file mode 100644
index 0000000..ddf2578
--- /dev/null
+++ b/engine/tests/Functional.multipathd/tests/multipathd_show.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+#  In the target start multipathd, and show the format wildcards used in interactive commands taking $format.
+
+test="show"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+service_status=$(exec_service_on_target multipathd is-active)
+
+exec_service_on_target multipathd stop
+
+if [ -f /etc/multipath.conf ]
+then
+    cp /etc/multipath.conf /etc/multipath.conf_bak
+fi
+
+if [ -f /etc/multipath.conf.example ]
+then
+    cp /etc/multipath.conf.example /etc/multipath.conf
+fi
+
+restore_target() {
+    if [ -f /etc/multipath.conf_bak ]
+    then
+        mv /etc/multipath.conf_bak /etc/multipath.conf
+    else
+        rm -f /etc/multipath.conf
+    fi
+}
+
+if exec_service_on_target multipathd start
+then
+    echo " -> start of multipathd succeeded."
+else
+    echo " -> start of multipathd failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if multipathd show wildcards | grep "multipath format wildcards:"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+restore_target
+if [ $service_status != "active" ]
+then
+    exec_service_on_target multipathd stop
+fi
diff --git a/engine/tests/Functional.multipathd/tests/multipathd_syslog.sh b/engine/tests/Functional.multipathd/tests/multipathd_syslog.sh
new file mode 100644
index 0000000..14c19d6
--- /dev/null
+++ b/engine/tests/Functional.multipathd/tests/multipathd_syslog.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+#  In the target start multipathd, and check the messages of /var/log/syslog.
+#  check the keyword "multipathd".
+
+test="syslog"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+logger_service=$(detect_logger_service)
+
+service_status=$(exec_service_on_target multipathd is-active)
+
+exec_service_on_target multipathd stop
+exec_service_on_target $logger_service stop
+
+if [ -f /etc/multipath.conf ]
+then
+    cp /etc/multipath.conf /etc/multipath.conf_bak
+fi
+
+if [ -f /etc/multipath.conf.example ]
+then
+    cp /etc/multipath.conf.example /etc/multipath.conf
+fi
+
+if [ -f /var/log/syslog ]
+then
+    mv /var/log/syslog /var/log/syslog_bak
+fi
+
+restore_target() {
+    if [ -f /etc/multipath.conf_bak ]
+    then
+        mv /etc/multipath.conf_bak /etc/multipath.conf
+    else
+        rm -f /etc/multipath.conf
+    fi
+
+    if [ -f /var/log/syslog_bak ]
+    then
+        mv /var/log/syslog_bak /var/log/syslog
+    fi
+}
+
+exec_service_on_target $logger_service restart
+
+if exec_service_on_target multipathd start
+then
+    echo " -> start of multipathd succeeded."
+else
+    echo " -> start of multipathd failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+sleep 10
+
+if cat /var/log/syslog | grep "multipath"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target multipathd stop
+restore_target
+if [ $multipathd_status = "active" ]
+then
+    exec_service_on_target multipathd start
+fi
-- 
1.8.3.1





More information about the Fuego mailing list