[Fuego] [PATCH] Add test case of service openhpid.

Tim.Bird at sony.com Tim.Bird at sony.com
Thu Jan 10 22:44:23 UTC 2019


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



More information about the Fuego mailing list