Steven Hardy | b1f9198 | 2014-04-04 15:35:55 +0100 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | # not use this file except in compliance with the License. You may obtain |
| 3 | # a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | # License for the specific language governing permissions and limitations |
| 11 | # under the License. |
| 12 | |
| 13 | import logging |
| 14 | |
| 15 | from tempest.api.orchestration import base |
| 16 | from tempest.common.utils import data_utils |
| 17 | from tempest import config |
| 18 | from tempest import test |
| 19 | |
| 20 | |
| 21 | CONF = config.CONF |
| 22 | LOG = logging.getLogger(__name__) |
| 23 | |
| 24 | |
| 25 | class CinderResourcesTest(base.BaseOrchestrationTest): |
| 26 | |
| 27 | @classmethod |
| 28 | def setUpClass(cls): |
| 29 | super(CinderResourcesTest, cls).setUpClass() |
| 30 | if not CONF.service_available.cinder: |
| 31 | raise cls.skipException('Cinder support is required') |
| 32 | |
| 33 | @test.attr(type='gate') |
| 34 | def test_cinder_volume_create_delete(self): |
| 35 | """Create and delete a volume via OS::Cinder::Volume.""" |
| 36 | stack_name = data_utils.rand_name('heat') |
| 37 | template = self.load_template('cinder_basic') |
| 38 | stack_identifier = self.create_stack(stack_name, template) |
| 39 | self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE') |
| 40 | |
| 41 | # Verify with cinder that the volume exists, with matching details |
| 42 | volume_id = self.get_stack_output(stack_identifier, 'volume_id') |
| 43 | self.assertIsNotNone(volume_id) |
| 44 | resp, volume = self.volumes_client.get_volume(volume_id) |
| 45 | self.assertEqual(200, resp.status) |
| 46 | self.assertEqual('available', volume.get('status')) |
| 47 | self.assertEqual(1, volume.get('size')) |
| 48 | self.assertEqual('a descriptive description', |
| 49 | volume.get('display_description')) |
| 50 | |
| 51 | # Verify the stack outputs are as expected |
| 52 | self.assertEqual('available', |
| 53 | self.get_stack_output(stack_identifier, 'status')) |
| 54 | self.assertEqual('1', |
| 55 | self.get_stack_output(stack_identifier, 'size')) |
| 56 | self.assertEqual('a descriptive description', |
| 57 | self.get_stack_output(stack_identifier, |
| 58 | 'display_description')) |