All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fuego] [PATCH] Add test cases of service openct.
@ 2019-01-09  9:45 Wang Mingyu
  2019-01-09  9:45 ` [Fuego] [PATCH] Add test case of service openhpid Wang Mingyu
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Wang Mingyu @ 2019-01-09  9:45 UTC (permalink / raw)
  To: fuego

OpenCT implements drivers for several smart card readers.
This test set is used to check the command openct-tool and openct-control of service openct.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 engine/tests/Functional.openct/fuego_test.sh       | 19 ++++++++++
 engine/tests/Functional.openct/openct_test.sh      |  4 ++
 engine/tests/Functional.openct/parser.py           | 22 +++++++++++
 engine/tests/Functional.openct/spec.json           |  7 ++++
 .../tests/Functional.openct/tests/openct_help.sh   | 12 ++++++
 engine/tests/Functional.openct/tests/openct_ps.sh  | 44 ++++++++++++++++++++++
 6 files changed, 108 insertions(+)
 create mode 100644 engine/tests/Functional.openct/fuego_test.sh
 create mode 100755 engine/tests/Functional.openct/openct_test.sh
 create mode 100644 engine/tests/Functional.openct/parser.py
 create mode 100644 engine/tests/Functional.openct/spec.json
 create mode 100644 engine/tests/Functional.openct/tests/openct_help.sh
 create mode 100644 engine/tests/Functional.openct/tests/openct_ps.sh

diff --git a/engine/tests/Functional.openct/fuego_test.sh b/engine/tests/Functional.openct/fuego_test.sh
new file mode 100644
index 0000000..e008fdf
--- /dev/null
+++ b/engine/tests/Functional.openct/fuego_test.sh
@@ -0,0 +1,19 @@
+function test_pre_check {
+    assert_has_program openct-control
+    assert_has_program openct-tool
+}
+
+function test_deploy {
+    put $TEST_HOME/openct_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;\
+    ./openct_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.openct/openct_test.sh b/engine/tests/Functional.openct/openct_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.openct/openct_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.openct/parser.py b/engine/tests/Functional.openct/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.openct/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.openct/spec.json b/engine/tests/Functional.openct/spec.json
new file mode 100644
index 0000000..e758b68
--- /dev/null
+++ b/engine/tests/Functional.openct/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.openct",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.openct/tests/openct_help.sh b/engine/tests/Functional.openct/tests/openct_help.sh
new file mode 100644
index 0000000..e7f6c9f
--- /dev/null
+++ b/engine/tests/Functional.openct/tests/openct_help.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+#  Check the help message of command openct-control.
+
+test="help"
+
+if openct-control -h | grep "usage"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/engine/tests/Functional.openct/tests/openct_ps.sh b/engine/tests/Functional.openct/tests/openct_ps.sh
new file mode 100644
index 0000000..cbb8ab4
--- /dev/null
+++ b/engine/tests/Functional.openct/tests/openct_ps.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+#  In the target start openct, and confirm the process condition by command ps.
+
+test="ps"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+service_status=$(exec_service_on_target openct is-active)
+
+exec_service_on_target openct stop
+
+if exec_service_on_target openct start
+then
+    echo " -> start of openct succeeded."
+else
+    echo " -> start of openct failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if [ "$init_manager" = "systemd" ]
+then
+    if exec_service_on_target openct is-active
+    then
+        echo " -> $test: TEST-PASS"
+    else
+        echo " -> $test: TEST-FAIL"
+    fi
+else
+    if exec_service_on_target openct status | grep "Waiting for reader attach/detach events"
+    then
+        echo " -> $test: TEST-PASS"
+    else
+        echo " -> $test: TEST-FAIL"
+    fi
+fi
+
+if [ $service_status != "active" ]
+then
+    exec_service_on_target openct stop
+fi
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Fuego] [PATCH] Add test case of service openhpid.
  2019-01-09  9:45 [Fuego] [PATCH] Add test cases of service openct Wang Mingyu
@ 2019-01-09  9:45 ` Wang Mingyu
  2019-01-10 22:44   ` Tim.Bird
  2019-01-09  9:45 ` [Fuego] [PATCH] Add test cases of service multipathd Wang Mingyu
  2019-01-10 22:35 ` [Fuego] [PATCH] Add test cases of service openct Tim.Bird
  2 siblings, 1 reply; 10+ messages in thread
From: Wang Mingyu @ 2019-01-09  9:45 UTC (permalink / raw)
  To: fuego

The openhpid is HPI instance to which multiple clients can connect.
This test set is used to check if the ps of service can be generated successfully.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 engine/tests/Functional.openhpid/fuego_test.sh     | 18 +++++++++++++++
 engine/tests/Functional.openhpid/openhpid_test.sh  |  4 ++++
 engine/tests/Functional.openhpid/parser.py         | 22 ++++++++++++++++++
 engine/tests/Functional.openhpid/spec.json         |  7 ++++++
 .../tests/Functional.openhpid/tests/openhpid_ps.sh | 26 ++++++++++++++++++++++
 5 files changed, 77 insertions(+)
 create mode 100644 engine/tests/Functional.openhpid/fuego_test.sh
 create mode 100755 engine/tests/Functional.openhpid/openhpid_test.sh
 create mode 100644 engine/tests/Functional.openhpid/parser.py
 create mode 100644 engine/tests/Functional.openhpid/spec.json
 create mode 100644 engine/tests/Functional.openhpid/tests/openhpid_ps.sh

diff --git a/engine/tests/Functional.openhpid/fuego_test.sh b/engine/tests/Functional.openhpid/fuego_test.sh
new file mode 100644
index 0000000..33507dc
--- /dev/null
+++ b/engine/tests/Functional.openhpid/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    assert_has_program openhpid
+}
+
+function test_deploy {
+    put $TEST_HOME/openhpid_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;\
+    ./openhpid_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.openhpid/openhpid_test.sh b/engine/tests/Functional.openhpid/openhpid_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.openhpid/openhpid_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.openhpid/parser.py b/engine/tests/Functional.openhpid/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.openhpid/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.openhpid/spec.json b/engine/tests/Functional.openhpid/spec.json
new file mode 100644
index 0000000..9004c0d
--- /dev/null
+++ b/engine/tests/Functional.openhpid/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.openhpid",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.openhpid/tests/openhpid_ps.sh b/engine/tests/Functional.openhpid/tests/openhpid_ps.sh
new file mode 100644
index 0000000..3d2f85d
--- /dev/null
+++ b/engine/tests/Functional.openhpid/tests/openhpid_ps.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#  In the target start openhpid, and confirm the process condition by command ps.
+
+test="ps"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+service_status=$(exec_service_on_target openhpid is-active)
+
+exec_service_on_target openhpid stop
+
+if exec_service_on_target openhpid start
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> start of openhpid failed."
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ $service_status != "active" ]
+then
+    exec_service_on_target openhpid stop
+fi
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Fuego] [PATCH] Add test cases of service multipathd.
  2019-01-09  9:45 [Fuego] [PATCH] Add test cases of service openct Wang Mingyu
  2019-01-09  9:45 ` [Fuego] [PATCH] Add test case of service openhpid Wang Mingyu
@ 2019-01-09  9:45 ` Wang Mingyu
  2019-01-10 22:48   ` Tim.Bird
  2019-01-10 22:35 ` [Fuego] [PATCH] Add test cases of service openct Tim.Bird
  2 siblings, 1 reply; 10+ messages in thread
From: Wang Mingyu @ 2019-01-09  9:45 UTC (permalink / raw)
  To: fuego

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@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




^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Fuego] [PATCH] Add test cases of service openct.
  2019-01-09  9:45 [Fuego] [PATCH] Add test cases of service openct Wang Mingyu
  2019-01-09  9:45 ` [Fuego] [PATCH] Add test case of service openhpid Wang Mingyu
  2019-01-09  9:45 ` [Fuego] [PATCH] Add test cases of service multipathd Wang Mingyu
@ 2019-01-10 22:35 ` Tim.Bird
  2 siblings, 0 replies; 10+ messages in thread
From: Tim.Bird @ 2019-01-10 22:35 UTC (permalink / raw)
  To: wangmy, fuego

See comments inline below.

> -----Original Message-----
> From: Wang Mingyu
> 
> OpenCT implements drivers for several smart card readers.
> This test set is used to check the command openct-tool and openct-control
> of service openct.
> 
> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> ---
>  engine/tests/Functional.openct/fuego_test.sh       | 19 ++++++++++
>  engine/tests/Functional.openct/openct_test.sh      |  4 ++
>  engine/tests/Functional.openct/parser.py           | 22 +++++++++++
>  engine/tests/Functional.openct/spec.json           |  7 ++++
>  .../tests/Functional.openct/tests/openct_help.sh   | 12 ++++++
>  engine/tests/Functional.openct/tests/openct_ps.sh  | 44
> ++++++++++++++++++++++
>  6 files changed, 108 insertions(+)
>  create mode 100644 engine/tests/Functional.openct/fuego_test.sh
>  create mode 100755 engine/tests/Functional.openct/openct_test.sh
>  create mode 100644 engine/tests/Functional.openct/parser.py
>  create mode 100644 engine/tests/Functional.openct/spec.json
>  create mode 100644 engine/tests/Functional.openct/tests/openct_help.sh
>  create mode 100644 engine/tests/Functional.openct/tests/openct_ps.sh
> 
> diff --git a/engine/tests/Functional.openct/fuego_test.sh
> b/engine/tests/Functional.openct/fuego_test.sh
> new file mode 100644
> index 0000000..e008fdf
> --- /dev/null
> +++ b/engine/tests/Functional.openct/fuego_test.sh
> @@ -0,0 +1,19 @@
> +function test_pre_check {
> +    assert_has_program openct-control
> +    assert_has_program openct-tool
> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/openct_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;\
> +    ./openct_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/engine/tests/Functional.openct/openct_test.sh
> b/engine/tests/Functional.openct/openct_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/engine/tests/Functional.openct/openct_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> diff --git a/engine/tests/Functional.openct/parser.py
> b/engine/tests/Functional.openct/parser.py
> new file mode 100644
> index 0000000..d85abd7
> --- /dev/null
> +++ b/engine/tests/Functional.openct/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.openct/spec.json
> b/engine/tests/Functional.openct/spec.json
> new file mode 100644
> index 0000000..e758b68
> --- /dev/null
> +++ b/engine/tests/Functional.openct/spec.json
> @@ -0,0 +1,7 @@
> +{
> +    "testName": "Functional.openct",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> +
> diff --git a/engine/tests/Functional.openct/tests/openct_help.sh
> b/engine/tests/Functional.openct/tests/openct_help.sh
> new file mode 100644
> index 0000000..e7f6c9f
> --- /dev/null
> +++ b/engine/tests/Functional.openct/tests/openct_help.sh
> @@ -0,0 +1,12 @@
> +#!/bin/sh
> +
> +#  Check the help message of command openct-control.
> +
> +test="help"
> +
> +if openct-control -h | grep "usage"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> diff --git a/engine/tests/Functional.openct/tests/openct_ps.sh
> b/engine/tests/Functional.openct/tests/openct_ps.sh
> new file mode 100644
> index 0000000..cbb8ab4
> --- /dev/null
> +++ b/engine/tests/Functional.openct/tests/openct_ps.sh
> @@ -0,0 +1,44 @@
> +#!/bin/sh
> +
> +#  In the target start openct, and confirm the process condition by
> command ps.
> +
> +test="ps"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +service_status=$(exec_service_on_target openct is-active)

This only works if init_manager is systemd.  That is, systemctl
supports is-active, but sysvinit doesn't.  It uses '<servicename> status'

Unfortunately, you don't get a standardized output from each service,
so you'll probably have to specialize examining the response, like
you've done below.

> +
> +exec_service_on_target openct stop
> +
> +if exec_service_on_target openct start
> +then
> +    echo " -> start of openct succeeded."
> +else
> +    echo " -> start of openct failed."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +if [ "$init_manager" = "systemd" ]
The test has too much knowledge of fuego_board_function_lib internals here.

It might be good to make a new function for getting service status
in the library, and hide these details inside it.

Something like:

target_service_status openct

And have it return success or failure depending on whether the
service is running or not.

Or maybe you'll have do some something like:

target_service_status openct <regex-to-check-for>

to make it work with non-systemd services.

> +then
> +    if exec_service_on_target openct is-active
> +    then
> +        echo " -> $test: TEST-PASS"
> +    else
> +        echo " -> $test: TEST-FAIL"
> +    fi
> +else
> +    if exec_service_on_target openct status | grep "Waiting for reader
> attach/detach events"
> +    then
> +        echo " -> $test: TEST-PASS"
> +    else
> +        echo " -> $test: TEST-FAIL"
> +    fi
> +fi
> +
> +if [ $service_status != "active" ]
> +then
> +    exec_service_on_target openct stop
> +fi
> --
> 1.8.3.1


Please let me know if you can address my comments.  If not, I'll take it as is.
But architecturally it's not pretty.
 -- Tim


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fuego] [PATCH] Add test case of service openhpid.
  2019-01-09  9:45 ` [Fuego] [PATCH] Add test case of service openhpid Wang Mingyu
@ 2019-01-10 22:44   ` Tim.Bird
  0 siblings, 0 replies; 10+ messages in thread
From: Tim.Bird @ 2019-01-10 22:44 UTC (permalink / raw)
  To: wangmy, fuego

This has the same problem as the openct patch.

exec_service_on_target doesn't support the 'is-active'
method, unless you're using systemd as your initmanager.

Another approach to fix this is to add special handling in
the function 'exec_service_on_target' to check for 'is-active'
and translate it to either 'systemctl is-active <service_name>'
or 'service <service_name> status', or, if 'service' is not
available, to '/etc/init.d/<service_name> status'.

However, many old-style sysvinit services did not support
the 'status' operation.  Many only support 'start' and 
'stop'.  This might be OK for modern systems, operating
on modern service processes.

Please let me know what you think.

> -----Original Message-----
> From Wang Mingyu
> 
> The openhpid is HPI instance to which multiple clients can connect.
> This test set is used to check if the ps of service can be generated
> successfully.
> 
> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> ---
>  engine/tests/Functional.openhpid/fuego_test.sh     | 18 +++++++++++++++
>  engine/tests/Functional.openhpid/openhpid_test.sh  |  4 ++++
>  engine/tests/Functional.openhpid/parser.py         | 22
> ++++++++++++++++++
>  engine/tests/Functional.openhpid/spec.json         |  7 ++++++
>  .../tests/Functional.openhpid/tests/openhpid_ps.sh | 26
> ++++++++++++++++++++++
>  5 files changed, 77 insertions(+)
>  create mode 100644 engine/tests/Functional.openhpid/fuego_test.sh
>  create mode 100755 engine/tests/Functional.openhpid/openhpid_test.sh
>  create mode 100644 engine/tests/Functional.openhpid/parser.py
>  create mode 100644 engine/tests/Functional.openhpid/spec.json
>  create mode 100644
> engine/tests/Functional.openhpid/tests/openhpid_ps.sh
> 
> diff --git a/engine/tests/Functional.openhpid/fuego_test.sh
> b/engine/tests/Functional.openhpid/fuego_test.sh
> new file mode 100644
> index 0000000..33507dc
> --- /dev/null
> +++ b/engine/tests/Functional.openhpid/fuego_test.sh
> @@ -0,0 +1,18 @@
> +function test_pre_check {
> +    assert_has_program openhpid
> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/openhpid_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;\
> +    ./openhpid_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/engine/tests/Functional.openhpid/openhpid_test.sh
> b/engine/tests/Functional.openhpid/openhpid_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/engine/tests/Functional.openhpid/openhpid_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> diff --git a/engine/tests/Functional.openhpid/parser.py
> b/engine/tests/Functional.openhpid/parser.py
> new file mode 100644
> index 0000000..d85abd7
> --- /dev/null
> +++ b/engine/tests/Functional.openhpid/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.openhpid/spec.json
> b/engine/tests/Functional.openhpid/spec.json
> new file mode 100644
> index 0000000..9004c0d
> --- /dev/null
> +++ b/engine/tests/Functional.openhpid/spec.json
> @@ -0,0 +1,7 @@
> +{
> +    "testName": "Functional.openhpid",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> +
> diff --git a/engine/tests/Functional.openhpid/tests/openhpid_ps.sh
> b/engine/tests/Functional.openhpid/tests/openhpid_ps.sh
> new file mode 100644
> index 0000000..3d2f85d
> --- /dev/null
> +++ b/engine/tests/Functional.openhpid/tests/openhpid_ps.sh
> @@ -0,0 +1,26 @@
> +#!/bin/sh
> +
> +#  In the target start openhpid, and confirm the process condition by
> command ps.
> +
> +test="ps"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +service_status=$(exec_service_on_target openhpid is-active)
This only works if init_manager is systemd.

> +
> +exec_service_on_target openhpid stop
> +
> +if exec_service_on_target openhpid start
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> start of openhpid failed."
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +if [ $service_status != "active" ]
> +then
> +    exec_service_on_target openhpid stop
> +fi
> --
> 1.8.3.1

I do appreciate that you're trying to restore openhpid to
the state it was previously running in.

Thanks,
 -- Tim


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fuego] [PATCH] Add test cases of service multipathd.
  2019-01-09  9:45 ` [Fuego] [PATCH] Add test cases of service multipathd Wang Mingyu
@ 2019-01-10 22:48   ` Tim.Bird
  2019-01-10 23:03     ` Tim.Bird
  0 siblings, 1 reply; 10+ messages in thread
From: Tim.Bird @ 2019-01-10 22:48 UTC (permalink / raw)
  To: wangmy, fuego

Same comments as other patches.

'is-active' is only supported by systemctl (when init_manager is 'systemd')

Let's fix that issue, and rework these patches with the solution we
decide upon.
 -- Tim


> -----Original Message-----
> From: Wang Mingyu
> 
> 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@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
> 
> 
> 
> _______________________________________________
> Fuego mailing list
> Fuego@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fuego] [PATCH] Add test cases of service multipathd.
  2019-01-10 22:48   ` Tim.Bird
@ 2019-01-10 23:03     ` Tim.Bird
  2019-01-11  2:27       ` Wang, Mingyu
  2019-02-12  6:09       ` Wang, Mingyu
  0 siblings, 2 replies; 10+ messages in thread
From: Tim.Bird @ 2019-01-10 23:03 UTC (permalink / raw)
  To: Tim.Bird, wangmy, fuego



> -----Original Message-----
> From: Tim.Bird@sony.com
> 
> Same comments as other patches.
> 
> 'is-active' is only supported by systemctl (when init_manager is 'systemd')
> 
> Let's fix that issue, and rework these patches with the solution we
> decide upon.

I was just looking at fuego_board_function_lib.sh and saw this:
exec_service_on_target() {
    if [ "$init_manager" = "systemd" ]
    then
        systemctl $2 $1
    else
        $1 $2
    fi
}

This doesn't seem right.  Has this library been used for testing on a non-systemd platform?

I'm pretty sure that the command after the 'else' should be one of the following:
  service $1 $2
or
 /etc/init.d/$1 $2

For example, on a system I have here built with Yocto Project:
$ dropbear status
(no result)
$ /etc/init.d/dropbear status
Usage: /etc/init.d/dropbear {start|stop|restart|force-reload}
$

Which shows that the dropbear binary executed by itself doesn't
perform the start/start operations. It's the init script in /etc/init.d
that does this.  Also, that init script (the one for dropbear) doesn't
support the 'status' operation.

So, I think that 'status' is not a well-supported operation for embedded
Linux services (at least on systems that are using sysvinit as the init manager).
So maybe this whole is_active thing needs to be re-thought.

Maybe it's acceptable to just say that these tests are dependent on the system-under-test
using 'systemd'.  Or, maybe the legacy init scripts for these particular services
do all support the 'status' operation.

I think it was Fujitsu that introduced this concept of providing an abstraction for
service management into Fuego.  Is Fujitsu using systems without systemd?
It doesn't look like this exec_service_on_target would work on non-systemd systems.

Let me know your thoughts.
 -- Tim


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fuego] [PATCH] Add test cases of service multipathd.
  2019-01-10 23:03     ` Tim.Bird
@ 2019-01-11  2:27       ` Wang, Mingyu
  2019-02-12  6:09       ` Wang, Mingyu
  1 sibling, 0 replies; 10+ messages in thread
From: Wang, Mingyu @ 2019-01-11  2:27 UTC (permalink / raw)
  To: fuego

Hi Tim

>exec_service_on_target() {
>  if [ "$init_manager" = "systemd" ]
>    then
>        systemctl $2 $1
>    else
>        $1 $2
>    fi
>}

There is a problem with this code, which has been fixed in [PATCH] Bugfix: modify the command to start the service of sysvinit.
Actually 'is-active' is only supported by systemctl. 
I will fully consider the various situations and then add the function to fuego_board_function_lib.
After that I will resubmmit the patch, thanks for pointing out the problem.

wangmy


-----Original Message-----
From: Tim.Bird@sony.com [mailto:Tim.Bird@sony.com] 
Sent: Friday, January 11, 2019 7:04 AM
To: Tim.Bird@sony.com; Wang, Mingyu/王 鸣瑜 <wangmy@cn.fujitsu.com>; fuego@lists.linuxfoundation.org
Subject: RE: [Fuego] [PATCH] Add test cases of service multipathd.



> -----Original Message-----
> From: Tim.Bird@sony.com
> 
> Same comments as other patches.
> 
> 'is-active' is only supported by systemctl (when init_manager is 
> 'systemd')
> 
> Let's fix that issue, and rework these patches with the solution we 
> decide upon.

I was just looking at fuego_board_function_lib.sh and saw this:
exec_service_on_target() {
    if [ "$init_manager" = "systemd" ]
    then
        systemctl $2 $1
    else
        $1 $2
    fi
}

This doesn't seem right.  Has this library been used for testing on a non-systemd platform?

I'm pretty sure that the command after the 'else' should be one of the following:
  service $1 $2
or
 /etc/init.d/$1 $2

For example, on a system I have here built with Yocto Project:
$ dropbear status
(no result)
$ /etc/init.d/dropbear status
Usage: /etc/init.d/dropbear {start|stop|restart|force-reload} $

Which shows that the dropbear binary executed by itself doesn't perform the start/start operations. It's the init script in /etc/init.d that does this.  Also, that init script (the one for dropbear) doesn't support the 'status' operation.

So, I think that 'status' is not a well-supported operation for embedded Linux services (at least on systems that are using sysvinit as the init manager).
So maybe this whole is_active thing needs to be re-thought.

Maybe it's acceptable to just say that these tests are dependent on the system-under-test using 'systemd'.  Or, maybe the legacy init scripts for these particular services do all support the 'status' operation.

I think it was Fujitsu that introduced this concept of providing an abstraction for service management into Fuego.  Is Fujitsu using systems without systemd?
It doesn't look like this exec_service_on_target would work on non-systemd systems.

Let me know your thoughts.
 -- Tim






^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fuego] [PATCH] Add test cases of service multipathd.
  2019-01-10 23:03     ` Tim.Bird
  2019-01-11  2:27       ` Wang, Mingyu
@ 2019-02-12  6:09       ` Wang, Mingyu
  2019-02-16  1:42         ` Tim.Bird
  1 sibling, 1 reply; 10+ messages in thread
From: Wang, Mingyu @ 2019-02-12  6:09 UTC (permalink / raw)
  To: fuego

Hi Tim,

I tried the system using sysvinit and found that there is a problem that the status option of the service cannot obtain the return value correctly. There are two cases: 
1. There is no status option defined in service files, so the service status XX cannot get the status of the service (such as acpid). 
2. Even if the status option is defined in the service file, the service will not generate a pid file, so the correct status of the status will not be obtained (such as openct). 

For the above two cases, the status of the service cannot be judged before the test is executed, so the status of the service cannot be restored after the test is completed.
Is it need to skip the test of above two cases in the sysvinit environment?
If you have any good suggestions, please let me know. 

In addition, not all environments have the command service, maybe it’s better to use /etc/init.d.

by Wangmy.

-----Original Message-----
From: Tim.Bird@sony.com [mailto:Tim.Bird@sony.com] 
Sent: Friday, January 11, 2019 7:04 AM
To: Tim.Bird@sony.com; Wang, Mingyu/王 鸣瑜 <wangmy@cn.fujitsu.com>; fuego@lists.linuxfoundation.org
Subject: RE: [Fuego] [PATCH] Add test cases of service multipathd.



> -----Original Message-----
> From: Tim.Bird@sony.com
> 
> Same comments as other patches.
> 
> 'is-active' is only supported by systemctl (when init_manager is 
> 'systemd')
> 
> Let's fix that issue, and rework these patches with the solution we 
> decide upon.

I was just looking at fuego_board_function_lib.sh and saw this:
exec_service_on_target() {
    if [ "$init_manager" = "systemd" ]
    then
        systemctl $2 $1
    else
        $1 $2
    fi
}

This doesn't seem right.  Has this library been used for testing on a non-systemd platform?

I'm pretty sure that the command after the 'else' should be one of the following:
  service $1 $2
or
 /etc/init.d/$1 $2

For example, on a system I have here built with Yocto Project:
$ dropbear status
(no result)
$ /etc/init.d/dropbear status
Usage: /etc/init.d/dropbear {start|stop|restart|force-reload} $

Which shows that the dropbear binary executed by itself doesn't perform the start/start operations. It's the init script in /etc/init.d that does this.  Also, that init script (the one for dropbear) doesn't support the 'status' operation.

So, I think that 'status' is not a well-supported operation for embedded Linux services (at least on systems that are using sysvinit as the init manager).
So maybe this whole is_active thing needs to be re-thought.

Maybe it's acceptable to just say that these tests are dependent on the system-under-test using 'systemd'.  Or, maybe the legacy init scripts for these particular services do all support the 'status' operation.

I think it was Fujitsu that introduced this concept of providing an abstraction for service management into Fuego.  Is Fujitsu using systems without systemd?
It doesn't look like this exec_service_on_target would work on non-systemd systems.

Let me know your thoughts.
 -- Tim






^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Fuego] [PATCH] Add test cases of service multipathd.
  2019-02-12  6:09       ` Wang, Mingyu
@ 2019-02-16  1:42         ` Tim.Bird
  0 siblings, 0 replies; 10+ messages in thread
From: Tim.Bird @ 2019-02-16  1:42 UTC (permalink / raw)
  To: wangmy, fuego



> -----Original Message-----
> From: Wang, Mingyu
> 
> Hi Tim,
> 
> I tried the system using sysvinit and found that there is a problem that the
> status option of the service cannot obtain the return value correctly. There
> are two cases:
> 1. There is no status option defined in service files, so the service status XX
> cannot get the status of the service (such as acpid).
> 2. Even if the status option is defined in the service file, the service will not
> generate a pid file, so the correct status of the status will not be obtained
> (such as openct).
> 
> For the above two cases, the status of the service cannot be judged before
> the test is executed, so the status of the service cannot be restored after the
> test is completed.
> Is it need to skip the test of above two cases in the sysvinit environment?
> If you have any good suggestions, please let me know.

Hopefully, we can detect the cases you mention.  If we don't see the expected
string from "/etc/init.d/<service> status", then we should assume that the
'status' operation is not supported, and return "unknown", and let
the test decide what to do.  See my comments
on the patch to fuego_board_function_lib.sh.

In those tests that try to save the status and restore it, I'm OK with 
leaving the service running if the test cannot determine the correct
pre-test state of the service.  It might be worth reporting that in the
test log, so users can be advised that the board might not be in the same
state as when the test started.

> 
> In addition, not all environments have the command service, maybe it’s
> better to use /etc/init.d.
See my comment in patch.

Modern systems have system.  Old systems support direct script execution.
The main reason for supporting 'service' is for systems that are "in between"
the two extremes.  'service' was introduced specifically to allow rc scripts
to be managed independent of the distribution (e.g. all of RedHat, SUSE
and Debian supported it, unifying the service management CLI)

I don't know if there are enough old systems still around to justify supporting
all three mechanisms or not.  I think I'm OK for now leaving support for 'service'
out (only supporting the systemctl and /etc/init.d/<service> methods
of managing the services)  and just making a note somewhere so that if this
problems crop up someone will have some clues to follow.
 -- Tim

> 
> by Wangmy.
> 
> -----Original Message-----
> From: Tim.Bird@sony.com [mailto:Tim.Bird@sony.com]
> Sent: Friday, January 11, 2019 7:04 AM
> To: Tim.Bird@sony.com; Wang, Mingyu/王 鸣瑜
> <wangmy@cn.fujitsu.com>; fuego@lists.linuxfoundation.org
> Subject: RE: [Fuego] [PATCH] Add test cases of service multipathd.
> 
> 
> 
> > -----Original Message-----
> > From: Tim.Bird@sony.com
> >
> > Same comments as other patches.
> >
> > 'is-active' is only supported by systemctl (when init_manager is
> > 'systemd')
> >
> > Let's fix that issue, and rework these patches with the solution we
> > decide upon.
> 
> I was just looking at fuego_board_function_lib.sh and saw this:
> exec_service_on_target() {
>     if [ "$init_manager" = "systemd" ]
>     then
>         systemctl $2 $1
>     else
>         $1 $2
>     fi
> }
> 
> This doesn't seem right.  Has this library been used for testing on a non-
> systemd platform?
> 
> I'm pretty sure that the command after the 'else' should be one of the
> following:
>   service $1 $2
> or
>  /etc/init.d/$1 $2
> 
> For example, on a system I have here built with Yocto Project:
> $ dropbear status
> (no result)
> $ /etc/init.d/dropbear status
> Usage: /etc/init.d/dropbear {start|stop|restart|force-reload} $
> 
> Which shows that the dropbear binary executed by itself doesn't perform
> the start/start operations. It's the init script in /etc/init.d that does this.  Also,
> that init script (the one for dropbear) doesn't support the 'status' operation.
> 
> So, I think that 'status' is not a well-supported operation for embedded Linux
> services (at least on systems that are using sysvinit as the init manager).
> So maybe this whole is_active thing needs to be re-thought.
> 
> Maybe it's acceptable to just say that these tests are dependent on the
> system-under-test using 'systemd'.  Or, maybe the legacy init scripts for
> these particular services do all support the 'status' operation.
> 
> I think it was Fujitsu that introduced this concept of providing an abstraction
> for service management into Fuego.  Is Fujitsu using systems without
> systemd?
> It doesn't look like this exec_service_on_target would work on non-systemd
> systems.
> 
> Let me know your thoughts.
>  -- Tim
> 
> 
> 
> 
> 
> _______________________________________________
> Fuego mailing list
> Fuego@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-02-16  1:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-09  9:45 [Fuego] [PATCH] Add test cases of service openct Wang Mingyu
2019-01-09  9:45 ` [Fuego] [PATCH] Add test case of service openhpid Wang Mingyu
2019-01-10 22:44   ` Tim.Bird
2019-01-09  9:45 ` [Fuego] [PATCH] Add test cases of service multipathd Wang Mingyu
2019-01-10 22:48   ` Tim.Bird
2019-01-10 23:03     ` Tim.Bird
2019-01-11  2:27       ` Wang, Mingyu
2019-02-12  6:09       ` Wang, Mingyu
2019-02-16  1:42         ` Tim.Bird
2019-01-10 22:35 ` [Fuego] [PATCH] Add test cases of service openct Tim.Bird

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.