summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDan Radez <dradez@redhat.com>2016-09-26 20:02:30 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-09-26 20:02:30 +0000
commit8d6e0e73023eeaeef681880bad87a5ea8044bc73 (patch)
tree040dabe09fc9ef5221cf8938e9ebf614d49656cc /tests
parentdd6bb69f77dda4d89876efd1524e907a1bf44748 (diff)
parent38de9ff18e44e5c3c1393c060481fbbb27543704 (diff)
Merge "migrating to proposed common network settings file"
Diffstat (limited to 'tests')
-rw-r--r--tests/config/network_settings_duplicate_nic.yaml115
-rw-r--r--tests/config/network_settings_missing_required_nic.yaml113
-rw-r--r--tests/config/network_settings_nic1_reserved.yaml113
-rw-r--r--tests/config/network_settings_nics_not_specified.yaml107
-rw-r--r--tests/test_apex_network_environment.py119
-rw-r--r--tests/test_apex_network_settings.py136
6 files changed, 183 insertions, 520 deletions
diff --git a/tests/config/network_settings_duplicate_nic.yaml b/tests/config/network_settings_duplicate_nic.yaml
deleted file mode 100644
index 24dd5ca0..00000000
--- a/tests/config/network_settings_duplicate_nic.yaml
+++ /dev/null
@@ -1,115 +0,0 @@
-# This configuration file defines Network Environment for a
-# Baremetal Deployment of OPNFV. It contains default values
-# for 4 following networks:
-#
-# - admin
-# - private*
-# - public
-# - storage*
-#
-# *) optional networks
-#
-# Any values missing from this configuration file will be
-# auto-detected by deployment script from the existing network
-# configuration of the jumphost.
-#
-# Optional networks will be consolidated with the admin network
-# if not explicitely configured.
-#
-# See short description of the networks in the comments below.
-#
-
-# DNS Servers for all nodes, comma delimited list
-dns_servers: ["8.8.8.8", "8.8.4.4"]
-
-# "admin" is the short name for Control Plane Network.
-# During OPNFV deployment it is used for node provisioning so
-# PXE boot should be enabled for the related interfaces on all
-# the nodes in the OPNFV cluster. After the deployment this
-# network is used as the OpenStack management network which
-# carries e.g. communication between its internal components.
-#
-admin_network:
- enabled: true
- network_type: bridged
- bridged_interface: ''
- bond_interfaces: ''
- compute_interface: eth1
- controller_interface: eth2
- usable_ip_range: 192.0.2.11,192.0.2.99
- gateway: 192.0.2.1
- provisioner_ip: 192.0.2.1
- cidr: 192.0.2.0/24
- dhcp_range: 192.0.2.2,192.0.2.10
- introspection_range: 192.0.2.100,192.0.2.120
-
-# "private" is an optional network used as underlying physical
-# network for virtual provider and tenant networks created by
-# users. Traffic between virtual machines is carried by this
-# network.
-#
-private_network:
- enabled: true
- vlan: native
- cidr: 11.0.0.0/24
- compute_interface: enp0s4
- controller_interface: nic3
-
-# "public" network is used for external connectivity.
-# The external network provides Internet access for virtual
-# machines. If floating IP range is defined for this network,
-# floating IP addresses can be used for accessing virtual
-# machines from outside of OPNFV cluster. Also external REST
-# API calls use this network.
-#
-public_network:
- enabled: true
- network_type: ''
- bridged_interface: ''
- compute_interface: eth1
- controller_interface: enp0s3
- vlan: native
- cidr: 192.168.37.0/24
- gateway: 192.168.37.1
- floating_ip_range: 192.168.37.200,192.168.37.220
- usable_ip_range: 192.168.37.10,192.168.37.199
- provisioner_ip: 192.168.37.1
-
-# "storage" is an optional network used by storage backends.
-# You can configure this network in order to reduce load on
-# Control Plane Network.
-#
-storage_network:
- enabled: true
- vlan: native
- cidr: 12.0.0.0/24
- compute_interface: eth5
- controller_interface: eth6
-
-#admin_network:
-# enabled: true
-# network_type: bridged #Indicates if this network will be bridged to an interface, or to a bond
-# bridged_interface: '' #Interface to bridge to for installer VM
-# bond_interfaces: '' #Interfaces to create bond with for installer VM
-# compute_interface: nic4 #Interface used for this network on the compute node. Can either be logical nic name like "nic1" or real name like "eth1"
-# controller_interface: nic4 #Interface used for this network on the controller node. Can either be logical nic name like "nic1" or real name like "eth1"
-# vlan: native #VLAN tag to use, native means none
-# usable_ip_range: 192.0.2.11,192.0.2.99 #Usable ip range, if empty entire range is usable, ex. 192.168.1.10,192.168.1.20
-# gateway: 192.0.2.1 #Gateway (only needed when public_network is disabled), if empty it is auto-detected
-# provisioner_ip: 192.0.2.1 #installer VM IP, if empty it is the next available IP in the admin subnet
-# cidr: 192.0.2.0/24 #subnet in CIDR format 192.168.1.0/24, if empty it will be auto-detected
-# dhcp_range: 192.0.2.2,192.0.2.10 #dhcp range for the admin network, if empty it will be automatically provisioned
-# introspection_range: 192.0.2.100,192.0.2.120 #Range used for introspection phase (examining nodes)
-#private_network:
-# enabled: false #If disabled, internal api traffic will collapse to admin_network
-#public_network:
-# enabled: true #If disabled, public_network traffic will collapse to admin network
-# network_type: ''
-# bridged_interface: ''
-# cidr: 192.168.37.0/24
-# gateway: 192.168.37.1
-# floating_ip_range: 192.168.37.200,192.168.37.220 #Range to allocate to floating IPs for the public network with Neutron
-# usable_ip_range: 192.168.37.10,192.168.37.199 #Usable IP range on the public network, usually this is a shared subnet
-# provisioner_ip: 192.168.37.1
-#storage_network:
-# enabled: false #If disabled, storage_network traffic will collapse to admin network
diff --git a/tests/config/network_settings_missing_required_nic.yaml b/tests/config/network_settings_missing_required_nic.yaml
deleted file mode 100644
index 18886278..00000000
--- a/tests/config/network_settings_missing_required_nic.yaml
+++ /dev/null
@@ -1,113 +0,0 @@
-# This configuration file defines Network Environment for a
-# Baremetal Deployment of OPNFV. It contains default values
-# for 4 following networks:
-#
-# - admin
-# - private*
-# - public
-# - storage*
-#
-# *) optional networks
-#
-# Any values missing from this configuration file will be
-# auto-detected by deployment script from the existing network
-# configuration of the jumphost.
-#
-# Optional networks will be consolidated with the admin network
-# if not explicitely configured.
-#
-# See short description of the networks in the comments below.
-#
-
-# DNS Servers for all nodes, comma delimited list
-dns_servers: ["8.8.8.8", "8.8.4.4"]
-
-# "admin" is the short name for Control Plane Network.
-# During OPNFV deployment it is used for node provisioning so
-# PXE boot should be enabled for the related interfaces on all
-# the nodes in the OPNFV cluster. After the deployment this
-# network is used as the OpenStack management network which
-# carries e.g. communication between its internal components.
-#
-admin_network:
- enabled: true
- network_type: bridged
- bridged_interface: ''
- bond_interfaces: ''
- compute_interface: eth1
- controller_interface: eth2
- usable_ip_range: 192.0.2.11,192.0.2.99
- gateway: 192.0.2.1
- provisioner_ip: 192.0.2.1
- cidr: 192.0.2.0/24
- dhcp_range: 192.0.2.2,192.0.2.10
- introspection_range: 192.0.2.100,192.0.2.120
-
-# "private" is an optional network used as underlying physical
-# network for virtual provider and tenant networks created by
-# users. Traffic between virtual machines is carried by this
-# network.
-#
-private_network:
- enabled: true
- vlan: native
- cidr: 11.0.0.0/24
- compute_interface: enp0s4
- controller_interface: nic3
-
-# "public" network is used for external connectivity.
-# The external network provides Internet access for virtual
-# machines. If floating IP range is defined for this network,
-# floating IP addresses can be used for accessing virtual
-# machines from outside of OPNFV cluster. Also external REST
-# API calls use this network.
-#
-public_network:
- enabled: true
- network_type: ''
- bridged_interface: ''
- vlan: native
- cidr: 192.168.37.0/24
- gateway: 192.168.37.1
- floating_ip_range: 192.168.37.200,192.168.37.220
- usable_ip_range: 192.168.37.10,192.168.37.199
- provisioner_ip: 192.168.37.1
-
-# "storage" is an optional network used by storage backends.
-# You can configure this network in order to reduce load on
-# Control Plane Network.
-#
-storage_network:
- enabled: true
- vlan: native
- cidr: 12.0.0.0/24
- compute_interface: eth5
- controller_interface: eth6
-
-#admin_network:
-# enabled: true
-# network_type: bridged #Indicates if this network will be bridged to an interface, or to a bond
-# bridged_interface: '' #Interface to bridge to for installer VM
-# bond_interfaces: '' #Interfaces to create bond with for installer VM
-# compute_interface: nic4 #Interface used for this network on the compute node. Can either be logical nic name like "nic1" or real name like "eth1"
-# controller_interface: nic4 #Interface used for this network on the controller node. Can either be logical nic name like "nic1" or real name like "eth1"
-# vlan: native #VLAN tag to use, native means none
-# usable_ip_range: 192.0.2.11,192.0.2.99 #Usable ip range, if empty entire range is usable, ex. 192.168.1.10,192.168.1.20
-# gateway: 192.0.2.1 #Gateway (only needed when public_network is disabled), if empty it is auto-detected
-# provisioner_ip: 192.0.2.1 #installer VM IP, if empty it is the next available IP in the admin subnet
-# cidr: 192.0.2.0/24 #subnet in CIDR format 192.168.1.0/24, if empty it will be auto-detected
-# dhcp_range: 192.0.2.2,192.0.2.10 #dhcp range for the admin network, if empty it will be automatically provisioned
-# introspection_range: 192.0.2.100,192.0.2.120 #Range used for introspection phase (examining nodes)
-#private_network:
-# enabled: false #If disabled, internal api traffic will collapse to admin_network
-#public_network:
-# enabled: true #If disabled, public_network traffic will collapse to admin network
-# network_type: ''
-# bridged_interface: ''
-# cidr: 192.168.37.0/24
-# gateway: 192.168.37.1
-# floating_ip_range: 192.168.37.200,192.168.37.220 #Range to allocate to floating IPs for the public network with Neutron
-# usable_ip_range: 192.168.37.10,192.168.37.199 #Usable IP range on the public network, usually this is a shared subnet
-# provisioner_ip: 192.168.37.1
-#storage_network:
-# enabled: false #If disabled, storage_network traffic will collapse to admin network
diff --git a/tests/config/network_settings_nic1_reserved.yaml b/tests/config/network_settings_nic1_reserved.yaml
deleted file mode 100644
index 8abcfc85..00000000
--- a/tests/config/network_settings_nic1_reserved.yaml
+++ /dev/null
@@ -1,113 +0,0 @@
-# This configuration file defines Network Environment for a
-# Baremetal Deployment of OPNFV. It contains default values
-# for 4 following networks:
-#
-# - admin
-# - private*
-# - public
-# - storage*
-#
-# *) optional networks
-#
-# Any values missing from this configuration file will be
-# auto-detected by deployment script from the existing network
-# configuration of the jumphost.
-#
-# Optional networks will be consolidated with the admin network
-# if not explicitely configured.
-#
-# See short description of the networks in the comments below.
-#
-
-# DNS Servers for all nodes, comma delimited list
-dns_servers: ["8.8.8.8", "8.8.4.4"]
-
-# "admin" is the short name for Control Plane Network.
-# During OPNFV deployment it is used for node provisioning so
-# PXE boot should be enabled for the related interfaces on all
-# the nodes in the OPNFV cluster. After the deployment this
-# network is used as the OpenStack management network which
-# carries e.g. communication between its internal components.
-#
-admin_network:
- enabled: true
- network_type: bridged
- bridged_interface: ''
- bond_interfaces: ''
- usable_ip_range: 192.0.2.11,192.0.2.99
- gateway: 192.0.2.1
- provisioner_ip: 192.0.2.1
- cidr: 192.0.2.0/24
- dhcp_range: 192.0.2.2,192.0.2.10
- introspection_range: 192.0.2.100,192.0.2.120
-
-# "private" is an optional network used as underlying physical
-# network for virtual provider and tenant networks created by
-# users. Traffic between virtual machines is carried by this
-# network.
-#
-private_network:
- enabled: true
- vlan: native
- cidr: 11.0.0.0/24
- compute_interface: enp0s4
- controller_interface: nic3
-
-# "public" network is used for external connectivity.
-# The external network provides Internet access for virtual
-# machines. If floating IP range is defined for this network,
-# floating IP addresses can be used for accessing virtual
-# machines from outside of OPNFV cluster. Also external REST
-# API calls use this network.
-#
-public_network:
- enabled: true
- network_type: ''
- bridged_interface: ''
- compute_interface: nic1
- controller_interface: enp0s3
- vlan: native
- cidr: 192.168.37.0/24
- gateway: 192.168.37.1
- floating_ip_range: 192.168.37.200,192.168.37.220
- usable_ip_range: 192.168.37.10,192.168.37.199
- provisioner_ip: 192.168.37.1
-
-# "storage" is an optional network used by storage backends.
-# You can configure this network in order to reduce load on
-# Control Plane Network.
-#
-storage_network:
- enabled: true
- vlan: native
- cidr: 12.0.0.0/24
- compute_interface: eth5
- controller_interface: eth6
-
-#admin_network:
-# enabled: true
-# network_type: bridged #Indicates if this network will be bridged to an interface, or to a bond
-# bridged_interface: '' #Interface to bridge to for installer VM
-# bond_interfaces: '' #Interfaces to create bond with for installer VM
-# overcloud_compute_interface: nic4 #Interface used for this network on the compute node. Can either be logical nic name like "nic1" or real name like "eth1"
-# overcloud_controller_interface: nic4 #Interface used for this network on the controller node. Can either be logical nic name like "nic1" or real name like "eth1"
-# vlan: native #VLAN tag to use, native means none
-# usable_ip_range: 192.0.2.11,192.0.2.99 #Usable ip range, if empty entire range is usable, ex. 192.168.1.10,192.168.1.20
-# gateway: 192.0.2.1 #Gateway (only needed when public_network is disabled), if empty it is auto-detected
-# provisioner_ip: 192.0.2.1 #installer VM IP, if empty it is the next available IP in the admin subnet
-# cidr: 192.0.2.0/24 #subnet in CIDR format 192.168.1.0/24, if empty it will be auto-detected
-# dhcp_range: 192.0.2.2,192.0.2.10 #dhcp range for the admin network, if empty it will be automatically provisioned
-# introspection_range: 192.0.2.100,192.0.2.120 #Range used for introspection phase (examining nodes)
-#private_network:
-# enabled: false #If disabled, internal api traffic will collapse to admin_network
-#public_network:
-# enabled: true #If disabled, public_network traffic will collapse to admin network
-# network_type: ''
-# bridged_interface: ''
-# cidr: 192.168.37.0/24
-# gateway: 192.168.37.1
-# floating_ip_range: 192.168.37.200,192.168.37.220 #Range to allocate to floating IPs for the public network with Neutron
-# usable_ip_range: 192.168.37.10,192.168.37.199 #Usable IP range on the public network, usually this is a shared subnet
-# provisioner_ip: 192.168.37.1
-#storage_network:
-# enabled: false #If disabled, storage_network traffic will collapse to admin network
diff --git a/tests/config/network_settings_nics_not_specified.yaml b/tests/config/network_settings_nics_not_specified.yaml
deleted file mode 100644
index e5089435..00000000
--- a/tests/config/network_settings_nics_not_specified.yaml
+++ /dev/null
@@ -1,107 +0,0 @@
-# This configuration file defines Network Environment for a
-# Baremetal Deployment of OPNFV. It contains default values
-# for 4 following networks:
-#
-# - admin
-# - private*
-# - public
-# - storage*
-#
-# *) optional networks
-#
-# Any values missing from this configuration file will be
-# auto-detected by deployment script from the existing network
-# configuration of the jumphost.
-#
-# Optional networks will be consolidated with the admin network
-# if not explicitely configured.
-#
-# See short description of the networks in the comments below.
-#
-
-# DNS Servers for all nodes, comma delimited list
-dns_servers: ["8.8.8.8", "8.8.4.4"]
-
-# "admin" is the short name for Control Plane Network.
-# During OPNFV deployment it is used for node provisioning so
-# PXE boot should be enabled for the related interfaces on all
-# the nodes in the OPNFV cluster. After the deployment this
-# network is used as the OpenStack management network which
-# carries e.g. communication between its internal components.
-#
-admin_network:
- enabled: true
- network_type: bridged
- bridged_interface: ''
- bond_interfaces: ''
- usable_ip_range: 192.0.2.11,192.0.2.99
- gateway: 192.0.2.1
- provisioner_ip: 192.0.2.1
- cidr: 192.0.2.0/24
- dhcp_range: 192.0.2.2,192.0.2.10
- introspection_range: 192.0.2.100,192.0.2.120
-
-# "private" is an optional network used as underlying physical
-# network for virtual provider and tenant networks created by
-# users. Traffic between virtual machines is carried by this
-# network.
-#
-private_network:
- enabled: true
- vlan: native
- cidr: 11.0.0.0/24
-
-# "public" network is used for external connectivity.
-# The external network provides Internet access for virtual
-# machines. If floating IP range is defined for this network,
-# floating IP addresses can be used for accessing virtual
-# machines from outside of OPNFV cluster. Also external REST
-# API calls use this network.
-#
-public_network:
- enabled: true
- network_type: ''
- bridged_interface: ''
- vlan: native
- cidr: 192.168.37.0/24
- gateway: 192.168.37.1
- floating_ip_range: 192.168.37.200,192.168.37.220
- usable_ip_range: 192.168.37.10,192.168.37.199
- provisioner_ip: 192.168.37.1
-
-# "storage" is an optional network used by storage backends.
-# You can configure this network in order to reduce load on
-# Control Plane Network.
-#
-storage_network:
- enabled: true
- vlan: native
- cidr: 12.0.0.0/24
-
-#admin_network:
-# enabled: true
-# network_type: bridged #Indicates if this network will be bridged to an interface, or to a bond
-# bridged_interface: '' #Interface to bridge to for installer VM
-# bond_interfaces: '' #Interfaces to create bond with for installer VM
-# compute_interface: nic4 #Interface used for this network on the compute node. Can either be logical nic name like "nic1" or real name like "eth1"
-# controller_interface: nic4 #Interface used for this network on the controller node. Can either be logical nic name like "nic1" or real name like "eth1"
-# vlan: native #VLAN tag to use, native means none
-# usable_ip_range: 192.0.2.11,192.0.2.99 #Usable ip range, if empty entire range is usable, ex. 192.168.1.10,192.168.1.20
-# gateway: 192.0.2.1 #Gateway (only needed when public_network is disabled), if empty it is auto-detected
-# provisioner_ip: 192.0.2.1 #installer VM IP, if empty it is the next available IP in the admin subnet
-# cidr: 192.0.2.0/24 #subnet in CIDR format 192.168.1.0/24, if empty it will be auto-detected
-# dhcp_range: 192.0.2.2,192.0.2.10 #dhcp range for the admin network, if empty it will be automatically provisioned
-# introspection_range: 192.0.2.100,192.0.2.120 #Range used for introspection phase (examining nodes)
-#private_network:
-# enabled: false #If disabled, internal api traffic will collapse to admin_network
-#public_network:
-# enabled: true #If disabled, public_network traffic will collapse to admin network
-# network_type: ''
-# bridged_interface: ''
-# cidr: 192.168.37.0/24
-# gateway: 192.168.37.1
-# floating_ip_range: 192.168.37.200,192.168.37.220 #Range to allocate to floating IPs for the public network with Neutron
-# usable_ip_range: 192.168.37.10,192.168.37.199 #Usable IP range on the public network, usually this is a shared subnet
-# provisioner_ip: 192.168.37.1
-#storage_network:
-# enabled: false #If disabled, storage_network traffic will collapse to admin network
diff --git a/tests/test_apex_network_environment.py b/tests/test_apex_network_environment.py
index 673368e8..7c9b922f 100644
--- a/tests/test_apex_network_environment.py
+++ b/tests/test_apex_network_environment.py
@@ -9,11 +9,14 @@
import ipaddress
+from copy import copy
+
from apex.common.constants import (
- PUBLIC_NETWORK,
- PRIVATE_NETWORK,
+ EXTERNAL_NETWORK,
+ TENANT_NETWORK,
STORAGE_NETWORK,
- API_NETWORK)
+ API_NETWORK,
+ CONTROLLER)
from apex.network_settings import NetworkSettings
from apex.network_environment import (
NetworkEnvironment,
@@ -33,6 +36,12 @@ class TestNetworkEnvironment(object):
@classmethod
def setup_class(klass):
"""This method is run once for each class before any tests are run"""
+ klass.ns = NetworkSettings(
+ '../config/network/network_settings.yaml', True)
+ klass.ns_vlans = NetworkSettings(
+ '../config/network/network_settings_vlans.yaml', True)
+ klass.ns_ipv6 = NetworkSettings(
+ '../config/network/network_settings_v6.yaml', True)
@classmethod
def teardown_class(klass):
@@ -48,84 +57,108 @@ class TestNetworkEnvironment(object):
assert_raises(NetworkEnvException, NetworkEnvironment,
None, '../build/network-environment.yaml')
- def test_netenv_settings_public_network(self):
- ns = NetworkSettings('../config/network/network_settings.yaml', True)
+ def test_netenv_settings_external_network_vlans(self):
# test vlans
- ns[PUBLIC_NETWORK]['vlan'] = 100
- ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
+ ne = NetworkEnvironment(self.ns_vlans,
+ '../build/network-environment.yaml')
assert_equal(ne['parameter_defaults']['NeutronExternalNetworkBridge'],
'""')
- assert_equal(ne['parameter_defaults']['ExternalNetworkVlanID'], 100)
+ assert_equal(ne['parameter_defaults']['ExternalNetworkVlanID'], 501)
+ def test_netenv_settings_external_network_ipv6(self):
# Test IPv6
- ns[PUBLIC_NETWORK]['cidr'] = ipaddress.ip_network('::1/128')
- ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
+ ne = NetworkEnvironment(self.ns_ipv6,
+ '../build/network-environment.yaml')
regstr = ne['resource_registry'][next(iter(EXTERNAL_RESOURCES.keys()))]
assert_equal(regstr.split('/')[-1], 'external_v6.yaml')
- def test_netenv_settings_private_network(self):
- ns = NetworkSettings('../config/network/network_settings.yaml', True)
- # test vlans
- ns[PRIVATE_NETWORK]['vlan'] = 100
+ def test_netenv_settings_external_network_removed(self):
+ ns = copy(self.ns)
+ # Test removing EXTERNAL_NETWORK
+ ns.enabled_network_list.remove(EXTERNAL_NETWORK)
ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
- assert_equal(ne['parameter_defaults']['TenantNetworkVlanID'], 100)
-
- # Test IPv6
- ns[PRIVATE_NETWORK]['cidr'] = ipaddress.ip_network('::1/128')
- ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
- regstr = ne['resource_registry'][next(iter(TENANT_RESOURCES.keys()))]
- assert_equal(regstr.split('/')[-1], 'tenant_v6.yaml')
+ regstr = ne['resource_registry'][next(iter(EXTERNAL_RESOURCES.keys()))]
+ assert_equal(regstr.split('/')[-1], 'noop.yaml')
- # Test removing PRIVATE_NETWORK
- ns.enabled_network_list.remove(PRIVATE_NETWORK)
+ def test_netenv_settings_tenant_network_vlans(self):
+ # test vlans
+ ne = NetworkEnvironment(self.ns_vlans,
+ '../build/network-environment.yaml')
+ assert_equal(ne['parameter_defaults']['TenantNetworkVlanID'], 401)
+
+# Apex is does not support v6 tenant networks
+# Though there is code that would fire if a
+# v6 cidr was passed in, just uncomment this to
+# cover that code
+# def test_netenv_settings_tenant_network_v6(self):
+# # Test IPv6
+# ne = NetworkEnvironment(self.ns_ipv6,
+# '../build/network-environment.yaml')
+# regstr = ne['resource_registry'][next(iter(TENANT_RESOURCES.keys()))]
+# assert_equal(regstr.split('/')[-1], 'tenant_v6.yaml')
+
+ def test_netenv_settings_tenant_network_removed(self):
+ ns = copy(self.ns)
+ # Test removing TENANT_NETWORK
+ ns.enabled_network_list.remove(TENANT_NETWORK)
ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
regstr = ne['resource_registry'][next(iter(TENANT_RESOURCES.keys()))]
assert_equal(regstr.split('/')[-1], 'noop.yaml')
- def test_netenv_settings_storage_network(self):
- ns = NetworkSettings('../config/network/network_settings.yaml', True)
+ def test_netenv_settings_storage_network_vlans(self):
# test vlans
- ns[STORAGE_NETWORK]['vlan'] = 100
- ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
- assert_equal(ne['parameter_defaults']['StorageNetworkVlanID'], 100)
+ ne = NetworkEnvironment(self.ns_vlans,
+ '../build/network-environment.yaml')
+ assert_equal(ne['parameter_defaults']['StorageNetworkVlanID'], 201)
+ def test_netenv_settings_storage_network_v6(self):
# Test IPv6
- ns[STORAGE_NETWORK]['cidr'] = ipaddress.ip_network('::1/128')
- ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
+ ne = NetworkEnvironment(self.ns_ipv6,
+ '../build/network-environment.yaml')
regstr = ne['resource_registry'][next(iter(STORAGE_RESOURCES.keys()))]
assert_equal(regstr.split('/')[-1], 'storage_v6.yaml')
+ def test_netenv_settings_storage_network_removed(self):
+ ns = copy(self.ns)
# Test removing STORAGE_NETWORK
ns.enabled_network_list.remove(STORAGE_NETWORK)
ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
regstr = ne['resource_registry'][next(iter(STORAGE_RESOURCES.keys()))]
assert_equal(regstr.split('/')[-1], 'noop.yaml')
- def test_netenv_settings_api_network(self):
- ns = NetworkSettings('../config/network/network_settings.yaml', True)
+ def test_netenv_settings_api_network_v4(self):
+ ns = copy(self.ns_vlans)
+ ns['networks'][API_NETWORK]['enabled'] = True
+ ns['networks'][API_NETWORK]['cidr'] = '10.11.12.0/24'
+ ns = NetworkSettings(ns, True)
# test vlans
- ns.enabled_network_list.append(API_NETWORK)
- ns[API_NETWORK] = {'vlan': 100,
- 'cidr': ipaddress.ip_network('10.10.10.0/24'),
- 'usable_ip_range': '10.10.10.10,10.10.10.100'}
ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
- assert_equal(ne['parameter_defaults']['InternalApiNetworkVlanID'], 100)
+ assert_equal(ne['parameter_defaults']['InternalApiNetworkVlanID'], 101)
- # Test IPv6
- ns[API_NETWORK]['cidr'] = ipaddress.ip_network('::1/128')
+ def test_netenv_settings_api_network_vlans(self):
+ ns = copy(self.ns_vlans)
+ ns['networks'][API_NETWORK]['enabled'] = True
+ ns = NetworkSettings(ns, True)
+ # test vlans
ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
+ assert_equal(ne['parameter_defaults']['InternalApiNetworkVlanID'], 101)
+
+ def test_netenv_settings_api_network_v6(self):
+ # Test IPv6
+ ne = NetworkEnvironment(self.ns_ipv6,
+ '../build/network-environment.yaml')
regstr = ne['resource_registry'][next(iter(API_RESOURCES.keys()))]
assert_equal(regstr.split('/')[-1], 'internal_api_v6.yaml')
- # Test removing API_NETWORK
- ns.enabled_network_list.remove(API_NETWORK)
+ def test_netenv_settings_api_network_removed(self):
+ ns = copy(self.ns)
+ # API_NETWORK is not in the default network settings file
ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
regstr = ne['resource_registry'][next(iter(API_RESOURCES.keys()))]
assert_equal(regstr.split('/')[-1], 'noop.yaml')
def test_numa_configs(self):
- ns = NetworkSettings('../config/network/network_settings.yaml', True)
- ne = NetworkEnvironment(ns, '../build/network-environment.yaml',
+ ne = NetworkEnvironment(self.ns, '../build/network-environment.yaml',
compute_pre_config=True,
controller_pre_config=True)
assert_is_instance(ne, dict)
diff --git a/tests/test_apex_network_settings.py b/tests/test_apex_network_settings.py
index ff61cc4b..47c13cc5 100644
--- a/tests/test_apex_network_settings.py
+++ b/tests/test_apex_network_settings.py
@@ -7,6 +7,12 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+from apex.common.constants import (
+ EXTERNAL_NETWORK,
+ STORAGE_NETWORK,
+ ADMIN_NETWORK,
+)
+
from apex.network_settings import (
NetworkSettings,
NetworkSettingsException,
@@ -18,6 +24,8 @@ from nose.tools import (
assert_raises
)
+files_dir = '../config/network/'
+
class TestNetworkSettings(object):
@classmethod
@@ -35,7 +43,42 @@ class TestNetworkSettings(object):
"""This method is run once after _each_ test method is executed"""
def test_init(self):
- NetworkSettings('../config/network/network_settings.yaml', True)
+ assert_is_instance(
+ NetworkSettings(files_dir+'network_settings.yaml', True),
+ NetworkSettings)
+
+ def test_init_vlans(self):
+ assert_is_instance(
+ NetworkSettings(files_dir+'network_settings_vlans.yaml', True),
+ NetworkSettings)
+
+# TODO, v6 test is stuck
+ # def test_init_v6(self):
+ # assert_is_instance(
+ # NetworkSettings(files_dir+'network_settings_v6.yaml', True),
+ # NetworkSettings)
+
+ def test_init_admin_disabled_or_missing(self):
+ ns = NetworkSettings(files_dir+'network_settings.yaml', True)
+ # remove admin, apex section will re-add it
+ ns['networks'].pop('admin', None)
+ assert_raises(NetworkSettingsException, NetworkSettings, ns, True)
+ # remove admin and apex
+ ns.pop('apex', None)
+ ns['networks'].pop('admin', None)
+ assert_raises(NetworkSettingsException, NetworkSettings, ns, True)
+
+ def test_init_collapse_storage(self):
+ ns = NetworkSettings(files_dir+'network_settings.yaml', True)
+ # remove storage
+ ns['networks'].pop('storage', None)
+ assert_is_instance(NetworkSettings(ns, True), NetworkSettings)
+
+ def test_init_missing_dns_domain(self):
+ ns = NetworkSettings(files_dir+'network_settings.yaml', True)
+ # remove storage
+ ns.pop('dns-domain', None)
+ assert_is_instance(NetworkSettings(ns, True), NetworkSettings)
def test_dump_bash(self):
ns = NetworkSettings('../config/network/network_settings.yaml', True)
@@ -44,39 +87,74 @@ class TestNetworkSettings(object):
def test_get_network_settings(self):
ns = NetworkSettings('../config/network/network_settings.yaml', True)
- assert_is_instance(ns, dict)
+ assert_is_instance(ns, NetworkSettings)
for role in ['controller', 'compute']:
nic_index = 1
- for network in ['admin_network', 'private_network',
- 'public_network', 'storage_network']:
- nic = 'nic' + str(nic_index)
- assert_equal(ns.nics[role][network], nic)
- nic_index += 1
-
- def test_get_network_settings_unspecified_nics(self):
- ns = NetworkSettings(
- '../tests/config/network_settings_nics_not_specified.yaml',
- True)
- assert_is_instance(ns, dict)
- for role in ['controller', 'compute']:
- nic_index = 1
- for network in ['admin_network', 'private_network',
- 'public_network', 'storage_network']:
+ print(ns.nics)
+ for network in ns.enabled_network_list:
nic = 'nic' + str(nic_index)
assert_equal(ns.nics[role][network], nic)
nic_index += 1
def test_get_enabled_networks(self):
ns = NetworkSettings('../config/network/network_settings.yaml', True)
- assert_is_instance(ns.get_enabled_networks(), list)
-
- def test_negative_network_settings(self):
- assert_raises(NetworkSettingsException, NetworkSettings,
- '../tests/config/network_settings_duplicate_nic.yaml',
- True)
- assert_raises(NetworkSettingsException, NetworkSettings,
- '../tests/config/network_settings_nic1_reserved.yaml',
- True)
- assert_raises(NetworkSettingsException, NetworkSettings,
- '../tests/config/network_settings_missing_required_nic'
- '.yaml', True)
+ assert_is_instance(ns.enabled_network_list, list)
+
+ def test_invalid_nic_members(self):
+ ns = NetworkSettings(files_dir+'network_settings.yaml', True)
+ storage_net_nicmap = ns['networks'][STORAGE_NETWORK]['nic_mapping']
+ # set duplicate nic
+ storage_net_nicmap['compute']['members'][0] = 'nic1'
+ assert_raises(NetworkSettingsException, NetworkSettings, ns, True)
+ # remove nic members
+ storage_net_nicmap['compute']['members'] = []
+ assert_raises(NetworkSettingsException, NetworkSettings, ns, True)
+
+ def test_missing_vlan(self):
+ ns = NetworkSettings(files_dir+'network_settings.yaml', True)
+ storage_net_nicmap = ns['networks'][STORAGE_NETWORK]['nic_mapping']
+ # remove vlan from storage net
+ storage_net_nicmap['compute'].pop('vlan', None)
+ assert_is_instance(NetworkSettings(ns, True), NetworkSettings)
+
+# TODO
+# need to manipulate interfaces some how
+# maybe for ip_utils to return something to pass this
+# def test_admin_auto_detect(self):
+# ns = NetworkSettings(files_dir+'network_settings.yaml', True)
+# # remove cidr to force autodetection
+# ns['networks'][ADMIN_NETWORK].pop('cidr', None)
+# assert_is_instance(NetworkSettings(ns, True), NetworkSettings)
+
+ def test_admin_fail_auto_detect(self):
+ ns = NetworkSettings(files_dir+'network_settings.yaml', True)
+ # remove cidr and installer_vm to fail autodetect
+ ns['networks'][ADMIN_NETWORK].pop('cidr', None)
+ ns['networks'][ADMIN_NETWORK].pop('installer_vm', None)
+ assert_raises(NetworkSettingsException, NetworkSettings, ns, True)
+
+ def test_exception(self):
+ e = NetworkSettingsException("test")
+ print(e)
+ assert_is_instance(e, NetworkSettingsException)
+
+ def test_config_ip(self):
+ ns = NetworkSettings(files_dir+'network_settings.yaml', True)
+ # set the provisioner ip to None to force _gen_ip to generate one
+ ns['networks'][ADMIN_NETWORK]['installer_vm']['ip'] = None
+ ns['networks'][EXTERNAL_NETWORK][0]['installer_vm']['ip'] = None
+ # Now rebuild network settings object and check for repopulated values
+ ns = NetworkSettings(ns, True)
+ assert_equal(ns['networks'][ADMIN_NETWORK]['installer_vm']['ip'],
+ '192.0.2.1')
+ assert_equal(ns['networks'][EXTERNAL_NETWORK][0]['installer_vm']['ip'],
+ '192.168.37.1')
+
+ def test_config_gateway(self):
+ ns = NetworkSettings(files_dir+'network_settings.yaml', True)
+ # set the gateway ip to None to force _config_gateway to generate one
+ ns['networks'][EXTERNAL_NETWORK][0]['gateway'] = None
+ # Now rebuild network settings object and check for a repopulated value
+ ns = NetworkSettings(ns, True)
+ assert_equal(ns['networks'][EXTERNAL_NETWORK][0]['gateway'],
+ '192.168.37.1')