@@ -776,7 +776,8 @@ def test_flush(self, flush):
776776 6 , self .parent .name , self .addr_cmd ._parent .namespace )
777777
778778 def test_wait_until_address_ready (self ):
779- self .addr_cmd .list = mock .Mock (return_value = [{'tentative' : False }])
779+ self .addr_cmd .list = mock .Mock (
780+ return_value = [{'tentative' : False , 'dadfailed' : False }])
780781 # this address is not tentative or failed so it should return
781782 self .assertIsNone (self .addr_cmd .wait_until_address_ready (
782783 '2001:470:9:1224:fd91:272:581e:3a32' ))
@@ -786,6 +787,24 @@ def test_wait_until_address_ready_non_existent_address(self):
786787 with testtools .ExpectedException (ip_lib .AddressNotReady ):
787788 self .addr_cmd .wait_until_address_ready ('abcd::1234' )
788789
790+ def test_wait_until_address_dadfailed (self ):
791+ self .addr_cmd .list = mock .Mock (
792+ return_value = [{'tentative' : True , 'dadfailed' : True }])
793+ with testtools .ExpectedException (ip_lib .AddressNotReady ):
794+ self .addr_cmd .wait_until_address_ready ('abcd::1234' )
795+
796+ @mock .patch .object (common_utils , 'wait_until_true' )
797+ def test_wait_until_address_ready_success_one_timeout (self , mock_wuntil ):
798+ tentative_address = 'fe80::3023:39ff:febc:22ae'
799+ self .addr_cmd .list = mock .Mock (return_value = [
800+ dict (scope = 'link' , dadfailed = False , tentative = True , dynamic = False ,
801+ cidr = tentative_address + '/64' ),
802+ dict (scope = 'link' , dadfailed = False , tentative = False , dynamic = False ,
803+ cidr = tentative_address + '/64' )])
804+ self .assertIsNone (self .addr_cmd .wait_until_address_ready (
805+ tentative_address , wait_time = 3 ))
806+ self .assertEqual (1 , mock_wuntil .call_count )
807+
789808 def test_wait_until_address_ready_timeout (self ):
790809 tentative_address = 'fe80::3023:39ff:febc:22ae'
791810 self .addr_cmd .list = mock .Mock (return_value = [
0 commit comments