@@ -87,7 +87,7 @@ def test_get_free_range_not_found(self):
87
87
88
88
class KeepalivedConfBaseMixin (object ):
89
89
90
- def _get_config (self , track = True ):
90
+ def _get_config (self ):
91
91
config = keepalived .KeepalivedConf ()
92
92
93
93
instance1 = keepalived .KeepalivedInstance ('MASTER' , 'eth0' , 1 ,
@@ -97,16 +97,16 @@ def _get_config(self, track=True):
97
97
instance1 .track_interfaces .append ("eth0" )
98
98
99
99
vip_address1 = keepalived .KeepalivedVipAddress ('192.168.1.0/24' ,
100
- 'eth1' , track = track )
100
+ 'eth1' , track = False )
101
101
102
102
vip_address2 = keepalived .KeepalivedVipAddress ('192.168.2.0/24' ,
103
- 'eth2' , track = track )
103
+ 'eth2' , track = False )
104
104
105
105
vip_address3 = keepalived .KeepalivedVipAddress ('192.168.3.0/24' ,
106
- 'eth2' , track = track )
106
+ 'eth2' , track = False )
107
107
108
108
vip_address_ex = keepalived .KeepalivedVipAddress ('192.168.55.0/24' ,
109
- 'eth10' , track = track )
109
+ 'eth10' , track = False )
110
110
111
111
instance1 .vips .append (vip_address1 )
112
112
instance1 .vips .append (vip_address2 )
@@ -115,7 +115,7 @@ def _get_config(self, track=True):
115
115
116
116
virtual_route = keepalived .KeepalivedVirtualRoute (n_consts .IPv4_ANY ,
117
117
"192.168.1.1" ,
118
- "eth1" , track = track )
118
+ "eth1" )
119
119
instance1 .virtual_routes .gateway_routes = [virtual_route ]
120
120
121
121
instance2 = keepalived .KeepalivedInstance ('MASTER' , 'eth4' , 2 ,
@@ -124,7 +124,7 @@ def _get_config(self, track=True):
124
124
instance2 .track_interfaces .append ("eth4" )
125
125
126
126
vip_address1 = keepalived .KeepalivedVipAddress ('192.168.3.0/24' ,
127
- 'eth6' , track = track )
127
+ 'eth6' , track = False )
128
128
129
129
instance2 .vips .append (vip_address1 )
130
130
instance2 .vips .append (vip_address2 )
@@ -192,8 +192,7 @@ def test_config_generation(self):
192
192
keepalived , '_is_keepalived_use_no_track_supported' ,
193
193
return_value = True ):
194
194
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 ())
197
196
198
197
def test_config_generation_no_track_not_supported (self ):
199
198
self ._mock_no_track_supported .start ().return_value = False
@@ -208,7 +207,7 @@ def test_config_with_reset(self):
208
207
with mock .patch .object (
209
208
keepalived , '_is_keepalived_use_no_track_supported' ,
210
209
return_value = True ):
211
- config = self ._get_config (track = False )
210
+ config = self ._get_config ()
212
211
self .assertEqual (self .expected , config .get_config_str ())
213
212
214
213
config .reset ()
@@ -239,24 +238,20 @@ def test_state_exception(self):
239
238
240
239
class KeepalivedInstanceRoutesTestCase (KeepalivedBaseTestCase ):
241
240
@classmethod
242
- def _get_instance_routes (cls , track = True ):
241
+ def _get_instance_routes (cls ):
243
242
routes = keepalived .KeepalivedInstanceRoutes ()
244
243
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' )
246
245
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' )
249
247
routes .gateway_routes = [default_gw_eth0 , default_gw_eth1 ]
250
248
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' )]
255
251
routes .extra_routes = extra_routes
256
252
extra_subnets = [
257
253
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' )]
260
255
routes .extra_subnets = extra_subnets
261
256
return routes
262
257
@@ -282,7 +277,7 @@ def test_build_config(self):
282
277
with mock .patch .object (
283
278
keepalived , '_is_keepalived_use_no_track_supported' ,
284
279
return_value = True ):
285
- routes = self ._get_instance_routes (track = False )
280
+ routes = self ._get_instance_routes ()
286
281
self .assertEqual (expected , '\n ' .join (routes .build_config ()))
287
282
288
283
def _get_no_track_less_expected_config (self ):
@@ -295,19 +290,11 @@ def _get_no_track_less_expected_config(self):
295
290
}"""
296
291
return expected
297
292
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
-
306
293
def test_build_config_no_track_not_supported (self ):
307
294
with mock .patch .object (
308
295
keepalived , '_is_keepalived_use_no_track_supported' ,
309
296
return_value = False ):
310
- routes = self ._get_instance_routes (track = False )
297
+ routes = self ._get_instance_routes ()
311
298
self .assertEqual (self ._get_no_track_less_expected_config (),
312
299
'\n ' .join (routes .build_config ()))
313
300
@@ -319,14 +306,12 @@ def test_get_primary_vip(self):
319
306
['169.254.192.0/18' ])
320
307
self .assertEqual ('169.254.0.42/24' , instance .get_primary_vip ())
321
308
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 ()
324
311
instance = config .get_instance (1 )
325
312
instance .remove_vips_vroutes_by_interface ('eth2' )
326
313
instance .remove_vips_vroutes_by_interface ('eth10' )
327
314
328
- no_track_value = ' no_track' if not track else ''
329
-
330
315
expected = KEEPALIVED_GLOBAL_CONFIG + textwrap .dedent ("""
331
316
vrrp_instance VR_1 {
332
317
state MASTER
@@ -378,19 +363,13 @@ def test_remove_addresses_by_interface(self):
378
363
with mock .patch .object (
379
364
keepalived , '_is_keepalived_use_no_track_supported' ,
380
365
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" )
388
367
389
368
def test_remove_address_by_interface_no_track_not_supported (self ):
390
369
with mock .patch .object (
391
370
keepalived , '_is_keepalived_use_no_track_supported' ,
392
371
return_value = False ):
393
- self ._test_remove_addresses_by_interface ()
372
+ self ._test_remove_addresses_by_interface ("" )
394
373
395
374
def test_build_config_no_vips (self ):
396
375
expected = textwrap .dedent ("""\
@@ -457,16 +436,6 @@ def test_virtual_route_with_dev(self):
457
436
return_value = True ):
458
437
route = keepalived .KeepalivedVirtualRoute (
459
438
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 )
470
439
self .assertEqual (
471
440
'0.0.0.0/0 via 1.2.3.4 dev eth0 no_track protocol static' ,
472
441
route .build_config ())
@@ -480,21 +449,11 @@ def test_virtual_route_with_dev_no_track_not_supported(self):
480
449
self .assertEqual ('0.0.0.0/0 via 1.2.3.4 dev eth0 protocol static' ,
481
450
route .build_config ())
482
451
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
-
492
452
def test_virtual_route_without_dev (self ):
493
453
with mock .patch .object (
494
454
keepalived , '_is_keepalived_use_no_track_supported' ,
495
455
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' )
498
457
self .assertEqual ('50.0.0.0/8 via 1.2.3.4 no_track protocol static' ,
499
458
route .build_config ())
500
459
0 commit comments