@@ -87,7 +87,7 @@ def test_get_free_range_not_found(self):
8787
8888class KeepalivedConfBaseMixin (object ):
8989
90- def _get_config (self , track = True ):
90+ def _get_config (self ):
9191 config = keepalived .KeepalivedConf ()
9292
9393 instance1 = keepalived .KeepalivedInstance ('MASTER' , 'eth0' , 1 ,
@@ -97,16 +97,16 @@ def _get_config(self, track=True):
9797 instance1 .track_interfaces .append ("eth0" )
9898
9999 vip_address1 = keepalived .KeepalivedVipAddress ('192.168.1.0/24' ,
100- 'eth1' , track = track )
100+ 'eth1' , track = False )
101101
102102 vip_address2 = keepalived .KeepalivedVipAddress ('192.168.2.0/24' ,
103- 'eth2' , track = track )
103+ 'eth2' , track = False )
104104
105105 vip_address3 = keepalived .KeepalivedVipAddress ('192.168.3.0/24' ,
106- 'eth2' , track = track )
106+ 'eth2' , track = False )
107107
108108 vip_address_ex = keepalived .KeepalivedVipAddress ('192.168.55.0/24' ,
109- 'eth10' , track = track )
109+ 'eth10' , track = False )
110110
111111 instance1 .vips .append (vip_address1 )
112112 instance1 .vips .append (vip_address2 )
@@ -115,7 +115,7 @@ def _get_config(self, track=True):
115115
116116 virtual_route = keepalived .KeepalivedVirtualRoute (n_consts .IPv4_ANY ,
117117 "192.168.1.1" ,
118- "eth1" , track = track )
118+ "eth1" )
119119 instance1 .virtual_routes .gateway_routes = [virtual_route ]
120120
121121 instance2 = keepalived .KeepalivedInstance ('MASTER' , 'eth4' , 2 ,
@@ -124,7 +124,7 @@ def _get_config(self, track=True):
124124 instance2 .track_interfaces .append ("eth4" )
125125
126126 vip_address1 = keepalived .KeepalivedVipAddress ('192.168.3.0/24' ,
127- 'eth6' , track = track )
127+ 'eth6' , track = False )
128128
129129 instance2 .vips .append (vip_address1 )
130130 instance2 .vips .append (vip_address2 )
@@ -192,8 +192,7 @@ def test_config_generation(self):
192192 keepalived , '_is_keepalived_use_no_track_supported' ,
193193 return_value = True ):
194194 config = self ._get_config ()
195- self .assertEqual (self .expected .replace (' no_track' , '' ),
196- config .get_config_str ())
195+ self .assertEqual (self .expected , config .get_config_str ())
197196
198197 def test_config_generation_no_track_not_supported (self ):
199198 self ._mock_no_track_supported .start ().return_value = False
@@ -208,7 +207,7 @@ def test_config_with_reset(self):
208207 with mock .patch .object (
209208 keepalived , '_is_keepalived_use_no_track_supported' ,
210209 return_value = True ):
211- config = self ._get_config (track = False )
210+ config = self ._get_config ()
212211 self .assertEqual (self .expected , config .get_config_str ())
213212
214213 config .reset ()
@@ -239,24 +238,20 @@ def test_state_exception(self):
239238
240239class KeepalivedInstanceRoutesTestCase (KeepalivedBaseTestCase ):
241240 @classmethod
242- def _get_instance_routes (cls , track = True ):
241+ def _get_instance_routes (cls ):
243242 routes = keepalived .KeepalivedInstanceRoutes ()
244243 default_gw_eth0 = keepalived .KeepalivedVirtualRoute (
245- '0.0.0.0/0' , '1.0.0.254' , 'eth0' , track = track )
244+ '0.0.0.0/0' , '1.0.0.254' , 'eth0' )
246245 default_gw_eth1 = keepalived .KeepalivedVirtualRoute (
247- '::/0' , 'fe80::3e97:eff:fe26:3bfa/64' , 'eth1' ,
248- track = track )
246+ '::/0' , 'fe80::3e97:eff:fe26:3bfa/64' , 'eth1' )
249247 routes .gateway_routes = [default_gw_eth0 , default_gw_eth1 ]
250248 extra_routes = [
251- keepalived .KeepalivedVirtualRoute (
252- '10.0.0.0/8' , '1.0.0.1' , track = track ),
253- keepalived .KeepalivedVirtualRoute (
254- '20.0.0.0/8' , '2.0.0.2' , track = track )]
249+ keepalived .KeepalivedVirtualRoute ('10.0.0.0/8' , '1.0.0.1' ),
250+ keepalived .KeepalivedVirtualRoute ('20.0.0.0/8' , '2.0.0.2' )]
255251 routes .extra_routes = extra_routes
256252 extra_subnets = [
257253 keepalived .KeepalivedVirtualRoute (
258- '30.0.0.0/8' , None , 'eth0' , scope = 'link' ,
259- track = track )]
254+ '30.0.0.0/8' , None , 'eth0' , scope = 'link' )]
260255 routes .extra_subnets = extra_subnets
261256 return routes
262257
@@ -282,7 +277,7 @@ def test_build_config(self):
282277 with mock .patch .object (
283278 keepalived , '_is_keepalived_use_no_track_supported' ,
284279 return_value = True ):
285- routes = self ._get_instance_routes (track = False )
280+ routes = self ._get_instance_routes ()
286281 self .assertEqual (expected , '\n ' .join (routes .build_config ()))
287282
288283 def _get_no_track_less_expected_config (self ):
@@ -295,19 +290,11 @@ def _get_no_track_less_expected_config(self):
295290 }"""
296291 return expected
297292
298- def test_build_config_without_no_track (self ):
299- with mock .patch .object (
300- keepalived , '_is_keepalived_use_no_track_supported' ,
301- return_value = True ):
302- routes = self ._get_instance_routes ()
303- self .assertEqual (self ._get_no_track_less_expected_config (),
304- '\n ' .join (routes .build_config ()))
305-
306293 def test_build_config_no_track_not_supported (self ):
307294 with mock .patch .object (
308295 keepalived , '_is_keepalived_use_no_track_supported' ,
309296 return_value = False ):
310- routes = self ._get_instance_routes (track = False )
297+ routes = self ._get_instance_routes ()
311298 self .assertEqual (self ._get_no_track_less_expected_config (),
312299 '\n ' .join (routes .build_config ()))
313300
@@ -319,14 +306,12 @@ def test_get_primary_vip(self):
319306 ['169.254.192.0/18' ])
320307 self .assertEqual ('169.254.0.42/24' , instance .get_primary_vip ())
321308
322- def _test_remove_addresses_by_interface (self , track = True ):
323- config = self ._get_config (track = track )
309+ def _test_remove_addresses_by_interface (self , no_track_value ):
310+ config = self ._get_config ()
324311 instance = config .get_instance (1 )
325312 instance .remove_vips_vroutes_by_interface ('eth2' )
326313 instance .remove_vips_vroutes_by_interface ('eth10' )
327314
328- no_track_value = ' no_track' if not track else ''
329-
330315 expected = KEEPALIVED_GLOBAL_CONFIG + textwrap .dedent ("""
331316 vrrp_instance VR_1 {
332317 state MASTER
@@ -378,19 +363,13 @@ def test_remove_addresses_by_interface(self):
378363 with mock .patch .object (
379364 keepalived , '_is_keepalived_use_no_track_supported' ,
380365 return_value = True ):
381- self ._test_remove_addresses_by_interface ()
382-
383- def test_remove_addresses_by_interface_with_no_track (self ):
384- with mock .patch .object (
385- keepalived , '_is_keepalived_use_no_track_supported' ,
386- return_value = True ):
387- self ._test_remove_addresses_by_interface (track = False )
366+ self ._test_remove_addresses_by_interface (" no_track" )
388367
389368 def test_remove_address_by_interface_no_track_not_supported (self ):
390369 with mock .patch .object (
391370 keepalived , '_is_keepalived_use_no_track_supported' ,
392371 return_value = False ):
393- self ._test_remove_addresses_by_interface ()
372+ self ._test_remove_addresses_by_interface ("" )
394373
395374 def test_build_config_no_vips (self ):
396375 expected = textwrap .dedent ("""\
@@ -457,16 +436,6 @@ def test_virtual_route_with_dev(self):
457436 return_value = True ):
458437 route = keepalived .KeepalivedVirtualRoute (
459438 n_consts .IPv4_ANY , '1.2.3.4' , 'eth0' )
460- self .assertEqual (
461- '0.0.0.0/0 via 1.2.3.4 dev eth0 protocol static' ,
462- route .build_config ())
463-
464- def test_virtual_route_with_dev_supported_no_track (self ):
465- with mock .patch .object (
466- keepalived , '_is_keepalived_use_no_track_supported' ,
467- return_value = True ):
468- route = keepalived .KeepalivedVirtualRoute (
469- n_consts .IPv4_ANY , '1.2.3.4' , 'eth0' , track = False )
470439 self .assertEqual (
471440 '0.0.0.0/0 via 1.2.3.4 dev eth0 no_track protocol static' ,
472441 route .build_config ())
@@ -480,21 +449,11 @@ def test_virtual_route_with_dev_no_track_not_supported(self):
480449 self .assertEqual ('0.0.0.0/0 via 1.2.3.4 dev eth0 protocol static' ,
481450 route .build_config ())
482451
483- def test_virtual_route_with_dev_no_track_not_supported_not_track (self ):
484- with mock .patch .object (
485- keepalived , '_is_keepalived_use_no_track_supported' ,
486- return_value = False ):
487- route = keepalived .KeepalivedVirtualRoute (
488- n_consts .IPv4_ANY , '1.2.3.4' , 'eth0' , track = False )
489- self .assertEqual ('0.0.0.0/0 via 1.2.3.4 dev eth0 protocol static' ,
490- route .build_config ())
491-
492452 def test_virtual_route_without_dev (self ):
493453 with mock .patch .object (
494454 keepalived , '_is_keepalived_use_no_track_supported' ,
495455 return_value = True ):
496- route = keepalived .KeepalivedVirtualRoute (
497- '50.0.0.0/8' , '1.2.3.4' , track = False )
456+ route = keepalived .KeepalivedVirtualRoute ('50.0.0.0/8' , '1.2.3.4' )
498457 self .assertEqual ('50.0.0.0/8 via 1.2.3.4 no_track protocol static' ,
499458 route .build_config ())
500459
0 commit comments