summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPanagiotis Karalis <pkaralis@intracom-telecom.com>2018-06-20 11:00:01 +0300
committerPanagiotis Karalis <pkaralis@intracom-telecom.com>2018-06-21 10:45:00 +0300
commitb24b949e50a742e96e3307426031e1fe3847b089 (patch)
tree3628b87eef59a5873d62cd06e079e238bfda79cc
parent485fe08235b7e2d06646b36c31b333e4b6096897 (diff)
Patch to make flavor configuration for tests more flexible.
JIRA: SNAPS-254 Change-Id: Ib81569df499bbf0652c2025fc7de37af92525f7f Signed-off-by: spisarski <s.pisarski@cablelabs.com> Signed-off-by: Panagiotis Karalis <pkaralis@intracom-telecom.com> (cherry picked from commit 44e8131216787127980558824b2a1def94fe317e)
-rw-r--r--snaps/file_utils.py1
-rw-r--r--snaps/openstack/tests/cluster_template_tests.py7
-rw-r--r--snaps/openstack/tests/create_instance_tests.py89
-rw-r--r--snaps/openstack/tests/create_stack_tests.py7
-rw-r--r--snaps/openstack/tests/openstack_tests.py27
-rw-r--r--snaps/openstack/utils/tests/nova_utils_tests.py8
-rw-r--r--snaps/provisioning/tests/ansible_utils_tests.py9
7 files changed, 93 insertions, 55 deletions
diff --git a/snaps/file_utils.py b/snaps/file_utils.py
index e4e3934..a520221 100644
--- a/snaps/file_utils.py
+++ b/snaps/file_utils.py
@@ -12,6 +12,7 @@
# 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.
+
import os
import logging
diff --git a/snaps/openstack/tests/cluster_template_tests.py b/snaps/openstack/tests/cluster_template_tests.py
index b08f260..eda790d 100644
--- a/snaps/openstack/tests/cluster_template_tests.py
+++ b/snaps/openstack/tests/cluster_template_tests.py
@@ -69,9 +69,10 @@ class CreateClusterTemplateTests(OSIntegrationTestCase):
self.image_creator = OpenStackImage(self.os_creds, os_image_settings)
- self.flavor_creator = OpenStackFlavor(
- self.os_creds, FlavorConfig(
- name=self.guid + '-flavor', ram=512, disk=10, vcpus=1))
+ flavor_config = openstack_tests.get_flavor_config(
+ name=self.guid + '-flavor', ram=512, disk=10,
+ vcpus=1, metadata=self.flavor_metadata)
+ self.flavor_creator = OpenStackFlavor(self.os_creds, flavor_config)
keypair_priv_filepath = 'tmp/' + self.guid
keypair_pub_filepath = keypair_priv_filepath + '.pub'
diff --git a/snaps/openstack/tests/create_instance_tests.py b/snaps/openstack/tests/create_instance_tests.py
index 6d3fa50..5ee6904 100644
--- a/snaps/openstack/tests/create_instance_tests.py
+++ b/snaps/openstack/tests/create_instance_tests.py
@@ -24,7 +24,6 @@ from neutronclient.common.exceptions import (
InvalidIpForSubnetClient, BadRequest)
from snaps import file_utils
-from snaps.config.flavor import FlavorConfig
from snaps.config.image import ImageConfig
from snaps.config.keypair import KeypairConfig
from snaps.config.network import PortConfig, NetworkConfig, SubnetConfig
@@ -335,10 +334,11 @@ class SimpleHealthCheck(OSIntegrationTestCase):
if (self.flavor_metadata and
self.flavor_metadata.get('hw:mem_page_size') == 'large'):
self.flavor_ram = 1024
+ flavor_config = openstack_tests.get_flavor_config(
+ name=guid + '-flavor-name', ram=self.flavor_ram, disk=10,
+ vcpus=1, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(name=guid + '-flavor-name', ram=self.flavor_ram,
- disk=10, vcpus=1, metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
except Exception as e:
self.tearDown()
@@ -437,10 +437,11 @@ class CreateInstanceSimpleTests(OSIntegrationTestCase):
self.image_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=self.guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(name=self.guid + '-flavor-name', ram=256, disk=10,
- vcpus=2, metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
self.network_creator = None
except Exception as e:
@@ -615,10 +616,11 @@ class CreateInstanceExternalNetTests(OSIntegrationTestCase):
self.image_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(name=guid + '-flavor-name', ram=256, disk=10,
- vcpus=2, metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
self.port_settings = PortConfig(
@@ -737,10 +739,11 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase):
self.router_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(name=guid + '-flavor-name', ram=256, disk=10,
- vcpus=2, metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
self.keypair_creator = OpenStackKeypair(
@@ -1146,11 +1149,11 @@ class CreateInstanceIPv6NetworkTests(OSIntegrationTestCase):
self.os_creds, os_image_settings)
self.image_creator.create()
+ flavor_config = openstack_tests.get_flavor_config(
+ name=self.guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(
- name=self.guid + '-flavor-name', ram=256, disk=10, vcpus=2,
- metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
self.keypair_creator = OpenStackKeypair(
@@ -1385,10 +1388,11 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase):
self.network_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=self.guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(name=self.guid + '-flavor-name', ram=256, disk=10,
- vcpus=2, metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
except Exception as e:
self.tearDown()
@@ -1760,10 +1764,11 @@ class CreateInstanceOnComputeHost(OSIntegrationTestCase):
self.network_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=guid + '-flavor-name', ram=512, disk=1,
+ vcpus=1, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(name=guid + '-flavor-name', ram=512, disk=1,
- vcpus=1, metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
# Create Image
@@ -1909,11 +1914,11 @@ class InstanceSecurityGroupTests(OSIntegrationTestCase):
self.network_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=self.guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(name=self.guid + '-flavor-name', ram=256,
- disk=10, vcpus=2,
- metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
self.port_settings = PortConfig(
@@ -2246,10 +2251,11 @@ class CreateInstanceFromThreePartImage(OSIntegrationTestCase):
self.image_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(name=guid + '-flavor-name', ram=256, disk=10,
- vcpus=2, metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
# Create Network
@@ -2368,11 +2374,11 @@ class CreateInstanceMockOfflineTests(OSComponentTestCase):
self.network_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=self.guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.os_creds,
- FlavorConfig(
- name=self.guid + '-flavor-name', ram=256, disk=10,
- vcpus=1))
+ self.os_creds, flavor_config)
self.flavor_creator.create()
except Exception as e:
self.tearDown()
@@ -2910,11 +2916,11 @@ class CreateInstanceTwoNetTests(OSIntegrationTestCase):
self.os_creds, router_settings)
self.router_creator.create()
+ flavor_config = openstack_tests.get_flavor_config(
+ name=self.guid + '-flavor-name', ram=512, disk=10,
+ vcpus=2, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(name=self.guid + '-flavor-name', ram=512,
- disk=10, vcpus=2,
- metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
sec_grp_name = self.guid + '-sec-grp'
@@ -3094,10 +3100,11 @@ class CreateInstanceVolumeTests(OSIntegrationTestCase):
self.image_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=guid + '-flavor-name', ram=256, disk=1,
+ vcpus=2, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(name=guid + '-flavor-name', ram=256, disk=1,
- vcpus=2, metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
# Create Network
diff --git a/snaps/openstack/tests/create_stack_tests.py b/snaps/openstack/tests/create_stack_tests.py
index 17acede..dc04894 100644
--- a/snaps/openstack/tests/create_stack_tests.py
+++ b/snaps/openstack/tests/create_stack_tests.py
@@ -150,10 +150,11 @@ class CreateStackSuccessTests(OSIntegrationTestCase):
self.image_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=self.guid + '-flavor-name', ram=256, disk=10,
+ vcpus=1, metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(
- name=self.guid + '-flavor-name', ram=256, disk=10, vcpus=1))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
self.network_name = self.guid + '-net'
diff --git a/snaps/openstack/tests/openstack_tests.py b/snaps/openstack/tests/openstack_tests.py
index 516d24d..b4101a6 100644
--- a/snaps/openstack/tests/openstack_tests.py
+++ b/snaps/openstack/tests/openstack_tests.py
@@ -16,6 +16,7 @@ import logging
import re
from snaps import file_utils
+from snaps.config.flavor import FlavorConfig
from snaps.config.image import ImageConfig
from snaps.config.network import NetworkConfig, SubnetConfig
from snaps.config.router import RouterConfig
@@ -328,6 +329,32 @@ def get_pub_net_config(
netconf_override=netconf_override)
+def get_flavor_config(name, ram, disk, vcpus, ephemeral=None, swap=None,
+ rxtx_factor=None, is_public=None, metadata=None):
+ if metadata:
+ if 'ram' in metadata:
+ ram = metadata['ram']
+ if 'disk' in metadata:
+ disk = metadata['disk']
+ if 'vcpus' in metadata:
+ vcpus = metadata['vcpus']
+ if 'ephemeral' in metadata:
+ ephemeral = metadata['ephemeral']
+ if 'swap' in metadata:
+ swap = metadata['swap']
+ if 'rxtx_factor' in metadata:
+ rxtx_factor = metadata['rxtx_factor']
+ if 'is_public' in metadata:
+ is_public = metadata['is_public']
+ if 'metadata' in metadata:
+ metadata = metadata['metadata']
+
+ return FlavorConfig(
+ name=name, ram=ram, disk=disk, vcpus=vcpus, ephemeral=ephemeral,
+ swap=swap, rxtx_factor=rxtx_factor, is_public=is_public,
+ metadata=metadata)
+
+
class OSNetworkConfig:
"""
Represents the settings required for the creation of a network in OpenStack
diff --git a/snaps/openstack/utils/tests/nova_utils_tests.py b/snaps/openstack/utils/tests/nova_utils_tests.py
index 1f60b9b..93aa7bf 100644
--- a/snaps/openstack/utils/tests/nova_utils_tests.py
+++ b/snaps/openstack/utils/tests/nova_utils_tests.py
@@ -400,11 +400,11 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
self.os_creds, network_settings)
self.network_creator.create()
+ flavor_settings = FlavorConfig(
+ name=guid + '-flavor', ram=256, disk=10, vcpus=1,
+ metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(
- self.os_creds,
- FlavorConfig(
- name=guid + '-flavor-name', ram=256, disk=10, vcpus=1,
- metadata=self.flavor_metadata))
+ self.os_creds, flavor_settings)
self.flavor_creator.create()
# Create Volume
diff --git a/snaps/provisioning/tests/ansible_utils_tests.py b/snaps/provisioning/tests/ansible_utils_tests.py
index 142e8ad..9ee17d4 100644
--- a/snaps/provisioning/tests/ansible_utils_tests.py
+++ b/snaps/provisioning/tests/ansible_utils_tests.py
@@ -105,11 +105,12 @@ class AnsibleProvisioningTests(OSIntegrationTestCase):
self.router_creator.create()
# Create Flavor
+ flavor_config = openstack_tests.get_flavor_config(
+ name=guid + '-flavor-name', ram=2048, disk=10,
+ vcpus=2, metadata=self.flavor_metadata)
+
self.flavor_creator = create_flavor.OpenStackFlavor(
- self.admin_os_creds,
- FlavorConfig(
- name=guid + '-flavor-name', ram=2048, disk=10, vcpus=2,
- metadata=self.flavor_metadata))
+ self.admin_os_creds, flavor_config)
self.flavor_creator.create()
# Create Key/Pair