All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fuego] [PATCH] ospfd: add test cases for ospfd.
@ 2018-09-18  6:05 Zheng Ruoqin
  0 siblings, 0 replies; only message in thread
From: Zheng Ruoqin @ 2018-09-18  6:05 UTC (permalink / raw)
  To: fuego

Before using these cases, you need to set remote_ifeth value in your
board file, for example:

$ cat myboard.board
remote_ifeth="eth0"

Signed-off-by: Zheng Ruoqin <zhengrq.fnst@cn.fujitsu.com>
---
 engine/tests/Functional.ospfd/data/ospfd.conf   | 23 +++++++++
 engine/tests/Functional.ospfd/data/zebra.conf   | 22 +++++++++
 engine/tests/Functional.ospfd/fuego_test.sh     | 23 +++++++++
 engine/tests/Functional.ospfd/ospfd_test.sh     |  4 ++
 engine/tests/Functional.ospfd/parser.py         | 22 +++++++++
 engine/tests/Functional.ospfd/spec.json         |  6 +++
 engine/tests/Functional.ospfd/tests/ospfd_01.sh | 62 +++++++++++++++++++++++
 engine/tests/Functional.ospfd/tests/ospfd_02.sh | 66 +++++++++++++++++++++++++
 engine/tests/Functional.ospfd/tests/ospfd_03.sh | 63 +++++++++++++++++++++++
 engine/tests/Functional.ospfd/tests/ospfd_04.sh | 65 ++++++++++++++++++++++++
 10 files changed, 356 insertions(+)
 create mode 100644 engine/tests/Functional.ospfd/data/ospfd.conf
 create mode 100644 engine/tests/Functional.ospfd/data/zebra.conf
 create mode 100644 engine/tests/Functional.ospfd/fuego_test.sh
 create mode 100644 engine/tests/Functional.ospfd/ospfd_test.sh
 create mode 100644 engine/tests/Functional.ospfd/parser.py
 create mode 100644 engine/tests/Functional.ospfd/spec.json
 create mode 100644 engine/tests/Functional.ospfd/tests/ospfd_01.sh
 create mode 100644 engine/tests/Functional.ospfd/tests/ospfd_02.sh
 create mode 100644 engine/tests/Functional.ospfd/tests/ospfd_03.sh
 create mode 100644 engine/tests/Functional.ospfd/tests/ospfd_04.sh

diff --git a/engine/tests/Functional.ospfd/data/ospfd.conf b/engine/tests/Functional.ospfd/data/ospfd.conf
new file mode 100644
index 0000000..ea0f155
--- /dev/null
+++ b/engine/tests/Functional.ospfd/data/ospfd.conf
@@ -0,0 +1,23 @@
+!
+! Zebra configuration saved from vty
+!   2000/01/01 02:22:47
+!
+hostname ospfd
+password zebra
+log file /var/log/quagga/ospfd.log
+log syslog informational
+!
+!
+!
+interface bmap
+!
+interface eth0
+!
+interface eth1
+!
+interface eth2
+!
+interface lo
+!
+line vty
+!
diff --git a/engine/tests/Functional.ospfd/data/zebra.conf b/engine/tests/Functional.ospfd/data/zebra.conf
new file mode 100644
index 0000000..7c8c216
--- /dev/null
+++ b/engine/tests/Functional.ospfd/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 192.168.246.0/24 eth0 reject
+!
+!ipv6 forwarding
+!
+line vty
+!
diff --git a/engine/tests/Functional.ospfd/fuego_test.sh b/engine/tests/Functional.ospfd/fuego_test.sh
new file mode 100644
index 0000000..3ec47ef
--- /dev/null
+++ b/engine/tests/Functional.ospfd/fuego_test.sh
@@ -0,0 +1,23 @@
+function test_pre_check {
+    is_on_target_path ospfd PROGRAM_OSPFD
+    assert_define PROGRAM_OSPFD "Missing 'ospfd' program on target board"
+    is_on_target_path zebra PROGRAM_ZEBRA
+    assert_define PROGRAM_ZEBRA "Missing 'zebra' program on target board"
+}
+
+function test_deploy {
+    put $TEST_HOME/ospfd_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/
+}
+
+function test_run {
+    report "sed -i 's/!interface xxx/interface $remote_ifeth/' $BOARD_TESTDIR/fuego.$TESTDIR/data/zebra.conf"
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR; \
+        sh ospfd_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.ospfd/ospfd_test.sh b/engine/tests/Functional.ospfd/ospfd_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.ospfd/ospfd_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.ospfd/parser.py b/engine/tests/Functional.ospfd/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.ospfd/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.ospfd/spec.json b/engine/tests/Functional.ospfd/spec.json
new file mode 100644
index 0000000..8800b6d
--- /dev/null
+++ b/engine/tests/Functional.ospfd/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.ospfd",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/engine/tests/Functional.ospfd/tests/ospfd_01.sh b/engine/tests/Functional.ospfd/tests/ospfd_01.sh
new file mode 100644
index 0000000..25c4f46
--- /dev/null
+++ b/engine/tests/Functional.ospfd/tests/ospfd_01.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+#  In the target start ospfd and zebra, then confirm the process condition by command ps.
+#  check the keyword "quagga/ospfd".
+
+test="ospfd01"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target ospfd stop
+exec_service_on_target zebra stop
+
+#Backup the config file
+mv /etc/quagga/ospfd.conf /etc/quagga/ospfd.conf.bck
+mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf.bck
+
+cp data/ospfd.conf /etc/quagga/ospfd.conf
+cp data/zebra.conf /etc/quagga/zebra.conf
+chown quagga:quagga /etc/quagga/*.conf
+
+if exec_service_on_target zebra start
+then
+    echo " -> start of zebra succeeded."
+else
+    echo " -> start of zebra failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if exec_service_on_target ospfd start
+then
+    echo " -> start of ospfd succeeded."
+else
+    echo " -> start of ospfd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if ps -N a | grep ospfd | grep ".*quagga/ospfd.*" | grep -v grep
+then
+    echo " -> get the pid of ospfd."
+else
+    echo " -> can't get the pid of ospfd."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+exec_service_on_target ospfd stop
+exec_service_on_target zebra stop
+
+if ps -N a | grep ospfd | grep ".*quagga/ospfd.*" | grep -v grep
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
+
+#Restore the config file
+mv /etc/quagga/ospfd.conf.bck /etc/quagga/ospfd.conf
+mv /etc/quagga/zebra.conf.bck /etc/quagga/zebra.conf
diff --git a/engine/tests/Functional.ospfd/tests/ospfd_02.sh b/engine/tests/Functional.ospfd/tests/ospfd_02.sh
new file mode 100644
index 0000000..df423b2
--- /dev/null
+++ b/engine/tests/Functional.ospfd/tests/ospfd_02.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+#  In the target start ospfd and zebra.
+#  At the same time, start syslog-ng and check the keyword "ospfd" in syslog.
+
+test="ospfd02"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target ospfd stop
+exec_service_on_target zebra stop
+exec_service_on_target syslog-ng stop
+
+#Backup the config file
+mv /etc/quagga/ospfd.conf /etc/quagga/ospfd.conf.bck
+mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf.bck
+
+cp data/ospfd.conf /etc/quagga/ospfd.conf
+cp data/zebra.conf /etc/quagga/zebra.conf
+chown quagga:quagga /etc/quagga/*.conf
+
+if exec_service_on_target syslog-ng restart
+then
+    echo " -> restart of syslog-ng succeeded."
+else
+    echo " -> restart of syslog-ng failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if exec_service_on_target zebra start
+then
+    echo " -> start of zebra succeeded."
+else
+    echo " -> start of zebra failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if exec_service_on_target ospfd start
+then
+    echo " -> start of ospfd succeeded."
+else
+    echo " -> start of ospfd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if tail -n 20 /var/log/syslog | grep ".*OSPF.*"
+then
+    echo " -> get the syslog of ospfd."
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> can't get the syslog of ospfd."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+exec_service_on_target ospfd stop
+exec_service_on_target zebra stop
+
+#Restore the config file
+mv /etc/quagga/ospfd.conf.bck /etc/quagga/ospfd.conf
+mv /etc/quagga/zebra.conf.bck /etc/quagga/zebra.conf
diff --git a/engine/tests/Functional.ospfd/tests/ospfd_03.sh b/engine/tests/Functional.ospfd/tests/ospfd_03.sh
new file mode 100644
index 0000000..c58a481
--- /dev/null
+++ b/engine/tests/Functional.ospfd/tests/ospfd_03.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+#  In the target start ospfd and zebra, then confirm the process condition by /var/run/quagga/ospfd.pid file.
+#  check the keyword "ospfd".
+
+test="ospfd03"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target ospfd stop
+exec_service_on_target zebra stop
+rm -f /var/run/quagga/ospfd.pid
+
+#Backup the config file
+mv /etc/quagga/ospfd.conf /etc/quagga/ospfd.conf.bck
+mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf.bck
+
+cp data/ospfd.conf /etc/quagga/ospfd.conf
+cp data/zebra.conf /etc/quagga/zebra.conf
+chown quagga:quagga /etc/quagga/*.conf
+
+if exec_service_on_target zebra start
+then
+    echo " -> start of zebra succeeded."
+else
+    echo " -> start of zebra failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if exec_service_on_target ospfd start
+then
+    echo " -> start of ospfd succeeded."
+else
+    echo " -> start of ospfd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if ls /var/run/quagga/ospfd.pid
+then
+    echo " -> get the pid of ospfd."
+else
+    echo " -> can't get the pid of ospfd."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+exec_service_on_target ospfd stop
+exec_service_on_target zebra stop
+
+if ls /var/run/quagga/ospfd.pid
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
+
+#Restore the config file
+mv /etc/quagga/ospfd.conf.bck /etc/quagga/ospfd.conf
+mv /etc/quagga/zebra.conf.bck /etc/quagga/zebra.conf
diff --git a/engine/tests/Functional.ospfd/tests/ospfd_04.sh b/engine/tests/Functional.ospfd/tests/ospfd_04.sh
new file mode 100644
index 0000000..eaa2d1d
--- /dev/null
+++ b/engine/tests/Functional.ospfd/tests/ospfd_04.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+#  In the target start ospfd and zebra, then confirm the log file.
+#  check the /var/log/quagga/ospfd.log file.
+
+test="ospfd04"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target ospfd stop
+exec_service_on_target zebra stop
+if [ -f /var/log/quagga/ospfd.log ]
+then
+    mv /var/log/quagga/ospfd.log /var/log/quagga/ospfd.log.bck
+fi
+
+#Backup the config file
+mv /etc/quagga/ospfd.conf /etc/quagga/ospfd.conf.bck
+mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf.bck
+
+cp data/ospfd.conf /etc/quagga/ospfd.conf
+cp data/zebra.conf /etc/quagga/zebra.conf
+chown quagga:quagga /etc/quagga/*.conf
+
+if exec_service_on_target zebra start
+then
+    echo " -> start of zebra succeeded."
+else
+    echo " -> start of zebra failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if exec_service_on_target ospfd start
+then
+    echo " -> start of ospfd succeeded."
+else
+    echo " -> start of ospfd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if ls /var/log/quagga/ospfd.log
+then
+    echo " -> get log file of ospfd."
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> can't get log file of ospfd."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+exec_service_on_target ospfd stop
+exec_service_on_target zebra stop
+
+#Restore the config file
+mv /etc/quagga/ospfd.conf.bck /etc/quagga/ospfd.conf
+mv /etc/quagga/zebra.conf.bck /etc/quagga/zebra.conf
+
+if [ -f /var/log/quagga/ospfd.log.bck ]
+then
+    mv /var/log/quagga/ospfd.log.bck /var/log/quagga/ospfd.log
+fi
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-09-18  6:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-18  6:05 [Fuego] [PATCH] ospfd: add test cases for ospfd Zheng Ruoqin

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.