Skip to content

Commit

Permalink
Clean up started volume services in tests.
Browse files Browse the repository at this point in the history
The test_preattach_status_volume test was failing due to state left by
another test. The interim solution was to skip the aforementioned test.
I tracked down the problem to 4 tests in test_admin_actions.py that
call self.start_service('volume', host='test'), and don't stop the
service. Stopping it in all 4 tests solves the problem.

HOWEVER, I don't know why these started services caused this particular
test to fail. I am still working to figure that out, but maybe someone
has an idea.

Change-Id: I2a5caaae9f61e7c7617c934917a10cf1cf3c0db6
Fixes: bug 1153108
  • Loading branch information
avishay-traeger committed Mar 21, 2013
1 parent 65e2910 commit d1b37a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 12 additions & 4 deletions cinder/tests/api/contrib/test_admin_actions.py
Expand Up @@ -252,14 +252,16 @@ def test_force_delete_snapshot(self):
# attach admin context to request
req.environ['cinder.context'] = ctx
# start service to handle rpc.cast for 'delete snapshot'
self.start_service('volume', host='test')
svc = self.start_service('volume', host='test')
# make request
resp = req.get_response(app())
# request is accepted
self.assertEquals(resp.status_int, 202)
# snapshot is deleted
self.assertRaises(exception.NotFound, db.snapshot_get, ctx,
snapshot['id'])
# cleanup
svc.stop()

def test_force_detach_volume(self):
# admin context
Expand All @@ -268,7 +270,7 @@ def test_force_detach_volume(self):
volume = db.volume_create(ctx, {'status': 'available', 'host': 'test',
'provider_location': ''})
# start service to handle rpc messages for attach requests
self.start_service('volume', host='test')
svc = self.start_service('volume', host='test')
self.volume_api.reserve_volume(ctx, volume)
self.volume_api.initialize_connection(ctx, volume, {})
mountpoint = '/dev/vbd'
Expand Down Expand Up @@ -297,6 +299,8 @@ def test_force_detach_volume(self):
self.assertEquals(volume['instance_uuid'], None)
self.assertEquals(volume['mountpoint'], None)
self.assertEquals(volume['attach_status'], 'detached')
# cleanup
svc.stop()

def test_attach_in_use_volume(self):
"""Test that attaching to an in-use volume fails."""
Expand All @@ -306,7 +310,7 @@ def test_attach_in_use_volume(self):
volume = db.volume_create(ctx, {'status': 'available', 'host': 'test',
'provider_location': ''})
# start service to handle rpc messages for attach requests
self.start_service('volume', host='test')
svc = self.start_service('volume', host='test')
self.volume_api.reserve_volume(ctx, volume)
self.volume_api.initialize_connection(ctx, volume, {})
mountpoint = '/dev/vbd'
Expand All @@ -317,6 +321,8 @@ def test_attach_in_use_volume(self):
volume,
fakes.get_fake_uuid(),
mountpoint)
# cleanup
svc.stop()

def test_attach_attaching_volume_with_different_instance(self):
"""Test that attaching volume reserved for another instance fails."""
Expand All @@ -326,7 +332,7 @@ def test_attach_attaching_volume_with_different_instance(self):
volume = db.volume_create(ctx, {'status': 'available', 'host': 'test',
'provider_location': ''})
# start service to handle rpc messages for attach requests
self.start_service('volume', host='test')
svc = self.start_service('volume', host='test')
self.volume_api.initialize_connection(ctx, volume, {})
values = {'status': 'attaching',
'instance_uuid': fakes.get_fake_uuid()}
Expand All @@ -338,3 +344,5 @@ def test_attach_attaching_volume_with_different_instance(self):
volume,
stubs.FAKE_UUID,
mountpoint)
# cleanup
svc.stop()
1 change: 0 additions & 1 deletion cinder/tests/test_volume.py
Expand Up @@ -293,7 +293,6 @@ def test_run_attach_detach_volume(self):
self.context,
volume_id)

@test.skip_test
def test_preattach_status_volume(self):
"""Ensure volume goes into pre-attaching state"""
instance_uuid = '12345678-1234-5678-1234-567812345678'
Expand Down

0 comments on commit d1b37a8

Please sign in to comment.