[Fuego] [PATCH] demo: Add test cases of service openvpn, openwsmand, ospf6d and ospfd.

Tim.Bird at sony.com Tim.Bird at sony.com
Wed Dec 12 01:47:44 UTC 2018


Please see my comments inline below.

> -----Original Message-----
> From: Wang Mingyu
> 
> From: root <root at localhost.localdomain>
This is not right.  I think your 'git config' is not set up properly.
This should be your name and e-mail address.

> 
> Signed-off-by: root <root at localhost.localdomain>
I cannot accept a patch with an improper Signed-off-by line.
Please re-submit with corrected Signed-off-by line.


> ---
>  engine/tests/Functional.demo/tests/demo_openvpn.sh | 69
> +++++++++++++++++++
>  .../tests/Functional.demo/tests/demo_openwsmand.sh | 37 ++++++++++
>  engine/tests/Functional.demo/tests/demo_ospf6d.sh  | 78
> ++++++++++++++++++++++
>  engine/tests/Functional.demo/tests/demo_ospfd.sh   | 78
> ++++++++++++++++++++++
>  4 files changed, 262 insertions(+)
>  create mode 100644
> engine/tests/Functional.demo/tests/demo_openvpn.sh
>  create mode 100644
> engine/tests/Functional.demo/tests/demo_openwsmand.sh
>  create mode 100644 engine/tests/Functional.demo/tests/demo_ospf6d.sh
>  create mode 100644 engine/tests/Functional.demo/tests/demo_ospfd.sh
> 
> diff --git a/engine/tests/Functional.demo/tests/demo_openvpn.sh
> b/engine/tests/Functional.demo/tests/demo_openvpn.sh
> new file mode 100644
> index 0000000..43f998a
> --- /dev/null
> +++ b/engine/tests/Functional.demo/tests/demo_openvpn.sh
The name of this test is too generic.  "demo" is a very generic name
and could refer to anything.

Please be more specific.  Is this referring to a Fujitsu demo of router
functionality?  All of the patches submitted by you today, and many 
previous patches (that are in my backlog queue) appear to be "underneath" this
Functional test, but it covers a wide range of utilities and services.

The collection of these tests might all relate to a single demo distribution
or product, but individual tests (like for postfix, sshd, or wpa_supplicant)
will likely be useful for other Fuego users.

I think this whole set of tests need to be refactored.

It looks like the "base" patch for "Functional.demo" was submitted
back on September 26 as "Add test cases for command acpid, atd, auditd".
This is the one with fuego_test.sh, parser.py, spec.json and demo_test.sh.

If that is too much work, I'm willing to allow you to rename this just to
"Functional.Fujitsu-router-demo", or something like that.  But ultimately
it would be more useful if all these sub-tests were broken out into separate
tests.

Let me know what you'd like to do.

Independent of that, other comments are inline below.

> @@ -0,0 +1,69 @@
> +#!/bin/sh
> +
> +#  In the target start openvpn, and confirm the process condition by
> command ps.
> +
> +test="openvpn"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +service_name="service-name-not-set"
> +
> +if [ "$init_manager" = "systemd" ]
> +then
> +    service_name="openvpn at loopback-server.service"
> +    config_file="/etc/openvpn/loopback-server.conf"
> +else
> +    service_name="openvpn"
> +    config_file="/etc/openvpn/testsrv.conf"
> +fi
> +
> +exec_service_on_target $service_name stop
> +
> +if [ -f $config_file ]
> +then
> +    cp $config_file ${config_file}_bak
> +fi
> +
> +cp data/testsrv.conf $config_file
> +
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +restore_target() {
> +    if [ -f ${config_file}_bak ]
> +    then
> +        mv ${config_file}_bak $config_file
> +    fi
> +}
> +
> +modprobe tun

Should add "assert_has_program modprobe" to fuego_test.sh for this test.

> +
> +mkdir -m 755 /dev/net
> +
> +mknod /dev/net/tun c 10 200
> +
> +if exec_service_on_target $service_name start
> +then
> +    echo " -> start of openvpn succeeded."
> +else
> +    echo " -> start of openvpn failed."
> +    echo " -> $test: TEST-FAIL"
> +    modprobe -r tun
does this automatically stop the service?

I would be more comfortable if there was an "exec_service_on_target $service_name stop" before
the modulde removal here.

> +    restore_target
> +    exit
> +fi
> +
> +sleep 5
> +
> +if ps aux | grep "[/]usr/sbin/openvpn"
> +then
> +    echo " -> get the process of openvpn."
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> can't get the process of openvpn."
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
Should stop the service here, if it was not running when we started the test.
Otherwise, (if it *was* running when the test started), we should
restoring the configuration and restart the service. 

> +modprobe -r tun
Should only remove the module if it was not present when we started the test.

> +restore_target
> diff --git a/engine/tests/Functional.demo/tests/demo_openwsmand.sh
> b/engine/tests/Functional.demo/tests/demo_openwsmand.sh
> new file mode 100644
> index 0000000..eb90cbc
> --- /dev/null
> +++ b/engine/tests/Functional.demo/tests/demo_openwsmand.sh
> @@ -0,0 +1,37 @@
> +#!/bin/sh
> +
> +#  In the target start openwsmand, and confirm the process condition by
> command ps.
> +
> +test="openwsmand"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +exec_service_on_target openwsmand stop
> +
> +cp /etc/openwsman/ssleay.cnf /etc/openwsman/ssleay.cnf_bak
> +
> +sed -i 's/random/urandom/g' /etc/openwsman/ssleay.cnf

Should add 'assert_has_program sed' in fuego_test.sh for this test

> +
> +if exec_service_on_target openwsmand start
> +then
> +    echo " -> start of openwsmand succeeded."
> +else
> +    echo " -> start of openwsmand failed."
> +    echo " -> $test: TEST-FAIL"
> +    mv /etc/openwsman/ssleay.cnf_bak /etc/openwsman/ssleay.cnf
> +    exit
> +fi
> +
> +sleep 5
> +
> +if ps aux | grep "[/]usr/sbin/openwsmand"
> +then
> +    echo " -> get the process of openwsmand."
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> can't get the process of openwsmand."
> +    echo " -> $test: TEST-FAIL"
> +fi
> +mv /etc/openwsman/ssleay.cnf_bak /etc/openwsman/ssleay.cnf
Should make sure machine is in same state after test as when we started.
If openwsmand was running when we started, it should be running when
we exit.  If not, it should be stopped when we exit.

> diff --git a/engine/tests/Functional.demo/tests/demo_ospf6d.sh
> b/engine/tests/Functional.demo/tests/demo_ospf6d.sh
> new file mode 100644
> index 0000000..22725d8
> --- /dev/null
> +++ b/engine/tests/Functional.demo/tests/demo_ospf6d.sh
> @@ -0,0 +1,78 @@
> +#!/bin/sh
> +
> +#  In the target start ospf6d, and confirm the process condition by command
> ps.
> +
> +test="ospf6d"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +restore_target() {
> +    if [ -f /etc/quagga/zebra.conf_bak ]
> +    then
> +        mv /etc/quagga/zebra.conf_bak /etc/quagga/zebra.conf
> +    else
> +        rm -f /etc/quagga/zebra.conf
> +    fi
> +
> +    if [ -f /etc/quagga/ospf6d.conf_bak ]
> +    then
> +        mv /etc/quagga/ospf6d.conf_bak /etc/quagga/ospf6d.conf
> +    else
> +        rm -f /etc/quagga/ospf6d.conf
> +    fi
> +}
> +
> +if [ "$init_manager" = "systemd" ]
> +then
> +    exec_service_on_target ospf6d stop
> +    exec_service_on_target zebra stop
> +else
> +    /etc/init.d/quagga stop ospf6d
> +    /etc/init.d/quagga stop zebra
> +fi
> +
> +if [ -f /etc/quagga/zebra.conf ]
> +then
> +    cp /etc/quagga/zebra.conf /etc/quagga/zebra.conf_bak
> +fi
> +
> +if [ -f /etc/quagga/ospf6d.conf ]
> +then
> +    cp /etc/quagga/ospf6d.conf /etc/quagga/ospf6d.conf_bak
> +fi
> +
> +cp data/zebra.conf /etc/quagga/zebra.conf
> +cp data/ospf6d.conf /etc/quagga/ospf6d.conf
> +chown quagga:quagga /etc/quagga/*.conf
> +
> +if [ "$init_manager" = "systemd" ]
> +then
> +    exec_service_on_target zebra start
> +    exec_service_on_target ospf6d start
> +else
> +    /etc/init.d/quagga start zebra
> +    /etc/init.d/quagga start ospf6d
> +fi
> +
> +sleep 5
> +
> +if ps aux | grep "[/]usr/sbin/ospf6d"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> can't get the process of ospf6d."
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +if [ "$init_manager" = "systemd" ]
> +then
> +    exec_service_on_target ospf6d stop
> +    exec_service_on_target zebra stop
> +else
> +    /etc/init.d/quagga stop ospf6d
> +    /etc/init.d/quagga stop zebra
> +fi
> +
> +restore_target
Should stop service if it was not running when we started.  Or re-start it
with restored configuration, if it *was* running when we started.

> diff --git a/engine/tests/Functional.demo/tests/demo_ospfd.sh
> b/engine/tests/Functional.demo/tests/demo_ospfd.sh
> new file mode 100644
> index 0000000..789a61f
> --- /dev/null
> +++ b/engine/tests/Functional.demo/tests/demo_ospfd.sh
> @@ -0,0 +1,78 @@
> +#!/bin/sh
> +
> +#  In the target start ospfd, and confirm the process condition by command
> ps.
> +
> +test="ospfd"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +restore_target() {
> +    if [ -f /etc/quagga/zebra.conf_bak ]
> +    then
> +        mv /etc/quagga/zebra.conf_bak /etc/quagga/zebra.conf
> +    else
> +        rm -f /etc/quagga/zebra.conf
> +    fi
> +
> +    if [ -f /etc/quagga/ospfd.conf_bak ]
> +    then
> +        mv /etc/quagga/ospfd.conf_bak /etc/quagga/ospfd.conf
> +    else
> +        rm -f /etc/quagga/ospfd.conf
> +    fi
> +}
> +
> +if [ "$init_manager" = "systemd" ]
> +then
> +    exec_service_on_target ospfd stop
> +    exec_service_on_target zebra stop
> +else
> +    /etc/init.d/quagga stop ospfd
> +    /etc/init.d/quagga stop zebra
> +fi
> +
> +if [ -f /etc/quagga/zebra.conf ]
> +then
> +    cp /etc/quagga/zebra.conf /etc/quagga/zebra.conf_bak
> +fi
> +
> +if [ -f /etc/quagga/ospfd.conf ]
> +then
> +    cp /etc/quagga/ospfd.conf /etc/quagga/ospfd.conf_bak
> +fi
> +
> +cp data/zebra.conf /etc/quagga/zebra.conf
> +cp data/ospfd.conf /etc/quagga/ospfd.conf
> +chown quagga:quagga /etc/quagga/*.conf
> +
> +if [ "$init_manager" = "systemd" ]
> +then
> +    exec_service_on_target zebra start
> +    exec_service_on_target ospfd start
> +else
> +    /etc/init.d/quagga start zebra
> +    /etc/init.d/quagga start ospfd
> +fi
> +
> +sleep 5
> +
> +if ps aux | grep "[/]usr/sbin/ospfd"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> can't get the process of ospfd."
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +if [ "$init_manager" = "systemd" ]
> +then
> +    exec_service_on_target ospfd stop
> +    exec_service_on_target zebra stop
> +else
> +    /etc/init.d/quagga stop ospfd
> +    /etc/init.d/quagga stop zebra
> +fi
> +
> +restore_target
Same issue here as with other tests.  Need to leave board in same state we found it.
> --

Thank you for this submission.  I'm sorry it's taken this long to review patches from
the "Functional.demo" suite.  Please let me know how you'd like to proceed
(either by refactoring this test into multiple test of individual functionality, or by
renaming "Functional.demo" to something less generic.)

My preference is to refactor.

Regards,
 -- Tim



More information about the Fuego mailing list