[Fuego] [PATCH] [PATCH v2] ospf6d: add test cases for ospf6d.

Tim.Bird at sony.com Tim.Bird at sony.com
Fri Nov 16 00:46:14 UTC 2018


Applied, with minor changes.  Thanks.
 -- Tim


> -----Original Message-----
> From: Zheng Ruoqin
> 
> ospf6d is a routing component that works with the Quagga routing engine.
> 
> Signed-off-by: Zheng Ruoqin <zhengrq.fnst at cn.fujitsu.com>
> ---
>  engine/tests/Functional.ospf6d/data/ospf6d.conf    | 55
> +++++++++++++++++
>  engine/tests/Functional.ospf6d/data/zebra.conf     | 22 +++++++
>  engine/tests/Functional.ospf6d/fuego_test.sh       | 23 +++++++
>  engine/tests/Functional.ospf6d/ospf6d_test.sh      |  4 ++
>  engine/tests/Functional.ospf6d/parser.py           | 22 +++++++
>  engine/tests/Functional.ospf6d/spec.json           |  6 ++
>  engine/tests/Functional.ospf6d/test.yaml           | 24 ++++++++
>  .../Functional.ospf6d/tests/ospf6d_logfile.sh      | 72
> ++++++++++++++++++++++
>  .../Functional.ospf6d/tests/ospf6d_pidfile.sh      | 63
> +++++++++++++++++++
>  engine/tests/Functional.ospf6d/tests/ospf6d_ps.sh  | 62
> +++++++++++++++++++
>  .../tests/Functional.ospf6d/tests/ospf6d_syslog.sh | 71
> +++++++++++++++++++++
>  11 files changed, 424 insertions(+)
>  create mode 100644 engine/tests/Functional.ospf6d/data/ospf6d.conf
>  create mode 100644 engine/tests/Functional.ospf6d/data/zebra.conf
>  create mode 100644 engine/tests/Functional.ospf6d/fuego_test.sh
>  create mode 100644 engine/tests/Functional.ospf6d/ospf6d_test.sh
>  create mode 100644 engine/tests/Functional.ospf6d/parser.py
>  create mode 100644 engine/tests/Functional.ospf6d/spec.json
>  create mode 100644 engine/tests/Functional.ospf6d/test.yaml
>  create mode 100644 engine/tests/Functional.ospf6d/tests/ospf6d_logfile.sh
>  create mode 100644 engine/tests/Functional.ospf6d/tests/ospf6d_pidfile.sh
>  create mode 100644 engine/tests/Functional.ospf6d/tests/ospf6d_ps.sh
>  create mode 100644 engine/tests/Functional.ospf6d/tests/ospf6d_syslog.sh
> 
> diff --git a/engine/tests/Functional.ospf6d/data/ospf6d.conf
> b/engine/tests/Functional.ospf6d/data/ospf6d.conf
> new file mode 100644
> index 0000000..7a292ce
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/data/ospf6d.conf
> @@ -0,0 +1,55 @@
> +!
> +! Zebra configuration saved from vty
> +!   2003/11/28 00:49:49
> +!
> +hostname ospf6d at plant
> +password zebra
> +
> +log file /var/log/quagga/ospf6d.log
> +log syslog informational
> +!log stdout
> +service advanced-vty
> +!
> +debug ospf6 neighbor state
> +!
> +interface fxp0
> + ipv6 ospf6 cost 1
> + ipv6 ospf6 hello-interval 10
> + ipv6 ospf6 dead-interval 40
> + ipv6 ospf6 retransmit-interval 5
> + ipv6 ospf6 priority 0
> + ipv6 ospf6 transmit-delay 1
> + ipv6 ospf6 instance-id 0
> +!
> +interface lo0
> + ipv6 ospf6 cost 1
> + ipv6 ospf6 hello-interval 10
> + ipv6 ospf6 dead-interval 40
> + ipv6 ospf6 retransmit-interval 5
> + ipv6 ospf6 priority 1
> + ipv6 ospf6 transmit-delay 1
> + ipv6 ospf6 instance-id 0
> +!
> +router ospf6
> + router-id 255.1.1.1
> + redistribute static route-map static-ospf6
> + interface fxp0 area 0.0.0.0
> +!
> +access-list access4 permit 127.0.0.1/32
> +!
> +ipv6 access-list access6 permit 3ffe:501::/32
> +ipv6 access-list access6 permit 2001:200::/48
> +ipv6 access-list access6 permit ::1/128
> +!
> +ipv6 prefix-list test-prefix seq 1000 deny any
> +!
> +route-map static-ospf6 permit 10
> + match ipv6 address prefix-list test-prefix
> + set metric-type type-2
> + set metric 2000
> +!
> +line vty
> + access-class access4
> + ipv6 access-class access6
> + exec-timeout 0 0
> +!
> diff --git a/engine/tests/Functional.ospf6d/data/zebra.conf
> b/engine/tests/Functional.ospf6d/data/zebra.conf
> new file mode 100644
> index 0000000..7c8c216
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/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.ospf6d/fuego_test.sh
> b/engine/tests/Functional.ospf6d/fuego_test.sh
> new file mode 100644
> index 0000000..01ce0bb
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/fuego_test.sh
> @@ -0,0 +1,23 @@
> +function test_pre_check {
> +    is_on_target_path ospf6d PROGRAM_OSPF6D
> +    assert_define PROGRAM_OSPF6D "Missing 'ospf6d' program on target
> board"
> +    is_on_target_path zebra PROGRAM_ZEBRA
> +    assert_define PROGRAM_ZEBRA "Missing 'zebra' program on target
> board"
> +}

I've changed these to assert_has_program calls.

> +
> +function test_deploy {
> +    put $TEST_HOME/ospf6d_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"
> +}
> +
> +function test_run {
> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR; \
> +        sh ospf6d_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/engine/tests/Functional.ospf6d/ospf6d_test.sh
> b/engine/tests/Functional.ospf6d/ospf6d_test.sh
> new file mode 100644
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/ospf6d_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> diff --git a/engine/tests/Functional.ospf6d/parser.py
> b/engine/tests/Functional.ospf6d/parser.py
> new file mode 100644
> index 0000000..d85abd7
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/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.ospf6d/spec.json
> b/engine/tests/Functional.ospf6d/spec.json
> new file mode 100644
> index 0000000..9e4f509
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/spec.json
> @@ -0,0 +1,6 @@
> +{
> +    "testName": "Functional.ospf6d",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> diff --git a/engine/tests/Functional.ospf6d/test.yaml
> b/engine/tests/Functional.ospf6d/test.yaml
> new file mode 100644
> index 0000000..0b757bd
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/test.yaml
> @@ -0,0 +1,24 @@
> +fuego_package_version: 1
> +name: Functional.ospfd
> +description: |
> +      ospf6d is a routing component that works with the Quagga routing
> engine.
> +      This is a simple test to examine whether ospf6d can start successfully
> +      and obtain the log. And zebra is the pre-service of ospfd.
> +license: BSD-3-Clause
> +author: Zheng Ruoqin <zhengrq.fnst at cn.fujitsu.com>
> +maintainer: Tim Bird <tim.bird at sony.com>
> +version: 1.00
> +fuego_release: 1
> +type: Functional
> +tags: ['router']
> +params:
> +    - IFETH:
> +        description: eth interface in your target board, defined in board file
> +        example: eth0
> +data_files:
> + - ospf6d_test.sh
> + - data
> + - fuego_test.sh
> + - parser.py
> + - spec.json
> + - tests
> diff --git a/engine/tests/Functional.ospf6d/tests/ospf6d_logfile.sh
> b/engine/tests/Functional.ospf6d/tests/ospf6d_logfile.sh
> new file mode 100644
> index 0000000..a9c7c17
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/tests/ospf6d_logfile.sh
> @@ -0,0 +1,72 @@
> +#!/bin/sh
> +
> +#  In the target start ospf6d and zebra, then confirm the log file.
> +#  check the /var/log/quagga/ospf6d.log file.
> +
> +test="logfile"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +exec_service_on_target ospf6d 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/ospf6d.log ]
> +then
> +   mv /var/log/quagga/ospf6d.log /var/log/quagga/ospf6d.log.bck
> +fi
> +
> +#Backup the config file
> +mv /etc/quagga/ospf6d.conf /etc/quagga/ospf6d.conf.bck
> +mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf.bck
> +
> +cp data/ospf6d.conf /etc/quagga/ospf6d.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 ospf6d start
> +then
> +    echo " -> start of ospf6d succeeded."
> +else
> +    echo " -> start of ospf6d failed."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +if ls /var/log/quagga/ospf6d.log
> +then
> +    echo " -> get log file of ospf6d."
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> can't get log file of ospf6d."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +exec_service_on_target ospf6d stop
> +exec_service_on_target zebra stop
> +
> +#Restore the config file
> +mv /etc/quagga/ospf6d.conf.bck /etc/quagga/ospf6d.conf
> +mv /etc/quagga/zebra.conf.bck /etc/quagga/zebra.conf
> +
> +if [ -f /var/log/quagga/ospf6d.log.bck ]
> +then
> +    mv /var/log/quagga/ospf6d.log.bck /var/log/quagga/ospf6d.log
> +fi
> diff --git a/engine/tests/Functional.ospf6d/tests/ospf6d_pidfile.sh
> b/engine/tests/Functional.ospf6d/tests/ospf6d_pidfile.sh
> new file mode 100644
> index 0000000..87319fd
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/tests/ospf6d_pidfile.sh
> @@ -0,0 +1,63 @@
> +#!/bin/sh
> +
> +#  In the target start ospf6d and zebra, then confirm the process condition
> by /var/run/quagga/ospf6d.pid file.
> +#  check the keyword "ospf6d".
> +
> +test="pidfile"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +exec_service_on_target ospf6d stop
> +exec_service_on_target zebra stop
> +rm -f /var/run/quagga/ospf6d.pid
> +
> +#Backup the config file
> +mv /etc/quagga/ospf6d.conf /etc/quagga/ospf6d.conf.bck
> +mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf.bck
> +
> +cp data/ospf6d.conf /etc/quagga/ospf6d.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 ospf6d start
> +then
> +    echo " -> start of ospf6d succeeded."
> +else
> +    echo " -> start of ospf6d failed."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +if ls /var/run/quagga/ospf6d.pid
> +then
> +    echo " -> get the pid of ospf6d."
> +else
> +    echo " -> can't get the pid of ospf6d."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +exec_service_on_target ospf6d stop
> +exec_service_on_target zebra stop
> +
> +if ls /var/run/quagga/ospf6d.pid
> +then
> +    echo " -> $test: TEST-FAIL"
> +else
> +    echo " -> $test: TEST-PASS"
> +fi
> +
> +#Restore the config file
> +mv /etc/quagga/ospf6d.conf.bck /etc/quagga/ospf6d.conf
> +mv /etc/quagga/zebra.conf.bck /etc/quagga/zebra.conf
> diff --git a/engine/tests/Functional.ospf6d/tests/ospf6d_ps.sh
> b/engine/tests/Functional.ospf6d/tests/ospf6d_ps.sh
> new file mode 100644
> index 0000000..8575a08
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/tests/ospf6d_ps.sh
> @@ -0,0 +1,62 @@
> +#!/bin/sh
> +
> +#  In the target start ospf6d and zebra, then confirm the process condition
> by command ps.
> +#  check the keyword "quagga/ospf6d".
> +
> +test="ps"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +exec_service_on_target ospf6d stop
> +exec_service_on_target zebra stop
> +
> +#Backup the config file
> +mv /etc/quagga/ospf6d.conf /etc/quagga/ospf6d.conf.bck
> +mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf.bck
> +
> +cp data/ospf6d.conf /etc/quagga/ospf6d.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 ospf6d start
> +then
> +    echo " -> start of ospf6d succeeded."
> +else
> +    echo " -> start of ospf6d failed."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +if ps -N a | grep "quagga/[o]spf6d"
> +then
> +    echo " -> get the pid of ospf6d."
> +else
> +    echo " -> can't get the pid of ospf6d."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +exec_service_on_target ospf6d stop
> +exec_service_on_target zebra stop
> +
> +if ps -N a | grep "quagga/[o]spf6d"
> +then
> +    echo " -> $test: TEST-FAIL"
> +else
> +    echo " -> $test: TEST-PASS"
> +fi
> +
> +#Restore the config file
> +mv /etc/quagga/ospf6d.conf.bck /etc/quagga/ospf6d.conf
> +mv /etc/quagga/zebra.conf.bck /etc/quagga/zebra.conf
> diff --git a/engine/tests/Functional.ospf6d/tests/ospf6d_syslog.sh
> b/engine/tests/Functional.ospf6d/tests/ospf6d_syslog.sh
> new file mode 100644
> index 0000000..aa5a0ba
> --- /dev/null
> +++ b/engine/tests/Functional.ospf6d/tests/ospf6d_syslog.sh
> @@ -0,0 +1,71 @@
> +#!/bin/sh
> +
> +#  In the target start ospf6d and zebra.
> +#  At the same time, start syslog-ng and check the keyword "ospf6d" in
> syslog.
> +
> +test="syslog"
> +
> +. ./fuego_board_function_lib.sh
> +
> +set_init_manager
> +
> +exec_service_on_target ospf6d stop
> +exec_service_on_target zebra stop
> +exec_service_on_target syslog-ng stop
> +
> +rm -f /var/run/quagga/ospf6d.pid
> +#Backup the config file
> +mv /etc/quagga/ospf6d.conf /etc/quagga/ospf6d.conf.bck
> +mv /etc/quagga/zebra.conf /etc/quagga/zebra.conf.bck
> +#Backup the config file
> +mv /var/log/syslog /var/log/syslog.bck
> +
> +cp data/ospf6d.conf /etc/quagga/ospf6d.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 ospf6d start
> +then
> +    echo " -> start of ospf6d succeeded."
> +else
> +    echo " -> start of ospf6d failed."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +if cat /var/log/syslog | grep "ospf6d"
> +then
> +    echo " -> get the syslog of ospf6d."
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> can't get the syslog of ospf6d."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +exec_service_on_target ospf6d stop
> +exec_service_on_target zebra stop
> +
> +#Restore the config file
> +mv /etc/quagga/ospf6d.conf.bck /etc/quagga/ospf6d.conf
> +mv /etc/quagga/zebra.conf.bck /etc/quagga/zebra.conf
> +#Restore the config file
> +mv /var/log/syslog.bck /var/log/syslog
> --
> 1.8.3.1
> 
> 
> 
> _______________________________________________
> Fuego mailing list
> Fuego at lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego


More information about the Fuego mailing list