All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate.
@ 2019-11-18 10:49 Wang Mingyu
  2019-11-18 10:49 ` [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn Wang Mingyu
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Wang Mingyu @ 2019-11-18 10:49 UTC (permalink / raw)
  To: fuego

Logrotate is designed to ease administration of systems that generate
large numbers of log files.
This test set is used to check if rotate file can be created.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.logrotate/data/test.conf     |   8 ++++
 tests/Functional.logrotate/data/testlog.sh    |   8 ++++
 tests/Functional.logrotate/data/testlog100k   | Bin 0 -> 105984 bytes
 tests/Functional.logrotate/fuego_test.sh      |  23 ++++++++++
 tests/Functional.logrotate/logrotate_test.sh  |   4 ++
 tests/Functional.logrotate/spec.json          |   6 +++
 tests/Functional.logrotate/test.yaml          |  24 ++++++++++
 .../tests/logrotate_config.sh                 |  28 ++++++++++++
 .../tests/logrotate_help.sh                   |  13 ++++++
 .../tests/logrotate_rotation.sh               |  42 ++++++++++++++++++
 .../tests/logrotate_size.sh                   |  39 ++++++++++++++++
 .../tests/logrotate_status.sh                 |  26 +++++++++++
 12 files changed, 221 insertions(+)
 create mode 100644 tests/Functional.logrotate/data/test.conf
 create mode 100644 tests/Functional.logrotate/data/testlog.sh
 create mode 100644 tests/Functional.logrotate/data/testlog100k
 create mode 100644 tests/Functional.logrotate/fuego_test.sh
 create mode 100755 tests/Functional.logrotate/logrotate_test.sh
 create mode 100644 tests/Functional.logrotate/spec.json
 create mode 100644 tests/Functional.logrotate/test.yaml
 create mode 100644 tests/Functional.logrotate/tests/logrotate_config.sh
 create mode 100644 tests/Functional.logrotate/tests/logrotate_help.sh
 create mode 100644 tests/Functional.logrotate/tests/logrotate_rotation.sh
 create mode 100644 tests/Functional.logrotate/tests/logrotate_size.sh
 create mode 100644 tests/Functional.logrotate/tests/logrotate_status.sh

diff --git a/tests/Functional.logrotate/data/test.conf b/tests/Functional.logrotate/data/test.conf
new file mode 100644
index 0000000..a346adf
--- /dev/null
+++ b/tests/Functional.logrotate/data/test.conf
@@ -0,0 +1,8 @@
+/var/log/testlog {
+        create 600 root root
+        ifempty
+        daily
+        nocompress
+        missingok
+        rotate 1
+}
diff --git a/tests/Functional.logrotate/data/testlog.sh b/tests/Functional.logrotate/data/testlog.sh
new file mode 100644
index 0000000..663abe3
--- /dev/null
+++ b/tests/Functional.logrotate/data/testlog.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+today=$(date +%s)
+# there are 86000 seconds in a day
+yesterday=$(( $today - 86000 ))
+ddch=$(date --date "@$yesterday" "+%Y-%m-%d")
+echo "logrotate state -- version 2" >> /var/lib/logrotate.status
+echo "\"/var/log/testlog\" $ddch" >> /var/lib/logrotate.status
diff --git a/tests/Functional.logrotate/data/testlog100k b/tests/Functional.logrotate/data/testlog100k
new file mode 100644
index 0000000000000000000000000000000000000000..1dc679f54731568a9cbda775a663b7ea51595fe3
GIT binary patch
literal 105984
zcmeI5d0-U9^2b*N!X;-EJdh;28zdV8yGaO9L{XdL$K@>wVs7M00!a`-{fUA^e4r2f
z0X{&`=Zyl&Q#|l~hzE+OPr(y!P(TqC1(8=ZGs|u^JKbNze|~PwA7rMhr<;7HQr%Ns
zU6bVTc!qWHcq*%_x`gQ5?O<8e*uv_n8n+rAPq1rNC?_k_H7l6i&ArxNU$S6WifZ-y
zk)EdQlWR@CZ4y=Z>I|EIwx%-6guez*l;{ECU-I)25dX$>-%vpRqnejf1A)hgf1_4M
z7;4#K*8gz@nEk0KzI>#vQI=m>IJPjWrn;)EB&)b8tE^_!NHSSj#T8kjDs{L1rDXps
zN>PjQT9E#?9bo#!nE#v+Hvb$=WtJ6=FRjv4@sw9omsS?%BszZ2C1ok<`|`us{*>!@
zv5fgIclhUODzi-ZYXC)wiirR24b5QwUpV}AlNOc<|0u|s(+c80cS&=Yzvpt>{^V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Aa@8K>fRi_5Ilak<$2Q%>VNf9Q&i$|H$)y)A$?l
z|0nkM*XHyJs7rcS@juY|mvZ*sg)|#rSSI=(Ux#B$pCkTL?zX;vWYmA2|9lAOe{3Ie
z?M~o>3j%6KCoKM)`IiCvzubEhNi2b1hXhpl#n}9l`FD5bKf3ta*goXioxr%_fSNk9
zxqF2u3G=@JSbvGSMNSO_<`Vx$ZZ=eM#LPbjh=0aflUht*en~)G_Zpsm=0a!xg`^+;
zbM)sv;@@!!_Ws5CKi{$cn%A#C=RcMptrUz3sOfXDUzYjb?&!Z}`5kLaYFPw691~Cv
z`SASPX94eDf)*#RbZkJ~*%+VyoCElO@ZP27a^l}43D<ul{$Hr#1RlO4poXl(^Pl|I
z!}h;v+&>;#|C0Py;3IgH_)oqQ+ke61FTx+}TB;F&;rCGd!(M#<9kTyLz~Tf-i2qHG
z;p^}Jp{g8zCH4nrtgAUOH&b2o631Ve^S|->%THndv!+qro@a`GW_iLVpCN|V5&!)s
zHG=uCJl58KP58NoWwQTBqo7fuTk|v3yKgt)`19JR;<%@*|LYz8I{y#LgnwLw^$PDH
z{`XT-ZG=D1e;xt!zg{O&;7Z^T;$Jfh^S`nF|8OE^e@yG|vj4(<B<=cUs&Nmp{ZB4%
zeMpXg`ENbi=C51-LiYa(e;ewu!I|pPVw`_YJDb1G|H(3w{!9Fc&HwOoGS%BFt@!^+
zyTtup*8c~F*!*c3()D1OjK8jU>Ieo8$yB>*t^M!N{HG|{=C50Sq4|HF%>V0PcD*>M
rFjK9XhUMR8{oi(p%|EDl0jAe4@xQqeuPfMaO{VH_1<yat@4x>AP`)FD

literal 0
HcmV?d00001

diff --git a/tests/Functional.logrotate/fuego_test.sh b/tests/Functional.logrotate/fuego_test.sh
new file mode 100644
index 0000000..c6e0579
--- /dev/null
+++ b/tests/Functional.logrotate/fuego_test.sh
@@ -0,0 +1,23 @@
+NEED_ROOT=1
+
+function test_pre_check {
+    assert_has_program logrotate
+    assert_has_program ntpdate
+    assert_has_program date
+}
+
+function test_deploy {
+    put $TEST_HOME/logrotate_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export test_host=$SRV_IP;\
+    ./logrotate_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.logrotate/logrotate_test.sh b/tests/Functional.logrotate/logrotate_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.logrotate/logrotate_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.logrotate/spec.json b/tests/Functional.logrotate/spec.json
new file mode 100644
index 0000000..cfd6646
--- /dev/null
+++ b/tests/Functional.logrotate/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.logrotate",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.logrotate/test.yaml b/tests/Functional.logrotate/test.yaml
new file mode 100644
index 0000000..d43799f
--- /dev/null
+++ b/tests/Functional.logrotate/test.yaml
@@ -0,0 +1,24 @@
+fuego_package_version: 1
+name: Functional.logrotate
+description: |
+      Logrotate is designed to ease administration of systems that generate
+      large numbers of log files.
+      It allows automatic rotation, compression, removal, and mailing of log files.
+      This is a simple test to check the common options and features of logrotate.
+license: BSD-3-Clause
+author: Wang Mingyu <wangmy@cn.fujitsu.com>
+maintainer: Wang Mingyu <wangmy@cn.fujitsu.com>
+version: 1.00
+fuego_release: 1
+type: Functional
+tags: ['logrotate']
+params:
+    SRV_IP:
+        description: the IP address of your host - Defined in board file
+data_files:
+ - logrotate_test.sh
+ - fuego_test.sh
+ - spec.json
+ - test.yaml
+ - data
+ - tests
diff --git a/tests/Functional.logrotate/tests/logrotate_config.sh b/tests/Functional.logrotate/tests/logrotate_config.sh
new file mode 100644
index 0000000..bc8d707
--- /dev/null
+++ b/tests/Functional.logrotate/tests/logrotate_config.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+#  Turns on verbose mode and confirm the result.
+#  option : -dv
+
+test="test config"
+
+if [ -f /var/lib/logrotate.status ]
+then
+    mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
+fi
+
+cp data/test.conf /etc/logrotate.d/test.conf
+
+chown root /etc/logrotate.d/test.conf
+
+if logrotate -dv /etc/logrotate.d/test.conf
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ -f /var/lib/logrotate.status_bak ]
+then
+    mv /var/lib/logrotate.status_bak /var/lib/logrotate.status
+fi
+rm -f /etc/logrotate.d/test.conf
diff --git a/tests/Functional.logrotate/tests/logrotate_help.sh b/tests/Functional.logrotate/tests/logrotate_help.sh
new file mode 100644
index 0000000..37390df
--- /dev/null
+++ b/tests/Functional.logrotate/tests/logrotate_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In the target to execute command logrotate and confirm the result.
+#  option : --help
+
+test="help"
+
+if logrotate --help | grep "Usage"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.logrotate/tests/logrotate_rotation.sh b/tests/Functional.logrotate/tests/logrotate_rotation.sh
new file mode 100644
index 0000000..f0d5e92
--- /dev/null
+++ b/tests/Functional.logrotate/tests/logrotate_rotation.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+#  Verify that the rotate file is created in the specified directory.
+#  option : -v
+
+test="log rotation"
+
+if [ -f /var/log/testlog* ]
+then
+    rm -f /var/log/testlog*
+fi
+
+if [ -f /var/lib/logrotate.status ]
+then
+    mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
+fi
+
+ntpdate $test_host
+
+cp data/test.conf /etc/logrotate.d/test.conf
+
+touch /var/log/testlog
+
+cp data/testlog.sh data/testlog_test.sh
+chmod +x data/testlog_test.sh
+data/testlog_test.sh
+chown root /etc/logrotate.d/test.conf
+logrotate -v /etc/logrotate.d/test.conf
+if ls /var/log/testlog.1
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+rm -f /etc/logrotate.d/test.conf
+rm -f /var/log/testlog*
+rm -f data/testlog_test.sh
+if [ -f /var/lib/logrotate.status_bak ]
+then
+    mv /var/lib/logrotate.status_bak /var/lib/logrotate.status
+fi
diff --git a/tests/Functional.logrotate/tests/logrotate_size.sh b/tests/Functional.logrotate/tests/logrotate_size.sh
new file mode 100644
index 0000000..2e215cd
--- /dev/null
+++ b/tests/Functional.logrotate/tests/logrotate_size.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+#  Verify that the rotate file is created in the specified directory.
+#  option : -v
+
+test="log rotation size"
+
+if [ -f /var/log/testlog* ]
+then
+    rm -f /var/log/testlog*
+fi
+
+if [ -f /var/lib/logrotate.status ]
+then
+    mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
+fi
+cp data/test.conf /etc/logrotate.d/test.conf
+
+cp data/testlog100k /var/log/testlog
+
+cp data/testlog.sh data/testlog_test.sh
+chmod +x data/testlog_test.sh
+data/testlog_test.sh
+chown root /etc/logrotate.d/test.conf
+logrotate -v /etc/logrotate.d/test.conf
+if ls /var/log/testlog.1
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+rm -f /etc/logrotate.d/test.conf
+rm -f /var/log/testlog*
+rm -f data/testlog_test.sh
+if [ -f /var/lib/logrotate.status_bak ]
+then
+    mv /var/lib/logrotate.status_bak /var/lib/logrotate.status
+fi
diff --git a/tests/Functional.logrotate/tests/logrotate_status.sh b/tests/Functional.logrotate/tests/logrotate_status.sh
new file mode 100644
index 0000000..36f61a3
--- /dev/null
+++ b/tests/Functional.logrotate/tests/logrotate_status.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#  Turns on verbose mode.
+#  option : -v
+
+test="log status add"
+
+if [ -f /var/lib/logrotate.status ]
+then
+    mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
+fi
+cp data/test.conf /etc/logrotate.d/test.conf
+
+logrotate -v /etc/logrotate.d/test.conf
+
+if tail /var/lib/logrotate.status | grep testlog
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f /etc/logrotate.d/test.conf
+if [ -f /var/lib/logrotate.status_bak ]
+then
+    mv /var/lib/logrotate.status_bak /var/lib/logrotate.status
+fi
-- 
2.17.1




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

* [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn.
  2019-11-18 10:49 [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate Wang Mingyu
@ 2019-11-18 10:49 ` Wang Mingyu
  2019-11-19 17:00   ` Tim.Bird
  2019-11-18 10:49 ` [Fuego] [PATCH] Add function to get the status of module Wang Mingyu
  2019-11-18 18:16 ` [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate Tim.Bird
  2 siblings, 1 reply; 8+ messages in thread
From: Wang Mingyu @ 2019-11-18 10:49 UTC (permalink / raw)
  To: fuego

This test set is used to check if the service openvpn can be started.
And check the process file, syslog file, tap0 can be created or not.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 scripts/fuego_board_function_lib.sh           | 14 ++++
 tests/Functional.openvpn/data/host-target.key | 22 ++++++
 tests/Functional.openvpn/data/testcli.conf    |  7 ++
 tests/Functional.openvpn/data/testenv.sh      | 79 +++++++++++++++++++
 tests/Functional.openvpn/data/testsrv.conf    | 16 ++++
 tests/Functional.openvpn/fuego_test.sh        | 21 +++++
 tests/Functional.openvpn/openvpn_test.sh      | 14 ++++
 tests/Functional.openvpn/spec.json            |  6 ++
 .../tests/openvpn_genkey.sh                   | 26 ++++++
 .../Functional.openvpn/tests/openvpn_lport.sh | 34 ++++++++
 tests/Functional.openvpn/tests/openvpn_pid.sh | 31 ++++++++
 tests/Functional.openvpn/tests/openvpn_ps.sh  | 36 +++++++++
 .../tests/openvpn_syslog-ng.sh                | 42 ++++++++++
 tests/Functional.openvpn/tests/openvpn_tun.sh | 27 +++++++
 14 files changed, 375 insertions(+)
 create mode 100644 tests/Functional.openvpn/data/host-target.key
 create mode 100644 tests/Functional.openvpn/data/testcli.conf
 create mode 100644 tests/Functional.openvpn/data/testenv.sh
 create mode 100644 tests/Functional.openvpn/data/testsrv.conf
 create mode 100644 tests/Functional.openvpn/fuego_test.sh
 create mode 100755 tests/Functional.openvpn/openvpn_test.sh
 create mode 100644 tests/Functional.openvpn/spec.json
 create mode 100644 tests/Functional.openvpn/tests/openvpn_genkey.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_lport.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_pid.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_ps.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_syslog-ng.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_tun.sh

diff --git a/scripts/fuego_board_function_lib.sh b/scripts/fuego_board_function_lib.sh
index a6cd842..115c615 100644
--- a/scripts/fuego_board_function_lib.sh
+++ b/scripts/fuego_board_function_lib.sh
@@ -12,6 +12,7 @@
 init_manager="init_manager-not-set"
 logger_service="logger_service-not-set"
 service_status="unknown"
+module_status="unknown"
 
 # set_init_manager:
 #   detects and sets the init_manager variable, which indicates which
@@ -100,3 +101,16 @@ get_service_logfile() {
     fi
     echo $service_logfile
 }
+
+# get_module_status:
+# get status of module
+# returns: status of module
+get_module_status() {
+    if lsmod | grep $1
+    then
+        module_status="loaded"
+    else
+        module_status="unloaded"
+    fi
+    echo $module_status
+}
diff --git a/tests/Functional.openvpn/data/host-target.key b/tests/Functional.openvpn/data/host-target.key
new file mode 100644
index 0000000..99743bf
--- /dev/null
+++ b/tests/Functional.openvpn/data/host-target.key
@@ -0,0 +1,22 @@
+#
+# 2048 bit OpenVPN static key
+#
+-----BEGIN OpenVPN Static key V1-----
+debe9557c7eb224c5cf4f3369d5211ff
+fb9c375a4784759edf6b0f6eb8f5da31
+bb280394d40382cc8e02d6cbb3e47492
+3509eac6b48965078e3d317b0791dea2
+dbcf0eddcab0fb20780fcf0908ce94cd
+7cb65a913fea73ac6bfe0ab34f085aa3
+a6c8b89a97d189e5145c3199955c4b34
+6d51f864f2b49f3252d1548c3b3510ec
+0ecd4b9f17f2039439a79f41a46f6a54
+c0385b962b2b94fcbe73e0108b224a5b
+2efae27d872f0efef67b244c7eb6f525
+581e4c2b4e6aa193fb1d37798bdb46ff
+7c6727f08e9601c10ac7478d73d731e6
+f4b652252f3e5309cd1d6d30c7a433cc
+134bd6dd50fa6a6fc7a843fdc058d38d
+fb8679b48eb09745badf004fbf4a434c
+-----END OpenVPN Static key V1-----
+
diff --git a/tests/Functional.openvpn/data/testcli.conf b/tests/Functional.openvpn/data/testcli.conf
new file mode 100644
index 0000000..2c252bb
--- /dev/null
+++ b/tests/Functional.openvpn/data/testcli.conf
@@ -0,0 +1,7 @@
+remote  192.168.0.1
+port    5000
+dev     tap
+#dev    tun
+verb    3
+ping    60
+
diff --git a/tests/Functional.openvpn/data/testenv.sh b/tests/Functional.openvpn/data/testenv.sh
new file mode 100644
index 0000000..0d89191
--- /dev/null
+++ b/tests/Functional.openvpn/data/testenv.sh
@@ -0,0 +1,79 @@
+service_name="service_name-not-set"
+config_file="config_file-not-set"
+pid_file="pid_file-not-set"
+module_status="unknown"
+
+#set the variable of service openvpn
+set_service_file() {
+    if [ "$init_manager" == "systemd" ]
+    then
+        service_name="openvpn@loopback-server.service"
+        config_file="/etc/openvpn/loopback-server.conf"
+        pid_file="/var/run/openvpn/loopback-server.pid"
+    else
+        service_name="openvpn"
+        if [ "$test_type" == "client" ]
+        then
+                config_file="/etc/openvpn/testcli.conf"
+                pid_file="/var/run/openvpn.testcli.pid"
+        elif [ "$test_type" == "server" ]
+        then
+                config_file="/etc/openvpn/testsrv.conf"
+                pid_file="/var/run/openvpn.testsrv.pid"
+        fi
+    fi
+}
+
+setup_routine() {
+    set_service_file
+    service_status=$(get_service_status $service_name)
+    module_status=$(get_module_status tun)
+    exec_service_on_target $service_name stop
+
+    if [ -f $config_file ]
+    then
+        mv $config_file "${config_file}_bak"
+    fi
+
+    test_type=$1
+    if [ "$test_type" = "client" ]
+    then
+        cp data/testcli.conf $config_file
+    elif [ "$test_type" = "server" ] ; then
+        cp data/testsrv.conf $config_file
+    fi
+
+    if [ -f /etc/openvpn/host-target.key ]
+    then
+        mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+    fi
+    cp data/host-target.key /etc/openvpn/host-target.key
+
+    if [ -d /dev/net ]
+    then
+        mv /dev/net /dev/net_bak
+    fi
+    mkdir -m 755 /dev/net
+    mknod /dev/net/tun c 10 200
+}
+
+restore_routine() {
+    if [ -d /dev/net_bak ]
+    then
+        mv /dev/net_bak /dev/net
+    fi
+    rm $config_file
+    if [ -f "${config_file}_bak" ]
+    then
+        mv "${config_file}_bak" $config_file
+    fi
+    rm -r /etc/openvpn/host-target.key
+    if [ -f /etc/openvpn/host-target.key_bak ]
+    then
+        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+    fi
+    if [ "$module_status" = "unloaded" ]
+    then
+        modprobe -r tun
+    fi
+}
diff --git a/tests/Functional.openvpn/data/testsrv.conf b/tests/Functional.openvpn/data/testsrv.conf
new file mode 100644
index 0000000..0c18a40
--- /dev/null
+++ b/tests/Functional.openvpn/data/testsrv.conf
@@ -0,0 +1,16 @@
+#
+proto           udp
+port            5000
+
+dev             tap
+
+secret          /etc/openvpn/host-target.key
+#link-mtu       1200
+
+ping            10
+ping-restart    60
+ping-timer-rem
+persist-key
+persist-tun
+verb            3
+
diff --git a/tests/Functional.openvpn/fuego_test.sh b/tests/Functional.openvpn/fuego_test.sh
new file mode 100644
index 0000000..a94740e
--- /dev/null
+++ b/tests/Functional.openvpn/fuego_test.sh
@@ -0,0 +1,21 @@
+function test_pre_check {
+    assert_has_program openvpn
+    assert_has_program netstat
+    assert_has_program ifconfig
+}
+
+function test_deploy {
+    put $TEST_HOME/openvpn_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/
+    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./openvpn_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.openvpn/openvpn_test.sh b/tests/Functional.openvpn/openvpn_test.sh
new file mode 100755
index 0000000..13bcf82
--- /dev/null
+++ b/tests/Functional.openvpn/openvpn_test.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+. ./fuego_board_function_lib.sh
+set_init_manager
+
+. data/testenv.sh
+
+for i in tests/*.sh; do
+    if [ "$i" = "tests/openvpn_genkey.sh" ]; then
+        source $i
+    else
+        source $i client
+        source $i server
+    fi
+done
diff --git a/tests/Functional.openvpn/spec.json b/tests/Functional.openvpn/spec.json
new file mode 100644
index 0000000..e9fdc5a
--- /dev/null
+++ b/tests/Functional.openvpn/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.openvpn",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.openvpn/tests/openvpn_genkey.sh b/tests/Functional.openvpn/tests/openvpn_genkey.sh
new file mode 100644
index 0000000..90d2474
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_genkey.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#  In target, run command openvpn.
+#  option: --genkey
+
+test="genkey"
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+
+openvpn --genkey --secret /etc/openvpn/host-target.key
+if [ -f /etc/openvpn/host-target.key ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f /etc/openvpn/host-target.key
+
+if [ -f /etc/openvpn/host-target.key_bak ]
+then
+    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+fi
+
diff --git a/tests/Functional.openvpn/tests/openvpn_lport.sh b/tests/Functional.openvpn/tests/openvpn_lport.sh
new file mode 100644
index 0000000..f19659a
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_lport.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the Listening port.
+
+test="lport_$1"
+
+test_type=$1
+
+setup_routine $test_type
+
+if exec_service_on_target $service_name start
+then
+    echo " -> $test: service start succeeded."
+else
+    echo " -> $test: service start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_routine
+    exit
+fi
+
+sleep 5
+
+if netstat -ln | grep ":5000"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target $service_name stop
+fi
+restore_routine
diff --git a/tests/Functional.openvpn/tests/openvpn_pid.sh b/tests/Functional.openvpn/tests/openvpn_pid.sh
new file mode 100644
index 0000000..dbcb61a
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_pid.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the pidfile.
+
+test="pid_$1"
+
+test_type=$1
+
+setup_routine $test_type
+
+if exec_service_on_target $service_name start
+then
+    echo " -> $test: service start succeeded."
+else
+    echo " -> $test: service start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_routine
+    exit
+fi
+
+if [ -f $pid_file ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target $service_name stop
+fi
+restore_routine
diff --git a/tests/Functional.openvpn/tests/openvpn_ps.sh b/tests/Functional.openvpn/tests/openvpn_ps.sh
new file mode 100644
index 0000000..d8b8c52
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_ps.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the status of process.
+
+test="ps_$1"
+
+test_type=$1
+
+setup_routine $test_type
+
+exec_service_on_target $service_name start
+
+if ps aux | grep "[/]usr/sbin/openvpn"
+then
+    echo " -> $test: get the process of openvpn succeeded."
+else
+    echo " -> $test: get the process of openvpn failed."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target $service_name stop
+    restore_routine
+    exit
+fi
+
+exec_service_on_target $service_name stop
+
+if ! ps aux | grep "[/]usr/sbin/openvpn"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+restore_routine
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_syslog-ng.sh b/tests/Functional.openvpn/tests/openvpn_syslog-ng.sh
new file mode 100644
index 0000000..8dd84ee
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_syslog-ng.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the message of syslog-ng.
+
+test="syslog-ng_$1"
+
+test_type=$1
+
+setup_routine $test_type
+logger_service=$(detect_logger_service)
+openvpn_logfile=$(get_service_logfile)
+
+exec_service_on_target $logger_service stop
+
+if [ -f $openvpn_logfile ]
+then
+    mv $openvpn_logfile $openvpn_logfile"_bak"
+fi
+
+exec_service_on_target $logger_service restart
+
+sleep 2
+
+exec_service_on_target $service_name start
+
+sleep 5
+
+if cat $openvpn_logfile | grep OpenVPN
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target $service_name stop
+
+restore_routine
+
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_tun.sh b/tests/Functional.openvpn/tests/openvpn_tun.sh
new file mode 100644
index 0000000..8902df8
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_tun.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# Verify the creation of the tun device (tap0) interface by openvpn.
+
+test="tun_$1"
+
+test_type=$1
+
+setup_routine $test_type
+
+exec_service_on_target $service_name start
+
+if ifconfig tap0
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target $service_name stop
+
+restore_routine
+
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
-- 
2.17.1




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

* [Fuego] [PATCH] Add function to get the status of module.
  2019-11-18 10:49 [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate Wang Mingyu
  2019-11-18 10:49 ` [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn Wang Mingyu
@ 2019-11-18 10:49 ` Wang Mingyu
  2019-11-18 17:59   ` Tim.Bird
  2019-11-18 18:16 ` [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate Tim.Bird
  2 siblings, 1 reply; 8+ messages in thread
From: Wang Mingyu @ 2019-11-18 10:49 UTC (permalink / raw)
  To: fuego

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 scripts/fuego_board_function_lib.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/scripts/fuego_board_function_lib.sh b/scripts/fuego_board_function_lib.sh
index a6cd842..115c615 100644
--- a/scripts/fuego_board_function_lib.sh
+++ b/scripts/fuego_board_function_lib.sh
@@ -12,6 +12,7 @@
 init_manager="init_manager-not-set"
 logger_service="logger_service-not-set"
 service_status="unknown"
+module_status="unknown"
 
 # set_init_manager:
 #   detects and sets the init_manager variable, which indicates which
@@ -100,3 +101,16 @@ get_service_logfile() {
     fi
     echo $service_logfile
 }
+
+# get_module_status:
+# get status of module
+# returns: status of module
+get_module_status() {
+    if lsmod | grep $1
+    then
+        module_status="loaded"
+    else
+        module_status="unloaded"
+    fi
+    echo $module_status
+}
-- 
2.17.1




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

* Re: [Fuego] [PATCH] Add function to get the status of module.
  2019-11-18 10:49 ` [Fuego] [PATCH] Add function to get the status of module Wang Mingyu
@ 2019-11-18 17:59   ` Tim.Bird
  0 siblings, 0 replies; 8+ messages in thread
From: Tim.Bird @ 2019-11-18 17:59 UTC (permalink / raw)
  To: wangmy, fuego



> -----Original Message-----
> From: Wang Mingyu
> Sent: Monday, November 18, 2019 11:49 AM
> To: fuego@lists.linuxfoundation.org
> Subject: [Fuego] [PATCH] Add function to get the status of module
Would have been nice to have a bit of description in the body
of the commit message, but this is short enough that I just
applied as is.

> 
> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> ---
>  scripts/fuego_board_function_lib.sh | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/scripts/fuego_board_function_lib.sh
> b/scripts/fuego_board_function_lib.sh
> index a6cd842..115c615 100644
> --- a/scripts/fuego_board_function_lib.sh
> +++ b/scripts/fuego_board_function_lib.sh
> @@ -12,6 +12,7 @@
>  init_manager="init_manager-not-set"
>  logger_service="logger_service-not-set"
>  service_status="unknown"
> +module_status="unknown"
> 
>  # set_init_manager:
>  #   detects and sets the init_manager variable, which indicates which
> @@ -100,3 +101,16 @@ get_service_logfile() {
>      fi
>      echo $service_logfile
>  }
> +
> +# get_module_status:
> +# get status of module
> +# returns: status of module
> +get_module_status() {
> +    if lsmod | grep $1
> +    then
> +        module_status="loaded"
> +    else
> +        module_status="unloaded"
> +    fi
> +    echo $module_status
> +}
> --
> 2.17.1

Looks good.  Applied and pushed to master.

Thanks!
 -- Tim


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

* Re: [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate.
  2019-11-18 10:49 [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate Wang Mingyu
  2019-11-18 10:49 ` [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn Wang Mingyu
  2019-11-18 10:49 ` [Fuego] [PATCH] Add function to get the status of module Wang Mingyu
@ 2019-11-18 18:16 ` Tim.Bird
  2 siblings, 0 replies; 8+ messages in thread
From: Tim.Bird @ 2019-11-18 18:16 UTC (permalink / raw)
  To: wangmy, fuego

Thanks for addressing my comments.  It looks good.

I've applied it, but I'm still testing it locally.  Can you give it a test and 
let me know if you see any problems?

Thanks,
 -- Tim


> -----Original Message-----
> From: Fuego [mailto:fuego-bounces@lists.linuxfoundation.org] On Behalf Of
> Wang Mingyu
> Sent: Monday, November 18, 2019 11:49 AM
> To: fuego@lists.linuxfoundation.org
> Subject: [Fuego] [PATCH v2] logrotate: Add test cases for command
> logrotate.
> 
> Logrotate is designed to ease administration of systems that generate
> large numbers of log files.
> This test set is used to check if rotate file can be created.
> 
> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> ---
>  tests/Functional.logrotate/data/test.conf     |   8 ++++
>  tests/Functional.logrotate/data/testlog.sh    |   8 ++++
>  tests/Functional.logrotate/data/testlog100k   | Bin 0 -> 105984 bytes
>  tests/Functional.logrotate/fuego_test.sh      |  23 ++++++++++
>  tests/Functional.logrotate/logrotate_test.sh  |   4 ++
>  tests/Functional.logrotate/spec.json          |   6 +++
>  tests/Functional.logrotate/test.yaml          |  24 ++++++++++
>  .../tests/logrotate_config.sh                 |  28 ++++++++++++
>  .../tests/logrotate_help.sh                   |  13 ++++++
>  .../tests/logrotate_rotation.sh               |  42 ++++++++++++++++++
>  .../tests/logrotate_size.sh                   |  39 ++++++++++++++++
>  .../tests/logrotate_status.sh                 |  26 +++++++++++
>  12 files changed, 221 insertions(+)
>  create mode 100644 tests/Functional.logrotate/data/test.conf
>  create mode 100644 tests/Functional.logrotate/data/testlog.sh
>  create mode 100644 tests/Functional.logrotate/data/testlog100k
>  create mode 100644 tests/Functional.logrotate/fuego_test.sh
>  create mode 100755 tests/Functional.logrotate/logrotate_test.sh
>  create mode 100644 tests/Functional.logrotate/spec.json
>  create mode 100644 tests/Functional.logrotate/test.yaml
>  create mode 100644 tests/Functional.logrotate/tests/logrotate_config.sh
>  create mode 100644 tests/Functional.logrotate/tests/logrotate_help.sh
>  create mode 100644 tests/Functional.logrotate/tests/logrotate_rotation.sh
>  create mode 100644 tests/Functional.logrotate/tests/logrotate_size.sh
>  create mode 100644 tests/Functional.logrotate/tests/logrotate_status.sh
> 
> diff --git a/tests/Functional.logrotate/data/test.conf
> b/tests/Functional.logrotate/data/test.conf
> new file mode 100644
> index 0000000..a346adf
> --- /dev/null
> +++ b/tests/Functional.logrotate/data/test.conf
> @@ -0,0 +1,8 @@
> +/var/log/testlog {
> +        create 600 root root
> +        ifempty
> +        daily
> +        nocompress
> +        missingok
> +        rotate 1
> +}
> diff --git a/tests/Functional.logrotate/data/testlog.sh
> b/tests/Functional.logrotate/data/testlog.sh
> new file mode 100644
> index 0000000..663abe3
> --- /dev/null
> +++ b/tests/Functional.logrotate/data/testlog.sh
> @@ -0,0 +1,8 @@
> +#!/bin/sh
> +
> +today=$(date +%s)
> +# there are 86000 seconds in a day
> +yesterday=$(( $today - 86000 ))
> +ddch=$(date --date "@$yesterday" "+%Y-%m-%d")
> +echo "logrotate state -- version 2" >> /var/lib/logrotate.status
> +echo "\"/var/log/testlog\" $ddch" >> /var/lib/logrotate.status
> diff --git a/tests/Functional.logrotate/data/testlog100k
> b/tests/Functional.logrotate/data/testlog100k
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..1dc679f54731568a9cbda775a6
> 63b7ea51595fe3
> GIT binary patch
> literal 105984
> zcmeI5d0-U9^2b*N!X;-EJdh;28zdV8yGaO9L{XdL$K@>wVs7M00!a`-
> {fUA^e4r2f
> z0X{&`=Zyl&Q#|l~hzE+OPr(y!P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*%+VyoCElO@ZP27a^l}43D<ul{$Hr#1RlO4poXl(^Pl|I
> z!}h;v+&>;#|C0Py;3IgH_)oqQ+ke61FTx+}TB;F&;rCGd!(M#<9kTyLz~Tf-i2qHG
> z;p^}Jp{g8zCH4nrtgAUOH&b2o631Ve^S|-
> >%THndv!+qro@a`GW_iLVpCN|V5&!)s
> zHG=uCJl58KP58NoWwQTBqo7fuTk|v3yKgt)`19JR;<%@*|LYz8I{y#LgnwLw^$
> PDH
> z{`XT-
> ZG=D1e;xt!zg{O&;7Z^T;$Jfh^S`nF|8OE^e@yG|vj4(<B<=cUs&Nmp{ZB4%
> zeMpXg`ENbi=C51-
> LiYa(e;ewu!I|pPVw`_YJDb1G|H(3w{!9Fc&HwOoGS%BFt@!^+
> zyTtup*8c~F*!*c3()D1OjK8jU>Ieo8$yB>*t^M!N{HG|{=C50Sq4|HF%>V0PcD
> *>M
> rFjK9XhUMR8{oi(p%|EDl0jAe4@xQqeuPfMaO{VH_1<yat@4x>AP`)FD
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/tests/Functional.logrotate/fuego_test.sh
> b/tests/Functional.logrotate/fuego_test.sh
> new file mode 100644
> index 0000000..c6e0579
> --- /dev/null
> +++ b/tests/Functional.logrotate/fuego_test.sh
> @@ -0,0 +1,23 @@
> +NEED_ROOT=1
> +
> +function test_pre_check {
> +    assert_has_program logrotate
> +    assert_has_program ntpdate
> +    assert_has_program date
> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/logrotate_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
> +    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
> +    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
> +}
> +
> +function test_run {
> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> +    export test_host=$SRV_IP;\
> +    ./logrotate_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/tests/Functional.logrotate/logrotate_test.sh
> b/tests/Functional.logrotate/logrotate_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/tests/Functional.logrotate/logrotate_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> diff --git a/tests/Functional.logrotate/spec.json
> b/tests/Functional.logrotate/spec.json
> new file mode 100644
> index 0000000..cfd6646
> --- /dev/null
> +++ b/tests/Functional.logrotate/spec.json
> @@ -0,0 +1,6 @@
> +{
> +    "testName": "Functional.logrotate",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> diff --git a/tests/Functional.logrotate/test.yaml
> b/tests/Functional.logrotate/test.yaml
> new file mode 100644
> index 0000000..d43799f
> --- /dev/null
> +++ b/tests/Functional.logrotate/test.yaml
> @@ -0,0 +1,24 @@
> +fuego_package_version: 1
> +name: Functional.logrotate
> +description: |
> +      Logrotate is designed to ease administration of systems that generate
> +      large numbers of log files.
> +      It allows automatic rotation, compression, removal, and mailing of log
> files.
> +      This is a simple test to check the common options and features of
> logrotate.
> +license: BSD-3-Clause
> +author: Wang Mingyu <wangmy@cn.fujitsu.com>
> +maintainer: Wang Mingyu <wangmy@cn.fujitsu.com>
> +version: 1.00
> +fuego_release: 1
> +type: Functional
> +tags: ['logrotate']
> +params:
> +    SRV_IP:
> +        description: the IP address of your host - Defined in board file
> +data_files:
> + - logrotate_test.sh
> + - fuego_test.sh
> + - spec.json
> + - test.yaml
> + - data
> + - tests
> diff --git a/tests/Functional.logrotate/tests/logrotate_config.sh
> b/tests/Functional.logrotate/tests/logrotate_config.sh
> new file mode 100644
> index 0000000..bc8d707
> --- /dev/null
> +++ b/tests/Functional.logrotate/tests/logrotate_config.sh
> @@ -0,0 +1,28 @@
> +#!/bin/sh
> +
> +#  Turns on verbose mode and confirm the result.
> +#  option : -dv
> +
> +test="test config"
> +
> +if [ -f /var/lib/logrotate.status ]
> +then
> +    mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
> +fi
> +
> +cp data/test.conf /etc/logrotate.d/test.conf
> +
> +chown root /etc/logrotate.d/test.conf
> +
> +if logrotate -dv /etc/logrotate.d/test.conf
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +if [ -f /var/lib/logrotate.status_bak ]
> +then
> +    mv /var/lib/logrotate.status_bak /var/lib/logrotate.status
> +fi
> +rm -f /etc/logrotate.d/test.conf
> diff --git a/tests/Functional.logrotate/tests/logrotate_help.sh
> b/tests/Functional.logrotate/tests/logrotate_help.sh
> new file mode 100644
> index 0000000..37390df
> --- /dev/null
> +++ b/tests/Functional.logrotate/tests/logrotate_help.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +#  In the target to execute command logrotate and confirm the result.
> +#  option : --help
> +
> +test="help"
> +
> +if logrotate --help | grep "Usage"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> diff --git a/tests/Functional.logrotate/tests/logrotate_rotation.sh
> b/tests/Functional.logrotate/tests/logrotate_rotation.sh
> new file mode 100644
> index 0000000..f0d5e92
> --- /dev/null
> +++ b/tests/Functional.logrotate/tests/logrotate_rotation.sh
> @@ -0,0 +1,42 @@
> +#!/bin/sh
> +
> +#  Verify that the rotate file is created in the specified directory.
> +#  option : -v
> +
> +test="log rotation"
> +
> +if [ -f /var/log/testlog* ]
> +then
> +    rm -f /var/log/testlog*
> +fi
> +
> +if [ -f /var/lib/logrotate.status ]
> +then
> +    mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
> +fi
> +
> +ntpdate $test_host
> +
> +cp data/test.conf /etc/logrotate.d/test.conf
> +
> +touch /var/log/testlog
> +
> +cp data/testlog.sh data/testlog_test.sh
> +chmod +x data/testlog_test.sh
> +data/testlog_test.sh
> +chown root /etc/logrotate.d/test.conf
> +logrotate -v /etc/logrotate.d/test.conf
> +if ls /var/log/testlog.1
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +rm -f /etc/logrotate.d/test.conf
> +rm -f /var/log/testlog*
> +rm -f data/testlog_test.sh
> +if [ -f /var/lib/logrotate.status_bak ]
> +then
> +    mv /var/lib/logrotate.status_bak /var/lib/logrotate.status
> +fi
> diff --git a/tests/Functional.logrotate/tests/logrotate_size.sh
> b/tests/Functional.logrotate/tests/logrotate_size.sh
> new file mode 100644
> index 0000000..2e215cd
> --- /dev/null
> +++ b/tests/Functional.logrotate/tests/logrotate_size.sh
> @@ -0,0 +1,39 @@
> +#!/bin/sh
> +
> +#  Verify that the rotate file is created in the specified directory.
> +#  option : -v
> +
> +test="log rotation size"
> +
> +if [ -f /var/log/testlog* ]
> +then
> +    rm -f /var/log/testlog*
> +fi
> +
> +if [ -f /var/lib/logrotate.status ]
> +then
> +    mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
> +fi
> +cp data/test.conf /etc/logrotate.d/test.conf
> +
> +cp data/testlog100k /var/log/testlog
> +
> +cp data/testlog.sh data/testlog_test.sh
> +chmod +x data/testlog_test.sh
> +data/testlog_test.sh
> +chown root /etc/logrotate.d/test.conf
> +logrotate -v /etc/logrotate.d/test.conf
> +if ls /var/log/testlog.1
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +rm -f /etc/logrotate.d/test.conf
> +rm -f /var/log/testlog*
> +rm -f data/testlog_test.sh
> +if [ -f /var/lib/logrotate.status_bak ]
> +then
> +    mv /var/lib/logrotate.status_bak /var/lib/logrotate.status
> +fi
> diff --git a/tests/Functional.logrotate/tests/logrotate_status.sh
> b/tests/Functional.logrotate/tests/logrotate_status.sh
> new file mode 100644
> index 0000000..36f61a3
> --- /dev/null
> +++ b/tests/Functional.logrotate/tests/logrotate_status.sh
> @@ -0,0 +1,26 @@
> +#!/bin/sh
> +
> +#  Turns on verbose mode.
> +#  option : -v
> +
> +test="log status add"
> +
> +if [ -f /var/lib/logrotate.status ]
> +then
> +    mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
> +fi
> +cp data/test.conf /etc/logrotate.d/test.conf
> +
> +logrotate -v /etc/logrotate.d/test.conf
> +
> +if tail /var/lib/logrotate.status | grep testlog
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +rm -f /etc/logrotate.d/test.conf
> +if [ -f /var/lib/logrotate.status_bak ]
> +then
> +    mv /var/lib/logrotate.status_bak /var/lib/logrotate.status
> +fi
> --
> 2.17.1
> 
> 
> 
> _______________________________________________
> Fuego mailing list
> Fuego@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego

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

* Re: [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn.
  2019-11-18 10:49 ` [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn Wang Mingyu
@ 2019-11-19 17:00   ` Tim.Bird
  0 siblings, 0 replies; 8+ messages in thread
From: Tim.Bird @ 2019-11-19 17:00 UTC (permalink / raw)
  To: wangmy, fuego



> -----Original Message-----
> From: Wang Mingyu
> 
> This test set is used to check if the service openvpn can be started.
> And check the process file, syslog file, tap0 can be created or not.
> 
> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> ---
>  scripts/fuego_board_function_lib.sh           | 14 ++++
>  tests/Functional.openvpn/data/host-target.key | 22 ++++++
>  tests/Functional.openvpn/data/testcli.conf    |  7 ++
>  tests/Functional.openvpn/data/testenv.sh      | 79 +++++++++++++++++++
>  tests/Functional.openvpn/data/testsrv.conf    | 16 ++++
>  tests/Functional.openvpn/fuego_test.sh        | 21 +++++
>  tests/Functional.openvpn/openvpn_test.sh      | 14 ++++
>  tests/Functional.openvpn/spec.json            |  6 ++
>  .../tests/openvpn_genkey.sh                   | 26 ++++++
>  .../Functional.openvpn/tests/openvpn_lport.sh | 34 ++++++++
>  tests/Functional.openvpn/tests/openvpn_pid.sh | 31 ++++++++
>  tests/Functional.openvpn/tests/openvpn_ps.sh  | 36 +++++++++
>  .../tests/openvpn_syslog-ng.sh                | 42 ++++++++++
>  tests/Functional.openvpn/tests/openvpn_tun.sh | 27 +++++++
>  14 files changed, 375 insertions(+)
>  create mode 100644 tests/Functional.openvpn/data/host-target.key
>  create mode 100644 tests/Functional.openvpn/data/testcli.conf
>  create mode 100644 tests/Functional.openvpn/data/testenv.sh
>  create mode 100644 tests/Functional.openvpn/data/testsrv.conf
>  create mode 100644 tests/Functional.openvpn/fuego_test.sh
>  create mode 100755 tests/Functional.openvpn/openvpn_test.sh
>  create mode 100644 tests/Functional.openvpn/spec.json
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_genkey.sh
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_lport.sh
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_pid.sh
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_ps.sh
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_syslog-ng.sh
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_tun.sh
> 
> diff --git a/scripts/fuego_board_function_lib.sh
> b/scripts/fuego_board_function_lib.sh
> index a6cd842..115c615 100644
> --- a/scripts/fuego_board_function_lib.sh
> +++ b/scripts/fuego_board_function_lib.sh
> @@ -12,6 +12,7 @@
>  init_manager="init_manager-not-set"
>  logger_service="logger_service-not-set"
>  service_status="unknown"
> +module_status="unknown"
> 
>  # set_init_manager:
>  #   detects and sets the init_manager variable, which indicates which
> @@ -100,3 +101,16 @@ get_service_logfile() {
>      fi
>      echo $service_logfile
>  }
> +
> +# get_module_status:
> +# get status of module
> +# returns: status of module
> +get_module_status() {
> +    if lsmod | grep $1
> +    then
> +        module_status="loaded"
> +    else
> +        module_status="unloaded"
> +    fi
> +    echo $module_status
> +}

This has already been applied as a separate patch.  I'll remove this
hunk.

> diff --git a/tests/Functional.openvpn/data/host-target.key
> b/tests/Functional.openvpn/data/host-target.key
> new file mode 100644
> index 0000000..99743bf
> --- /dev/null
> +++ b/tests/Functional.openvpn/data/host-target.key
> @@ -0,0 +1,22 @@
> +#
> +# 2048 bit OpenVPN static key
> +#
> +-----BEGIN OpenVPN Static key V1-----
> +debe9557c7eb224c5cf4f3369d5211ff
> +fb9c375a4784759edf6b0f6eb8f5da31
> +bb280394d40382cc8e02d6cbb3e47492
> +3509eac6b48965078e3d317b0791dea2
> +dbcf0eddcab0fb20780fcf0908ce94cd
> +7cb65a913fea73ac6bfe0ab34f085aa3
> +a6c8b89a97d189e5145c3199955c4b34
> +6d51f864f2b49f3252d1548c3b3510ec
> +0ecd4b9f17f2039439a79f41a46f6a54
> +c0385b962b2b94fcbe73e0108b224a5b
> +2efae27d872f0efef67b244c7eb6f525
> +581e4c2b4e6aa193fb1d37798bdb46ff
> +7c6727f08e9601c10ac7478d73d731e6
> +f4b652252f3e5309cd1d6d30c7a433cc
> +134bd6dd50fa6a6fc7a843fdc058d38d
> +fb8679b48eb09745badf004fbf4a434c
> +-----END OpenVPN Static key V1-----
> +
> diff --git a/tests/Functional.openvpn/data/testcli.conf
> b/tests/Functional.openvpn/data/testcli.conf
> new file mode 100644
> index 0000000..2c252bb
> --- /dev/null
> +++ b/tests/Functional.openvpn/data/testcli.conf
> @@ -0,0 +1,7 @@
> +remote  192.168.0.1
Will this work on any machine?  Does this need address to be
substituted with a valid address for the board under test?
Or does it need to avoid an address already in use by the 
board?

> +port    5000
> +dev     tap
> +#dev    tun
> +verb    3
> +ping    60
> +
> diff --git a/tests/Functional.openvpn/data/testenv.sh
> b/tests/Functional.openvpn/data/testenv.sh
> new file mode 100644
> index 0000000..0d89191
> --- /dev/null
> +++ b/tests/Functional.openvpn/data/testenv.sh
> @@ -0,0 +1,79 @@
> +service_name="service_name-not-set"
> +config_file="config_file-not-set"
> +pid_file="pid_file-not-set"
> +module_status="unknown"
> +
> +#set the variable of service openvpn
> +set_service_file() {
> +    if [ "$init_manager" == "systemd" ]
> +    then
> +        service_name="openvpn@loopback-server.service"
> +        config_file="/etc/openvpn/loopback-server.conf"
> +        pid_file="/var/run/openvpn/loopback-server.pid"
> +    else
> +        service_name="openvpn"
> +        if [ "$test_type" == "client" ]
> +        then
> +                config_file="/etc/openvpn/testcli.conf"
> +                pid_file="/var/run/openvpn.testcli.pid"
> +        elif [ "$test_type" == "server" ]
> +        then
> +                config_file="/etc/openvpn/testsrv.conf"
> +                pid_file="/var/run/openvpn.testsrv.pid"
> +        fi
> +    fi
> +}
> +
> +setup_routine() {
> +    set_service_file
> +    service_status=$(get_service_status $service_name)
> +    module_status=$(get_module_status tun)
> +    exec_service_on_target $service_name stop
> +
> +    if [ -f $config_file ]
> +    then
> +        mv $config_file "${config_file}_bak"
> +    fi
> +
> +    test_type=$1
> +    if [ "$test_type" = "client" ]
> +    then
> +        cp data/testcli.conf $config_file
> +    elif [ "$test_type" = "server" ] ; then
> +        cp data/testsrv.conf $config_file
> +    fi
> +
> +    if [ -f /etc/openvpn/host-target.key ]
> +    then
> +        mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +    fi
> +    cp data/host-target.key /etc/openvpn/host-target.key
> +
> +    if [ -d /dev/net ]
> +    then
> +        mv /dev/net /dev/net_bak
> +    fi
> +    mkdir -m 755 /dev/net
> +    mknod /dev/net/tun c 10 200
> +}
> +
> +restore_routine() {
> +    if [ -d /dev/net_bak ]
> +    then
> +        mv /dev/net_bak /dev/net
> +    fi
> +    rm $config_file
> +    if [ -f "${config_file}_bak" ]
> +    then
> +        mv "${config_file}_bak" $config_file
> +    fi
> +    rm -r /etc/openvpn/host-target.key
> +    if [ -f /etc/openvpn/host-target.key_bak ]
> +    then
> +        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +    fi
> +    if [ "$module_status" = "unloaded" ]
> +    then
> +        modprobe -r tun
> +    fi
> +}

Nice.  Thanks.  If we use this pattern a lot, then we might want
to add some generic functions for backing up and restoring
files, starting and stopping services, and loading and unloading
modules - and add them to fuego_board_function_lib.sh

However, let's keep these local for now and see if we get more
examples of this in additional tests.

> diff --git a/tests/Functional.openvpn/data/testsrv.conf
> b/tests/Functional.openvpn/data/testsrv.conf
> new file mode 100644
> index 0000000..0c18a40
> --- /dev/null
> +++ b/tests/Functional.openvpn/data/testsrv.conf
> @@ -0,0 +1,16 @@
> +#
> +proto           udp
> +port            5000
> +
> +dev             tap
> +
> +secret          /etc/openvpn/host-target.key
> +#link-mtu       1200
> +
> +ping            10
> +ping-restart    60
> +ping-timer-rem
> +persist-key
> +persist-tun
> +verb            3
> +
> diff --git a/tests/Functional.openvpn/fuego_test.sh
> b/tests/Functional.openvpn/fuego_test.sh
> new file mode 100644
> index 0000000..a94740e
> --- /dev/null
> +++ b/tests/Functional.openvpn/fuego_test.sh
> @@ -0,0 +1,21 @@

Probably need a NEED_ROOT=1 here.
This test does a lot of manipulation of system-wide configuration
files, loading/unloading modules and starting/stopping services.

> +function test_pre_check {
> +    assert_has_program openvpn
> +    assert_has_program netstat
> +    assert_has_program ifconfig
> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/openvpn_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/
> +    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
> +}
> +
> +function test_run {
> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> +    ./openvpn_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/tests/Functional.openvpn/openvpn_test.sh
> b/tests/Functional.openvpn/openvpn_test.sh
> new file mode 100755
> index 0000000..13bcf82
> --- /dev/null
> +++ b/tests/Functional.openvpn/openvpn_test.sh
> @@ -0,0 +1,14 @@
> +#!/bin/sh
> +. ./fuego_board_function_lib.sh
> +set_init_manager
> +
> +. data/testenv.sh
> +
> +for i in tests/*.sh; do
> +    if [ "$i" = "tests/openvpn_genkey.sh" ]; then
> +        source $i
> +    else
> +        source $i client
> +        source $i server
> +    fi
> +done
> diff --git a/tests/Functional.openvpn/spec.json
> b/tests/Functional.openvpn/spec.json
> new file mode 100644
> index 0000000..e9fdc5a
> --- /dev/null
> +++ b/tests/Functional.openvpn/spec.json
> @@ -0,0 +1,6 @@
> +{
> +    "testName": "Functional.openvpn",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> diff --git a/tests/Functional.openvpn/tests/openvpn_genkey.sh
> b/tests/Functional.openvpn/tests/openvpn_genkey.sh
> new file mode 100644
> index 0000000..90d2474
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_genkey.sh
> @@ -0,0 +1,26 @@
> +#!/bin/sh
> +
> +#  In target, run command openvpn.
> +#  option: --genkey
> +
> +test="genkey"
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +
> +openvpn --genkey --secret /etc/openvpn/host-target.key
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +rm -f /etc/openvpn/host-target.key
> +
> +if [ -f /etc/openvpn/host-target.key_bak ]
> +then
> +    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +fi
> +
> diff --git a/tests/Functional.openvpn/tests/openvpn_lport.sh
> b/tests/Functional.openvpn/tests/openvpn_lport.sh
> new file mode 100644
> index 0000000..f19659a
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_lport.sh
> @@ -0,0 +1,34 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the Listening port.
> +
> +test="lport_$1"
> +
> +test_type=$1
> +
> +setup_routine $test_type
> +
> +if exec_service_on_target $service_name start
> +then
> +    echo " -> $test: service start succeeded."
> +else
> +    echo " -> $test: service start failed."
> +    echo " -> $test: TEST-FAIL"
> +    restore_routine
> +    exit
> +fi
> +
> +sleep 5
> +
> +if netstat -ln | grep ":5000"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +if [ "$service_status" = "inactive" ]
> +then
> +    exec_service_on_target $service_name stop
> +fi
> +restore_routine
> diff --git a/tests/Functional.openvpn/tests/openvpn_pid.sh
> b/tests/Functional.openvpn/tests/openvpn_pid.sh
> new file mode 100644
> index 0000000..dbcb61a
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_pid.sh
> @@ -0,0 +1,31 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the pidfile.
> +
> +test="pid_$1"
> +
> +test_type=$1
> +
> +setup_routine $test_type
> +
> +if exec_service_on_target $service_name start
> +then
> +    echo " -> $test: service start succeeded."
> +else
> +    echo " -> $test: service start failed."
> +    echo " -> $test: TEST-FAIL"
> +    restore_routine
> +    exit
> +fi
> +
> +if [ -f $pid_file ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +if [ "$service_status" = "inactive" ]
> +then
> +    exec_service_on_target $service_name stop
> +fi
> +restore_routine
> diff --git a/tests/Functional.openvpn/tests/openvpn_ps.sh
> b/tests/Functional.openvpn/tests/openvpn_ps.sh
> new file mode 100644
> index 0000000..d8b8c52
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_ps.sh
> @@ -0,0 +1,36 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the status of process.
> +
> +test="ps_$1"
> +
> +test_type=$1
> +
> +setup_routine $test_type
> +
> +exec_service_on_target $service_name start
> +
> +if ps aux | grep "[/]usr/sbin/openvpn"
> +then
> +    echo " -> $test: get the process of openvpn succeeded."
> +else
> +    echo " -> $test: get the process of openvpn failed."
> +    echo " -> $test: TEST-FAIL"
> +    exec_service_on_target $service_name stop
> +    restore_routine
> +    exit
> +fi
> +
> +exec_service_on_target $service_name stop
> +
> +if ! ps aux | grep "[/]usr/sbin/openvpn"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +restore_routine
> +if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> +    exec_service_on_target $service_name start
> +fi
> diff --git a/tests/Functional.openvpn/tests/openvpn_syslog-ng.sh
> b/tests/Functional.openvpn/tests/openvpn_syslog-ng.sh
> new file mode 100644
> index 0000000..8dd84ee
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_syslog-ng.sh
> @@ -0,0 +1,42 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the message of syslog-ng.
> +
> +test="syslog-ng_$1"
> +
> +test_type=$1
> +
> +setup_routine $test_type
> +logger_service=$(detect_logger_service)
> +openvpn_logfile=$(get_service_logfile)
> +
> +exec_service_on_target $logger_service stop
> +
> +if [ -f $openvpn_logfile ]
> +then
> +    mv $openvpn_logfile $openvpn_logfile"_bak"
> +fi
> +
> +exec_service_on_target $logger_service restart
> +
> +sleep 2
> +
> +exec_service_on_target $service_name start
> +
> +sleep 5
> +
> +if cat $openvpn_logfile | grep OpenVPN
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +exec_service_on_target $service_name stop
> +
> +restore_routine
> +
> +if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> +    exec_service_on_target $service_name start
> +fi
> diff --git a/tests/Functional.openvpn/tests/openvpn_tun.sh
> b/tests/Functional.openvpn/tests/openvpn_tun.sh
> new file mode 100644
> index 0000000..8902df8
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_tun.sh
> @@ -0,0 +1,27 @@
> +#!/bin/sh
> +
> +# Verify the creation of the tun device (tap0) interface by openvpn.
> +
> +test="tun_$1"
> +
> +test_type=$1
> +
> +setup_routine $test_type
> +
> +exec_service_on_target $service_name start
> +
> +if ifconfig tap0
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +exec_service_on_target $service_name stop
> +
> +restore_routine
> +
> +if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> +    exec_service_on_target $service_name start
> +fi
> --
> 2.17.1

OK - this looks good.

I'm going to apply it, but please respond to my comments above.
I'll go ahead and add the NEED_ROOT=1.

Let me know about the address in the configuration file (whether that
matters for this test).

Thanks,
 -- Tim


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

* Re: [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn.
  2019-11-05  9:01 ` [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn Wang Mingyu
@ 2019-11-08 13:13   ` Tim.Bird
  0 siblings, 0 replies; 8+ messages in thread
From: Tim.Bird @ 2019-11-08 13:13 UTC (permalink / raw)
  To: wangmy, fuego



> -----Original Message-----
> From: Wang Mingyu
> 
> This test set is used to check if the service openvpn can be started.
> And check the process file, syslog file, tap0 can be created or not.
> 
> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> ---
>  tests/Functional.openvpn/data/host-target.key | 22 ++++++
>  tests/Functional.openvpn/data/testcli.conf    |  7 ++
>  tests/Functional.openvpn/data/testenv.sh      | 18 +++++
>  tests/Functional.openvpn/data/testsrv.conf    | 16 +++++
>  tests/Functional.openvpn/fuego_test.sh        | 19 +++++
>  tests/Functional.openvpn/openvpn_test.sh      |  9 +++
>  tests/Functional.openvpn/spec.json            |  6 ++
>  .../tests/openvpn_genkey.sh                   | 26 +++++++
>  .../tests/openvpn_lport_client.sh             | 66 +++++++++++++++++
>  .../tests/openvpn_lport_server.sh             | 65 +++++++++++++++++
>  .../tests/openvpn_pid_client.sh               | 62 ++++++++++++++++
>  .../tests/openvpn_pid_server.sh               | 63 ++++++++++++++++
>  .../tests/openvpn_ps_client.sh                | 67 +++++++++++++++++
>  .../tests/openvpn_ps_server.sh                | 67 +++++++++++++++++
>  .../tests/openvpn_syslog-ng_client.sh         | 71 +++++++++++++++++++
>  .../tests/openvpn_syslog-ng_server.sh         | 69 ++++++++++++++++++
>  .../tests/openvpn_tun_client.sh               | 56 +++++++++++++++
>  .../tests/openvpn_tun_server.sh               | 56 +++++++++++++++
>  18 files changed, 765 insertions(+)
>  create mode 100644 tests/Functional.openvpn/data/host-target.key
>  create mode 100644 tests/Functional.openvpn/data/testcli.conf
>  create mode 100644 tests/Functional.openvpn/data/testenv.sh
>  create mode 100644 tests/Functional.openvpn/data/testsrv.conf
>  create mode 100644 tests/Functional.openvpn/fuego_test.sh
>  create mode 100755 tests/Functional.openvpn/openvpn_test.sh
>  create mode 100644 tests/Functional.openvpn/spec.json
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_genkey.sh
>  create mode 100644
> tests/Functional.openvpn/tests/openvpn_lport_client.sh
>  create mode 100644
> tests/Functional.openvpn/tests/openvpn_lport_server.sh
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_pid_client.sh
>  create mode 100644
> tests/Functional.openvpn/tests/openvpn_pid_server.sh
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_ps_client.sh
>  create mode 100644
> tests/Functional.openvpn/tests/openvpn_ps_server.sh
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_syslog-
> ng_client.sh
>  create mode 100644 tests/Functional.openvpn/tests/openvpn_syslog-
> ng_server.sh
>  create mode 100644
> tests/Functional.openvpn/tests/openvpn_tun_client.sh
>  create mode 100644
> tests/Functional.openvpn/tests/openvpn_tun_server.sh
> 
> diff --git a/tests/Functional.openvpn/data/host-target.key
> b/tests/Functional.openvpn/data/host-target.key
> new file mode 100644
> index 0000000..99743bf
> --- /dev/null
> +++ b/tests/Functional.openvpn/data/host-target.key
> @@ -0,0 +1,22 @@
> +#
> +# 2048 bit OpenVPN static key
> +#
> +-----BEGIN OpenVPN Static key V1-----
> +debe9557c7eb224c5cf4f3369d5211ff
> +fb9c375a4784759edf6b0f6eb8f5da31
> +bb280394d40382cc8e02d6cbb3e47492
> +3509eac6b48965078e3d317b0791dea2
> +dbcf0eddcab0fb20780fcf0908ce94cd
> +7cb65a913fea73ac6bfe0ab34f085aa3
> +a6c8b89a97d189e5145c3199955c4b34
> +6d51f864f2b49f3252d1548c3b3510ec
> +0ecd4b9f17f2039439a79f41a46f6a54
> +c0385b962b2b94fcbe73e0108b224a5b
> +2efae27d872f0efef67b244c7eb6f525
> +581e4c2b4e6aa193fb1d37798bdb46ff
> +7c6727f08e9601c10ac7478d73d731e6
> +f4b652252f3e5309cd1d6d30c7a433cc
> +134bd6dd50fa6a6fc7a843fdc058d38d
> +fb8679b48eb09745badf004fbf4a434c
> +-----END OpenVPN Static key V1-----
> +
> diff --git a/tests/Functional.openvpn/data/testcli.conf
> b/tests/Functional.openvpn/data/testcli.conf
> new file mode 100644
> index 0000000..2c252bb
> --- /dev/null
> +++ b/tests/Functional.openvpn/data/testcli.conf
> @@ -0,0 +1,7 @@
> +remote  192.168.0.1
> +port    5000
> +dev     tap
> +#dev    tun
> +verb    3
> +ping    60
> +
> diff --git a/tests/Functional.openvpn/data/testenv.sh
> b/tests/Functional.openvpn/data/testenv.sh
> new file mode 100644
> index 0000000..8c01d58
> --- /dev/null
> +++ b/tests/Functional.openvpn/data/testenv.sh
> @@ -0,0 +1,18 @@
> +#set the variable
> +if [ "$init_manager" == "systemd" ]
> +then
> +        service_name="openvpn@loopback-server.service"
> +        config_file="/etc/openvpn/loopback-server.conf"
> +        pid_file="/var/run/openvpn/loopback-server.pid"
> +else
> +        service_name="openvpn"
> +        if [ "$test_type" == "client" ]
> +        then
> +                config_file="/etc/openvpn/testcli.conf"
> +                pid_file="/var/run/openvpn.testcli.pid"
> +        elif [ "$test_type" == "server" ]
> +        then
> +                config_file="/etc/openvpn/testsrv.conf"
> +                pid_file="/var/run/openvpn.testsrv.pid"
> +        fi
> +fi
> diff --git a/tests/Functional.openvpn/data/testsrv.conf
> b/tests/Functional.openvpn/data/testsrv.conf
> new file mode 100644
> index 0000000..0c18a40
> --- /dev/null
> +++ b/tests/Functional.openvpn/data/testsrv.conf
> @@ -0,0 +1,16 @@
> +#
> +proto           udp
> +port            5000
> +
> +dev             tap
> +
> +secret          /etc/openvpn/host-target.key
> +#link-mtu       1200
> +
> +ping            10
> +ping-restart    60
> +ping-timer-rem
> +persist-key
> +persist-tun
> +verb            3
> +
> diff --git a/tests/Functional.openvpn/fuego_test.sh
> b/tests/Functional.openvpn/fuego_test.sh
> new file mode 100644
> index 0000000..65d2991
> --- /dev/null
> +++ b/tests/Functional.openvpn/fuego_test.sh
> @@ -0,0 +1,19 @@
> +function test_pre_check {
> +    assert_has_program openvpn
> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/openvpn_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/
> +    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
> +}
> +
> +function test_run {
> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> +    ./openvpn_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/tests/Functional.openvpn/openvpn_test.sh
> b/tests/Functional.openvpn/openvpn_test.sh
> new file mode 100755
> index 0000000..42f41ea
> --- /dev/null
> +++ b/tests/Functional.openvpn/openvpn_test.sh
> @@ -0,0 +1,9 @@
> +#!/bin/sh
> +. ./fuego_board_function_lib.sh
> +set_init_manager
> +
> +. data/testenv.sh

I don't see how this works.
This source ('.') only happens once, in this wrapper script.
But the variables set by the if statement in data/testenv.sh
need to change depending on $test_type, that is sourced 
in the loop below.

The first part of data/testenv.sh, which sets the service name
can be done once per invocation of openvpn_test.sh.
But the setting of config_file and pid_file needs to
happen *after* the sub-test script has been sourced.

This needs to be restructured so that setting the getting
the config_file and pid_file is done using a function, called
by each sub-test shell script.

This code won't work in the non-systemd case at all.

> +
> +for i in tests/*.sh; do
> +    source $i
> +done
> diff --git a/tests/Functional.openvpn/spec.json
> b/tests/Functional.openvpn/spec.json
> new file mode 100644
> index 0000000..e9fdc5a
> --- /dev/null
> +++ b/tests/Functional.openvpn/spec.json
> @@ -0,0 +1,6 @@
> +{
> +    "testName": "Functional.openvpn",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> diff --git a/tests/Functional.openvpn/tests/openvpn_genkey.sh
> b/tests/Functional.openvpn/tests/openvpn_genkey.sh
> new file mode 100644
> index 0000000..cef533e
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_genkey.sh
> @@ -0,0 +1,26 @@
> +#!/bin/sh
> +
> +#  In target, run command openvpn.
> +#  option: --genkey
> +
> +test="genkey"
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +
> +openvpn --genkey --secret /etc/openvpn/host-target.key
> +if ls /etc/openvpn/host-target.key
should use 'if [ -f /etc/openvpn/host-target.key' here

Using test (or '[') for file existence is preferred over ls.

> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +rm -f /etc/openvpn/host-target.key
> +
> +if [ -f /etc/openvpn/host-target.key_bak ]
> +then
> +    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +fi
> +
> diff --git a/tests/Functional.openvpn/tests/openvpn_lport_client.sh
> b/tests/Functional.openvpn/tests/openvpn_lport_client.sh
> new file mode 100644
> index 0000000..f8aac80
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_lport_client.sh
> @@ -0,0 +1,66 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the Listening port.
> +
> +test="lport_client"
> +
> +test_type="client"
> +
> +service_status=$(get_service_status $service_name)
> +exec_service_on_target $service_name stop
> +
> +if [ -f $config_file ]
> +then
> +    mv $config_file $config_file"_bak"

I would prefer it is you used "${config_file}_bak"
instead of $config_file"_bak", throughout all these test scripts.

Starting quotes in the middle of the string is hard to read.

> +fi
> +cp data/testcli.conf $config_file
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +mkdir -m 755 /dev/net
> +mknod /dev/net/tun c 10 200
> +
> +restore_target() {
> +    rm -fr /dev/net
> +    rm $config_file
> +    if [ -f $config_file"_bak" ]
> +    then
> +        mv $config_file"_bak" $config_file
> +    fi
> +    rm -r /etc/openvpn/host-target.key
> +    if [ -f /etc/openvpn/host-target.key_bak ]
> +    then
> +        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +    fi
> +
> +    modprobe -r tun
There's no check whether module 'tun' was loaded before the test or not.
If it was already loaded, we should not remove it.

> +}
> +
> +if exec_service_on_target $service_name start
> +then
> +    echo " -> $test: service start succeeded."
> +else
> +    echo " -> $test: service start failed."
> +    echo " -> $test: TEST-FAIL"
> +    restore_target
> +    exit
> +fi
> +
> +sleep 5
> +
> +if netstat -ln | grep ":5000"

Need to add 'assert_has_program netstat' to test_precheck in fuego_test.sh.

> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +if [ "$service_status" = "inactive" ]
> +then
> +    exec_service_on_target $service_name stop
> +fi
> +restore_target
> diff --git a/tests/Functional.openvpn/tests/openvpn_lport_server.sh
> b/tests/Functional.openvpn/tests/openvpn_lport_server.sh
> new file mode 100644
> index 0000000..0377c2d
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_lport_server.sh
> @@ -0,0 +1,65 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the Listening port.
> +
> +test="lport_server"
> +
> +test_type="server"
> +
> +service_status=$(get_service_status $service_name)
> +
> +if [ -f $config_file ]
> +then
> +    mv $config_file $config_file"_bak"
> +fi
> +cp data/testsrv.conf $config_file
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +mkdir -m 755 /dev/net
> +mknod /dev/net/tun c 10 200
> +
> +restore_target() {
> +    rm -fr /dev/net
What happens if /dev/net already existed before the test?

If I ran this test on my Ubuntu machine as root, I would lose my
default installation of /dev/net/tun.  Please only remove this
directory if it did not already exist when the test started.
(You'll have to save the status of this above when you do the
mkdir)

> +    rm $config_file
> +    if [ -f $config_file"_bak" ]
> +    then
> +        mv $config_file"_bak" $config_file
> +    fi
> +    rm -r /etc/openvpn/host-target.key
> +    if [ -f /etc/openvpn/host-target.key_bak ]
> +    then
> +        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +    fi
> +
> +    modprobe -r tun
> +}
> +
> +if exec_service_on_target $service_name start
> +then
> +    echo " -> $test: service start succeeded."
> +else
> +    echo " -> $test: service start failed."
> +    echo " -> $test: TEST-FAIL"
> +    restore_target
> +    exit
> +fi
> +
> +sleep 5
> +
> +if netstat -ln | grep ":5000"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +if [ "$service_status" = "inactive" ]
> +then
> +    exec_service_on_target $service_name stop
> +fi
> +restore_target
> diff --git a/tests/Functional.openvpn/tests/openvpn_pid_client.sh
> b/tests/Functional.openvpn/tests/openvpn_pid_client.sh
> new file mode 100644
> index 0000000..a7829b2
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_pid_client.sh
> @@ -0,0 +1,62 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the pidfile.
> +
> +test="pid_client"
> +
> +test_type="client"
> +
> +service_status=$(get_service_status $service_name)
> +exec_service_on_target $service_name stop
> +
> +if [ -f $config_file ]
> +then
> +    mv $config_file $config_file"_bak"
> +fi
> +cp data/testcli.conf $config_file
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +mkdir -m 755 /dev/net
> +mknod /dev/net/tun c 10 200
> +
> +restore_target() {
> +    rm -fr /dev/net
Same issue here.  Please don't remove stuff unless you know you created it.

> +    rm $config_file
> +    if [ -f $config_file"_bak" ]
> +    then
> +        mv $config_file"_bak" $config_file
> +    fi
> +    rm -r /etc/openvpn/host-target.key
> +    if [ -f /etc/openvpn/host-target.key_bak ]
> +    then
> +        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +    fi
> +    modprobe -r tun
Please don't remove modules unless you know you inserted them.

> +}
> +
> +if exec_service_on_target $service_name start
> +then
> +    echo " -> $test: service start succeeded."
> +else
> +    echo " -> $test: service start failed."
> +    echo " -> $test: TEST-FAIL"
> +    restore_target
> +    exit
> +fi
> +
> +if ls $pid_file
Please check for presence of a file with '[ -f $pid_file'

> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +if [ "$service_status" = "inactive" ]
> +then
> +    exec_service_on_target $service_name stop
> +fi
> +restore_target
> diff --git a/tests/Functional.openvpn/tests/openvpn_pid_server.sh
> b/tests/Functional.openvpn/tests/openvpn_pid_server.sh
> new file mode 100644
> index 0000000..e2f2e7b
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_pid_server.sh
> @@ -0,0 +1,63 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the pidfile.
> +
> +test="pid_server"
> +
> +test_type="server"
> +
> +service_status=$(get_service_status $service_name)
> +exec_service_on_target $service_name stop
> +
> +if [ -f $config_file ]
> +then
> +    mv $config_file $config_file"_bak"
> +fi
> +cp data/testsrv.conf $config_file
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +mkdir -m 755 /dev/net
> +mknod /dev/net/tun c 10 200
> +
> +restore_target() {
> +    rm -fr /dev/net
Same issue as above.

> +    rm $config_file
> +    if [ -f $config_file"_bak" ]
> +    then
> +        mv $config_file"_bak" $config_file
> +    fi
> +    rm -r /etc/openvpn/host-target.key
> +    if [ -f /etc/openvpn/host-target.key_bak ]
> +    then
> +        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +    fi
> +    modprobe -r tun
> +}
> +
> +if exec_service_on_target $service_name start
> +then
> +    echo " -> $test: service start succeeded."
> +else
> +    echo " -> $test: service start failed."
> +    echo " -> $test: TEST-FAIL"
> +    restore_target
> +    exit
> +fi
> +
> +if ls $pid_file
please use '[ -f $pid_file' for detecting the presence of a file.

> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +if [ "$service_status" = "inactive" ]
> +then
> +    exec_service_on_target $service_name stop
> +fi
> +restore_target
> diff --git a/tests/Functional.openvpn/tests/openvpn_ps_client.sh
> b/tests/Functional.openvpn/tests/openvpn_ps_client.sh
> new file mode 100644
> index 0000000..956c2fd
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_ps_client.sh
> @@ -0,0 +1,67 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the status of process.
> +
> +test="ps_client"
> +
> +test_type="client"
> +
> +service_status=$(get_service_status $service_name)
> +exec_service_on_target $service_name stop
> +
> +if [ -f $config_file ]
> +then
> +    mv $config_file $config_file"_bak"
> +fi
> +cp data/testcli.conf $config_file
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +mkdir -m 755 /dev/net
> +mknod /dev/net/tun c 10 200

This pattern is repeated a lot.  You should put this into a 
shell library and source it into all the sub-scripts.

I think you should probably structure this with a setup routine (in data/testenv.sh)
and a restore routine (also in data/testenv.sh)

> +
> +restore_target() {
> +    rm -fr /dev/net
> +    rm $config_file
> +    if [ -f $config_file"_bak" ]
> +    then
> +        mv $config_file"_bak" $config_file
> +    fi
> +    rm -r /etc/openvpn/host-target.key
> +    if [ -f /etc/openvpn/host-target.key_bak ]
> +    then
> +        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +    fi
> +    modprobe -r tun
> +}
> +
> +exec_service_on_target $service_name start
> +
> +if ps aux | grep "[/]usr/sbin/openvpn"
> +then
> +    echo " -> $test: get the process of openvpn succeeded."
> +else
> +    echo " -> $test: get the process of openvpn failed."
> +    echo " -> $test: TEST-FAIL"
> +    exec_service_on_target $service_name stop
> +    restore_target
> +    exit
> +fi
> +
> +exec_service_on_target $service_name stop
> +
> +if ! ps aux | grep "[/]usr/sbin/openvpn"
> +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 $service_name start
> +fi
> diff --git a/tests/Functional.openvpn/tests/openvpn_ps_server.sh
> b/tests/Functional.openvpn/tests/openvpn_ps_server.sh
> new file mode 100644
> index 0000000..6a6a25c
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_ps_server.sh
> @@ -0,0 +1,67 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the status of process.
> +
> +test="ps_server"
> +
> +test_type="server"
> +
> +service_status=$(get_service_status $service_name)
> +exec_service_on_target $service_name stop
> +
> +if [ -f $config_file ]
> +then
> +    mv $config_file $config_file"_bak"
> +fi
> +cp data/testsrv.conf $config_file
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +mkdir -m 755 /dev/net
> +mknod /dev/net/tun c 10 200
> +
> +restore_target() {
> +    rm -fr /dev/net
> +    rm $config_file
> +    if [ -f $config_file"_bak" ]
> +    then
> +        mv $config_file"_bak" $config_file
> +    fi
> +    rm -r /etc/openvpn/host-target.key
> +    if [ -f /etc/openvpn/host-target.key_bak ]
> +    then
> +        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +    fi
> +    modprobe -r tun
> +}
> +
> +exec_service_on_target $service_name start
> +
> +if ps aux | grep "[/]usr/sbin/openvpn"
> +then
> +    echo " -> $test: get the process of openvpn succeeded."
> +else
> +    echo " -> $test: get the process of openvpn failed."
> +    echo " -> $test: TEST-FAIL"
> +    exec_service_on_target $service_name stop
> +    restore_target
> +    exit
> +fi
> +
> +exec_service_on_target $service_name stop
> +
> +if ! ps aux | grep "[/]usr/sbin/openvpn"
> +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 $service_name start
> +fi
> diff --git a/tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh
> b/tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh
> new file mode 100644
> index 0000000..7b4f36c
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh
> @@ -0,0 +1,71 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the message of syslog-ng.
> +
> +test="syslog-ng_client"
> +
> +test_type="client"
> +
> +logger_service=$(detect_logger_service)
> +openvpn_logfile=$(get_service_logfile)
> +service_status=$(get_service_status $service_name)
> +
> +exec_service_on_target $service_name stop
> +exec_service_on_target $logger_service stop
> +
> +if [ -f $openvpn_logfile ]
> +then
> +    mv $openvpn_logfile $openvpn_logfile"_bak"
> +fi
> +
> +exec_service_on_target $logger_service restart
> +
> +sleep 2
> +
> +if [ -f $config_file ]
> +then
> +    mv $config_file $config_file"_bak"
> +fi
> +cp data/testcli.conf $config_file
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +mkdir -m 755 /dev/net
> +mknod /dev/net/tun c 10 200
> +
> +exec_service_on_target $service_name start
> +
> +sleep 5
> +
> +if cat $openvpn_logfile | grep OpenVPN
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +exec_service_on_target $service_name stop
> +
> +rm -fr /dev/net
> +
> +rm $config_file
> +if [ -f $config_file"_bak" ]
> +then
> +    mv $config_file"_bak" $config_file
> +fi
> +
> +rm -r /etc/openvpn/host-target.key
> +if [ -f /etc/openvpn/host-target.key_bak ]
> +then
> +    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +fi
> +
> +modprobe -r tun
> +if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> +    exec_service_on_target $service_name start
> +fi
> diff --git a/tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh
> b/tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh
> new file mode 100644
> index 0000000..29a53b9
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh
> @@ -0,0 +1,69 @@
> +#!/bin/sh
> +
> +#  In the target, run openvpn and check the message of syslog-ng.
> +
> +test="syslog-ng_server"
> +
This script is missing the line:
test_type="server"

This wouldn't work in the non-systemd case (even if the source of data/testenv.sh was correct)

> +logger_service=$(detect_logger_service)
> +service_status=$(get_service_status $service_name)
> +openvpn_logfile=$(get_service_logfile)
> +
> +exec_service_on_target $service_name stop
> +exec_service_on_target $logger_service stop
> +
> +if [ -f $openvpn_logfile ]
> +then
> +    mv $openvpn_logfile $openvpn_logfile"_bak"
> +fi
> +
> +exec_service_on_target $logger_service restart
> +
> +sleep 2
> +
> +if [ -f $config_file ]
> +then
> +    mv $config_file $config_file"_bak"
> +fi
> +cp data/testsrv.conf $config_file

If you restructure this with some library functions for setup and teardown, you can
probably include the cp in the library setup function.
that is, something like this:
if [ "$test_type" = "client" ] ; then
    cp data/testcli.conf $config_file
elif [ "$test_type" = "server" ] ; then
    cp data/testsrc.conf $config_file
else
    echo " -> $test: TEST-ERROR - invalid test_type"
    return 1
fi
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +mkdir -m 755 /dev/net
> +mknod /dev/net/tun c 10 200
> +
> +exec_service_on_target $service_name start
> +
> +sleep 5
> +
> +if cat $openvpn_logfile | grep OpenVPN
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +exec_service_on_target $service_name stop
> +
> +rm -fr /dev/net
> +
> +rm $config_file
> +if [ -f $config_file"_bak" ]
> +then
> +    mv $config_file"_bak" $config_file
> +fi
> +
> +rm -r /etc/openvpn/host-target.key
> +if [ -f /etc/openvpn/host-target.key_bak ]
> +then
> +    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +fi
> +
> +modprobe -r tun
> +if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> +    exec_service_on_target $service_name start
> +fi
> diff --git a/tests/Functional.openvpn/tests/openvpn_tun_client.sh
> b/tests/Functional.openvpn/tests/openvpn_tun_client.sh
> new file mode 100644
> index 0000000..7bba41e
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_tun_client.sh
> @@ -0,0 +1,56 @@
> +#!/bin/sh
> +
> +# Verify the creation of the tun device (tap0) interface by openvpn.
> +
> +test="tun_client"
> +
> +test_type="client"
> +
> +service_status=$(get_service_status $service_name)
> +exec_service_on_target $service_name stop
> +
> +if [ -f $config_file ]
> +then
> +    mv $config_file $config_file"_bak"
> +fi
> +cp data/testcli.conf $config_file
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +mkdir -m 755 /dev/net
> +mknod /dev/net/tun c 10 200
> +
> +exec_service_on_target $service_name start
> +
> +if ifconfig tap0

Need to add 'assert_has_program ifconfig' to test_precheck in fuego_test.sh

> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +exec_service_on_target $service_name stop
> +
> +rm -fr /dev/net
> +
> +rm $config_file
> +if [ -f $config_file"_bak" ]
> +then
> +    mv $config_file"_bak" $config_file
> +fi
> +
> +rm -r /etc/openvpn/host-target.key
> +if [ -f /etc/openvpn/host-target.key_bak ]
> +then
> +    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +fi
> +
> +modprobe -r tun
> +if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> +    exec_service_on_target $service_name start
> +fi
> diff --git a/tests/Functional.openvpn/tests/openvpn_tun_server.sh
> b/tests/Functional.openvpn/tests/openvpn_tun_server.sh
> new file mode 100644
> index 0000000..4a9aa46
> --- /dev/null
> +++ b/tests/Functional.openvpn/tests/openvpn_tun_server.sh
> @@ -0,0 +1,56 @@
> +#!/bin/sh
> +
> +# Verify the creation of the tun device (tap0) interface by openvpn.
> +
> +test="tun_server"
> +
> +test_type="server"
> +
> +service_status=$(get_service_status $service_name)
> +exec_service_on_target $service_name stop
> +
> +if [ -f $config_file ]
> +then
> +    mv $config_file $config_file"_bak"
> +fi
> +cp data/testsrv.conf $config_file
> +
> +if [ -f /etc/openvpn/host-target.key ]
> +then
> +    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
> +fi
> +cp data/host-target.key /etc/openvpn/host-target.key
> +
> +mkdir -m 755 /dev/net
> +mknod /dev/net/tun c 10 200
> +
> +exec_service_on_target $service_name start
> +
> +if ifconfig tap0
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +exec_service_on_target $service_name stop
> +
> +rm -fr /dev/net
> +
> +rm $config_file
> +if [ -f $config_file"_bak" ]
> +then
> +    mv $config_file"_bak" $config_file
> +fi
> +
> +rm -r /etc/openvpn/host-target.key
> +if [ -f /etc/openvpn/host-target.key_bak ]
> +then
> +    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
> +fi
> +
> +modprobe -r tun
> +if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
> +then
> +    exec_service_on_target $service_name start
> +fi
> --
> 2.17.1

Thanks for the submission.
This is getting better.  Please address my comments and submit it again.
 -- Tim


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

* [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn.
  2019-11-05  9:01 [Fuego] [PATCH v3] " Wang Mingyu
@ 2019-11-05  9:01 ` Wang Mingyu
  2019-11-08 13:13   ` Tim.Bird
  0 siblings, 1 reply; 8+ messages in thread
From: Wang Mingyu @ 2019-11-05  9:01 UTC (permalink / raw)
  To: fuego

This test set is used to check if the service openvpn can be started.
And check the process file, syslog file, tap0 can be created or not.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.openvpn/data/host-target.key | 22 ++++++
 tests/Functional.openvpn/data/testcli.conf    |  7 ++
 tests/Functional.openvpn/data/testenv.sh      | 18 +++++
 tests/Functional.openvpn/data/testsrv.conf    | 16 +++++
 tests/Functional.openvpn/fuego_test.sh        | 19 +++++
 tests/Functional.openvpn/openvpn_test.sh      |  9 +++
 tests/Functional.openvpn/spec.json            |  6 ++
 .../tests/openvpn_genkey.sh                   | 26 +++++++
 .../tests/openvpn_lport_client.sh             | 66 +++++++++++++++++
 .../tests/openvpn_lport_server.sh             | 65 +++++++++++++++++
 .../tests/openvpn_pid_client.sh               | 62 ++++++++++++++++
 .../tests/openvpn_pid_server.sh               | 63 ++++++++++++++++
 .../tests/openvpn_ps_client.sh                | 67 +++++++++++++++++
 .../tests/openvpn_ps_server.sh                | 67 +++++++++++++++++
 .../tests/openvpn_syslog-ng_client.sh         | 71 +++++++++++++++++++
 .../tests/openvpn_syslog-ng_server.sh         | 69 ++++++++++++++++++
 .../tests/openvpn_tun_client.sh               | 56 +++++++++++++++
 .../tests/openvpn_tun_server.sh               | 56 +++++++++++++++
 18 files changed, 765 insertions(+)
 create mode 100644 tests/Functional.openvpn/data/host-target.key
 create mode 100644 tests/Functional.openvpn/data/testcli.conf
 create mode 100644 tests/Functional.openvpn/data/testenv.sh
 create mode 100644 tests/Functional.openvpn/data/testsrv.conf
 create mode 100644 tests/Functional.openvpn/fuego_test.sh
 create mode 100755 tests/Functional.openvpn/openvpn_test.sh
 create mode 100644 tests/Functional.openvpn/spec.json
 create mode 100644 tests/Functional.openvpn/tests/openvpn_genkey.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_lport_client.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_lport_server.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_pid_client.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_pid_server.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_ps_client.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_ps_server.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_tun_client.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_tun_server.sh

diff --git a/tests/Functional.openvpn/data/host-target.key b/tests/Functional.openvpn/data/host-target.key
new file mode 100644
index 0000000..99743bf
--- /dev/null
+++ b/tests/Functional.openvpn/data/host-target.key
@@ -0,0 +1,22 @@
+#
+# 2048 bit OpenVPN static key
+#
+-----BEGIN OpenVPN Static key V1-----
+debe9557c7eb224c5cf4f3369d5211ff
+fb9c375a4784759edf6b0f6eb8f5da31
+bb280394d40382cc8e02d6cbb3e47492
+3509eac6b48965078e3d317b0791dea2
+dbcf0eddcab0fb20780fcf0908ce94cd
+7cb65a913fea73ac6bfe0ab34f085aa3
+a6c8b89a97d189e5145c3199955c4b34
+6d51f864f2b49f3252d1548c3b3510ec
+0ecd4b9f17f2039439a79f41a46f6a54
+c0385b962b2b94fcbe73e0108b224a5b
+2efae27d872f0efef67b244c7eb6f525
+581e4c2b4e6aa193fb1d37798bdb46ff
+7c6727f08e9601c10ac7478d73d731e6
+f4b652252f3e5309cd1d6d30c7a433cc
+134bd6dd50fa6a6fc7a843fdc058d38d
+fb8679b48eb09745badf004fbf4a434c
+-----END OpenVPN Static key V1-----
+
diff --git a/tests/Functional.openvpn/data/testcli.conf b/tests/Functional.openvpn/data/testcli.conf
new file mode 100644
index 0000000..2c252bb
--- /dev/null
+++ b/tests/Functional.openvpn/data/testcli.conf
@@ -0,0 +1,7 @@
+remote  192.168.0.1
+port    5000
+dev     tap
+#dev    tun
+verb    3
+ping    60
+
diff --git a/tests/Functional.openvpn/data/testenv.sh b/tests/Functional.openvpn/data/testenv.sh
new file mode 100644
index 0000000..8c01d58
--- /dev/null
+++ b/tests/Functional.openvpn/data/testenv.sh
@@ -0,0 +1,18 @@
+#set the variable
+if [ "$init_manager" == "systemd" ]
+then
+        service_name="openvpn@loopback-server.service"
+        config_file="/etc/openvpn/loopback-server.conf"
+        pid_file="/var/run/openvpn/loopback-server.pid"
+else
+        service_name="openvpn"
+        if [ "$test_type" == "client" ]
+        then
+                config_file="/etc/openvpn/testcli.conf"
+                pid_file="/var/run/openvpn.testcli.pid"
+        elif [ "$test_type" == "server" ]
+        then
+                config_file="/etc/openvpn/testsrv.conf"
+                pid_file="/var/run/openvpn.testsrv.pid"
+        fi
+fi
diff --git a/tests/Functional.openvpn/data/testsrv.conf b/tests/Functional.openvpn/data/testsrv.conf
new file mode 100644
index 0000000..0c18a40
--- /dev/null
+++ b/tests/Functional.openvpn/data/testsrv.conf
@@ -0,0 +1,16 @@
+#
+proto           udp
+port            5000
+
+dev             tap
+
+secret          /etc/openvpn/host-target.key
+#link-mtu       1200
+
+ping            10
+ping-restart    60
+ping-timer-rem
+persist-key
+persist-tun
+verb            3
+
diff --git a/tests/Functional.openvpn/fuego_test.sh b/tests/Functional.openvpn/fuego_test.sh
new file mode 100644
index 0000000..65d2991
--- /dev/null
+++ b/tests/Functional.openvpn/fuego_test.sh
@@ -0,0 +1,19 @@
+function test_pre_check {
+    assert_has_program openvpn
+}
+
+function test_deploy {
+    put $TEST_HOME/openvpn_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/
+    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./openvpn_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.openvpn/openvpn_test.sh b/tests/Functional.openvpn/openvpn_test.sh
new file mode 100755
index 0000000..42f41ea
--- /dev/null
+++ b/tests/Functional.openvpn/openvpn_test.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+. ./fuego_board_function_lib.sh
+set_init_manager
+
+. data/testenv.sh
+
+for i in tests/*.sh; do
+    source $i
+done
diff --git a/tests/Functional.openvpn/spec.json b/tests/Functional.openvpn/spec.json
new file mode 100644
index 0000000..e9fdc5a
--- /dev/null
+++ b/tests/Functional.openvpn/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.openvpn",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.openvpn/tests/openvpn_genkey.sh b/tests/Functional.openvpn/tests/openvpn_genkey.sh
new file mode 100644
index 0000000..cef533e
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_genkey.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#  In target, run command openvpn.
+#  option: --genkey
+
+test="genkey"
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+
+openvpn --genkey --secret /etc/openvpn/host-target.key
+if ls /etc/openvpn/host-target.key
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f /etc/openvpn/host-target.key
+
+if [ -f /etc/openvpn/host-target.key_bak ]
+then
+    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+fi
+
diff --git a/tests/Functional.openvpn/tests/openvpn_lport_client.sh b/tests/Functional.openvpn/tests/openvpn_lport_client.sh
new file mode 100644
index 0000000..f8aac80
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_lport_client.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the Listening port.
+
+test="lport_client"
+
+test_type="client"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+
+if [ -f $config_file ]
+then
+    mv $config_file $config_file"_bak"
+fi
+cp data/testcli.conf $config_file
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    rm $config_file
+    if [ -f $config_file"_bak" ]
+    then
+        mv $config_file"_bak" $config_file
+    fi
+    rm -r /etc/openvpn/host-target.key
+    if [ -f /etc/openvpn/host-target.key_bak ]
+    then
+        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+    fi
+
+    modprobe -r tun
+}
+
+if exec_service_on_target $service_name start
+then
+    echo " -> $test: service start succeeded."
+else
+    echo " -> $test: service start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if netstat -ln | grep ":5000"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target $service_name stop
+fi
+restore_target
diff --git a/tests/Functional.openvpn/tests/openvpn_lport_server.sh b/tests/Functional.openvpn/tests/openvpn_lport_server.sh
new file mode 100644
index 0000000..0377c2d
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_lport_server.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the Listening port.
+
+test="lport_server"
+
+test_type="server"
+
+service_status=$(get_service_status $service_name)
+
+if [ -f $config_file ]
+then
+    mv $config_file $config_file"_bak"
+fi
+cp data/testsrv.conf $config_file
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    rm $config_file
+    if [ -f $config_file"_bak" ]
+    then
+        mv $config_file"_bak" $config_file
+    fi
+    rm -r /etc/openvpn/host-target.key
+    if [ -f /etc/openvpn/host-target.key_bak ]
+    then
+        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+    fi
+
+    modprobe -r tun
+}
+
+if exec_service_on_target $service_name start
+then
+    echo " -> $test: service start succeeded."
+else
+    echo " -> $test: service start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if netstat -ln | grep ":5000"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target $service_name stop
+fi
+restore_target
diff --git a/tests/Functional.openvpn/tests/openvpn_pid_client.sh b/tests/Functional.openvpn/tests/openvpn_pid_client.sh
new file mode 100644
index 0000000..a7829b2
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_pid_client.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the pidfile.
+
+test="pid_client"
+
+test_type="client"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+
+if [ -f $config_file ]
+then
+    mv $config_file $config_file"_bak"
+fi
+cp data/testcli.conf $config_file
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    rm $config_file
+    if [ -f $config_file"_bak" ]
+    then
+        mv $config_file"_bak" $config_file
+    fi
+    rm -r /etc/openvpn/host-target.key
+    if [ -f /etc/openvpn/host-target.key_bak ]
+    then
+        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+    fi
+    modprobe -r tun
+}
+
+if exec_service_on_target $service_name start
+then
+    echo " -> $test: service start succeeded."
+else
+    echo " -> $test: service start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if ls $pid_file
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target $service_name stop
+fi
+restore_target
diff --git a/tests/Functional.openvpn/tests/openvpn_pid_server.sh b/tests/Functional.openvpn/tests/openvpn_pid_server.sh
new file mode 100644
index 0000000..e2f2e7b
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_pid_server.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the pidfile.
+
+test="pid_server"
+
+test_type="server"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+
+if [ -f $config_file ]
+then
+    mv $config_file $config_file"_bak"
+fi
+cp data/testsrv.conf $config_file
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    rm $config_file
+    if [ -f $config_file"_bak" ]
+    then
+        mv $config_file"_bak" $config_file
+    fi
+    rm -r /etc/openvpn/host-target.key
+    if [ -f /etc/openvpn/host-target.key_bak ]
+    then
+        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+    fi
+    modprobe -r tun
+}
+
+if exec_service_on_target $service_name start
+then
+    echo " -> $test: service start succeeded."
+else
+    echo " -> $test: service start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if ls $pid_file
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target $service_name stop
+fi
+restore_target
diff --git a/tests/Functional.openvpn/tests/openvpn_ps_client.sh b/tests/Functional.openvpn/tests/openvpn_ps_client.sh
new file mode 100644
index 0000000..956c2fd
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_ps_client.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the status of process.
+
+test="ps_client"
+
+test_type="client"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+
+if [ -f $config_file ]
+then
+    mv $config_file $config_file"_bak"
+fi
+cp data/testcli.conf $config_file
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    rm $config_file
+    if [ -f $config_file"_bak" ]
+    then
+        mv $config_file"_bak" $config_file
+    fi
+    rm -r /etc/openvpn/host-target.key
+    if [ -f /etc/openvpn/host-target.key_bak ]
+    then
+        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+    fi
+    modprobe -r tun
+}
+
+exec_service_on_target $service_name start
+
+if ps aux | grep "[/]usr/sbin/openvpn"
+then
+    echo " -> $test: get the process of openvpn succeeded."
+else
+    echo " -> $test: get the process of openvpn failed."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target $service_name stop
+    restore_target
+    exit
+fi
+
+exec_service_on_target $service_name stop
+
+if ! ps aux | grep "[/]usr/sbin/openvpn"
+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 $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_ps_server.sh b/tests/Functional.openvpn/tests/openvpn_ps_server.sh
new file mode 100644
index 0000000..6a6a25c
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_ps_server.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the status of process.
+
+test="ps_server"
+
+test_type="server"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+
+if [ -f $config_file ]
+then
+    mv $config_file $config_file"_bak"
+fi
+cp data/testsrv.conf $config_file
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    rm $config_file
+    if [ -f $config_file"_bak" ]
+    then
+        mv $config_file"_bak" $config_file
+    fi
+    rm -r /etc/openvpn/host-target.key
+    if [ -f /etc/openvpn/host-target.key_bak ]
+    then
+        mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+    fi
+    modprobe -r tun
+}
+
+exec_service_on_target $service_name start
+
+if ps aux | grep "[/]usr/sbin/openvpn"
+then
+    echo " -> $test: get the process of openvpn succeeded."
+else
+    echo " -> $test: get the process of openvpn failed."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target $service_name stop
+    restore_target
+    exit
+fi
+
+exec_service_on_target $service_name stop
+
+if ! ps aux | grep "[/]usr/sbin/openvpn"
+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 $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh b/tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh
new file mode 100644
index 0000000..7b4f36c
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the message of syslog-ng.
+
+test="syslog-ng_client"
+
+test_type="client"
+
+logger_service=$(detect_logger_service)
+openvpn_logfile=$(get_service_logfile)
+service_status=$(get_service_status $service_name)
+
+exec_service_on_target $service_name stop
+exec_service_on_target $logger_service stop
+
+if [ -f $openvpn_logfile ]
+then
+    mv $openvpn_logfile $openvpn_logfile"_bak"
+fi
+
+exec_service_on_target $logger_service restart
+
+sleep 2
+
+if [ -f $config_file ]
+then
+    mv $config_file $config_file"_bak"
+fi
+cp data/testcli.conf $config_file
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+exec_service_on_target $service_name start
+
+sleep 5
+
+if cat $openvpn_logfile | grep OpenVPN
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target $service_name stop
+
+rm -fr /dev/net
+
+rm $config_file
+if [ -f $config_file"_bak" ]
+then
+    mv $config_file"_bak" $config_file
+fi
+
+rm -r /etc/openvpn/host-target.key
+if [ -f /etc/openvpn/host-target.key_bak ]
+then
+    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+fi
+
+modprobe -r tun
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh b/tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh
new file mode 100644
index 0000000..29a53b9
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the message of syslog-ng.
+
+test="syslog-ng_server"
+
+logger_service=$(detect_logger_service)
+service_status=$(get_service_status $service_name)
+openvpn_logfile=$(get_service_logfile)
+
+exec_service_on_target $service_name stop
+exec_service_on_target $logger_service stop
+
+if [ -f $openvpn_logfile ]
+then
+    mv $openvpn_logfile $openvpn_logfile"_bak"
+fi
+
+exec_service_on_target $logger_service restart
+
+sleep 2
+
+if [ -f $config_file ]
+then
+    mv $config_file $config_file"_bak"
+fi
+cp data/testsrv.conf $config_file
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+exec_service_on_target $service_name start
+
+sleep 5
+
+if cat $openvpn_logfile | grep OpenVPN
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target $service_name stop
+
+rm -fr /dev/net
+
+rm $config_file
+if [ -f $config_file"_bak" ]
+then
+    mv $config_file"_bak" $config_file
+fi
+
+rm -r /etc/openvpn/host-target.key
+if [ -f /etc/openvpn/host-target.key_bak ]
+then
+    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+fi
+
+modprobe -r tun
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_tun_client.sh b/tests/Functional.openvpn/tests/openvpn_tun_client.sh
new file mode 100644
index 0000000..7bba41e
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_tun_client.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# Verify the creation of the tun device (tap0) interface by openvpn.
+
+test="tun_client"
+
+test_type="client"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+
+if [ -f $config_file ]
+then
+    mv $config_file $config_file"_bak"
+fi
+cp data/testcli.conf $config_file
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+exec_service_on_target $service_name start
+
+if ifconfig tap0
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target $service_name stop
+
+rm -fr /dev/net
+
+rm $config_file
+if [ -f $config_file"_bak" ]
+then
+    mv $config_file"_bak" $config_file
+fi
+
+rm -r /etc/openvpn/host-target.key
+if [ -f /etc/openvpn/host-target.key_bak ]
+then
+    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+fi
+
+modprobe -r tun
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_tun_server.sh b/tests/Functional.openvpn/tests/openvpn_tun_server.sh
new file mode 100644
index 0000000..4a9aa46
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_tun_server.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# Verify the creation of the tun device (tap0) interface by openvpn.
+
+test="tun_server"
+
+test_type="server"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+
+if [ -f $config_file ]
+then
+    mv $config_file $config_file"_bak"
+fi
+cp data/testsrv.conf $config_file
+
+if [ -f /etc/openvpn/host-target.key ]
+then
+    mv /etc/openvpn/host-target.key /etc/openvpn/host-target.key_bak
+fi
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+exec_service_on_target $service_name start
+
+if ifconfig tap0
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target $service_name stop
+
+rm -fr /dev/net
+
+rm $config_file
+if [ -f $config_file"_bak" ]
+then
+    mv $config_file"_bak" $config_file
+fi
+
+rm -r /etc/openvpn/host-target.key
+if [ -f /etc/openvpn/host-target.key_bak ]
+then
+    mv /etc/openvpn/host-target.key_bak /etc/openvpn/host-target.key
+fi
+
+modprobe -r tun
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
-- 
2.17.1




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

end of thread, other threads:[~2019-11-19 17:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 10:49 [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate Wang Mingyu
2019-11-18 10:49 ` [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn Wang Mingyu
2019-11-19 17:00   ` Tim.Bird
2019-11-18 10:49 ` [Fuego] [PATCH] Add function to get the status of module Wang Mingyu
2019-11-18 17:59   ` Tim.Bird
2019-11-18 18:16 ` [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate Tim.Bird
  -- strict thread matches above, loose matches on Subject: below --
2019-11-05  9:01 [Fuego] [PATCH v3] " Wang Mingyu
2019-11-05  9:01 ` [Fuego] [PATCH v3] openvpn: Add test cases of service openvpn Wang Mingyu
2019-11-08 13:13   ` 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.