summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/config/inventory.yaml57
-rwxr-xr-xtests/smoke_tests/execute_smoke_tests.sh3
-rw-r--r--tests/smoke_tests/execute_tests.yml11
-rw-r--r--tests/smoke_tests/prepare_undercloud.yml9
-rw-r--r--tests/smoke_tests/smoke_tests.yml3
-rw-r--r--tests/test_apex_clean.py41
-rw-r--r--tests/test_apex_common_utils.py39
-rw-r--r--tests/test_apex_deploy_settings.py107
-rw-r--r--tests/test_apex_inventory.py81
-rw-r--r--tests/test_apex_ip_utils.py135
-rw-r--r--tests/test_apex_network_environment.py170
-rw-r--r--tests/test_apex_network_settings.py160
-rw-r--r--tests/test_apex_python_utils_py.py91
13 files changed, 0 insertions, 907 deletions
diff --git a/tests/config/inventory.yaml b/tests/config/inventory.yaml
deleted file mode 100644
index 2abe0fc9..00000000
--- a/tests/config/inventory.yaml
+++ /dev/null
@@ -1,57 +0,0 @@
----
-nodes:
- node1:
- mac_address: "00:25:B5:cc:00:1e"
- ipmi_ip: 72.30.8.69
- ipmi_user: admin
- ipmi_pass: octopus
- pm_type: "pxe_ipmitool"
- cpus: 2
- memory: 8192
- disk: 40
- arch: "x86_64"
- capabilities: "profile:control"
- node2:
- mac_address: "00:25:B5:cc:00:5d"
- ipmi_ip: 72.30.8.78
- ipmi_user: admin
- ipmi_pass: octopus
- pm_type: "pxe_ipmitool"
- cpus: 2
- memory: 8192
- disk: 40
- arch: "x86_64"
- capabilities: "profile:control"
- node3:
- mac_address: "00:25:B5:cc:00:1d"
- ipmi_ip: 72.30.8.67
- ipmi_user: admin
- ipmi_pass: octopus
- pm_type: "pxe_ipmitool"
- cpus: 2
- memory: 8192
- disk: 40
- arch: "x86_64"
- capabilities: "profile:control"
- node4:
- mac_address: "00:25:B5:cc:00:3c"
- ipmi_ip: 72.30.8.76
- ipmi_user: admin
- ipmi_pass: octopus
- pm_type: "pxe_ipmitool"
- cpus: 2
- memory: 8192
- disk: 40
- arch: "x86_64"
- capabilities: "profile:compute"
- node5:
- mac_address: "00:25:B5:cc:00:5b"
- ipmi_ip: 72.30.8.71
- ipmi_user: admin
- ipmi_pass: octopus
- pm_type: "pxe_ipmitool"
- cpus: 2
- memory: 8192
- disk: 40
- arch: "x86_64"
- capabilities: "profile:compute"
diff --git a/tests/smoke_tests/execute_smoke_tests.sh b/tests/smoke_tests/execute_smoke_tests.sh
deleted file mode 100755
index 27f95251..00000000
--- a/tests/smoke_tests/execute_smoke_tests.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-
-python ~/snaps/snaps/test_runner.py -e ~stack/overcloudrc -n external -c -a -i -f -k -l INFO &> ~stack/smoke-tests.out \ No newline at end of file
diff --git a/tests/smoke_tests/execute_tests.yml b/tests/smoke_tests/execute_tests.yml
deleted file mode 100644
index 5042d230..00000000
--- a/tests/smoke_tests/execute_tests.yml
+++ /dev/null
@@ -1,11 +0,0 @@
----
-- hosts: all
- become: yes
- become_method: sudo
- become_user: root
-
- tasks:
- - name: Copy execute_smoke_tests.sh
- copy: src=execute_smoke_tests.sh dest=~/execute_smoke_tests.sh mode=0755
- - name: Execute Tests
- command: sh ~/execute_smoke_tests.sh | tee ~/unit_tests.out \ No newline at end of file
diff --git a/tests/smoke_tests/prepare_undercloud.yml b/tests/smoke_tests/prepare_undercloud.yml
deleted file mode 100644
index 7ad769c0..00000000
--- a/tests/smoke_tests/prepare_undercloud.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-- hosts: all
- become: yes
- become_method: sudo
- become_user: root
-
- tasks:
- - git: repo=https://gerrit.opnfv.org/gerrit/snaps dest=~/snaps
- - command: pip install -e ~/snaps/
diff --git a/tests/smoke_tests/smoke_tests.yml b/tests/smoke_tests/smoke_tests.yml
deleted file mode 100644
index b67c194f..00000000
--- a/tests/smoke_tests/smoke_tests.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-- include: prepare_undercloud.yml
-- include: execute_tests.yml \ No newline at end of file
diff --git a/tests/test_apex_clean.py b/tests/test_apex_clean.py
deleted file mode 100644
index 2a436a7c..00000000
--- a/tests/test_apex_clean.py
+++ /dev/null
@@ -1,41 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 Tim Rozet (Red Hat)
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-import mock
-import pyipmi
-import pyipmi.chassis
-
-from apex import clean_nodes
-from mock import patch
-from nose import tools
-
-
-class TestClean(object):
- @classmethod
- def setup_class(klass):
- """This method is run once for each class before any tests are run"""
-
- @classmethod
- def teardown_class(klass):
- """This method is run once for each class _after_ all tests are run"""
-
- def setUp(self):
- """This method is run once before _each_ test method is executed"""
-
- def teardown(self):
- """This method is run once after _each_ test method is executed"""
-
- def test_clean(self):
- with mock.patch.object(pyipmi.Session, 'establish') as mock_method:
- with patch.object(pyipmi.chassis.Chassis,
- 'chassis_control_power_down') as mock_method2:
- clean_nodes('config/inventory.yaml')
-
- tools.assert_equal(mock_method.call_count, 5)
- tools.assert_equal(mock_method2.call_count, 5)
diff --git a/tests/test_apex_common_utils.py b/tests/test_apex_common_utils.py
deleted file mode 100644
index 94598657..00000000
--- a/tests/test_apex_common_utils.py
+++ /dev/null
@@ -1,39 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 Dan Radez (Red Hat)
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-import nose.tools
-
-from apex.common import utils
-
-
-class TestCommonUtils(object):
- @classmethod
- def setup_class(klass):
- """This method is run once for each class before any tests are run"""
-
- @classmethod
- def teardown_class(klass):
- """This method is run once for each class _after_ all tests are run"""
-
- def setUp(self):
- """This method is run once before _each_ test method is executed"""
-
- def teardown(self):
- """This method is run once after _each_ test method is executed"""
-
- def test_str2bool(self):
- nose.tools.assert_equal(utils.str2bool(True), True)
- nose.tools.assert_equal(utils.str2bool(False), False)
- nose.tools.assert_equal(utils.str2bool("True"), True)
- nose.tools.assert_equal(utils.str2bool("YES"), True)
-
- def test_parse_yaml(self):
- nose.tools.assert_is_instance(
- utils.parse_yaml('../config/network/network_settings.yaml'),
- dict)
diff --git a/tests/test_apex_deploy_settings.py b/tests/test_apex_deploy_settings.py
deleted file mode 100644
index 00eb2744..00000000
--- a/tests/test_apex_deploy_settings.py
+++ /dev/null
@@ -1,107 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 Dan Radez (Red Hat)
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# https://docs.python.org/3/library/io.html
-import io
-import tempfile
-
-from apex.deploy_settings import DeploySettings
-from apex.deploy_settings import DeploySettingsException
-
-from nose.tools import assert_equal
-from nose.tools import assert_raises
-from nose.tools import assert_is_instance
-
-deploy_files = ('deploy_settings.yaml',
- 'os-nosdn-nofeature-noha.yaml',
- 'os-nosdn-ovs_dpdk-noha.yaml',
- 'os-ocl-nofeature-ha.yaml',
- 'os-odl-bgpvpn-ha.yaml',
- 'os-odl-bgpvpn-noha.yaml',
- 'os-odl-nofeature-ha.yaml',
- 'os-nosdn-nofeature-ha.yaml',
- 'os-nosdn-ovs_dpdk-ha.yaml',
- 'os-nosdn-performance-ha.yaml',
- 'os-odl-nofeature-ha.yaml',
- 'os-onos-nofeature-ha.yaml',
- 'os-onos-sfc-ha.yaml')
-
-test_deploy_content = (
- 'global_params:',
- 'deploy_options: string',
- """deploy_options: string
-global_params:""",
- """global_params:
-deploy_options:
- error: error
-""",
- """global_params:
-deploy_options:
- performance: string
-""",
- """global_params:
-deploy_options:
- dataplane: invalid
-""",
- """global_params:
-deploy_options:
- performance:
- Controller:
- error: error
-""",
- """global_params:
-deploy_options:
- performance:
- InvalidRole:
- error: error
-""",)
-
-
-class TestIpUtils(object):
- @classmethod
- def setup_class(klass):
- """This method is run once for each class before any tests are run"""
-
- @classmethod
- def teardown_class(klass):
- """This method is run once for each class _after_ all tests are run"""
-
- def setUp(self):
- """This method is run once before _each_ test method is executed"""
-
- def teardown(self):
- """This method is run once after _each_ test method is executed"""
-
- def test_init(self):
- for f in deploy_files:
- ds = DeploySettings('../config/deploy/{}'.format(f))
- ds = DeploySettings(ds)
-
- def test__validate_settings(self):
- for c in test_deploy_content:
- try:
- f = tempfile.NamedTemporaryFile(mode='w')
- f.write(c)
- f.flush()
- assert_raises(DeploySettingsException,
- DeploySettings, f.name)
- finally:
- f.close()
-
- def test_dump_bash(self):
- # the performance file has the most use of the function
- # so using that as the test case
- ds = DeploySettings('../config/deploy/os-nosdn-performance-ha.yaml')
- assert_equal(ds.dump_bash(), None)
- assert_equal(ds.dump_bash(path='/dev/null'), None)
-
- def test_exception(sefl):
- e = DeploySettingsException("test")
- print(e)
- assert_is_instance(e, DeploySettingsException)
diff --git a/tests/test_apex_inventory.py b/tests/test_apex_inventory.py
deleted file mode 100644
index ec75856b..00000000
--- a/tests/test_apex_inventory.py
+++ /dev/null
@@ -1,81 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 Dan Radez (Red Hat)
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-import sys
-
-from apex.inventory import Inventory
-from apex.inventory import InventoryException
-
-from nose.tools import assert_is_instance
-from nose.tools import assert_raises
-from nose.tools import assert_equal
-from nose.tools import assert_regexp_matches
-from io import StringIO
-
-inventory_files = ('intel_pod2_settings.yaml',
- 'nokia_pod1_settings.yaml',
- 'pod_example_settings.yaml')
-
-
-class TestInventory(object):
- @classmethod
- def setup_class(klass):
- """This method is run once for each class before any tests are run"""
-
- @classmethod
- def teardown_class(klass):
- """This method is run once for each class _after_ all tests are run"""
-
- def setUp(self):
- """This method is run once before _each_ test method is executed"""
-
- def teardown(self):
- """This method is run once after _each_ test method is executed"""
-
- def test_init(self):
- for f in inventory_files:
- i = Inventory('../config/inventory/{}'.format(f))
- assert_equal(i.dump_instackenv_json(), None)
-
- # test virtual
- i = Inventory(i, virtual=True)
- assert_equal(i.dump_instackenv_json(), None)
-
- # Remove nodes to violate HA node count
- while len(i['nodes']) >= 5:
- i['nodes'].pop()
- assert_raises(InventoryException,
- Inventory, i)
-
- # Remove nodes to violate non-HA node count
- while len(i['nodes']) >= 2:
- i['nodes'].pop()
- assert_raises(InventoryException,
- Inventory, i, ha=False)
-
- def test_exception(sefl):
- e = InventoryException("test")
- print(e)
- assert_is_instance(e, InventoryException)
-
- def test_dump_bash_default(self):
- i = Inventory('../config/inventory/intel_pod2_settings.yaml')
- out = StringIO()
- sys.stdout = out
- i.dump_bash()
- output = out.getvalue().strip()
- assert_regexp_matches(output, 'root_disk_list=sda')
-
- def test_dump_bash_set_root_device(self):
- i = Inventory('../config/inventory/pod_example_settings.yaml')
- out = StringIO()
- sys.stdout = out
- i.dump_bash()
- output = out.getvalue().strip()
- assert_regexp_matches(output, 'root_disk_list=sdb')
diff --git a/tests/test_apex_ip_utils.py b/tests/test_apex_ip_utils.py
deleted file mode 100644
index e5e84b63..00000000
--- a/tests/test_apex_ip_utils.py
+++ /dev/null
@@ -1,135 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 Dan Radez (Red Hat)
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-import re
-import ipaddress
-
-from apex.ip_utils import IPUtilsException
-from apex.ip_utils import get_interface
-from apex.ip_utils import find_gateway
-from apex.ip_utils import get_ip
-from apex.ip_utils import get_ip_range
-from apex.ip_utils import _validate_ip_range
-
-from nose.tools import assert_true
-from nose.tools import assert_false
-from nose.tools import assert_equal
-from nose.tools import assert_raises
-from nose.tools import assert_is_instance
-from nose.tools import assert_regexp_matches
-
-from ipaddress import IPv4Address
-from ipaddress import IPv6Address
-from ipaddress import ip_network
-
-
-ip4_pattern = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
-ip4_range_pattern = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\d{1,'
- '3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
-
-
-def get_default_gateway_linux():
- """Read the default gateway directly from /proc."""
- with open("/proc/net/route") as fh:
- for line in fh:
- fields = line.strip().split()
- if fields[2] not in ('00000000', 'Gateway'):
- return fields[0]
-
-
-class TestIpUtils(object):
- @classmethod
- def setup_class(klass):
- """This method is run once for each class before any tests are run"""
- klass.iface_name = get_default_gateway_linux()
- iface = get_interface(klass.iface_name)
- klass.iface = iface
-
- @classmethod
- def teardown_class(klass):
- """This method is run once for each class _after_ all tests are run"""
-
- def setUp(self):
- """This method is run once before _each_ test method is executed"""
-
- def teardown(self):
- """This method is run once after _each_ test method is executed"""
-
- def test_get_interface(self):
- assert_equal(get_interface(''), None)
- assert_equal(get_interface('notreal'), None)
- assert_is_instance(get_interface(self.iface_name,
- address_family=4),
- IPv4Address)
- # can't enable this until there's a v6 address on the ci hosts
- # assert_is_instance(get_interface(
- # self.iface_name,
- # address_family=6), IPv6Address)
- assert_raises(IPUtilsException,
- get_interface, self.iface_name, 0)
-
- def test_find_gateway(self):
- assert_is_instance(find_gateway(self.iface), str)
- iface_virbr0 = get_interface('virbr0')
- assert_equal(find_gateway(iface_virbr0), None)
-
- def test_get_ip(self):
- cidr = ipaddress.ip_network("10.10.10.0/24")
- assert_equal(get_ip(1, cidr=cidr), "10.10.10.1")
- assert_raises(IPUtilsException, get_ip, 1000, interface=self.iface)
- assert_regexp_matches(get_ip(1, interface=self.iface), ip4_pattern)
- assert_raises(IPUtilsException, get_ip, 1)
-
- def test_get_ip_range_raises(self):
- assert_raises(IPUtilsException, get_ip_range)
- assert_raises(IPUtilsException, get_ip_range, interface=self.iface)
-
- def test_get_ip_range_with_interface(self):
- assert_regexp_matches(get_ip_range(interface=self.iface,
- start_offset=1, end_offset=20),
- ip4_range_pattern)
- assert_regexp_matches(get_ip_range(interface=self.iface,
- start_offset=1, count=10),
- ip4_range_pattern)
- assert_regexp_matches(get_ip_range(interface=self.iface, end_offset=20,
- count=10), ip4_range_pattern)
-
- def test_get_ip_range_with_cidr(self):
- cidr = ip_network('10.10.10.0/24')
- assert_raises(IPUtilsException, get_ip_range, cidr=cidr)
- assert_regexp_matches(get_ip_range(cidr=cidr, start_offset=1,
- end_offset=20), ip4_pattern)
- assert_regexp_matches(get_ip_range(cidr=cidr, start_offset=1,
- count=10), ip4_pattern)
- assert_regexp_matches(get_ip_range(cidr=cidr, end_offset=20,
- count=10), ip4_pattern)
-
- def test__validate_ip_range(self):
- cidr = ip_network('10.10.10.0/24')
- assert_true(_validate_ip_range(
- start_ip=ipaddress.IPv4Address('10.10.10.1'),
- end_ip=ipaddress.IPv4Address('10.10.10.10'),
- cidr=cidr))
- assert_false(_validate_ip_range(
- start_ip=ipaddress.IPv4Address('10.10.10.10'),
- end_ip=ipaddress.IPv4Address('10.10.10.1'),
- cidr=cidr))
- assert_false(_validate_ip_range(
- start_ip=ipaddress.IPv4Address('10.10.0.1'),
- end_ip=ipaddress.IPv4Address('10.10.10.10'),
- cidr=cidr))
- assert_false(_validate_ip_range(
- start_ip=ipaddress.IPv4Address('10.10.10.1'),
- end_ip=ipaddress.IPv4Address('10.10.11.10'),
- cidr=cidr))
-
- def test_exception(self):
- e = IPUtilsException("test")
- print(e)
- assert_is_instance(e, IPUtilsException)
diff --git a/tests/test_apex_network_environment.py b/tests/test_apex_network_environment.py
deleted file mode 100644
index b4d7e717..00000000
--- a/tests/test_apex_network_environment.py
+++ /dev/null
@@ -1,170 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 Dan Radez (Red Hat)
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-import ipaddress
-
-from copy import copy
-
-from apex.common.constants import (
- EXTERNAL_NETWORK,
- TENANT_NETWORK,
- STORAGE_NETWORK,
- API_NETWORK,
- CONTROLLER)
-from apex.network_settings import NetworkSettings
-from apex.network_environment import (
- NetworkEnvironment,
- NetworkEnvException,
- EXTERNAL_RESOURCES,
- TENANT_RESOURCES,
- STORAGE_RESOURCES,
- API_RESOURCES)
-
-from nose.tools import assert_equal
-from nose.tools import assert_raises
-from nose.tools import assert_is_instance
-from nose.tools import assert_not_equal
-
-
-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')
- klass.ns_vlans = NetworkSettings(
- '../config/network/network_settings_vlans.yaml')
- klass.ns_ipv6 = NetworkSettings(
- '../config/network/network_settings_v6.yaml')
-
- @classmethod
- def teardown_class(klass):
- """This method is run once for each class _after_ all tests are run"""
-
- def setUp(self):
- """This method is run once before _each_ test method is executed"""
-
- def teardown(self):
- """This method is run once after _each_ test method is executed"""
-
- def test_init(self):
- assert_raises(NetworkEnvException, NetworkEnvironment,
- None, '../build/network-environment.yaml')
-
- def test_netenv_settings_external_network_vlans(self):
- # test vlans
- ne = NetworkEnvironment(self.ns_vlans,
- '../build/network-environment.yaml')
- assert_equal(ne['parameter_defaults']['NeutronExternalNetworkBridge'],
- '""')
- assert_equal(ne['parameter_defaults']['ExternalNetworkVlanID'], 501)
-
- def test_netenv_settings_external_network_ipv6(self):
- # Test IPv6
- ne = NetworkEnvironment(self.ns_ipv6,
- '../build/network-environment.yaml')
- regstr = ne['resource_registry']['OS::TripleO::Network::External']
- assert_equal(regstr.split('/')[-1], 'external_v6.yaml')
-
- 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')
- regstr = ne['resource_registry']['OS::TripleO::Network::External']
- assert_equal(regstr.split('/')[-1], 'OS::Heat::None')
-
- 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']['OS::TripleO::Network::Tenant']
- assert_equal(regstr.split('/')[-1], 'OS::Heat::None')
-
- def test_netenv_settings_storage_network_vlans(self):
- # test vlans
- 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
- ne = NetworkEnvironment(self.ns_ipv6,
- '../build/network-environment.yaml')
- regstr = ne['resource_registry']['OS::TripleO::Network::Storage']
- 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']['OS::TripleO::Network::Storage']
- assert_equal(regstr.split('/')[-1], 'OS::Heat::None')
-
- 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)
- # test vlans
- ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
- assert_equal(ne['parameter_defaults']['InternalApiNetworkVlanID'], 101)
-
- def test_netenv_settings_api_network_vlans(self):
- ns = copy(self.ns_vlans)
- ns['networks'][API_NETWORK]['enabled'] = True
- ns = NetworkSettings(ns)
- # 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']['OS::TripleO::Network::InternalApi']
- assert_equal(regstr.split('/')[-1], 'internal_api_v6.yaml')
-
- 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']['OS::TripleO::Network::InternalApi']
- assert_equal(regstr.split('/')[-1], 'OS::Heat::None')
-
- def test_numa_configs(self):
- ne = NetworkEnvironment(self.ns, '../build/network-environment.yaml',
- compute_pre_config=True,
- controller_pre_config=True)
- assert_is_instance(ne, dict)
- assert_not_equal(ne, {})
-
- def test_exception(self):
- e = NetworkEnvException("test")
- print(e)
- assert_is_instance(e, NetworkEnvException)
diff --git a/tests/test_apex_network_settings.py b/tests/test_apex_network_settings.py
deleted file mode 100644
index a1dbaf1c..00000000
--- a/tests/test_apex_network_settings.py
+++ /dev/null
@@ -1,160 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 Dan Radez (Red Hat)
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# 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,
-)
-
-from nose.tools import (
- assert_equal,
- assert_is_instance,
- assert_raises
-)
-
-files_dir = '../config/network/'
-
-
-class TestNetworkSettings(object):
- @classmethod
- def setup_class(klass):
- """This method is run once for each class before any tests are run"""
-
- @classmethod
- def teardown_class(klass):
- """This method is run once for each class _after_ all tests are run"""
-
- def setUp(self):
- """This method is run once before _each_ test method is executed"""
-
- def teardown(self):
- """This method is run once after _each_ test method is executed"""
-
- def test_init(self):
- assert_is_instance(
- NetworkSettings(files_dir+'network_settings.yaml'),
- NetworkSettings)
-
- def test_init_vlans(self):
- assert_is_instance(
- NetworkSettings(files_dir+'network_settings_vlans.yaml'),
- 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')
- # remove admin, apex section will re-add it
- ns['networks'].pop('admin', None)
- assert_raises(NetworkSettingsException, NetworkSettings, ns)
- # remove admin and apex
- ns.pop('apex', None)
- ns['networks'].pop('admin', None)
- assert_raises(NetworkSettingsException, NetworkSettings, ns)
-
- def test_init_collapse_storage(self):
- ns = NetworkSettings(files_dir+'network_settings.yaml')
- # remove storage
- ns['networks'].pop('storage', None)
- assert_is_instance(NetworkSettings(ns), NetworkSettings)
-
- def test_init_missing_dns_domain(self):
- ns = NetworkSettings(files_dir+'network_settings.yaml')
- # remove storage
- ns.pop('dns-domain', None)
- assert_is_instance(NetworkSettings(ns), NetworkSettings)
-
- def test_dump_bash(self):
- ns = NetworkSettings('../config/network/network_settings.yaml')
- assert_equal(ns.dump_bash(), None)
- assert_equal(ns.dump_bash(path='/dev/null'), None)
-
- def test_get_network_settings(self):
- ns = NetworkSettings('../config/network/network_settings.yaml')
- assert_is_instance(ns, NetworkSettings)
- for role in ['controller', 'compute']:
- nic_index = 0
- print(ns.nics)
- for network in ns.enabled_network_list:
- nic = 'eth' + 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')
- assert_is_instance(ns.enabled_network_list, list)
-
- def test_invalid_nic_members(self):
- ns = NetworkSettings(files_dir+'network_settings.yaml')
- storage_net_nicmap = ns['networks'][STORAGE_NETWORK]['nic_mapping']
- # set duplicate nic
- storage_net_nicmap['controller']['members'][0] = 'eth0'
- assert_raises(NetworkSettingsException, NetworkSettings, ns)
- # remove nic members
- storage_net_nicmap['controller']['members'] = []
- assert_raises(NetworkSettingsException, NetworkSettings, ns)
-
- def test_missing_vlan(self):
- ns = NetworkSettings(files_dir+'network_settings.yaml')
- 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), 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')
-# # remove cidr to force autodetection
-# ns['networks'][ADMIN_NETWORK].pop('cidr', None)
-# assert_is_instance(NetworkSettings(ns), NetworkSettings)
-
- def test_admin_fail_auto_detect(self):
- ns = NetworkSettings(files_dir+'network_settings.yaml')
- # 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)
-
- 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')
- # 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)
- 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')
- # 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)
- assert_equal(ns['networks'][EXTERNAL_NETWORK][0]['gateway'],
- '192.168.37.1')
diff --git a/tests/test_apex_python_utils_py.py b/tests/test_apex_python_utils_py.py
deleted file mode 100644
index 550042f5..00000000
--- a/tests/test_apex_python_utils_py.py
+++ /dev/null
@@ -1,91 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 Dan Radez (Red Hat)
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-import shutil
-import sys
-import tempfile
-
-from test_apex_ip_utils import get_default_gateway_linux
-from apex_python_utils import main
-from apex_python_utils import get_parser
-from apex_python_utils import parse_net_settings
-from apex_python_utils import parse_deploy_settings
-from apex_python_utils import find_ip
-from apex_python_utils import build_nic_template
-from apex_python_utils import parse_inventory
-
-from nose.tools import assert_equal
-from nose.tools import assert_raises
-
-
-net_sets = '../config/network/network_settings.yaml'
-net_env = '../build/network-environment.yaml'
-deploy_sets = '../config/deploy/deploy_settings.yaml'
-nic_template = '../build/nics-template.yaml.jinja2'
-inventory = '../config/inventory/pod_example_settings.yaml'
-
-
-class TestCommonUtils(object):
- @classmethod
- def setup_class(klass):
- """This method is run once for each class before any tests are run"""
- klass.parser = get_parser()
- klass.iface_name = get_default_gateway_linux()
-
- @classmethod
- def teardown_class(klass):
- """This method is run once for each class _after_ all tests are run"""
-
- def setUp(self):
- """This method is run once before _each_ test method is executed"""
-
- def teardown(self):
- """This method is run once after _each_ test method is executed"""
-
- def test_main(self):
- sys.argv = ['apex_python_utils', '-l', '/dev/null']
- assert_raises(SystemExit, main)
- sys.argv = ['apex_python_utils', '--debug', '-l', '/dev/null']
- assert_raises(SystemExit, main)
- sys.argv = ['apex_python_utils', '-l', '/dev/null',
- 'parse-deploy-settings',
- '-f', deploy_sets]
- assert_equal(main(), None)
-
- def test_parse_net_settings(self):
- tmp_dir = tempfile.mkdtemp()
- args = self.parser.parse_args(['parse-net-settings',
- '-s', net_sets,
- '-td', tmp_dir,
- '-e', net_env])
- assert_equal(parse_net_settings(args), None)
- shutil.rmtree(tmp_dir, ignore_errors=True)
-
- def test_parse_deploy_settings(self):
- args = self.parser.parse_args(['parse-deploy-settings',
- '-f', deploy_sets])
- assert_equal(parse_deploy_settings(args), None)
-
- def test_find_ip(self):
- args = self.parser.parse_args(['find-ip',
- '-i', self.iface_name])
- assert_equal(find_ip(args), None)
-
- def test_build_nic_template(self):
- args = self.parser.parse_args(['nic-template',
- '-s', net_sets,
- '-r', 'compute',
- '-t', nic_template,
- '--deploy-settings-file', deploy_sets])
- assert_equal(build_nic_template(args), None)
-
- def test_parse_inventory(self):
- args = self.parser.parse_args(['parse-inventory',
- '-f', inventory])
- assert_equal(parse_inventory(args), None)