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

Wang Mingyu wangmy at cn.fujitsu.com
Wed Dec 12 08:05:53 UTC 2018


From: root <root at localhost.localdomain>

Signed-off-by: root <root at localhost.localdomain>
---
 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
@@ -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
+
+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
+    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
+
+modprobe -r tun
+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
+
+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
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
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
-- 
1.8.3.1





More information about the Fuego mailing list