@@ -175,3 +175,50 @@ def _fake_live_migration_with_rollback(
175
175
attachments = self .cinder .volume_to_attachment .get (volume_id )
176
176
self .assertIn (src_attachment_id , attachments .keys ())
177
177
self .assertEqual (1 , len (attachments ))
178
+
179
+
180
+ class LiveMigrationNeutronFailure (integrated_helpers ._IntegratedTestBase ):
181
+ # NOTE(artom) We need the admin API to force the host when booting the test
182
+ # server.
183
+ ADMIN_API = True
184
+ microversion = 'latest'
185
+
186
+ def _setup_compute_service (self ):
187
+ self ._start_compute ('src' )
188
+ self ._start_compute ('dest' )
189
+
190
+ def test_live_migrate_get_nw_info_fails (self ):
191
+ """Test that if the driver.post_live_migration() call fails (for
192
+ example by not being able to connect to Neutron), the exception goes
193
+ unhandled and results in the live-migration erroring out. This is bug
194
+ 1879787.
195
+ """
196
+ server = self ._create_server (networks = 'auto' ,
197
+ host = self .computes ['src' ].host )
198
+
199
+ orig_plm = self .computes ['src' ].manager ._post_live_migration
200
+
201
+ def stub_plm (* args , ** kwargs ):
202
+ """We simulate a failure in driver.post_live_migration() on the
203
+ source by stubbing the source compute's _post_live_migration() with
204
+ a method that, within a context that mocks
205
+ driver.post_live_migration() to raise an exception, calls the
206
+ original compute.manager._post_live_migration(). This is needed to
207
+ make sure driver.post_live_migration() raises only once, and only
208
+ on the source.
209
+ """
210
+ with mock .patch .object (self .computes ['src' ].manager .network_api ,
211
+ 'get_instance_nw_info' ,
212
+ side_effect = ConnectionError ):
213
+ return orig_plm (* args , ** kwargs )
214
+
215
+ with mock .patch .object (self .computes ['src' ].manager ,
216
+ '_post_live_migration' ,
217
+ side_effect = stub_plm ):
218
+ # FIXME(artom) Until bug 1879787 is fixed, the raised
219
+ # ConnectionError will go unhandled, the migration will fail, and
220
+ # the instance will still be reported as being on the source, even
221
+ # though it's actually running on the destination.
222
+ self ._live_migrate (server , 'error' , server_expected_state = 'ERROR' )
223
+ server = self .api .get_server (server ['id' ])
224
+ self .assertEqual ('src' , server ['OS-EXT-SRV-ATTR:host' ])
0 commit comments