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):
707
707
assert host .iproute2 .exists
708
708
709
709
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"
711
720
712
721
713
722
def test_iproute2_vrfs (host ):
@@ -722,3 +731,10 @@ def test_iproute2_netns(host):
722
731
723
732
namespaces = host .iproute2 .netns ()
724
733
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(
161
161
out = self .check_output (cmd )
162
162
return json .loads (out )
163
163
164
- def tunnels (self ):
164
+ def tunnels (self , ifname = None ):
165
165
"""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 )
167
173
out = self .check_output (cmd )
168
174
return json .loads (out )
169
175
You can’t perform that action at this time.
0 commit comments