diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py index 3f8db3df5f..bf0cc70e6a 100755 --- a/tempest/cmd/javelin.py +++ b/tempest/cmd/javelin.py @@ -213,9 +213,7 @@ class JavelinCheck(unittest.TestCase): self.check_users() self.check_objects() self.check_servers() - # TODO(sdague): Volumes not yet working, bring it back once the - # code is self testing. - # self.check_volumes() + self.check_volumes() self.check_telemetry() def check_users(self): @@ -300,15 +298,15 @@ class JavelinCheck(unittest.TestCase): LOG.info("checking volumes") for volume in self.res['volumes']: client = client_for_user(volume['owner']) - found = _get_volume_by_name(client, volume['name']) + vol_body = _get_volume_by_name(client, volume['name']) self.assertIsNotNone( - found, + vol_body, "Couldn't find expected volume %s" % volume['name']) # Verify that a volume's attachment retrieved server_id = _get_server_by_name(client, volume['server'])['id'] - attachment = self.client.get_attachment_from_volume(volume) - self.assertEqual(volume['id'], attachment['volume_id']) + attachment = client.volumes.get_attachment_from_volume(vol_body) + self.assertEqual(vol_body['id'], attachment['volume_id']) self.assertEqual(server_id, attachment['server_id']) def _confirm_telemetry_sample(self, server, sample): @@ -501,8 +499,8 @@ def destroy_servers(servers): def _get_volume_by_name(client, name): r, body = client.volumes.list_volumes() - for volume in body['volumes']: - if name == volume['name']: + for volume in body: + if name == volume['display_name']: return volume return None @@ -512,11 +510,15 @@ def create_volumes(volumes): client = client_for_user(volume['owner']) # only create a volume if the name isn't here - r, body = client.volumes.list_volumes() - if any(item['name'] == volume['name'] for item in body): + if _get_volume_by_name(client, volume['name']): + LOG.info("volume '%s' already exists" % volume['name']) continue - client.volumes.create_volume(volume['name'], volume['size']) + size = volume['gb'] + v_name = volume['name'] + resp, body = client.volumes.create_volume(size=size, + display_name=v_name) + client.volumes.wait_for_volume_status(body['id'], 'available') def destroy_volumes(volumes): @@ -529,9 +531,10 @@ def destroy_volumes(volumes): def attach_volumes(volumes): for volume in volumes: client = client_for_user(volume['owner']) - server_id = _get_server_by_name(client, volume['server'])['id'] - client.volumes.attach_volume(volume['name'], server_id) + volume_id = _get_volume_by_name(client, volume['name'])['id'] + device = volume['device'] + client.volumes.attach_volume(volume_id, server_id, device) ####################### @@ -552,10 +555,8 @@ def create_resources(): create_objects(RES['objects']) create_images(RES['images']) create_servers(RES['servers']) - # TODO(sdague): volumes definition doesn't work yet, bring it - # back once we're actually executing the code - # create_volumes(RES['volumes']) - # attach_volumes(RES['volumes']) + create_volumes(RES['volumes']) + attach_volumes(RES['volumes']) def destroy_resources(): diff --git a/tempest/cmd/resources.yaml b/tempest/cmd/resources.yaml index 3450e1fe37..19ee6d595a 100644 --- a/tempest/cmd/resources.yaml +++ b/tempest/cmd/resources.yaml @@ -36,11 +36,13 @@ volumes: - name: assegai server: peltast owner: javelin - size: 1 + gb: 1 + device: /dev/vdb - name: pifpouf server: hoplite owner: javelin - size: 2 + gb: 2 + device: /dev/vdb servers: - name: peltast owner: javelin