@@ -33,6 +33,7 @@ def setUp(self):
3333 self .addCleanup (self ._remove_ns , self .namespace )
3434 self .device = 'int_dummy'
3535 priv_ip_lib .create_interface (self .device , self .namespace , 'dummy' )
36+ priv_ip_lib .set_link_attribute (self .device , self .namespace , state = 'up' )
3637
3738 def _remove_ns (self , namespace ):
3839 priv_ip_lib .remove_netns (namespace )
@@ -52,7 +53,8 @@ def test_add_tc_qdisc_htb(self):
5253 namespace = self .namespace )
5354 qdiscs = priv_tc_lib .list_tc_qdiscs (self .device ,
5455 namespace = self .namespace )
55- self .assertEqual (0 , len (qdiscs ))
56+ self .assertEqual (1 , len (qdiscs ))
57+ self .assertEqual ('noqueue' , tc_lib ._get_attr (qdiscs [0 ], 'TCA_KIND' ))
5658
5759 def test_add_tc_qdisc_htb_no_handle (self ):
5860 priv_tc_lib .add_tc_qdisc (
@@ -69,7 +71,8 @@ def test_add_tc_qdisc_htb_no_handle(self):
6971 namespace = self .namespace )
7072 qdiscs = priv_tc_lib .list_tc_qdiscs (self .device ,
7173 namespace = self .namespace )
72- self .assertEqual (0 , len (qdiscs ))
74+ self .assertEqual (1 , len (qdiscs ))
75+ self .assertEqual ('noqueue' , tc_lib ._get_attr (qdiscs [0 ], 'TCA_KIND' ))
7376
7477 def test_add_tc_qdisc_tbf (self ):
7578 burst = 192000
@@ -95,23 +98,26 @@ def test_add_tc_qdisc_tbf(self):
9598 namespace = self .namespace )
9699 qdiscs = priv_tc_lib .list_tc_qdiscs (self .device ,
97100 namespace = self .namespace )
98- self .assertEqual (0 , len (qdiscs ))
101+ self .assertEqual (1 , len (qdiscs ))
102+ self .assertEqual ('noqueue' , tc_lib ._get_attr (qdiscs [0 ], 'TCA_KIND' ))
99103
100104 def test_add_tc_qdisc_ingress (self ):
101105 priv_tc_lib .add_tc_qdisc (self .device , kind = 'ingress' ,
102106 namespace = self .namespace )
103107 qdiscs = priv_tc_lib .list_tc_qdiscs (self .device ,
104108 namespace = self .namespace )
105- self .assertEqual (1 , len (qdiscs ))
106- self .assertEqual ('ingress' , tc_lib ._get_attr (qdiscs [0 ], 'TCA_KIND' ))
107- self .assertEqual (rtnl .TC_H_INGRESS , qdiscs [0 ]['parent' ])
108- self .assertEqual (0xffff0000 , qdiscs [0 ]['handle' ])
109+ self .assertEqual (2 , len (qdiscs ))
110+ self .assertEqual ('noqueue' , tc_lib ._get_attr (qdiscs [0 ], 'TCA_KIND' ))
111+ self .assertEqual ('ingress' , tc_lib ._get_attr (qdiscs [1 ], 'TCA_KIND' ))
112+ self .assertEqual (rtnl .TC_H_INGRESS , qdiscs [1 ]['parent' ])
113+ self .assertEqual (0xffff0000 , qdiscs [1 ]['handle' ])
109114
110115 priv_tc_lib .delete_tc_qdisc (self .device , kind = 'ingress' ,
111116 namespace = self .namespace )
112117 qdiscs = priv_tc_lib .list_tc_qdiscs (self .device ,
113118 namespace = self .namespace )
114- self .assertEqual (0 , len (qdiscs ))
119+ self .assertEqual (1 , len (qdiscs ))
120+ self .assertEqual ('noqueue' , tc_lib ._get_attr (qdiscs [0 ], 'TCA_KIND' ))
115121
116122 def test_delete_tc_qdisc_no_device (self ):
117123 self .assertRaises (
@@ -138,14 +144,16 @@ def test_delete_tc_qdisc_ingress_twice(self):
138144 namespace = self .namespace )
139145 qdiscs = priv_tc_lib .list_tc_qdiscs (self .device ,
140146 namespace = self .namespace )
141- self .assertEqual (1 , len (qdiscs ))
142- self .assertEqual ('ingress' , tc_lib ._get_attr (qdiscs [0 ], 'TCA_KIND' ))
147+ self .assertEqual (2 , len (qdiscs ))
148+ self .assertEqual ('noqueue' , tc_lib ._get_attr (qdiscs [0 ], 'TCA_KIND' ))
149+ self .assertEqual ('ingress' , tc_lib ._get_attr (qdiscs [1 ], 'TCA_KIND' ))
143150 self .assertIsNone (
144151 priv_tc_lib .delete_tc_qdisc (self .device , kind = 'ingress' ,
145152 namespace = self .namespace ))
146153 qdiscs = priv_tc_lib .list_tc_qdiscs (self .device ,
147154 namespace = self .namespace )
148- self .assertEqual (0 , len (qdiscs ))
155+ self .assertEqual (1 , len (qdiscs ))
156+ self .assertEqual ('noqueue' , tc_lib ._get_attr (qdiscs [0 ], 'TCA_KIND' ))
149157 self .assertEqual (
150158 errno .EINVAL ,
151159 priv_tc_lib .delete_tc_qdisc (self .device , kind = 'ingress' ,
@@ -167,6 +175,7 @@ def setUp(self):
167175 self .addCleanup (self ._remove_ns , self .namespace )
168176 self .device = 'int_dummy'
169177 priv_ip_lib .create_interface ('int_dummy' , self .namespace , 'dummy' )
178+ priv_ip_lib .set_link_attribute (self .device , self .namespace , state = 'up' )
170179
171180 def _remove_ns (self , namespace ):
172181 priv_ip_lib .remove_netns (namespace )
@@ -248,6 +257,7 @@ def setUp(self):
248257 self .addCleanup (self ._remove_ns , self .namespace )
249258 self .device = 'int_dummy'
250259 priv_ip_lib .create_interface ('int_dummy' , self .namespace , 'dummy' )
260+ priv_ip_lib .set_link_attribute (self .device , self .namespace , state = 'up' )
251261
252262 def _remove_ns (self , namespace ):
253263 priv_ip_lib .remove_netns (namespace )
@@ -274,9 +284,8 @@ def test_add_tc_filter_match32(self):
274284 self .assertEqual (value , filter_keys [index ])
275285
276286 def test_add_tc_filter_policy (self ):
277- priv_tc_lib .add_tc_qdisc (
278- self .device , parent = rtnl .TC_H_ROOT , kind = 'ingress' ,
279- namespace = self .namespace )
287+ priv_tc_lib .add_tc_qdisc (self .device , kind = 'ingress' ,
288+ namespace = self .namespace )
280289
281290 # NOTE(ralonsoh):
282291 # - rate: 320000 bytes/sec (pyroute2 units) = 2560 kbits/sec (OS units)
0 commit comments