Skip to contentSkip to conversation

Run tests forcely in separated netns

PATCH In review Vadim Kochan 2 participants 4 messages May 12, 2015 – May 21, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Run tests forcely in separated netns

From: Vadim Kochan <[email protected]>

Changed to run each test in separated network namespace by using 'unshare' tool from util-linux tools set, it allows to do not affect network setup on the host machine, 'unshare' tool is required by default.

Also added test which checks already fixed BUG related to adding default route.

Vadim Kochan (2):
tests: Run each test in network namespace
tests: Add test for 'ip route add default'

 testsuite/Makefile                           |  7 ++++++-
 testsuite/tests/ip/route/add_default_route.t | 12 ++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100755 testsuite/tests/ip/route/add_default_route.t
Signature · 1 line
2.3.1
#1 lore raw

PATCH 1/2 tests: Run each test in network namespace

From: Vadim Kochan <[email protected]>

Changed to forcely running each test in network namespace to do not affect on current network setup.

---
 testsuite/Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
testsuite/Makefile +6 -1
index a2c8a2d..4b945b0 100644
@@ -1,9 +1,11 @@
 ## -- Config --
 DEV := lo
-PREFIX := sudo -E
+PREFIX := sudo -E unshare -n
 RESULTS_DIR := results
 ## -- End Config --
 
+HAVE_UNSHARED_UTIL := $(shell unshare --version 2> /dev/null)
+
 rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
 
 TESTS := $(patsubst tests/%,%,$(call rwildcard,tests/,*.t))
@@ -38,6 +40,9 @@ distclean: clean
 	echo "Entering iproute2" && cd iproute2 && $(MAKE) distclean && cd ..;
 
 $(TESTS): clean
+ifeq (,$(HAVE_UNSHARED_UTIL))
+	$(error Please install util-linux tools to run tests in separated network namespace)
+endif
 	@mkdir -p $(RESULTS_DIR)
 	
 	@for d in $(TESTS_DIR); do \
Signature · 1 line
2.3.1
#2 lore raw

PATCH 2/2 tests: Add test for 'ip route add default'

In reply to Vadim Kochan

From: Vadim Kochan <[email protected]>

---
 testsuite/tests/ip/route/add_default_route.t | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100755 testsuite/tests/ip/route/add_default_route.t
testsuite/tests/ip/route/add_default_route.t new file +12 -0
new file mode 100755
index 0000000..2908528
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+source lib/generic.sh
+
+ts_log "[Testing add default route]"
+
+DEV=dummy0
+
+ts_ip "$0" "Add new interface $DEV" link add $DEV type dummy
+ts_ip "$0" "Set $DEV into UP state" link set up dev $DEV
+ts_ip "$0" "Add 1.1.1.1/24 addr on $DEV" addr add 1.1.1.1/24 dev $DEV
+ts_ip "$0" "Add default route via 1.1.1.1" route add default via 1.1.1.1
Signature · 1 line
2.3.1
#3 lore raw
In reply to Vadim Kochan
Quoted 8 lines · On Tue, 12 May 2015 17:40:14 +0300 Vadim Kochan <[email protected]> wrote:

From: Vadim Kochan <[email protected]>

Changed to run each test in separated network namespace by using 'unshare' tool from util-linux tools set, it allows to do not affect network setup on the host machine, 'unshare' tool is required by default.

Also added test which checks already fixed BUG related to adding default route.

Quoted 9 lines

Vadim Kochan (2):
tests: Run each test in network namespace
tests: Add test for 'ip route add default'

 testsuite/Makefile                           |  7 ++++++-
 testsuite/tests/ip/route/add_default_route.t | 12 ++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100755 testsuite/tests/ip/route/add_default_route.t

Applied thanks