[Fuego] [PATCH] Add test cases of service radvd.
Wang Mingyu
wangmy at cn.fujitsu.com
Wed Nov 14 09:30:21 UTC 2018
This test set is used to check if there is radvd group in the target,
and test the logfile and process status of service radvd.
Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
engine/tests/Functional.radvd/data/radvd.conf | 96 ++++++++++++++++++++++
engine/tests/Functional.radvd/fuego_test.sh | 20 +++++
engine/tests/Functional.radvd/parser.py | 22 +++++
engine/tests/Functional.radvd/radvd_test.sh | 4 +
engine/tests/Functional.radvd/spec.json | 7 ++
engine/tests/Functional.radvd/tests/radvd_group.sh | 13 +++
.../tests/Functional.radvd/tests/radvd_logfile.sh | 64 +++++++++++++++
engine/tests/Functional.radvd/tests/radvd_ps.sh | 54 ++++++++++++
.../tests/Functional.radvd/tests/radvd_tcpdump.sh | 38 +++++++++
9 files changed, 318 insertions(+)
create mode 100644 engine/tests/Functional.radvd/data/radvd.conf
create mode 100644 engine/tests/Functional.radvd/fuego_test.sh
create mode 100644 engine/tests/Functional.radvd/parser.py
create mode 100755 engine/tests/Functional.radvd/radvd_test.sh
create mode 100644 engine/tests/Functional.radvd/spec.json
create mode 100644 engine/tests/Functional.radvd/tests/radvd_group.sh
create mode 100644 engine/tests/Functional.radvd/tests/radvd_logfile.sh
create mode 100644 engine/tests/Functional.radvd/tests/radvd_ps.sh
create mode 100644 engine/tests/Functional.radvd/tests/radvd_tcpdump.sh
diff --git a/engine/tests/Functional.radvd/data/radvd.conf b/engine/tests/Functional.radvd/data/radvd.conf
new file mode 100644
index 0000000..fdf8532
--- /dev/null
+++ b/engine/tests/Functional.radvd/data/radvd.conf
@@ -0,0 +1,96 @@
+interface eth0
+{
+ AdvSendAdvert on;
+
+# This may be needed on some interfaces which are not active when
+# radvd starts, but becomoe available later on, and are activated by sending a
+# HUP signal to radvd; see man page for details.
+
+ # IgnoreIfMissing on;
+
+#
+# These settings cause advertisements to be sent every 3-10 seconds. This
+# range is good for 6to4 with a dynamic IPv4 address, but can be greatly
+# increased when not using 6to4 prefixes.
+#
+
+ MinRtrAdvInterval 3;
+ MaxRtrAdvInterval 10;
+
+#
+# You can use AdvDefaultPreference setting to advertise the preference of
+# the router for the purposes of default router determination.
+# NOTE: This feature is still being specified and is not widely supported!
+#
+ AdvDefaultPreference low;
+
+#
+# Disable Mobile IPv6 support
+#
+ AdvHomeAgentFlag off;
+
+#
+# example of a standard prefix
+#
+#prefix 3ffe:0302:0011:0002::/64
+ prefix 2001:02c0:0418:0001::/64
+ {
+ AdvOnLink on;
+ AdvAutonomous on;
+ AdvRouterAddr off;
+ };
+
+#
+# example of a more specific route
+# NOTE: This feature is still being specified and is not widely supported!
+#
+ route 2001:db0:fff::/48
+ {
+ AdvRoutePreference high;
+ AdvRouteLifetime 3600;
+ };
+
+#
+# example of a 6to4 prefix
+#
+# Note that the first 48 bits are specified here as zeros. These will be
+# replaced with the appropriate 6to4 address when radvd starts or is
+# reconfigured. Be sure that the SLA ID (1234 in this case) is specified
+# here!
+#
+# prefix 0:0:0:1234::/64
+# {
+# AdvOnLink on;
+# AdvAutonomous on;
+# AdvRouterAddr off;
+#
+#
+# This setting causes radvd to replace the first 48 bits of the prefix
+# with the 6to4 address generated from the specified interface. For example,
+# if the address of ppp0 is 192.0.2.25 when radvd configures itself, this
+# prefix will be advertised as 2002:C000:0219:1234::/64.
+#
+# If ppp0 is not available at configuration time, this prefix will not be
+# advertised, but other prefixes listed in the configuration will be
+# advertised as usual.
+#
+# When using the Base6to4Interface option, make sure radvd receives a
+# SIGHUP every time the ppp0 interface goes up, down, or is assigned a
+# new IPv4 address. The SIGHUP will cause radvd to recognize that the
+# ppp0 interface has changed and will adjust the advertisements
+# accordingly.
+#
+
+# Base6to4Interface ppp0;
+
+#
+# If the IP address of ppp0 is assigned dynamically, be sure to set the
+# lifetimes for this prefix to be small. Otherwise, hosts on your network
+# may continue to use a prefix that no longer corresponds to the address
+# on ppp0!
+#
+# AdvPreferredLifetime 120;
+# AdvValidLifetime 300;
+# };
+
+};
diff --git a/engine/tests/Functional.radvd/fuego_test.sh b/engine/tests/Functional.radvd/fuego_test.sh
new file mode 100644
index 0000000..9df2819
--- /dev/null
+++ b/engine/tests/Functional.radvd/fuego_test.sh
@@ -0,0 +1,20 @@
+function test_pre_check {
+ assert_has_program radvd
+ assert_has_program tcpdump
+}
+
+function test_deploy {
+ put $TEST_HOME/radvd_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 "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+ ./radvd_test.sh"
+}
+
+function test_processing {
+ log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.radvd/parser.py b/engine/tests/Functional.radvd/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.radvd/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.radvd/radvd_test.sh b/engine/tests/Functional.radvd/radvd_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.radvd/radvd_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+ sh $i
+done
diff --git a/engine/tests/Functional.radvd/spec.json b/engine/tests/Functional.radvd/spec.json
new file mode 100644
index 0000000..2302bd7
--- /dev/null
+++ b/engine/tests/Functional.radvd/spec.json
@@ -0,0 +1,7 @@
+{
+ "testName": "Functional.radvd",
+ "specs": {
+ "default": {}
+ }
+}
+
diff --git a/engine/tests/Functional.radvd/tests/radvd_group.sh b/engine/tests/Functional.radvd/tests/radvd_group.sh
new file mode 100644
index 0000000..9f5b8b9
--- /dev/null
+++ b/engine/tests/Functional.radvd/tests/radvd_group.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Verify that the radvd group exists on the target.
+
+test="group"
+
+if grep radvd /etc/group
+then
+ echo " -> $test: TEST-PASS"
+else
+ echo " -> there is no radvd group onthe target."
+ echo " -> $test: TEST-FAIL"
+fi
diff --git a/engine/tests/Functional.radvd/tests/radvd_logfile.sh b/engine/tests/Functional.radvd/tests/radvd_logfile.sh
new file mode 100644
index 0000000..85d74af
--- /dev/null
+++ b/engine/tests/Functional.radvd/tests/radvd_logfile.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+# In the target to start radvd radvd, to confirm the acquisition of the log.
+# check the keyword "radvd".
+
+test="logfile"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+logger_service=$(detect_logger_service)
+
+exec_service_on_target radvd stop
+
+echo 0 > /proc/sys/net/ipv6/conf/all/accept_ra
+if [ -f /etc/radvd.conf ]
+then
+ mv /etc/radvd.conf /etc/radvd.conf_bak
+fi
+cp data/radvd.conf /etc/radvd.conf
+
+exec_service_on_target $logger_service stop
+if [ -f /var/log/syslog ]
+then
+ mv /var/log/syslog /var/log/syslog_bak
+fi
+
+restore_target() {
+ if [ -f /etc/radvd.conf_bak ]
+ then
+ mv /etc/radvd.conf_bak /etc/radvd.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 radvd start
+then
+ echo " -> start of radvd succeeded."
+else
+ echo " -> start of radvd failed."
+ echo " -> $test: TEST-FAIL"
+ exec_service_on_target radvd stop
+ exec_service_on_target $logger_service stop
+ restore_target
+ exit
+fi
+
+sleep 5
+
+if cat /var/log/syslog | grep "radvd"
+then
+ echo " -> $test: TEST-PASS"
+else
+ echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target radvd stop
+exec_service_on_target $logger_service stop
+echo 1 > /proc/sys/net/ipv6/conf/all/accept_ra
+restore_target
diff --git a/engine/tests/Functional.radvd/tests/radvd_ps.sh b/engine/tests/Functional.radvd/tests/radvd_ps.sh
new file mode 100644
index 0000000..f144ca8
--- /dev/null
+++ b/engine/tests/Functional.radvd/tests/radvd_ps.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# In the target start radvd, and confirm the process condition by command ps.
+# check the keyword "radvd".
+
+test="ps"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target radvd stop
+
+echo 0 > /proc/sys/net/ipv6/conf/all/accept_ra
+
+mv /etc/radvd.conf /etc/radvd.conf_bak
+cp data/radvd.conf /etc/radvd.conf
+
+if exec_service_on_target radvd start
+then
+ echo " -> start of radvd succeeded."
+else
+ echo " -> start of radvd failed."
+ echo " -> $test: TEST-FAIL"
+ exit
+fi
+
+if ps -ax -ocommand | grep "[/]usr/sbin/radvd -n -u radvd"
+then
+ echo " -> get the pid of radvd."
+else
+ echo " -> can't get the pid of radvd."
+ echo " -> $test: TEST-FAIL"
+ exit
+fi
+
+if exec_service_on_target radvd stop
+then
+ echo " -> stop of radvd succeeded."
+else
+ echo " -> stop of radvd failed."
+ echo " -> $test: TEST-FAIL"
+ exit
+fi
+
+if ps -ax -ocommand | grep "[/]usr/sbin/radvd -n -u radvd"
+then
+ echo " -> $test: TEST-FAIL"
+else
+ echo " -> $test: TEST-PASS"
+fi
+
+mv /etc/radvd.conf_bak /etc/radvd.conf
+echo 1 > /proc/sys/net/ipv6/conf/all/accept_ra
diff --git a/engine/tests/Functional.radvd/tests/radvd_tcpdump.sh b/engine/tests/Functional.radvd/tests/radvd_tcpdump.sh
new file mode 100644
index 0000000..7ebe23d
--- /dev/null
+++ b/engine/tests/Functional.radvd/tests/radvd_tcpdump.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Start radvd on the target and verify the sending packet of icmp6 by radvd.
+# It checks using tcpdump in the host.
+
+test="tcpdump"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target radvd stop
+
+echo 0 > /proc/sys/net/ipv6/conf/all/accept_ra
+mv /etc/radvd.conf /etc/radvd.conf_bak
+cp data/radvd.conf /etc/radvd.conf
+
+if exec_service_on_target radvd start
+then
+ echo " -> start of radvd succeeded."
+else
+ echo " -> start of radvd failed."
+ echo " -> $test: TEST-FAIL"
+ exit
+fi
+
+if tcpdump -ex -i $test_host_ifeth ip6 &
+then
+ echo " -> $test: TEST-PASS"
+else
+ echo " -> $test: TEST-FAIL"
+fi;
+
+killall tcpdump
+
+exec_service_on_target radvd stop
+mv /etc/radvd.conf_bak /etc/radvd.conf
+echo 1 > /proc/sys/net/ipv6/conf/all/accept_ra
--
1.8.3.1
More information about the Fuego
mailing list