diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-10-30 14:22:20 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2017-10-31 07:57:06 -0600 |
commit | b20a368daa581e3f649ac5a772da31cd09fdb484 (patch) | |
tree | edda6bab9d5918b7a989d4bf6425069094e1d625 /snaps/openstack/tests | |
parent | 85eb362579efbbc57e2851b2da2fd9599461f1ae (diff) |
Added method to OpenStackHeatStack to return OpenStackFlavor objects.
Continuation of the story SNAPS-153 for adding creator/state machine
instances for OpenStack objects deployed via Heat.
JIRA: SNAPS-174
Change-Id: I791e427efc487045c0f72cd836dabd9a66a4f60f
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/tests')
-rw-r--r-- | snaps/openstack/tests/create_flavor_tests.py | 2 | ||||
-rw-r--r-- | snaps/openstack/tests/create_stack_tests.py | 62 | ||||
-rw-r--r-- | snaps/openstack/tests/heat/flavor_heat_template.yaml | 27 |
3 files changed, 90 insertions, 1 deletions
diff --git a/snaps/openstack/tests/create_flavor_tests.py b/snaps/openstack/tests/create_flavor_tests.py index 4852d06..3eb07bd 100644 --- a/snaps/openstack/tests/create_flavor_tests.py +++ b/snaps/openstack/tests/create_flavor_tests.py @@ -399,7 +399,7 @@ def validate_flavor(nova, flavor_settings, flavor): equals = False break - swap = str() + swap = None if flavor_settings.swap != 0: swap = flavor_settings.swap diff --git a/snaps/openstack/tests/create_stack_tests.py b/snaps/openstack/tests/create_stack_tests.py index 8f9339a..94085a0 100644 --- a/snaps/openstack/tests/create_stack_tests.py +++ b/snaps/openstack/tests/create_stack_tests.py @@ -589,6 +589,68 @@ class CreateStackVolumeTests(OSIntegrationTestCase): self.assertEqual(volume_type.id, encryption.volume_type_id) +class CreateStackFlavorTests(OSIntegrationTestCase): + """ + Tests for the CreateStack class defined in create_stack.py + """ + + def setUp(self): + """ + Instantiates the CreateStack object that is responsible for downloading + and creating an OS stack file within OpenStack + """ + super(self.__class__, self).__start__() + + self.guid = self.__class__.__name__ + '-' + str(uuid.uuid4()) + + self.heat_creds = self.admin_os_creds + self.heat_creds.project_name = self.admin_os_creds.project_name + + self.heat_cli = heat_utils.heat_client(self.heat_creds) + self.stack_creator = None + + self.heat_tmplt_path = pkg_resources.resource_filename( + 'snaps.openstack.tests.heat', 'flavor_heat_template.yaml') + + stack_settings = StackSettings( + name=self.guid + '-stack', + template_path=self.heat_tmplt_path) + self.stack_creator = create_stack.OpenStackHeatStack( + self.heat_creds, stack_settings) + self.created_stack = self.stack_creator.create() + self.assertIsNotNone(self.created_stack) + + def tearDown(self): + """ + Cleans the stack and downloaded stack file + """ + if self.stack_creator: + try: + self.stack_creator.clean() + except: + pass + + super(self.__class__, self).__clean__() + + def test_retrieve_flavor_creator(self): + """ + Tests the creation of an OpenStack stack from Heat template file and + the retrieval of an OpenStackVolume creator/state machine instance + """ + flavor_creators = self.stack_creator.get_flavor_creators() + self.assertEqual(1, len(flavor_creators)) + + creator = flavor_creators[0] + self.assertTrue(creator.get_flavor().name.startswith(self.guid)) + self.assertEqual(1024, creator.get_flavor().ram) + self.assertEqual(200, creator.get_flavor().disk) + self.assertEqual(8, creator.get_flavor().vcpus) + self.assertEqual(0, creator.get_flavor().ephemeral) + self.assertIsNone(creator.get_flavor().swap) + self.assertEqual(1.0, creator.get_flavor().rxtx_factor) + self.assertTrue(creator.get_flavor().is_public) + + class CreateStackKeypairTests(OSIntegrationTestCase): """ Tests for the CreateStack class as they pertain to keypairs diff --git a/snaps/openstack/tests/heat/flavor_heat_template.yaml b/snaps/openstack/tests/heat/flavor_heat_template.yaml new file mode 100644 index 0000000..060c85c --- /dev/null +++ b/snaps/openstack/tests/heat/flavor_heat_template.yaml @@ -0,0 +1,27 @@ +############################################################################## +# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs") +# and others. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################## +heat_template_version: 2015-04-30 + +description: Simple template to deploy a single volume with encryption + +resources: + flavor: + type: OS::Nova::Flavor + properties: + ram: 1024 + vcpus: 8 + disk: 200 |