Volume and group on same backend in update_group
In a multiple backend environment, a volume can be created
on a different backend from a group, add volume to group
will fail in this case. The 'host' field of a volume or a
group is an internal field that cannot be retrieved by
using Cinder volume APIs. The only way to make sure a volume
is created on the same backend as the host is to create the
volume with the group_id parameter. After that remove the
volume from the group, and then add the volume back to the
group. This way the volume to be added to the group will be
on the same backend as the group.
This will make the test longer than desired, but it is
the only way to make sure the added volume is on the same
backend as the group.
Change-Id: I376f0188984d706e83740f67bd6f301f680914f8
Closes-Bug: #1709739
diff --git a/tempest/api/volume/admin/test_groups.py b/tempest/api/volume/admin/test_groups.py
index 3f8664c..baea37b 100644
--- a/tempest/api/volume/admin/test_groups.py
+++ b/tempest/api/volume/admin/test_groups.py
@@ -270,19 +270,20 @@
# Create Group
grp = self._create_group(group_type, volume_type)
- # Create a volume in the group
- vol1 = self.create_volume(volume_type=volume_type['id'],
- group_id=grp['id'])
- # Create a volume not in the group
- vol2 = self.create_volume(volume_type=volume_type['id'])
+ # Create volumes
+ grp_vols = []
+ for _ in range(2):
+ vol = self.create_volume(volume_type=volume_type['id'],
+ group_id=grp['id'])
+ grp_vols.append(vol)
+ vol2 = grp_vols[1]
# Remove a volume from group and update name and description
new_grp_name = 'new_group'
new_desc = 'This is a new group'
grp_params = {'name': new_grp_name,
'description': new_desc,
- 'remove_volumes': vol1['id'],
- 'add_volumes': vol2['id']}
+ 'remove_volumes': vol2['id']}
self.groups_client.update_group(grp['id'], **grp_params)
# Wait for group status to become available
@@ -302,5 +303,20 @@
if vol['group_id'] == grp['id']:
grp_vols.append(vol)
self.assertEqual(1, len(grp_vols))
- self.assertEqual(vol2['id'], grp_vols[0]['id'])
- self.assertNotEqual(vol1['id'], grp_vols[0]['id'])
+
+ # Add a volume to the group
+ grp_params = {'add_volumes': vol2['id']}
+ self.groups_client.update_group(grp['id'], **grp_params)
+
+ # Wait for group status to become available
+ waiters.wait_for_volume_resource_status(
+ self.groups_client, grp['id'], 'available')
+
+ # Get volumes in the group
+ vols = self.volumes_client.list_volumes(
+ detail=True)['volumes']
+ grp_vols = []
+ for vol in vols:
+ if vol['group_id'] == grp['id']:
+ grp_vols.append(vol)
+ self.assertEqual(2, len(grp_vols))