tests: add tests for VRF executor
This commit is contained in:
parent
ba2ad348ff
commit
ba98705c8f
3 changed files with 39 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
handle_init() {
|
handle_init() {
|
||||||
${MOCK} /sbin/ip link $1 $IFACE type vrf table $IF_VRF_TABLE
|
${MOCK} /sbin/ip link $1 $IFACE type vrf table $IF_VRF_TABLE
|
||||||
${MOCK} /sbin/ip rule $1 iif $IFACE table $IF_VRF_TABLE
|
${MOCK} /sbin/ip rule $1 iif $IFACE table $IF_VRF_TABLE
|
||||||
|
@ -15,9 +17,11 @@ case "$PHASE" in
|
||||||
pre-up)
|
pre-up)
|
||||||
[ -n "$IF_VRF_TABLE" ] && handle_init "add"
|
[ -n "$IF_VRF_TABLE" ] && handle_init "add"
|
||||||
[ -n "$IF_VRF_MEMBER" ] && handle_member
|
[ -n "$IF_VRF_MEMBER" ] && handle_member
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
post-down)
|
post-down)
|
||||||
[ -n "$IF_VRF_TABLE" ] && handle_init "del"
|
[ -n "$IF_VRF_TABLE" ] && handle_init "del"
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -6,3 +6,4 @@ atf_test_program{name='link_test'}
|
||||||
atf_test_program{name='ipv6-ra_test'}
|
atf_test_program{name='ipv6-ra_test'}
|
||||||
atf_test_program{name='dhcp_test'}
|
atf_test_program{name='dhcp_test'}
|
||||||
atf_test_program{name='static_test'}
|
atf_test_program{name='static_test'}
|
||||||
|
atf_test_program{name='vrf_test'}
|
||||||
|
|
34
tests/linux/vrf_test
Executable file
34
tests/linux/vrf_test
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env atf-sh
|
||||||
|
|
||||||
|
. $(atf_get_srcdir)/../test_env.sh
|
||||||
|
EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/vrf"
|
||||||
|
|
||||||
|
tests_init \
|
||||||
|
leader_bringup \
|
||||||
|
leader_teardown \
|
||||||
|
member_bringup
|
||||||
|
|
||||||
|
leader_bringup_body() {
|
||||||
|
export MOCK=echo IFACE=vrf-red PHASE=pre-up IF_VRF_TABLE=1 IF_VRF_MEMBER=
|
||||||
|
atf_check -s exit:0 \
|
||||||
|
-o match:'ip link add vrf-red type vrf table 1' \
|
||||||
|
-o match:'ip rule add iif vrf-red table 1' \
|
||||||
|
-o match:'ip rule add oif vrf-red table 1' \
|
||||||
|
${EXECUTOR}
|
||||||
|
}
|
||||||
|
|
||||||
|
leader_teardown_body() {
|
||||||
|
export MOCK=echo IFACE=vrf-red PHASE=post-down IF_VRF_TABLE=1 IF_VRF_MEMBER=
|
||||||
|
atf_check -s exit:0 \
|
||||||
|
-o match:'ip link del vrf-red type vrf table 1' \
|
||||||
|
-o match:'ip rule del iif vrf-red table 1' \
|
||||||
|
-o match:'ip rule del oif vrf-red table 1' \
|
||||||
|
${EXECUTOR}
|
||||||
|
}
|
||||||
|
|
||||||
|
member_bringup_body() {
|
||||||
|
export MOCK=echo IFACE=eth0 PHASE=pre-up IF_VRF_MEMBER=vrf-red IF_VRF_TABLE=
|
||||||
|
atf_check -s exit:0 \
|
||||||
|
-o match:'ip link set eth0 master vrf-red' \
|
||||||
|
${EXECUTOR}
|
||||||
|
}
|
Loading…
Reference in a new issue