|
|
@@ -3,6 +3,7 @@ import uuid
|
|
|
|
|
|
from test import helpers
|
|
|
from test.helpers import ProviderTestBase
|
|
|
+from test.helpers import standard_interface_tests as sit
|
|
|
|
|
|
from cloudbridge.cloud.interfaces import SnapshotState
|
|
|
from cloudbridge.cloud.interfaces import VolumeState
|
|
|
@@ -32,63 +33,10 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
with helpers.cleanup_action(lambda: cleanup_vol(test_vol)):
|
|
|
test_vol.wait_till_ready()
|
|
|
- self.assertTrue(
|
|
|
- test_vol.id in repr(test_vol),
|
|
|
- "repr(obj) should contain the object id so that the object"
|
|
|
- " can be reconstructed, but does not. eval(repr(obj)) == obj")
|
|
|
- volumes = self.provider.block_store.volumes.list()
|
|
|
- list_volumes = [vol for vol in volumes if vol.name == name]
|
|
|
- self.assertTrue(
|
|
|
- len(list_volumes) == 1,
|
|
|
- "List volumes does not return the expected volume %s" %
|
|
|
- name)
|
|
|
+ sit.check_standard_behaviour(
|
|
|
+ self, self.provider.block_store.volumes, test_vol)
|
|
|
|
|
|
- # check iteration
|
|
|
- iter_volumes = [vol for vol in self.provider.block_store.volumes
|
|
|
- if vol.name == name]
|
|
|
- self.assertTrue(
|
|
|
- len(iter_volumes) == 1,
|
|
|
- "Iter volumes does not return the expected volume %s" %
|
|
|
- name)
|
|
|
-
|
|
|
- # check find
|
|
|
- find_vols = self.provider.block_store.volumes.find(name=name)
|
|
|
- self.assertTrue(
|
|
|
- len(find_vols) == 1,
|
|
|
- "Find volumes does not return the expected volume %s" %
|
|
|
- name)
|
|
|
-
|
|
|
- # check non-existent find
|
|
|
- # TODO: Moto has a bug with filters causing the following test
|
|
|
- # to fail. Need to add tag based filtering support for volumes
|
|
|
-# find_vols = self.provider.block_store.volumes.find(
|
|
|
-# name="non_existent_vol")
|
|
|
-# self.assertTrue(
|
|
|
-# len(find_vols) == 0,
|
|
|
-# "Find() for a non-existent volume returned %s" % find_vols)
|
|
|
-
|
|
|
- get_vol = self.provider.block_store.volumes.get(
|
|
|
- test_vol.id)
|
|
|
- self.assertTrue(
|
|
|
- list_volumes[0] ==
|
|
|
- get_vol == test_vol,
|
|
|
- "Ids returned by list: {0} and get: {1} are not as "
|
|
|
- " expected: {2}" .format(list_volumes[0].id,
|
|
|
- get_vol.id,
|
|
|
- test_vol.id))
|
|
|
- self.assertTrue(
|
|
|
- list_volumes[0].name ==
|
|
|
- get_vol.name == test_vol.name,
|
|
|
- "Names returned by list: {0} and get: {1} are not as "
|
|
|
- " expected: {2}" .format(list_volumes[0].name,
|
|
|
- get_vol.name,
|
|
|
- test_vol.name))
|
|
|
- volumes = self.provider.block_store.volumes.list()
|
|
|
- found_volumes = [vol for vol in volumes if vol.name == name]
|
|
|
- self.assertTrue(
|
|
|
- len(found_volumes) == 0,
|
|
|
- "Volume %s should have been deleted but still exists." %
|
|
|
- name)
|
|
|
+ sit.check_delete(self, self.provider.block_store.volumes, test_vol)
|
|
|
|
|
|
@helpers.skipIfNoService(['block_store.volumes'])
|
|
|
def test_attach_detach_volume(self):
|
|
|
@@ -211,62 +159,8 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
with helpers.cleanup_action(lambda: cleanup_snap(test_snap)):
|
|
|
test_snap.wait_till_ready()
|
|
|
- self.assertTrue(
|
|
|
- test_snap.id in repr(test_snap),
|
|
|
- "repr(obj) should contain the object id so that the object"
|
|
|
- " can be reconstructed, but does not.")
|
|
|
-
|
|
|
- snaps = self.provider.block_store.snapshots.list()
|
|
|
- list_snaps = [snap for snap in snaps
|
|
|
- if snap.name == snap_name]
|
|
|
- self.assertTrue(
|
|
|
- len(list_snaps) == 1,
|
|
|
- "List snapshots does not return the expected volume %s" %
|
|
|
- name)
|
|
|
-
|
|
|
- # check iteration
|
|
|
- iter_snaps = [
|
|
|
- snap for snap in self.provider.block_store.snapshots
|
|
|
- if snap.name == snap_name]
|
|
|
- self.assertTrue(
|
|
|
- len(iter_snaps) == 1,
|
|
|
- "Iter snapshots does not return the expected volume %s" %
|
|
|
- name)
|
|
|
-
|
|
|
- # check find
|
|
|
- find_snap = self.provider.block_store.snapshots.find(
|
|
|
- name=snap_name)
|
|
|
- self.assertTrue(
|
|
|
- len(find_snap) == 1,
|
|
|
- "Find snaps does not return the expected snapshot %s" %
|
|
|
- name)
|
|
|
-
|
|
|
- # check non-existent find
|
|
|
- # TODO: Moto has a bug with filters causing the following test
|
|
|
- # to fail. Need to add tag based filtering support for snaps
|
|
|
-# find_snap = self.provider.block_store.snapshots.find(
|
|
|
-# name="non_existent_snap")
|
|
|
-# self.assertTrue(
|
|
|
-# len(find_snap) == 0,
|
|
|
-# "Find() for a non-existent snap returned %s" %
|
|
|
-# find_snap)
|
|
|
-
|
|
|
- get_snap = self.provider.block_store.snapshots.get(
|
|
|
- test_snap.id)
|
|
|
- self.assertTrue(
|
|
|
- list_snaps[0] ==
|
|
|
- get_snap == test_snap,
|
|
|
- "Ids returned by list: {0} and get: {1} are not as "
|
|
|
- " expected: {2}" .format(list_snaps[0].id,
|
|
|
- get_snap.id,
|
|
|
- test_snap.id))
|
|
|
- self.assertTrue(
|
|
|
- list_snaps[0].name ==
|
|
|
- get_snap.name == test_snap.name,
|
|
|
- "Names returned by list: {0} and get: {1} are not as "
|
|
|
- " expected: {2}" .format(list_snaps[0].name,
|
|
|
- get_snap.name,
|
|
|
- test_snap.name))
|
|
|
+ sit.check_standard_behaviour(
|
|
|
+ self, self.provider.block_store.snapshots, test_snap)
|
|
|
|
|
|
# Test volume creation from a snapshot (via VolumeService)
|
|
|
sv_name = "CBUnitTestSnapVol-{0}".format(name)
|
|
|
@@ -284,13 +178,8 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
|
|
|
with helpers.cleanup_action(lambda: snap_vol2.delete()):
|
|
|
snap_vol2.wait_till_ready()
|
|
|
|
|
|
- snaps = self.provider.block_store.snapshots.list()
|
|
|
- found_snaps = [snap for snap in snaps
|
|
|
- if snap.name == snap_name]
|
|
|
- self.assertTrue(
|
|
|
- len(found_snaps) == 0,
|
|
|
- "Snapshot %s should have been deleted but still exists." %
|
|
|
- snap_name)
|
|
|
+ sit.check_delete(
|
|
|
+ self, self.provider.block_store.snapshots, test_snap)
|
|
|
|
|
|
# Test creation of a snap via SnapshotService
|
|
|
snap_too_name = "CBSnapToo-{0}".format(name)
|