'Creates and deletes a group snapshot.'

def test_create_and_delete_group_snapshot(self):

    created_group = self.api.post_group({'group': {'group_type': self.group_type['id'], 'volume_types': [self.volume_type['id']]}})
    self.assertTrue(uuidutils.is_uuid_like(created_group['id']))
    created_group_id = created_group['id']
    found_group = self._poll_group_while(created_group_id, ['creating'])
    self.assertEqual(created_group_id, found_group['id'])
    self.assertEqual(self.group_type['id'], found_group['group_type'])
    self.assertEqual('available', found_group['status'])
    created_volume = self.api.post_volume({'volume': {'size': 1, 'group_id': created_group_id, 'volume_type': self.volume_type['id']}})
    self.assertTrue(uuidutils.is_uuid_like(created_volume['id']))
    created_volume_id = created_volume['id']
    found_volume = self.api.get_volume(created_volume_id)
    self.assertEqual(created_volume_id, found_volume['id'])
    self.assertEqual(self._vol_type_name, found_volume['volume_type'])
    self.assertEqual(created_group_id, found_volume['group_id'])
    found_volume = self._poll_volume_while(created_volume_id, ['creating'])
    self.assertEqual('available', found_volume['status'])
    created_group_snapshot = self.api.post_group_snapshot({'group_snapshot': {'group_id': created_group_id}})
    self.assertTrue(uuidutils.is_uuid_like(created_group_snapshot['id']))
    created_group_snapshot_id = created_group_snapshot['id']
    found_group_snapshot = self._poll_group_snapshot_while(created_group_snapshot_id, [fields.GroupSnapshotStatus.CREATING])
    self.assertEqual(created_group_snapshot_id, found_group_snapshot['id'])
    self.assertEqual(created_group_id, found_group_snapshot['group_id'])
    self.assertEqual(fields.GroupSnapshotStatus.AVAILABLE, found_group_snapshot['status'])
    self.api.delete_group_snapshot(created_group_snapshot_id)
    found_group_snapshot = self._poll_group_snapshot_while(created_group_snapshot_id, [fields.GroupSnapshotStatus.DELETING])
    self.api.delete_group(created_group_id, {'delete': {'delete-volumes': True}})
    found_volume = self._poll_volume_while(created_volume_id, ['deleting'])
    found_group = self._poll_group_while(created_group_id, ['deleting'])
    self.assertFalse(found_group_snapshot)
    self.assertFalse(found_volume)
    self.assertFalse(found_group)
