[Fuego] [PATCH v2] Add test cases of service multipathd.
Tim.Bird at sony.com
Tim.Bird at sony.com
Wed Mar 13 22:26:44 UTC 2019
Same issues as other tests.
I fixed up the issues in these test, but I plan to reject patches
if they still have these issues, after the 1.5 release.
-- Tim
> -----Original Message-----
> From: fuego-bounces at lists.linuxfoundation.org [mailto:fuego-
> bounces at lists.linuxfoundation.org] On Behalf Of Wang Mingyu
> Sent: Wednesday, March 06, 2019 2:08 AM
> To: fuego at lists.linuxfoundation.org
> Subject: [Fuego] [PATCH v2] Add test cases of service multipathd.
>
> 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>
> ---
> tests/Functional.multipathd/fuego_test.sh | 18 ++++++
> tests/Functional.multipathd/multipathd_test.sh | 7 +++
> tests/Functional.multipathd/parser.py | 22 +++++++
> tests/Functional.multipathd/spec.json | 7 +++
> .../tests/multipathd_pidfile.sh | 71 ++++++++++++++++++++++
> tests/Functional.multipathd/tests/multipathd_ps.sh | 69
> +++++++++++++++++++++
> .../Functional.multipathd/tests/multipathd_show.sh | 51
> ++++++++++++++++
> .../tests/multipathd_syslog.sh | 70 +++++++++++++++++++++
> 8 files changed, 315 insertions(+)
> create mode 100644 tests/Functional.multipathd/fuego_test.sh
> create mode 100755 tests/Functional.multipathd/multipathd_test.sh
> create mode 100644 tests/Functional.multipathd/parser.py
> create mode 100644 tests/Functional.multipathd/spec.json
> create mode 100644
> tests/Functional.multipathd/tests/multipathd_pidfile.sh
> create mode 100644 tests/Functional.multipathd/tests/multipathd_ps.sh
> create mode 100644 tests/Functional.multipathd/tests/multipathd_show.sh
> create mode 100644
> tests/Functional.multipathd/tests/multipathd_syslog.sh
>
> diff --git a/tests/Functional.multipathd/fuego_test.sh
> b/tests/Functional.multipathd/fuego_test.sh
> new file mode 100644
> index 0000000..81454fa
> --- /dev/null
> +++ b/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/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/tests/Functional.multipathd/multipathd_test.sh
> b/tests/Functional.multipathd/multipathd_test.sh
> new file mode 100755
> index 0000000..95c34db
> --- /dev/null
> +++ b/tests/Functional.multipathd/multipathd_test.sh
> @@ -0,0 +1,7 @@
> +#!/bin/sh
> +. ./fuego_board_function_lib.sh
> +set_init_manager
> +
> +for i in tests/*.sh; do
> + source $i
> +done
> diff --git a/tests/Functional.multipathd/parser.py
> b/tests/Functional.multipathd/parser.py
> new file mode 100644
> index 0000000..d85abd7
> --- /dev/null
> +++ b/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/tests/Functional.multipathd/spec.json
> b/tests/Functional.multipathd/spec.json
> new file mode 100644
> index 0000000..e444db0
> --- /dev/null
> +++ b/tests/Functional.multipathd/spec.json
> @@ -0,0 +1,7 @@
> +{
> + "testName": "Functional.multipathd",
> + "specs": {
> + "default": {}
> + }
> +}
> +
> diff --git a/tests/Functional.multipathd/tests/multipathd_pidfile.sh
> b/tests/Functional.multipathd/tests/multipathd_pidfile.sh
> new file mode 100644
> index 0000000..6240f87
> --- /dev/null
> +++ b/tests/Functional.multipathd/tests/multipathd_pidfile.sh
> @@ -0,0 +1,71 @@
> +#!/bin/sh
> +
> +# In the target start multipathd, and check if the /var/run/multipathd.pid is
> exist
> +# check the keyword "multipathd".
> +
> +test="pidfile"
> +
> +service_status=$(get_service_status multipathd)
> +
> +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 [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> + 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 [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> + exec_service_on_target multipathd start
> +fi
> diff --git a/tests/Functional.multipathd/tests/multipathd_ps.sh
> b/tests/Functional.multipathd/tests/multipathd_ps.sh
> new file mode 100644
> index 0000000..86c4352
> --- /dev/null
> +++ b/tests/Functional.multipathd/tests/multipathd_ps.sh
> @@ -0,0 +1,69 @@
> +#!/bin/sh
> +
> +# In the target start multipathd, and confirm the process condition by
> command ps.
> +
> +test="ps"
> +
> +service_status=$(get_service_status multipathd)
> +
> +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" -o "$service_status" = "unknown" ]
> + 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" -o "$service_status" = "unknown" ]
> +then
> + exec_service_on_target multipathd start
> +fi
> diff --git a/tests/Functional.multipathd/tests/multipathd_show.sh
> b/tests/Functional.multipathd/tests/multipathd_show.sh
> new file mode 100644
> index 0000000..73ac45a
> --- /dev/null
> +++ b/tests/Functional.multipathd/tests/multipathd_show.sh
> @@ -0,0 +1,51 @@
> +#!/bin/sh
> +
> +# In the target start multipathd, and show the format wildcards used in
> interactive commands taking $format.
> +
> +test="show"
> +
> +service_status=$(get_service_status multipathd)
> +
> +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" -o "$service_status" = "unknown" ]
> +then
> + exec_service_on_target multipathd start
> +fi
> diff --git a/tests/Functional.multipathd/tests/multipathd_syslog.sh
> b/tests/Functional.multipathd/tests/multipathd_syslog.sh
> new file mode 100644
> index 0000000..dbfcd55
> --- /dev/null
> +++ b/tests/Functional.multipathd/tests/multipathd_syslog.sh
> @@ -0,0 +1,70 @@
> +#!/bin/sh
> +
> +# In the target start multipathd, and check the messages of /var/log/syslog.
> +# check the keyword "multipathd".
> +
> +test="syslog"
> +
> +logger_service=$(detect_logger_service)
> +
> +service_status=$(get_service_status multipathd)
> +
> +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 [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> + exec_service_on_target multipathd start
> +fi
> --
> 1.8.3.1
>
>
>
> _______________________________________________
> Fuego mailing list
> Fuego at lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego
More information about the Fuego
mailing list