summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2018-06-11 13:24:26 -0600
committerspisarski <s.pisarski@cablelabs.com>2018-06-11 13:27:37 -0600
commite6ec3766be49d69a44ca1e1348bbf5e6ed692c84 (patch)
tree70753322ccdd682dde81fb741d25041815f4f91b
parente0c640946294e6fc190f03f341e873e6db483291 (diff)
Added MTU network config and updated flavor_metadata test support
JIRA: SNAPS-315 Change-Id: Ie4cbab24ea0af41e93c475e04c9440422617466f Signed-off-by: spisarski <s.pisarski@cablelabs.com>
-rw-r--r--snaps/config/network.py5
-rw-r--r--snaps/config/tests/network_tests.py9
-rw-r--r--snaps/domain/network.py4
-rw-r--r--snaps/domain/test/network_tests.py4
-rw-r--r--snaps/openstack/tests/conf/os_env.yaml.template5
-rw-r--r--snaps/openstack/tests/create_network_tests.py12
-rw-r--r--snaps/openstack/tests/create_stack_tests.py12
-rw-r--r--snaps/openstack/tests/heat/floating_ip_heat_template.yaml4
-rw-r--r--snaps/openstack/tests/openstack_tests.py16
-rw-r--r--snaps/openstack/tests/os_source_file_test.py8
-rw-r--r--snaps/openstack/utils/tests/neutron_utils_tests.py12
-rw-r--r--snaps/openstack/utils/tests/nova_utils_tests.py19
-rw-r--r--snaps/provisioning/tests/ansible_utils_tests.py8
-rw-r--r--snaps/test_runner.py7
14 files changed, 82 insertions, 43 deletions
diff --git a/snaps/config/network.py b/snaps/config/network.py
index 49d1a7a..620640f 100644
--- a/snaps/config/network.py
+++ b/snaps/config/network.py
@@ -46,6 +46,7 @@ class NetworkConfig(object):
:param segmentation_id: the id of the segmentation
(this is required when network_type is 'vlan')
:param subnets or subnet_settings: List of SubnetConfig objects.
+ :param mtu: MTU setting (optional)
:return:
"""
@@ -88,6 +89,8 @@ class NetworkConfig(object):
if not self.name or len(self.name) < 1:
raise NetworkConfigError('Name required for networks')
+ self.mtu = kwargs.get('mtu')
+
def get_project_id(self, os_creds):
"""
Returns the project ID for a given project_name or None
@@ -144,6 +147,8 @@ class NetworkConfig(object):
out['provider:segmentation_id'] = self.segmentation_id
if self.external:
out['router:external'] = self.external
+ if self.mtu:
+ out['mtu'] = self.mtu
return {'network': out}
diff --git a/snaps/config/tests/network_tests.py b/snaps/config/tests/network_tests.py
index 62ce067..cbc71af 100644
--- a/snaps/config/tests/network_tests.py
+++ b/snaps/config/tests/network_tests.py
@@ -42,6 +42,7 @@ class NetworkConfigUnitTests(unittest.TestCase):
self.assertIsNone(settings.network_type)
self.assertIsNone(settings.segmentation_id)
self.assertEqual(0, len(settings.subnet_settings))
+ self.assertIsNone(settings.mtu)
def test_config_with_name_only(self):
settings = NetworkConfig(**{'name': 'foo'})
@@ -53,13 +54,14 @@ class NetworkConfigUnitTests(unittest.TestCase):
self.assertIsNone(settings.network_type)
self.assertIsNone(settings.segmentation_id)
self.assertEqual(0, len(settings.subnet_settings))
+ self.assertIsNone(settings.mtu)
def test_all(self):
sub_settings = SubnetConfig(name='foo-subnet', cidr='10.0.0.0/24')
settings = NetworkConfig(
name='foo', admin_state_up=False, shared=True, project_name='bar',
external=True, network_type='vlan', physical_network='phy',
- segmentation_id=2366, subnet_settings=[sub_settings])
+ segmentation_id=2366, subnet_settings=[sub_settings], mtu=999)
self.assertEqual('foo', settings.name)
self.assertFalse(settings.admin_state_up)
self.assertTrue(settings.shared)
@@ -70,6 +72,7 @@ class NetworkConfigUnitTests(unittest.TestCase):
self.assertEqual(2366, settings.segmentation_id)
self.assertEqual(1, len(settings.subnet_settings))
self.assertEqual('foo-subnet', settings.subnet_settings[0].name)
+ self.assertEqual(999, settings.mtu)
def test_config_all(self):
settings = NetworkConfig(
@@ -79,7 +82,8 @@ class NetworkConfigUnitTests(unittest.TestCase):
'segmentation_id': 2366,
'subnets':
[{'subnet': {'name': 'foo-subnet',
- 'cidr': '10.0.0.0/24'}}]})
+ 'cidr': '10.0.0.0/24'}}],
+ 'mtu': 999})
self.assertEqual('foo', settings.name)
self.assertFalse(settings.admin_state_up)
self.assertTrue(settings.shared)
@@ -90,6 +94,7 @@ class NetworkConfigUnitTests(unittest.TestCase):
self.assertEqual(2366, settings.segmentation_id)
self.assertEqual(1, len(settings.subnet_settings))
self.assertEqual('foo-subnet', settings.subnet_settings[0].name)
+ self.assertEqual(999, settings.mtu)
class SubnetConfigUnitTests(unittest.TestCase):
diff --git a/snaps/domain/network.py b/snaps/domain/network.py
index 9f634aa..3d5e4af 100644
--- a/snaps/domain/network.py
+++ b/snaps/domain/network.py
@@ -39,6 +39,7 @@ class Network:
self.external = kwargs.get('router:external', kwargs.get('external'))
self.type = kwargs.get('provider:network_type', kwargs.get('type'))
self.subnets = kwargs.get('subnets', list())
+ self.mtu = kwargs.get('mtu')
def __eq__(self, other):
return (self.name == other.name and self.id == other.id and
@@ -46,7 +47,8 @@ class Network:
self.admin_state_up == other.admin_state_up and
self.shared == other.shared and
self.external == other.external and
- self.subnets == other.subnets)
+ self.subnets == other.subnets and
+ self.mtu == other.mtu)
class Subnet:
diff --git a/snaps/domain/test/network_tests.py b/snaps/domain/test/network_tests.py
index 5f70c3f..2c4c841 100644
--- a/snaps/domain/test/network_tests.py
+++ b/snaps/domain/test/network_tests.py
@@ -31,7 +31,8 @@ class NetworkObjectTests(unittest.TestCase):
network = Network(
**{'name': 'foo', 'id': 'bar', 'project_id': 'proj1',
'provider:network_type': 'flat', 'admin_state_up': False,
- 'shared': True, 'router:external': False, 'subnets': [subnet]})
+ 'shared': True, 'router:external': False, 'subnets': [subnet],
+ 'mtu': 999})
self.assertEqual('foo', network.name)
self.assertEqual('bar', network.id)
self.assertEqual('proj1', network.project_id)
@@ -40,6 +41,7 @@ class NetworkObjectTests(unittest.TestCase):
self.assertFalse(network.external)
self.assertTrue(network.shared)
self.assertEqual([subnet], network.subnets)
+ self.assertEqual(999, network.mtu)
def test_construction_kwargs_2(self):
subnet = Subnet(
diff --git a/snaps/openstack/tests/conf/os_env.yaml.template b/snaps/openstack/tests/conf/os_env.yaml.template
index 36e3cfd..53d500f 100644
--- a/snaps/openstack/tests/conf/os_env.yaml.template
+++ b/snaps/openstack/tests/conf/os_env.yaml.template
@@ -14,4 +14,7 @@
#os_auth_url: http://<host>:<port>/
#project_name: admin
#identity_api_version: 3
-#ext_net: <external network name> \ No newline at end of file
+#ext_net: <external network name>
+
+flavor_metadata:
+ hw:mem_page_size: large
diff --git a/snaps/openstack/tests/create_network_tests.py b/snaps/openstack/tests/create_network_tests.py
index 41eb45a..26c57bd 100644
--- a/snaps/openstack/tests/create_network_tests.py
+++ b/snaps/openstack/tests/create_network_tests.py
@@ -366,8 +366,10 @@ class CreateNetworkSuccessTests(OSIntegrationTestCase):
guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
self.net_config = openstack_tests.get_pub_net_config(
project_name=self.os_creds.project_name,
- net_name=guid + '-pub-net', subnet_name=guid + '-pub-subnet',
- router_name=guid + '-pub-router', external_net=self.ext_net_name,
+ net_name="{}-{}".format(guid, 'pub-net'), mtu=999,
+ subnet_name="{}-{}".format(guid, 'pub-subnet'),
+ router_name="{}-{}".format(guid, 'pub-router'),
+ external_net=self.ext_net_name,
netconf_override=self.netconf_override)
self.neutron = neutron_utils.neutron_client(
@@ -402,7 +404,7 @@ class CreateNetworkSuccessTests(OSIntegrationTestCase):
self.assertTrue(neutron_utils_tests.validate_network(
self.neutron, self.keystone,
self.net_creator.network_settings.name, True,
- self.os_creds.project_name))
+ self.os_creds.project_name, mtu=999))
# Validate subnets
self.assertTrue(neutron_utils_tests.validate_subnet(
@@ -423,7 +425,7 @@ class CreateNetworkSuccessTests(OSIntegrationTestCase):
self.assertTrue(neutron_utils_tests.validate_network(
self.neutron, self.keystone,
self.net_creator.network_settings.name, True,
- self.os_creds.project_name))
+ self.os_creds.project_name, mtu=999))
neutron_utils.delete_network(
self.neutron, self.net_creator.get_network())
@@ -453,7 +455,7 @@ class CreateNetworkSuccessTests(OSIntegrationTestCase):
self.assertTrue(neutron_utils_tests.validate_network(
self.neutron, self.keystone,
self.net_creator.network_settings.name, True,
- self.os_creds.project_name))
+ self.os_creds.project_name, mtu=999))
# Validate subnets
self.assertTrue(neutron_utils_tests.validate_subnet(
diff --git a/snaps/openstack/tests/create_stack_tests.py b/snaps/openstack/tests/create_stack_tests.py
index dc04894..a320aa0 100644
--- a/snaps/openstack/tests/create_stack_tests.py
+++ b/snaps/openstack/tests/create_stack_tests.py
@@ -569,14 +569,15 @@ class CreateStackNestedResourceTests(OSIntegrationTestCase):
self.image_creator = OpenStackImage(
self.os_creds, openstack_tests.cirros_image_settings(
- name=self.guid + '-image',
+ name="{}-{}".format(self.guid, 'image'),
image_metadata=self.image_metadata))
self.image_creator.create()
+ flavor_config = openstack_tests.get_flavor_config(
+ name="{}-{}".format(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()
env_values = {
@@ -593,7 +594,8 @@ class CreateStackNestedResourceTests(OSIntegrationTestCase):
'snaps.openstack.tests.heat', 'agent.yaml')
stack_settings = StackConfig(
- name=self.__class__.__name__ + '-' + str(self.guid) + '-stack',
+ name="{}-{}".format(
+ self.__class__.__name__, str(self.guid) + '-stack'),
template_path=heat_tmplt_path,
resource_files=[heat_resource_path],
env_values=env_values)
diff --git a/snaps/openstack/tests/heat/floating_ip_heat_template.yaml b/snaps/openstack/tests/heat/floating_ip_heat_template.yaml
index a191acc..c8a5f1d 100644
--- a/snaps/openstack/tests/heat/floating_ip_heat_template.yaml
+++ b/snaps/openstack/tests/heat/floating_ip_heat_template.yaml
@@ -88,12 +88,16 @@ resources:
ram: 1024
vcpus: 2
disk: 2
+ extra_specs:
+ hw:mem_page_size: large
flavor2:
type: OS::Nova::Flavor
properties:
ram: 1024
vcpus: 2
disk: 2
+ extra_specs:
+ hw:mem_page_size: large
network:
type: OS::Neutron::Net
diff --git a/snaps/openstack/tests/openstack_tests.py b/snaps/openstack/tests/openstack_tests.py
index e8e0b75..f3a1df7 100644
--- a/snaps/openstack/tests/openstack_tests.py
+++ b/snaps/openstack/tests/openstack_tests.py
@@ -313,18 +313,18 @@ def ubuntu_image_settings(name, url=None, image_metadata=None,
public=public)
-def get_priv_net_config(project_name, net_name, subnet_name, router_name=None,
- cidr='10.55.0.0/24', external_net=None,
- netconf_override=None):
+def get_priv_net_config(project_name, net_name, mtu=None, subnet_name=None,
+ router_name=None, cidr='10.55.0.0/24',
+ external_net=None, netconf_override=None):
return OSNetworkConfig(
- project_name, net_name, subnet_name, cidr, router_name,
+ project_name, net_name, mtu, subnet_name, cidr, router_name,
external_gateway=external_net, netconf_override=netconf_override)
def get_pub_net_config(
- project_name, net_name, subnet_name=None, router_name=None,
+ project_name, net_name, mtu=None, subnet_name=None, router_name=None,
cidr='10.55.1.0/24', external_net=None, netconf_override=None):
- return OSNetworkConfig(project_name, net_name, subnet_name, cidr,
+ return OSNetworkConfig(project_name, net_name, mtu, subnet_name, cidr,
router_name, external_gateway=external_net,
netconf_override=netconf_override)
@@ -395,7 +395,7 @@ class OSNetworkConfig:
physical_network and segmentation_id
"""
- def __init__(self, project_name, net_name, subnet_name=None,
+ def __init__(self, project_name, net_name, mtu=None, subnet_name=None,
subnet_cidr=None, router_name=None, external_gateway=None,
netconf_override=None):
"""
@@ -405,7 +405,7 @@ class OSNetworkConfig:
"""
if subnet_name and subnet_cidr:
network_conf = NetworkConfig(
- name=net_name, subnet_settings=[
+ name=net_name, mtu=mtu, subnet_settings=[
SubnetConfig(cidr=subnet_cidr, name=subnet_name)])
else:
network_conf = NetworkConfig(name=net_name)
diff --git a/snaps/openstack/tests/os_source_file_test.py b/snaps/openstack/tests/os_source_file_test.py
index c632e02..bd98ad3 100644
--- a/snaps/openstack/tests/os_source_file_test.py
+++ b/snaps/openstack/tests/os_source_file_test.py
@@ -63,7 +63,13 @@ class OSComponentTestCase(unittest.TestCase):
test_conf = file_utils.read_yaml(dev_os_env_file)
self.ext_net_name = test_conf.get('ext_net')
- self.flavor_metadata = flavor_metadata
+ if flavor_metadata:
+ self.flavor_metadata = flavor_metadata
+ else:
+ os_env_dict = file_utils.read_yaml(dev_os_env_file)
+ flavor_metadata = os_env_dict.get('flavor_metadata')
+ if flavor_metadata:
+ self.flavor_metadata = {'metadata': flavor_metadata}
self.image_metadata = image_metadata
@staticmethod
diff --git a/snaps/openstack/utils/tests/neutron_utils_tests.py b/snaps/openstack/utils/tests/neutron_utils_tests.py
index d43b969..a55f779 100644
--- a/snaps/openstack/utils/tests/neutron_utils_tests.py
+++ b/snaps/openstack/utils/tests/neutron_utils_tests.py
@@ -575,9 +575,11 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
"""
subnet_setting = self.net_config.network_settings.subnet_settings[0]
self.net_config = openstack_tests.OSNetworkConfig(
- self.os_creds.project_name, self.net_config.network_settings.name,
- subnet_setting.name, subnet_setting.cidr,
- self.net_config.router_settings.name, self.ext_net_name)
+ project_name=self.os_creds.project_name,
+ net_name=self.net_config.network_settings.name,
+ subnet_name=subnet_setting.name, subnet_cidr=subnet_setting.cidr,
+ router_name=self.net_config.router_settings.name,
+ external_gateway=self.ext_net_name)
self.router = neutron_utils.create_router(
self.neutron, self.os_creds, self.net_config.router_settings)
validate_router(
@@ -1108,7 +1110,7 @@ Validation routines
"""
-def validate_network(neutron, keystone, name, exists, project_name):
+def validate_network(neutron, keystone, name, exists, project_name, mtu=None):
"""
Returns true if a network for a given name DOES NOT exist if the exists
parameter is false conversely true. Returns false if a network for a given
@@ -1126,6 +1128,8 @@ def validate_network(neutron, keystone, name, exists, project_name):
return True
if not exists and not network:
return True
+ if mtu:
+ return mtu == network.mtu
return False
diff --git a/snaps/openstack/utils/tests/nova_utils_tests.py b/snaps/openstack/utils/tests/nova_utils_tests.py
index 3e55558..7c343f8 100644
--- a/snaps/openstack/utils/tests/nova_utils_tests.py
+++ b/snaps/openstack/utils/tests/nova_utils_tests.py
@@ -269,16 +269,17 @@ class NovaUtilsInstanceTests(OSComponentTestCase):
self.image_creator.create()
network_settings = openstack_tests.get_priv_net_config(
- self.os_creds.project_name, guid + '-net',
- guid + '-subnet').network_settings
+ project_name=self.os_creds.project_name,
+ net_name="{}-{}".format(guid, 'net'),
+ subnet_name="{}-{}".format(guid, 'subnet')).network_settings
self.network_creator = OpenStackNetwork(
self.os_creds, network_settings)
self.network_creator.create()
- self.flavor_creator = OpenStackFlavor(
- self.os_creds,
- FlavorConfig(
- name=guid + '-flavor-name', ram=256, disk=10, vcpus=1))
+ flavor_config = openstack_tests.get_flavor_config(
+ name="{}-{}".format(guid, 'flavor-name'), ram=256, disk=10,
+ vcpus=1, metadata=self.flavor_metadata)
+ self.flavor_creator = OpenStackFlavor(self.os_creds, flavor_config)
self.flavor_creator.create()
port_settings = PortConfig(
@@ -394,8 +395,10 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
self.image_creator.create()
network_settings = openstack_tests.get_priv_net_config(
- self.os_creds.project_name, guid + '-net',
- guid + '-subnet').network_settings
+ project_name=self.os_creds.project_name,
+ net_name="{}-{}".format(guid, 'net'),
+ subnet_name="{}-{}".format(guid, 'subnet')).network_settings
+
self.network_creator = OpenStackNetwork(
self.os_creds, network_settings)
self.network_creator.create()
diff --git a/snaps/provisioning/tests/ansible_utils_tests.py b/snaps/provisioning/tests/ansible_utils_tests.py
index 9ee17d4..209b1e0 100644
--- a/snaps/provisioning/tests/ansible_utils_tests.py
+++ b/snaps/provisioning/tests/ansible_utils_tests.py
@@ -19,7 +19,6 @@ import os
import pkg_resources
from scp import SCPClient
-from snaps.config.flavor import FlavorConfig
from snaps.config.keypair import KeypairConfig
from snaps.config.network import PortConfig
from snaps.config.security_group import (
@@ -84,14 +83,15 @@ class AnsibleProvisioningTests(OSIntegrationTestCase):
os_image_settings = openstack_tests.ubuntu_image_settings(
name=guid + '-' + '-image',
image_metadata=self.image_metadata)
- self.image_creator = create_image.OpenStackImage(self.os_creds,
- os_image_settings)
+ self.image_creator = create_image.OpenStackImage(
+ self.os_creds, os_image_settings)
self.image_creator.create()
# First network is public
self.pub_net_config = openstack_tests.get_pub_net_config(
project_name=self.os_creds.project_name,
- net_name=guid + '-pub-net', subnet_name=guid + '-pub-subnet',
+ net_name=guid + '-pub-net',
+ mtu=1450, subnet_name=guid + '-pub-subnet',
router_name=guid + '-pub-router',
external_net=self.ext_net_name)
diff --git a/snaps/test_runner.py b/snaps/test_runner.py
index 830881a..cddfdef 100644
--- a/snaps/test_runner.py
+++ b/snaps/test_runner.py
@@ -185,7 +185,8 @@ def main(arguments):
flavor_metadata = None
if arguments.flavor_metadata:
- flavor_metadata = json.loads(arguments.flavor_metadata)
+ flavor_metadata = {
+ 'metadata': {'hw:mem_page_size': arguments.flavor_metadata}}
image_metadata = None
if arguments.image_metadata_file:
@@ -321,8 +322,8 @@ if __name__ == '__main__':
'network and is able to create users and groups')
parser.add_argument(
'-fm', '--flavor-meta', dest='flavor_metadata',
- help='JSON string to be used as flavor metadata for all test instances'
- ' created')
+ help='hw:mem_page_size flavor setting value (i.e. large). '
+ 'Required for DPDK')
parser.add_argument(
'-im', '--image-meta', dest='image_metadata_file', default=None,
help='Location of YAML file containing the image metadata')