--- /dev/null
+[
+ {
+ "Status": "ACTIVE",
+ "Networks": "ctlplane=192.30.9.9",
+ "ID": "a5ff8aeb-5fd0-467f-9d89-791dfbc6267b",
+ "Image Name": "overcloud-full",
+ "Name": "overcloud-novacompute-1"
+ },
+ {
+ "Status": "ACTIVE",
+ "Networks": "ctlplane=192.30.9.10",
+ "ID": "c8be26ae-6bef-4841-bb03-c7f336cfd785",
+ "Image Name": "overcloud-full",
+ "Name": "overcloud-novacompute-0"
+ },
+ {
+ "Status": "ACTIVE",
+ "Networks": "ctlplane=192.30.9.8",
+ "ID": "105d1c61-78d3-498f-9191-6b21823b8544",
+ "Image Name": "overcloud-full",
+ "Name": "overcloud-controller-0"
+ }
+]
--- /dev/null
+# Clear any old environment that may conflict.
+for key in $( set | awk '{FS="="} /^OS_/ {print $1}' ); do unset $key ; done
+export OS_USERNAME=admin
+export OS_BAREMETAL_API_VERSION=1.29
+export NOVA_VERSION=1.1
+export OS_PROJECT_NAME=admin
+export OS_PASSWORD=Wd8ruyf6qG8cmcms6dq2HM93f
+export OS_NO_CACHE=True
+export COMPUTE_API_VERSION=1.1
+export no_proxy=,172.30.9.29,192.30.9.5
+export OS_CLOUDNAME=overcloud
+export OS_AUTH_URL=http://172.30.9.29:5000/v2.0
+export IRONIC_API_VERSION=1.29
+export OS_AUTH_TYPE=password
+export PYTHONWARNINGS="ignore:Certificate has no, ignore:A true SSLContext object is not available"
+export OS_PROJECT_ID=4695721d82c1421094005ef4ab86d33a
+export OS_TENANT_NAME=admin
TEST_CONFIG_DIR = 'config'
TEST_BUILD_DIR = 'build'
TEST_PLAYBOOK_DIR = 'playbooks'
+TEST_DUMMY_CONFIG = 'apex/tests/config'
from apex import clean_nodes
-class TestClean(object):
+class TestClean:
@classmethod
- def setup_class(klass):
+ def setup_class(cls):
"""This method is run once for each class before any tests are run"""
@classmethod
- def teardown_class(klass):
+ def teardown_class(cls):
"""This method is run once for each class _after_ all tests are run"""
- def setUp(self):
+ def setup(self):
"""This method is run once before _each_ test method is executed"""
def teardown(self):
--- /dev/null
+##############################################################################
+# 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 os
+
+from apex.tests import constants as con
+from apex.common import parsers as apex_parsers
+from nose.tools import (
+ assert_is_instance,
+ assert_dict_equal
+)
+
+
+class TestCommonParsers:
+ @classmethod
+ def setup_class(cls):
+ """This method is run once for each class before any tests are run"""
+
+ @classmethod
+ def teardown_class(cls):
+ """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_parse_nova_output(self):
+ output = apex_parsers.parse_nova_output(
+ os.path.join(con.TEST_DUMMY_CONFIG, 'nova_output.json'))
+ assert_is_instance(output, dict)
+ nodes = {
+ 'overcloud-controller-0': '192.30.9.8',
+ 'overcloud-novacompute-0': '192.30.9.10',
+ 'overcloud-novacompute-1': '192.30.9.9'
+ }
+ print(output)
+ assert_dict_equal(output, nodes)
+
+ def test_parse_overcloudrc(self):
+ output = apex_parsers.parse_overcloudrc(
+ os.path.join(con.TEST_DUMMY_CONFIG, 'test_overcloudrc'))
+ assert_is_instance(output, dict)
+ assert 'OS_AUTH_TYPE' in output.keys()
+ assert output['OS_AUTH_TYPE'] == 'password'
+ assert 'OS_PASSWORD' in output.keys()
+ assert output['OS_PASSWORD'] == 'Wd8ruyf6qG8cmcms6dq2HM93f'
##############################################################################
import ipaddress
-import nose.tools
import os
from apex.common import utils
TEST_CONFIG_DIR,
TEST_PLAYBOOK_DIR)
+from nose.tools import (
+ assert_equal,
+ assert_is_instance,
+ assert_not_is_instance)
+
NET_SETS = os.path.join(TEST_CONFIG_DIR, 'network', 'network_settings.yaml')
-class TestCommonUtils(object):
+class TestCommonUtils:
@classmethod
- def setup_class(klass):
+ def setup_class(cls):
"""This method is run once for each class before any tests are run"""
@classmethod
- def teardown_class(klass):
+ def teardown_class(cls):
"""This method is run once for each class _after_ all tests are run"""
- def setUp(self):
+ 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)
+ assert_equal(utils.str2bool(True), True)
+ assert_equal(utils.str2bool(False), False)
+ assert_equal(utils.str2bool("True"), True)
+ assert_equal(utils.str2bool("YES"), True)
def test_parse_yaml(self):
- nose.tools.assert_is_instance(utils.parse_yaml(NET_SETS), dict)
+ assert_is_instance(utils.parse_yaml(NET_SETS), dict)
def test_dict_to_string(self):
net_settings = NetworkSettings(NET_SETS)
output = utils.dict_objects_to_str(net_settings)
- nose.tools.assert_is_instance(output, dict)
+ assert_is_instance(output, dict)
for k, v in output.items():
- nose.tools.assert_is_instance(k, str)
- nose.tools.assert_not_is_instance(v, ipaddress.IPv4Address)
+ assert_is_instance(k, str)
+ assert_not_is_instance(v, ipaddress.IPv4Address)
def test_run_ansible(self):
playbook = 'apex/tests/playbooks/test_playbook.yaml'
- nose.tools.assert_equal(
- utils.run_ansible(None, os.path.join(playbook),
- dry_run=True), None)
+ assert_equal(utils.run_ansible(None, os.path.join(playbook),
+ dry_run=True), None)
""",)
-class TestIpUtils(object):
+class TestIpUtils:
@classmethod
- def setup_class(klass):
+ def setup_class(cls):
"""This method is run once for each class before any tests are run"""
@classmethod
- def teardown_class(klass):
+ def teardown_class(cls):
"""This method is run once for each class _after_ all tests are run"""
- def setUp(self):
+ def setup(self):
"""This method is run once before _each_ test method is executed"""
def teardown(self):
##############################################################################
import os
-import sys
-from io import StringIO
-from nose.tools import assert_equal
-from nose.tools import assert_is_instance
-from nose.tools import assert_raises
-from nose.tools import assert_regexp_matches
+from nose.tools import (
+ assert_equal,
+ assert_is_instance,
+ assert_raises)
from apex import Inventory
from apex.inventory.inventory import InventoryException
files_dir = os.path.join(TEST_CONFIG_DIR, 'inventory')
-class TestInventory(object):
+class TestInventory:
@classmethod
- def setup_class(klass):
+ def setup_class(cls):
"""This method is run once for each class before any tests are run"""
@classmethod
- def teardown_class(klass):
+ def teardown_class(cls):
"""This method is run once for each class _after_ all tests are run"""
- def setUp(self):
+ def setup(self):
"""This method is run once before _each_ test method is executed"""
def teardown(self):
from ipaddress import IPv4Address
from ipaddress import ip_network
-from nose.tools import assert_equal
-from nose.tools import assert_false
-from nose.tools import assert_is_instance
-from nose.tools import assert_raises
-from nose.tools import assert_regexp_matches
-from nose.tools import assert_true
-
-from apex.network.ip_utils import IPUtilsException
-from apex.network.ip_utils import _validate_ip_range
-from apex.network.ip_utils import find_gateway
-from apex.network.ip_utils import get_interface
-from apex.network.ip_utils import get_ip
-from apex.network.ip_utils import get_ip_range
+from nose.tools import (
+ assert_equal,
+ assert_false,
+ assert_is_instance,
+ assert_raises,
+ assert_regexp_matches,
+ assert_true)
+
+from apex.network.ip_utils import (
+ IPUtilsException,
+ _validate_ip_range,
+ find_gateway,
+ get_interface,
+ get_ip,
+ get_ip_range)
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,'
return fields[0]
-class TestIpUtils(object):
+class TestIpUtils:
@classmethod
- def setup_class(klass):
+ def setup_class(cls):
"""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
+ cls.iface_name = get_default_gateway_linux()
+ iface = get_interface(cls.iface_name)
+ cls.iface = iface
@classmethod
- def teardown_class(klass):
+ def teardown_class(cls):
"""This method is run once for each class _after_ all tests are run"""
- def setUp(self):
+ def setup(self):
"""This method is run once before _each_ test method is executed"""
def teardown(self):
from copy import copy
-from nose.tools import assert_equal
-from nose.tools import assert_is_instance
-from nose.tools import assert_not_equal
-from nose.tools import assert_raises
+from nose.tools import (
+ assert_equal,
+ assert_is_instance,
+ assert_not_equal,
+ assert_raises)
from apex.common.constants import (
EXTERNAL_NETWORK,
from apex.tests.constants import TEST_BUILD_DIR
-class TestNetworkEnvironment(object):
+class TestNetworkEnvironment:
@classmethod
- def setup_class(klass):
+ def setup_class(cls):
"""This method is run once for each class before any tests are run"""
- klass.ns = NetworkSettings(
+ cls.ns = NetworkSettings(
os.path.join(TEST_CONFIG_DIR, 'network/network_settings.yaml'))
- klass.ns_vlans = NetworkSettings(
+ cls.ns_vlans = NetworkSettings(
os.path.join(TEST_CONFIG_DIR,
'network/network_settings_vlans.yaml'))
- klass.ns_ipv6 = NetworkSettings(
+ cls.ns_ipv6 = NetworkSettings(
os.path.join(TEST_CONFIG_DIR, '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):
+ def setup(self):
"""This method is run once before _each_ test method is executed"""
def teardown(self):
files_dir = os.path.join(TEST_CONFIG_DIR, 'network')
-class TestNetworkSettings(object):
+class TestNetworkSettings:
@classmethod
- def setup_class(klass):
+ def setup_class(cls):
"""This method is run once for each class before any tests are run"""
@classmethod
- def teardown_class(klass):
+ def teardown_class(cls):
"""This method is run once for each class _after_ all tests are run"""
- def setUp(self):
+ def setup(self):
"""This method is run once before _each_ test method is executed"""
def teardown(self):