@@ -194,21 +194,29 @@ def test_migrate_confirm_after_deleted_source_compute(self):
194194 # Delete the source compute service.
195195 service = self .admin_api .get_services (
196196 binary = 'nova-compute' , host = 'host1' )[0 ]
197- self .admin_api .api_delete ('/os-services/%s' % service ['id' ])
198- # FIXME(mriedem): This is bug 1852610 where the compute service is
199- # deleted but the resource provider is not because there are still
200- # migration-based allocations against the source node provider.
197+ # We expect the delete request to fail with a 409 error because of the
198+ # instance in VERIFY_RESIZE status even though that instance is marked
199+ # as being on host2 now.
200+ ex = self .assertRaises (api_client .OpenStackApiException ,
201+ self .admin_api .api_delete ,
202+ '/os-services/%s' % service ['id' ])
203+ self .assertEqual (409 , ex .response .status_code )
204+ self .assertIn ('Unable to delete compute service that has in-progress '
205+ 'migrations' , six .text_type (ex ))
206+ self .assertIn ('There are 1 in-progress migrations involving the host' ,
207+ self .stdlog .logger .output )
208+ # The provider is still around because we did not delete the service.
201209 resp = self .placement_api .get ('/resource_providers/%s' % host1_rp_uuid )
202210 self .assertEqual (200 , resp .status )
203211 self .assertFlavorMatchesUsage (host1_rp_uuid , flavor )
204212 # Now try to confirm the migration.
205- # FIXME(mriedem): This will fail until bug 1852610 is fixed and the
206- # source compute service delete is blocked while there is an
207- # in-progress migration involving the node .
208- self .assertNotIn ( 'ComputeHostNotFound' , self . stdlog . logger . output )
209- self . api . post_server_action ( server [ 'id' ], { 'confirmResize' : None })
210- self ._wait_for_state_change ( self . api , server , 'ERROR' )
211- self .assertIn ( 'ComputeHostNotFound' , self . stdlog . logger . output )
213+ self . _confirm_resize ( server )
214+ # Delete the host1 service since the migration is confirmed and the
215+ # server is on host2 .
216+ self .admin_api . api_delete ( '/os-services/%s' % service [ 'id' ] )
217+ # The host1 resource provider should be gone.
218+ resp = self .placement_api . get ( '/resource_providers/%s' % host1_rp_uuid )
219+ self .assertEqual ( 404 , resp . status )
212220
213221 def test_resize_revert_after_deleted_source_compute (self ):
214222 """Tests a scenario where a server is resized and while in
@@ -231,25 +239,34 @@ def test_resize_revert_after_deleted_source_compute(self):
231239 # Delete the source compute service.
232240 service = self .admin_api .get_services (
233241 binary = 'nova-compute' , host = 'host1' )[0 ]
234- self .admin_api .api_delete ('/os-services/%s' % service ['id' ])
235- # FIXME(mriedem): This is bug 1852610 where the compute service is
236- # deleted but the resource provider is not because there are still
237- # migration-based allocations against the source node provider.
242+ # We expect the delete request to fail with a 409 error because of the
243+ # instance in VERIFY_RESIZE status even though that instance is marked
244+ # as being on host2 now.
245+ ex = self .assertRaises (api_client .OpenStackApiException ,
246+ self .admin_api .api_delete ,
247+ '/os-services/%s' % service ['id' ])
248+ self .assertEqual (409 , ex .response .status_code )
249+ self .assertIn ('Unable to delete compute service that has in-progress '
250+ 'migrations' , six .text_type (ex ))
251+ self .assertIn ('There are 1 in-progress migrations involving the host' ,
252+ self .stdlog .logger .output )
253+ # The provider is still around because we did not delete the service.
238254 resp = self .placement_api .get ('/resource_providers/%s' % host1_rp_uuid )
239255 self .assertEqual (200 , resp .status )
240256 self .assertFlavorMatchesUsage (host1_rp_uuid , flavor1 )
241- # Now try to revert the resize.
242- # NOTE(mriedem): This actually works because the drop_move_claim
243- # happens in revert_resize on the dest host which still has its
244- # ComputeNode record. The migration-based allocations are reverted
245- # so the instance holds the allocations for the source provider and
246- # the allocations against the dest provider are dropped.
247- self .api .post_server_action (server ['id' ], {'revertResize' : None })
248- self ._wait_for_state_change (self .api , server , 'ACTIVE' )
249- self .assertNotIn ('ComputeHostNotFound' , self .stdlog .logger .output )
257+ # Now revert the resize.
258+ self ._revert_resize (server )
250259 self .assertFlavorMatchesUsage (host1_rp_uuid , flavor1 )
251260 zero_flavor = {'vcpus' : 0 , 'ram' : 0 , 'disk' : 0 , 'extra_specs' : {}}
252261 self .assertFlavorMatchesUsage (host2_rp_uuid , zero_flavor )
262+ # Delete the host2 service since the migration is reverted and the
263+ # server is on host1 again.
264+ service2 = self .admin_api .get_services (
265+ binary = 'nova-compute' , host = 'host2' )[0 ]
266+ self .admin_api .api_delete ('/os-services/%s' % service2 ['id' ])
267+ # The host2 resource provider should be gone.
268+ resp = self .placement_api .get ('/resource_providers/%s' % host2_rp_uuid )
269+ self .assertEqual (404 , resp .status )
253270
254271
255272class ComputeStatusFilterTest (integrated_helpers .ProviderUsageBaseTestCase ):
0 commit comments