[Fuego] [PATCH] Add test cases of service nfs-statd, nfsserver, nscd, ntpd and ntpdate.

Wang Mingyu wangmy at cn.fujitsu.com
Wed Nov 28 15:47:43 UTC 2018


Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 .../tests/Functional.demo/tests/demo_nfs-statd.sh  | 54 ++++++++++++++++
 .../tests/Functional.demo/tests/demo_nfsserver.sh  | 71 ++++++++++++++++++++++
 engine/tests/Functional.demo/tests/demo_nscd.sh    | 42 +++++++++++++
 engine/tests/Functional.demo/tests/demo_ntpd.sh    | 41 +++++++++++++
 engine/tests/Functional.demo/tests/demo_ntpdate.sh | 49 +++++++++++++++
 5 files changed, 257 insertions(+)
 create mode 100644 engine/tests/Functional.demo/tests/demo_nfs-statd.sh
 create mode 100644 engine/tests/Functional.demo/tests/demo_nfsserver.sh
 create mode 100644 engine/tests/Functional.demo/tests/demo_nscd.sh
 create mode 100644 engine/tests/Functional.demo/tests/demo_ntpd.sh
 create mode 100644 engine/tests/Functional.demo/tests/demo_ntpdate.sh

diff --git a/engine/tests/Functional.demo/tests/demo_nfs-statd.sh b/engine/tests/Functional.demo/tests/demo_nfs-statd.sh
new file mode 100644
index 0000000..d3e7963
--- /dev/null
+++ b/engine/tests/Functional.demo/tests/demo_nfs-statd.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+#  In the target start nfs-statd, and confirm the process condition by command ps.
+
+test="nfs-statd"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+if [ "$init_manager" = "systemd" ]
+then
+    exec_service_on_target nfs-statd stop
+
+    if exec_service_on_target nfs-statd start
+    then
+        echo " -> start of nfs-statd succeeded."
+    else
+        echo " -> start of nfs-statd failed."
+        echo " -> $test: TEST-FAIL"
+        exit
+    fi
+
+    sleep 5
+
+    if ps aux | grep "[/]usr/sbin/rpc.statd"
+    then
+        echo " -> get the process of rpc.statd."
+    else
+        echo " -> can't get the process of rpc.statd."
+        echo " -> $test: TEST-FAIL"
+        exec_service_on_target nfs-statd stop
+        exit
+    fi
+
+    exec_service_on_target nfs-statd stop
+
+    if ps aux | grep "[/]usr/sbin/rpc.statd"
+    then
+        echo " -> $test: TEST-FAIL"
+    else
+        echo " -> $test: TEST-PASS"
+    fi
+else
+    /etc/init.d/nfslock stop
+    sleep 5
+    if /etc/init.d/nfslock start
+    then
+        echo " -> $test: TEST-FAIL"
+    else
+        echo " -> $test: TEST-PASS"
+    fi
+    /etc/init.d/nfslock stop
+fi
diff --git a/engine/tests/Functional.demo/tests/demo_nfsserver.sh b/engine/tests/Functional.demo/tests/demo_nfsserver.sh
new file mode 100644
index 0000000..31b2747
--- /dev/null
+++ b/engine/tests/Functional.demo/tests/demo_nfsserver.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+#  In the target start nfsserver, and confirm the process condition by command ps.
+
+test="nfsserver"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+if [ "$init_manager" = "systemd" ]
+then
+    service_name="nfs-server"
+else
+    service_name="nfsserver"
+fi
+
+if [ -f /etc/exports ]
+then
+    mv /etc/exports /etc/exports_bak
+fi
+
+touch /etc/exports
+
+restore_target() {
+    if [ -f /etc/exports_bak ]
+    then
+        mv /etc/exports_bak /etc/exports
+    else
+        rm -f /etc/exports
+    fi
+}
+
+exec_service_on_target $service_name stop
+exec_service_on_target rpcbind start
+
+if exec_service_on_target $service_name start
+then
+    echo " -> start of nfsserver succeeded."
+else
+    echo " -> start of nfsserver failed."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target rpcbind stop
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if ps aux | grep "[\[]nfsd"
+then
+    echo " -> get the process of nfsd."
+else
+    echo " -> can't get the process of nfsd."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target rpcbind stop
+    exec_service_on_target $service_name stop
+    restore_target
+    exit
+fi
+
+exec_service_on_target rpcbind stop
+exec_service_on_target $service_name stop
+
+if ps aux | grep "[\[]nfsd"
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
+restore_target
diff --git a/engine/tests/Functional.demo/tests/demo_nscd.sh b/engine/tests/Functional.demo/tests/demo_nscd.sh
new file mode 100644
index 0000000..25e1bd0
--- /dev/null
+++ b/engine/tests/Functional.demo/tests/demo_nscd.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+#  In the target start nscd, and confirm the process condition by command ps.
+
+test="nscd"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+killall -q /usr/sbin/nscd
+
+
+if exec_service_on_target nscd start
+then
+    echo " -> start of nscd succeeded."
+else
+    echo " -> start of nscd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
+
+if ps aux | grep "[/]usr/sbin/nscd"
+then
+    echo " -> get the process of nscd."
+else
+    echo " -> can't get the process of nscd."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target nscd stop
+    exit
+fi
+
+exec_service_on_target nscd stop
+
+if ps aux | grep "[/]usr/sbin/nscd"
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
diff --git a/engine/tests/Functional.demo/tests/demo_ntpd.sh b/engine/tests/Functional.demo/tests/demo_ntpd.sh
new file mode 100644
index 0000000..b871e43
--- /dev/null
+++ b/engine/tests/Functional.demo/tests/demo_ntpd.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+#  In the target start ntpd, and confirm the process condition by command ps.
+
+test="ntpd"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target ntpd stop
+
+if exec_service_on_target ntpd start
+then
+    echo " -> start of ntpd succeeded."
+else
+    echo " -> start of ntpd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
+
+if ps aux | grep "[/]usr/sbin/ntpd"
+then
+    echo " -> get the process of ntpd."
+else
+    echo " -> can't get the process of ntpd."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target ntpd stop
+    exit
+fi
+
+exec_service_on_target ntpd stop
+
+if ps aux | grep "[/]usr/sbin/ntpd"
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
diff --git a/engine/tests/Functional.demo/tests/demo_ntpdate.sh b/engine/tests/Functional.demo/tests/demo_ntpdate.sh
new file mode 100644
index 0000000..6f41454
--- /dev/null
+++ b/engine/tests/Functional.demo/tests/demo_ntpdate.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+#  In the target start ntpdate, and confirm the process condition by command ps.
+
+test="ntpdate"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target ntp stop
+exec_service_on_target ntpdate stop
+
+if [ -f /etc/default/ntpdate ]
+then
+    cp /etc/default/ntpdate /etc/default/ntpdate_bak
+fi
+
+restore_target() {
+    if [ -f /etc/default/ntpdate_bak ]
+    then
+        mv /etc/default/ntpdate_bak /etc/default/ntpdate
+    else
+        rm -fr /etc/default/ntpdate
+    fi
+}
+
+echo "NTPSERVERS=\"$SRV_IP\"" >> /etc/default/ntpdate
+
+if exec_service_on_target ntpdate start
+then
+    echo " -> start of ntpdate succeeded."
+else
+    echo " -> start of ntpdate failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if exec_service_on_target ntpdate is-active
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> ntpdate is not active."
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target ntpdate stop
+restore_target
-- 
1.8.3.1





More information about the Fuego mailing list