@@ -176,9 +176,12 @@ def _test_spawn_metadata_proxy(self, dad_failed=False):
176176 "%s.conf" % router_id )
177177 mock_open = self .useFixture (
178178 lib_fixtures .OpenFixture (cfg_file )).mock_open
179+ bind_v6_line = 'bind %s:%s interface %s' % (
180+ self .METADATA_DEFAULT_IPV6 , self .METADATA_PORT , 'fake-if' )
179181 if dad_failed :
180182 mock_wait .side_effect = ip_lib .DADFailed (
181- address = self .METADATA_DEFAULT_IP , reason = 'DAD failed' )
183+ address = self .METADATA_DEFAULT_IPV6 , reason = 'DAD failed' )
184+ bind_v6_line = ''
182185 else :
183186 mock_wait .return_value = True
184187 agent .metadata_driver .spawn_monitored_metadata_proxy (
@@ -197,8 +200,6 @@ def _test_spawn_metadata_proxy(self, dad_failed=False):
197200
198201 log_tag = ("haproxy-" + metadata_driver .METADATA_SERVICE_NAME +
199202 "-" + router_id )
200- bind_v6_line = 'bind %s:%s interface %s' % (
201- self .METADATA_DEFAULT_IPV6 , self .METADATA_PORT , 'fake-if' )
202203 cfg_contents = metadata_driver ._HAPROXY_CONFIG_TEMPLATE % {
203204 'user' : self .EUNAME ,
204205 'group' : self .EGNAME ,
@@ -214,26 +215,26 @@ def _test_spawn_metadata_proxy(self, dad_failed=False):
214215 'bind_v6_line' : bind_v6_line }
215216
216217 if dad_failed :
217- agent .process_monitor .register .assert_not_called ()
218218 mock_del .assert_called_once_with (self .METADATA_DEFAULT_IPV6 ,
219219 'fake-if' ,
220220 namespace = router_ns )
221221 else :
222- mock_open .assert_has_calls ([
223- mock .call (cfg_file , 'w' ),
224- mock .call ().write (cfg_contents )], any_order = True )
225-
226- ip_mock .assert_has_calls ([
227- mock .call (namespace = router_ns ),
228- mock .call ().netns .execute (netns_execute_args ,
229- addl_env = None , run_as_root = True )
230- ])
231-
232- agent .process_monitor .register .assert_called_once_with (
233- router_id , metadata_driver .METADATA_SERVICE_NAME ,
234- mock .ANY )
235222 mock_del .assert_not_called ()
236223
224+ mock_open .assert_has_calls ([
225+ mock .call (cfg_file , 'w' ),
226+ mock .call ().write (cfg_contents )], any_order = True )
227+
228+ ip_mock .assert_has_calls ([
229+ mock .call (namespace = router_ns ),
230+ mock .call ().netns .execute (netns_execute_args , addl_env = None ,
231+ run_as_root = True )
232+ ])
233+
234+ agent .process_monitor .register .assert_called_once_with (
235+ router_id , metadata_driver .METADATA_SERVICE_NAME ,
236+ mock .ANY )
237+
237238 def test_spawn_metadata_proxy (self ):
238239 self ._test_spawn_metadata_proxy ()
239240
0 commit comments