File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -707,7 +707,16 @@ def test_iproute2_tunnels(host):
707707 assert host .iproute2 .exists
708708
709709 tunnels = host .iproute2 .tunnels ()
710- assert len (tunnels ) == 0
710+ assert len (tunnels ) > 0
711+
712+ cmd = host .run ("ip tunnel add test mode ipip remote 127.0.0.1" )
713+ assert cmd .exit_status == 0 , f"{ cmd .stdout } \n { cmd .stderr } "
714+
715+ tunnels = host .iproute2 .tunnels (ifname = "test" )
716+ assert len (tunnels ) > 0
717+ assert tunnels [0 ].get ("ifname" ) == "test"
718+ assert tunnels [0 ].get ("mode" ) == "ip/ip"
719+ assert tunnels [0 ].get ("remote" ) == "127.0.0.1"
711720
712721
713722def test_iproute2_vrfs (host ):
@@ -722,3 +731,10 @@ def test_iproute2_netns(host):
722731
723732 namespaces = host .iproute2 .netns ()
724733 assert len (namespaces ) == 0
734+
735+ cmd = host .run ("ip netns add test" )
736+ assert cmd .exit_status == 0 , f"{ cmd .stdout } \n { cmd .stderr } "
737+
738+ namespaces = host .iproute2 .netns ()
739+ assert len (namespaces ) == 1
740+ assert namespaces [0 ].get ("name" ) == "test"
Original file line number Diff line number Diff line change @@ -161,9 +161,15 @@ def rules(
161161 out = self .check_output (cmd )
162162 return json .loads (out )
163163
164- def tunnels (self ):
164+ def tunnels (self , ifname = None ):
165165 """Return all configured tunnels"""
166- cmd = f"{ self ._ip } --json tunnel show"
166+ cmd = f"{ self ._ip } --json tunnel show "
167+
168+ options = []
169+ if ifname is not None :
170+ options += [ifname ]
171+
172+ cmd += " " .join (options )
167173 out = self .check_output (cmd )
168174 return json .loads (out )
169175
You can’t perform that action at this time.
0 commit comments