[Fuego] [PATCH] Add test cases of service ripngd.

Wang Mingyu wangmy at cn.fujitsu.com
Wed Nov 21 08:08:52 UTC 2018


ripngd is a routing component that works with the Quagga routing engine.
This test set is used to check the generation of logfile, pidfile, process and syslog of service ripngd.

Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.ripngd/data/ripngd.conf    |  24 +++++
 engine/tests/Functional.ripngd/data/zebra.conf     |  22 ++++
 engine/tests/Functional.ripngd/fuego_test.sh       |  22 ++++
 engine/tests/Functional.ripngd/parser.py           |  22 ++++
 engine/tests/Functional.ripngd/ripngd_test.sh      |   4 +
 engine/tests/Functional.ripngd/spec.json           |   7 ++
 .../Functional.ripngd/tests/ripngd_logfile.sh      | 111 +++++++++++++++++++
 .../Functional.ripngd/tests/ripngd_pidfile.sh      | 119 +++++++++++++++++++++
 engine/tests/Functional.ripngd/tests/ripngd_ps.sh  | 115 ++++++++++++++++++++
 .../tests/Functional.ripngd/tests/ripngd_syslog.sh | 109 +++++++++++++++++++
 10 files changed, 555 insertions(+)
 create mode 100644 engine/tests/Functional.ripngd/data/ripngd.conf
 create mode 100644 engine/tests/Functional.ripngd/data/zebra.conf
 create mode 100644 engine/tests/Functional.ripngd/fuego_test.sh
 create mode 100644 engine/tests/Functional.ripngd/parser.py
 create mode 100755 engine/tests/Functional.ripngd/ripngd_test.sh
 create mode 100644 engine/tests/Functional.ripngd/spec.json
 create mode 100644 engine/tests/Functional.ripngd/tests/ripngd_logfile.sh
 create mode 100644 engine/tests/Functional.ripngd/tests/ripngd_pidfile.sh
 create mode 100644 engine/tests/Functional.ripngd/tests/ripngd_ps.sh
 create mode 100644 engine/tests/Functional.ripngd/tests/ripngd_syslog.sh

diff --git a/engine/tests/Functional.ripngd/data/ripngd.conf b/engine/tests/Functional.ripngd/data/ripngd.conf
new file mode 100644
index 0000000..3082d4c
--- /dev/null
+++ b/engine/tests/Functional.ripngd/data/ripngd.conf
@@ -0,0 +1,24 @@
+! -*- rip -*-
+!
+! RIPngd sample configuration file
+!
+! $Id: ripngd.conf.sample,v 1.1.1.1 2002/12/13 20:15:30 paul Exp $
+!
+hostname ripngd
+password zebra
+log file /var/log/quagga/ripngd.log
+log syslog informational
+!
+! debug ripng events
+! debug ripng packet
+!
+!
+router ripng
+! network sit1
+! route 3ffe:506::0/32
+! distribute-list local-only out sit1
+!
+!ipv6 access-list local-only permit 3ffe:506::0/32
+!ipv6 access-list local-only deny any
+!
+!log stdout
diff --git a/engine/tests/Functional.ripngd/data/zebra.conf b/engine/tests/Functional.ripngd/data/zebra.conf
new file mode 100644
index 0000000..730e7cf
--- /dev/null
+++ b/engine/tests/Functional.ripngd/data/zebra.conf
@@ -0,0 +1,22 @@
+!
+! Zebra configuration saved from vty
+!   2000/01/01 01:54:01
+!
+hostname Router
+password zebra
+enable password zebra
+log file /var/log/quagga/zebra.log
+log syslog informational
+!
+!interface bmap
+!
+!interface xxx
+!
+interface lo
+!
+ip route xxx/24 xxx reject
+!
+!ipv6 forwarding
+!
+line vty
+!
diff --git a/engine/tests/Functional.ripngd/fuego_test.sh b/engine/tests/Functional.ripngd/fuego_test.sh
new file mode 100644
index 0000000..ce457a3
--- /dev/null
+++ b/engine/tests/Functional.ripngd/fuego_test.sh
@@ -0,0 +1,22 @@
+function test_pre_check {
+    assert_has_program ripngd
+    assert_has_program zebra
+}
+
+function test_deploy {
+    put $TEST_HOME/ripngd_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put $FUEGO_CORE/engine/scripts/fuego_board_function_lib.sh $BOARD_TESTDIR/fuego.$TESTDIR
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
+    cmd "sed -i 's/!interface xxx/interface $IFETH/' $BOARD_TESTDIR/fuego.$TESTDIR/data/zebra.conf"
+    cmd "sed -i 's/ip route xxx\/24 xxx reject/ip route $ROUTER\/24 $IFETH reject/' $BOARD_TESTDIR/fuego.$TESTDIR/data/zebra.conf"
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./ripngd_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.ripngd/parser.py b/engine/tests/Functional.ripngd/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.ripngd/parser.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/engine/tests/Functional.ripngd/ripngd_test.sh b/engine/tests/Functional.ripngd/ripngd_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.ripngd/ripngd_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.ripngd/spec.json b/engine/tests/Functional.ripngd/spec.json
new file mode 100644
index 0000000..42d0cae
--- /dev/null
+++ b/engine/tests/Functional.ripngd/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.ripngd",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.ripngd/tests/ripngd_logfile.sh b/engine/tests/Functional.ripngd/tests/ripngd_logfile.sh
new file mode 100644
index 0000000..cd04867
--- /dev/null
+++ b/engine/tests/Functional.ripngd/tests/ripngd_logfile.sh
@@ -0,0 +1,111 @@
+#!/bin/sh
+
+#  In the target start ripngd, and confirm the ripngd log.
+
+test="logfile"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+zebra_status=0
+ripngd_status=0
+if exec_service_on_target ripngd status | grep "running"
+then
+    ripngd_status=1
+fi
+if exec_service_on_target zebra status | grep "running"
+then
+    zebra_status=1
+fi
+
+exec_service_on_target ripngd stop
+exec_service_on_target zebra stop
+
+if [ ! -d /var/log/quagga ]
+then
+   mkdir /var/log/quagga
+   chown -R quagga:quagga /var/log/quagga
+fi
+
+if [ -f /var/log/quagga/ripngd.log ]
+then
+    mv /var/log/quagga/ripngd.log /var/log/quagga/ripngd.log_bak
+fi
+
+if [ -f /etc/quagga/zebra.conf ]
+then
+    mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf_bak
+fi
+cp data/zebra.conf /etc/quagga/zebra.conf
+
+if [ -f /etc/quagga/ripngd.conf ]
+then
+    mv /etc/quagga/ripngd.conf /etc/quagga/ripngd.conf_bak
+fi
+cp data/ripngd.conf /etc/quagga/ripngd.conf
+
+chown quagga:quagga /etc/quagga/*.conf
+
+restore_target() {
+    if [ -f /etc/quagga/zebra.conf_bak ]
+    then
+        mv /etc/quagga/zebra.conf_bak /etc/quagga/zebra.conf
+    else
+        rm /etc/quagga/zebra.conf
+    fi
+    if [ -f /etc/quagga/ripngd.conf_bak ]
+    then
+        mv /etc/quagga/ripngd.conf_bak /etc/quagga/ripngd.conf
+    else
+        rm /etc/quagga/ripngd.conf
+    fi
+    if [ -f /var/log/quagga/ripngd.log_bak ]
+    then
+        mv /var/log/quagga/ripngd.log_bak /var/log/quagga/ripngd.log
+    fi
+}
+
+if exec_service_on_target zebra start
+then
+    echo " -> start of zebra succeeded."
+else
+    echo " -> start of zebra failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if exec_service_on_target ripngd start
+then
+    echo " -> start of ripngd succeeded."
+else
+    echo " -> start of ripngd failed."
+    echo " -> $test: TEST-FAIL"
+    if zebra_status=0
+    then
+        exec_service_on_target zebra stop
+    fi
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if [ -f /var/log/quagga/ripngd.log ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> can't get the logfile of ripngd."
+    echo " -> $test: TEST-FAIL"
+fi
+
+if zebra_status=0
+then
+    exec_service_on_target zebra stop
+fi
+if ripngd_status=0
+then
+    exec_service_on_target ripngd stop
+fi
+restore_target
diff --git a/engine/tests/Functional.ripngd/tests/ripngd_pidfile.sh b/engine/tests/Functional.ripngd/tests/ripngd_pidfile.sh
new file mode 100644
index 0000000..cf7d6f5
--- /dev/null
+++ b/engine/tests/Functional.ripngd/tests/ripngd_pidfile.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+#  In the target start ripngd, and confirm the process condition by command ps.
+
+test="pidfile"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+zebra_status=0
+ripngd_status=0
+if exec_service_on_target ripngd status | grep "running"
+then
+    ripngd_status=1
+fi
+if exec_service_on_target zebra status | grep "running"
+then
+    zebra_status=1
+fi
+
+exec_service_on_target ripngd stop
+exec_service_on_target zebra stop
+
+rm -f /var/run/quagga/ripngd.pid
+
+if [ -f /etc/quagga/zebra.conf ]
+then
+    mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf_bak
+fi
+cp data/zebra.conf /etc/quagga/zebra.conf
+
+if [ -f /etc/quagga/ripngd.conf ]
+then
+    mv /etc/quagga/ripngd.conf /etc/quagga/ripngd.conf_bak
+fi
+cp data/ripngd.conf /etc/quagga/ripngd.conf
+
+chown quagga:quagga /etc/quagga/*.conf
+
+restore_target() {
+    if [ -f /etc/quagga/zebra.conf_bak ]
+    then
+        mv /etc/quagga/zebra.conf_bak /etc/quagga/zebra.conf
+    else
+        rm /etc/quagga/zebra.conf
+    fi
+    if [ -f /etc/quagga/ripngd.conf_bak ]
+    then
+        mv /etc/quagga/ripngd.conf_bak /etc/quagga/ripngd.conf
+    else
+        rm /etc/quagga/ripngd.conf
+    fi
+}
+
+if exec_service_on_target zebra start
+then
+    echo " -> start of zebra succeeded."
+else
+    echo " -> start of zebra failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if exec_service_on_target ripngd start
+then
+    echo " -> start of ripngd succeeded."
+else
+    echo " -> start of ripngd failed."
+    echo " -> $test: TEST-FAIL"
+    if zebra_status=0
+    then
+        exec_service_on_target zebra stop
+    fi
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if [ -f /var/run/quagga/ripngd.pid ]
+then
+    echo " -> get the pidfile of ripngd."
+else
+    echo " -> can't get the pidfile of ripngd."
+    echo " -> $test: TEST-FAIL"
+    if zebra_status=0
+    then
+        exec_service_on_target zebra stop
+    fi
+    if ripngd_status=0
+    then
+        exec_service_on_target ripngd stop
+    fi
+    restore_target
+    exit 
+fi
+
+exec_service_on_target zebra stop
+exec_service_on_target ripngd stop
+
+if [ ! -f /var/run/quagga/ripngd.pid ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if zebra_status=1
+then
+    exec_service_on_target zebra start
+fi
+if ripngd_status=1
+then
+    exec_service_on_target ripngd start
+fi
+
+restore_target
diff --git a/engine/tests/Functional.ripngd/tests/ripngd_ps.sh b/engine/tests/Functional.ripngd/tests/ripngd_ps.sh
new file mode 100644
index 0000000..4df002b
--- /dev/null
+++ b/engine/tests/Functional.ripngd/tests/ripngd_ps.sh
@@ -0,0 +1,115 @@
+#!/bin/sh
+
+#  In the target start ripngd, and confirm the process condition by command ps.
+
+test="ps"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+zebra_status=0
+ripngd_status=0
+if exec_service_on_target ripngd status | grep "running"
+then
+    ripngd_status=1
+fi
+if exec_service_on_target zebra status | grep "running"
+then
+    zebra_status=1
+fi
+
+exec_service_on_target ripngd stop
+exec_service_on_target zebra stop
+
+if [ -f /etc/quagga/zebra.conf ]
+then
+    mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf_bak
+fi
+cp data/zebra.conf /etc/quagga/zebra.conf
+
+if [ -f /etc/quagga/ripngd.conf ]
+then
+    mv /etc/quagga/ripngd.conf /etc/quagga/ripngd.conf_bak
+fi
+cp data/ripngd.conf /etc/quagga/ripngd.conf
+
+chown quagga:quagga /etc/quagga/*.conf
+
+restore_target() {
+    if [ -f /etc/quagga/zebra.conf_bak ]
+    then
+        mv /etc/quagga/zebra.conf_bak /etc/quagga/zebra.conf
+    else
+        rm /etc/quagga/zebra.conf
+    fi
+    if [ -f /etc/quagga/ripngd.conf_bak ]
+    then
+        mv /etc/quagga/ripngd.conf_bak /etc/quagga/ripngd.conf
+    else
+        rm /etc/quagga/ripngd.conf
+    fi
+}
+
+if exec_service_on_target zebra start
+then
+    echo " -> start of zebra succeeded."
+else
+    echo " -> start of zebra failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if exec_service_on_target ripngd start
+then
+    echo " -> start of ripngd succeeded."
+else
+    echo " -> start of ripngd failed."
+    echo " -> $test: TEST-FAIL"
+    if zebra_status=0
+    then
+        exec_service_on_target zebra stop
+    fi
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if ps aux | grep "[/]usr/sbin/ripngd"
+then
+    echo " -> get the process of ripngd."
+else
+    echo " -> can't get the process of ripngd."
+    echo " -> $test: TEST-FAIL"
+    if zebra_status=0
+    then
+        exec_service_on_target zebra stop
+    fi
+    if ripngd_status=0
+    then
+        exec_service_on_target ripngd stop
+    fi
+    restore_target
+    exit
+fi
+
+exec_service_on_target ripngd stop
+exec_service_on_target zebra stop
+
+if ps aux | grep "[/]usr/sbin/ripngd"
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
+if zebra_status=1
+then
+    exec_service_on_target zebra start
+fi
+if ripngd_status=1
+then
+    exec_service_on_target ripngd start
+fi
+restore_target
diff --git a/engine/tests/Functional.ripngd/tests/ripngd_syslog.sh b/engine/tests/Functional.ripngd/tests/ripngd_syslog.sh
new file mode 100644
index 0000000..aaf193a
--- /dev/null
+++ b/engine/tests/Functional.ripngd/tests/ripngd_syslog.sh
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+#  In the target start ripngd, and confirm the log file.
+
+test="syslog"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+logger_service=$(detect_logger_service)
+
+zebra_status=0
+ripngd_status=0
+if exec_service_on_target ripngd status | grep "running"
+then
+    ripngd_status=1
+fi
+if exec_service_on_target zebra status | grep "running"
+then
+    zebra_status=1
+fi
+
+exec_service_on_target ripngd stop
+exec_service_on_target zebra stop
+exec_service_on_target $logger_service stop
+
+if [ -f /var/log/syslog ]
+then
+    mv /var/log/syslog /var/log/syslog_bak
+fi
+
+if [ -f /etc/quagga/zebra.conf ]
+then
+    mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf_bak
+fi
+cp data/zebra.conf /etc/quagga/zebra.conf
+
+if [ -f /etc/quagga/ripngd.conf ]
+then
+    mv /etc/quagga/ripngd.conf /etc/quagga/ripngd.conf_bak
+fi
+cp data/ripngd.conf /etc/quagga/ripngd.conf
+
+chown quagga:quagga /etc/quagga/*.conf
+
+restore_target() {
+    if [ -f /etc/quagga/zebra.conf_bak ]
+    then
+        mv /etc/quagga/zebra.conf_bak /etc/quagga/zebra.conf
+    else
+        rm /etc/quagga/zebra.conf
+    fi
+    if [ -f /etc/quagga/ripngd.conf_bak ]
+    then
+        mv /etc/quagga/ripngd.conf_bak /etc/quagga/ripngd.conf
+    else
+        rm /etc/quagga/ripngd.conf
+    fi
+    if [ -f /var/log/syslog_bak ]
+    then
+        mv /var/log/syslog_bak /var/log/syslog
+    fi
+}
+
+exec_service_on_target $logger_service restart
+
+if exec_service_on_target zebra start
+then
+    echo " -> start of zebra succeeded."
+else
+    echo " -> start of zebra failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if exec_service_on_target ripngd start
+then
+    echo " -> start of ripngd succeeded."
+else
+    echo " -> start of ripngd failed."
+    echo " -> $test: TEST-FAIL"
+    if zebra_status=0
+    then
+        exec_service_on_target zebra stop
+    fi
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if tail /var/log/syslog | grep "ripngd"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> can't get the syslog of ripngd."
+    echo " -> $test: TEST-FAIL"
+fi
+
+if zebra_status=0
+then
+    exec_service_on_target zebra stop
+fi
+if ripngd_status=0
+then
+    exec_service_on_target ripngd stop
+fi
+restore_target
-- 
1.8.3.1





More information about the Fuego mailing list