summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/Makefile10
-rwxr-xr-xbuild/overcloud-full.sh9
-rw-r--r--build/variables.sh8
-rw-r--r--ci/PR_revision.log1
-rwxr-xr-xci/build.sh20
-rwxr-xr-xci/deploy.sh11
-rwxr-xr-xci/test.sh33
-rw-r--r--lib/python/apex/common/constants.py1
-rw-r--r--lib/python/apex/network_settings.py3
-rwxr-xr-xtests/python-coverage.sh65
-rw-r--r--tests/python_coverage_ip_utils.py25
-rw-r--r--tests/test_apex_common_utils.py34
-rw-r--r--tests/test_apex_deploy_env.py88
-rw-r--r--tests/test_apex_ip_utils.py95
-rw-r--r--tests/test_apex_network_environment.py42
-rw-r--r--tests/test_apex_network_settings.py45
16 files changed, 373 insertions, 117 deletions
diff --git a/build/Makefile b/build/Makefile
index 3f3d1c3a..f599f42f 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -19,6 +19,10 @@ export RPMODL = $(shell pwd)/noarch/opnfv-apex-$(RPMVERS)-$(shell echo ${RELEASE
export RPMONO = $(shell pwd)/noarch/opnfv-apex-onos-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
export RPMSFC = $(shell pwd)/noarch/opnfv-apex-opendaylight-sfc-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
+all_networks="admin_network private_network storage_network external_network api_network"
+
+
+
.PHONY: all
all: iso
@@ -62,7 +66,11 @@ $(RPMCOM):
.PHONY: python-tests
python-tests:
- cd ../tests && ./python-coverage.sh
+ # run nose tests
+ cd ../tests && PYTHONPATH=../lib/python/ nosetests-3.4 . --with-coverage --cover-package apex
+ # generate reports
+ cd ../tests && coverage3 html --include '*lib/python/*'
+ cd ../tests && coverage3 report --include '*lib/python/*' -m
###############
diff --git a/build/overcloud-full.sh b/build/overcloud-full.sh
index 065201f8..af978edb 100755
--- a/build/overcloud-full.sh
+++ b/build/overcloud-full.sh
@@ -23,10 +23,19 @@ mv -f images/overcloud-full.qcow2 images/overcloud-full_build.qcow2
pushd images > /dev/null
+dpdk_pkg_str=''
+for package in ${dpdk_rpms[@]}; do
+ curl -O "$dpdk_uri_base/$package"
+ dpdk_pkg_str+=" --upload $package:/root/dpdk_rpms"
+done
+
# remove openstack-neutron-openvswitch, ain't nobody need that in OPNFV
# enable connection tracking for protocal sctp
+# upload dpdk rpms but do not install
LIBGUESTFS_BACKEND=direct virt-customize \
--run-command "echo 'nf_conntrack_proto_sctp' > /etc/modules-load.d/nf_conntrack_proto_sctp.conf" \
+ --run-command "mkdir /root/dpdk_rpms" \
+ $dpdk_pkg_str \
-a overcloud-full_build.qcow2
mv -f overcloud-full_build.qcow2 overcloud-full.qcow2
diff --git a/build/variables.sh b/build/variables.sh
index 115650da..ad1edf91 100644
--- a/build/variables.sh
+++ b/build/variables.sh
@@ -11,3 +11,11 @@
rdo_images_uri=https://ci.centos.org/artifacts/rdo/images/mitaka/delorean/stable/
onos_release_uri=https://dl.dropboxusercontent.com/u/7079970/
onos_release_file=onos-1.5.0.tar.gz
+
+dpdk_uri_base=http://artifacts.opnfv.org/ovsnfv
+dpdk_rpms=(
+'ovs4opnfv-dpdk-16.04.0-2.el7.centos.x86_64.rpm'
+'ovs4opnfv-dpdk-devel-16.04.0-2.el7.centos.x86_64.rpm'
+'ovs4opnfv-dpdk-examples-16.04.0-2.el7.centos.x86_64.rpm'
+'ovs4opnfv-dpdk-tools-16.04.0-2.el7.centos.x86_64.rpm'
+) \ No newline at end of file
diff --git a/ci/PR_revision.log b/ci/PR_revision.log
index da13a48f..0b479c65 100644
--- a/ci/PR_revision.log
+++ b/ci/PR_revision.log
@@ -6,3 +6,4 @@
18,Fix sql race condition
21,Serialize db_sync calls and increase sql-sleep timer
23,Fix odl env files
+25,Force metadata on all scenarios
diff --git a/ci/build.sh b/ci/build.sh
index 1bd96d53..dd9f9fd1 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -34,7 +34,6 @@ BUILD_BASE=$(readlink -e ../build/)
CACHE_DEST=""
CACHE_DIR="cache"
CACHE_NAME="apex-cache"
-PYTHON_TESTS="TRUE"
MAKE_TARGETS="images"
REQUIRED_PKGS="rpm-build python-docutils"
@@ -64,11 +63,6 @@ parse_cmdline() {
echo "Buiding opnfv-apex RPMs"
shift 1
;;
- --skip-python-tests )
- PYTHON_TESTS="FALSE"
- echo "Skipping Python Tests"
- shift 1
- ;;
--debug )
debug="TRUE"
echo "Enable debug output"
@@ -151,20 +145,6 @@ if ! rpm -q python34-devel > /dev/null; then
fi
fi
-if [ "$PYTHON_TESTS" == "TRUE" ]; then
- # Make sure coverage is installed
- if ! python3 -c "import coverage" &> /dev/null; then sudo easy_install-3.4 coverage; fi
-
- run_make python-tests
- pushd ../tests/ > /dev/null
- percent=$(coverage3 report --include '*lib/python/*' -m | grep TOTAL | tr -s ' ' | awk '{ print $4 }' | cut -d % -f 1)
- if [[ percent -lt 80 ]]; then
- echo "Python Coverage: $percent"
- echo "WARNING: Does not meet 80% requirement"
- fi
- popd
-fi
-
# Execute make against targets
for t in $MAKE_TARGETS; do
run_make $t
diff --git a/ci/deploy.sh b/ci/deploy.sh
index a2634c16..50a11fb7 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -804,11 +804,7 @@ function undercloud_prep_overcloud_deploy {
exit 1
fi
- # Handle different dataplanes
- if [ "${deploy_options_array['dataplane']}" != 'ovs' ]; then
- echo "${red}ovs is the only currently available dataplane. ${deploy_options_array['dataplane']} not implemented${reset}"
- exit 1
- fi
+
# Make sure the correct overcloud image is available
if [ ! -f $RESOURCES/overcloud-full-${SDN_IMAGE}.qcow2 ]; then
@@ -842,9 +838,12 @@ EOF
--upload uio_pci_generic.modules:/etc/sysconfig/modules/ \
--run-command "chmod 0755 /etc/sysconfig/modules/vfio_pci.modules" \
--run-command "chmod 0755 /etc/sysconfig/modules/uio_pci_generic.modules" \
+ --run-command "yum install -y /root/dpdk_rpms/*" \
-a overcloud-full.qcow2
EOI
-
+ elif [ "${deploy_options_array['dataplane']}" != 'ovs' ]; then
+ echo "${red}${deploy_options_array['dataplane']} not supported${reset}"
+ exit 1
fi
# Set ODL version accordingly
diff --git a/ci/test.sh b/ci/test.sh
new file mode 100755
index 00000000..0f2bc046
--- /dev/null
+++ b/ci/test.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+##############################################################################
+# 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
+##############################################################################
+
+set -e
+
+# Make sure python is installed
+if ! rpm -q python34-devel > /dev/null; then
+ sudo yum install -y epel-release
+ if ! sudo yum install -y python34-devel; then
+ echo "Failed to install python34-devel package..."
+ exit 1
+ fi
+fi
+
+# Make sure coverage is installed
+if ! python3 -c "import coverage" &> /dev/null; then sudo easy_install-3.4 coverage; fi
+
+make python-tests
+pushd ../tests/ > /dev/null
+percent=$(coverage3 report --include '*lib/python/*' -m | grep TOTAL | tr -s ' ' | awk '{ print $4 }' | cut -d % -f 1)
+if [[ percent -lt 80 ]]; then
+ echo "Python Coverage: $percent"
+ echo "Does not meet 80% requirement"
+ exit 1
+fi
+popd > /dev/nul
diff --git a/lib/python/apex/common/constants.py b/lib/python/apex/common/constants.py
index 506b7b2b..8ed49ff7 100644
--- a/lib/python/apex/common/constants.py
+++ b/lib/python/apex/common/constants.py
@@ -14,3 +14,4 @@ STORAGE_NETWORK = 'storage_network'
API_NETWORK = 'api_network'
OPNFV_NETWORK_TYPES = [ADMIN_NETWORK, PRIVATE_NETWORK, PUBLIC_NETWORK,
STORAGE_NETWORK, API_NETWORK]
+DNS_SERVERS = ["8.8.8.8", "8.8.4.4"]
diff --git a/lib/python/apex/network_settings.py b/lib/python/apex/network_settings.py
index ea7f4ca9..1ddf4620 100644
--- a/lib/python/apex/network_settings.py
+++ b/lib/python/apex/network_settings.py
@@ -70,6 +70,9 @@ class NetworkSettings:
logging.info("{} is not in specified, will collapse with "
"admin_network".format(network))
+ self.settings_obj['dns_servers'] = self.settings_obj.get(
+ 'dns_servers', constants.DNS_SERVERS)
+
def _config_required_settings(self, network):
"""
Configures either CIDR or bridged_interface setting
diff --git a/tests/python-coverage.sh b/tests/python-coverage.sh
deleted file mode 100755
index 8de6157d..00000000
--- a/tests/python-coverage.sh
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/bash
-set -x
-all_networks="admin_network private_network storage_network external_network"
-
-# exercise help
-coverage3 run ../lib/python/apex-python-utils.py -l /dev/null > /dev/null
-
-# exercise parse-net-settings
-# throw debug on the first to exercise it
-coverage3 run -a ../lib/python/apex-python-utils.py --debug parse-net-settings -s ../config/network/network_settings.yaml -i True -e ../build/network-environment.yaml > /dev/null
-
-# exercise proper nic-template runs
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null nic-template -t ../config/network/network_settings.yaml -n "$all_networks" -e interface -af 4 > /dev/null
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null nic-template -t ../config/network/network_settings.yaml -n "$all_networks" -e interface -af 6 > /dev/null
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null nic-template -t ../config/network/network_settings.yaml -n "$all_networks" -e br-ex -af 4 > /dev/null
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null nic-template -t ../config/network/network_settings.yaml -n "$all_networks" -e br-ex -af 6 > /dev/null
-
-# exercise find-ip
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null find-ip -i $(ip a | grep 2: | cut -d \ -f 2 | head -n 1 | cut -d : -f 1) > /dev/null
-
-# exercise parse-deploy-settings
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f ../config/deploy/os-nosdn-nofeature-noha.yaml > /dev/null
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f ../config/deploy/os-nosdn-performance-ha.yaml > /dev/null
-
-# exercise parse-deploy-settings errors
-echo "global_params:" > /tmp/python-coverage.test
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
-echo "deploy_options: string" > /tmp/python-coverage.test
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
-echo "global_params:" >> /tmp/python-coverage.test
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
-cat > /tmp/python-coverage.test << EOF
-global_params:
-deploy_options:
- error: error
-EOF
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
-cat > /tmp/python-coverage.test << EOF
-global_params:
-deploy_options:
- performance: string
-EOF
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
-cat > /tmp/python-coverage.test << EOF
-global_params:
-deploy_options:
- performance:
- error: error
-EOF
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
-cat > /tmp/python-coverage.test << EOF
-global_params:
-deploy_options:
- performance:
- Controller:
- error: error
-EOF
-coverage3 run -a ../lib/python/apex-python-utils.py -l /dev/null parse-deploy-settings -f /tmp/python-coverage.test &> /dev/null
-
-# coverage for ip_utils
-PYTHONPATH=../lib/python/ coverage3 run -a python_coverage_ip_utils.py $(ip r | grep default | awk '{ print $5 }')
-
-# generate reports
-coverage3 html --include '*lib/python/*'
-coverage3 report --include '*lib/python/*' -m
diff --git a/tests/python_coverage_ip_utils.py b/tests/python_coverage_ip_utils.py
deleted file mode 100644
index 35280c18..00000000
--- a/tests/python_coverage_ip_utils.py
+++ /dev/null
@@ -1,25 +0,0 @@
-import sys
-from apex import ip_utils
-
-iface = ip_utils.get_interface(sys.argv[1])
-
-erroring_tests = (
- "ip_utils.get_interface('')",
- "ip_utils.get_interface('lo', address_family=0)",
- "ip_utils.get_interface('lo', address_family=6)",
- "ip_utils.get_interface('lo')",
- "ip_utils.get_ip_range()",
- "ip_utils.get_ip_range(interface=iface)")
-
-for t in erroring_tests:
- try:
- eval(t)
- except:
- pass
-
-ip_utils.find_gateway(interface=iface)
-ip_utils.get_ip(1, cidr="10.10.10.0/24")
-ip_utils.get_ip(1, interface=iface)
-ip_utils.get_ip_range(interface=iface, start_offset=1, end_offset=20)
-ip_utils.get_ip_range(interface=iface, start_offset=1, count=10)
-ip_utils.get_ip_range(interface=iface, end_offset=20, count=10)
diff --git a/tests/test_apex_common_utils.py b/tests/test_apex_common_utils.py
new file mode 100644
index 00000000..7c988e3d
--- /dev/null
+++ b/tests/test_apex_common_utils.py
@@ -0,0 +1,34 @@
+##############################################################################
+# 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.utils import str2bool
+
+from nose.tools import assert_equal
+
+
+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):
+ assert_equal(str2bool(True), True)
+ assert_equal(str2bool(False), False)
+ assert_equal(str2bool("True"), True)
+ assert_equal(str2bool("YES"), True)
diff --git a/tests/test_apex_deploy_env.py b/tests/test_apex_deploy_env.py
new file mode 100644
index 00000000..0cd144ef
--- /dev/null
+++ b/tests/test_apex_deploy_env.py
@@ -0,0 +1,88 @@
+##############################################################################
+# 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 io
+# https://docs.python.org/3/library/io.html
+
+from apex.deploy_env import DeploySettings
+from apex.deploy_env import DeploySettingsException
+
+from nose.tools import assert_equal
+from nose.tools import assert_raises
+
+deploy_files = ('deploy_settings.yaml',
+ 'os-nosdn-nofeature-noha.yaml',
+ 'os-nosdn-ovs-noha.yaml',
+ 'os-ocl-nofeature-ha.yaml',
+ 'os-odl_l2-sdnvpn-ha.yaml',
+ 'os-odl_l3-nofeature-ha.yaml',
+ 'os-nosdn-nofeature-ha.yaml',
+ 'os-nosdn-ovs-ha.yaml',
+ 'os-nosdn-performance-ha.yaml',
+ 'os-odl_l2-nofeature-ha.yaml',
+ 'os-odl_l2-sfc-noha.yaml',
+ 'os-onos-nofeature-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
+""",)
+
+
+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))
+
+ def test__validate_settings(self):
+ for c in test_deploy_content:
+ f = open('/tmp/apex_deploy_test_file', 'w')
+ f.write(c)
+ f.close()
+ assert_raises(DeploySettingsException, DeploySettings, '/tmp/apex_deploy_test_file')
+
+ 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)
diff --git a/tests/test_apex_ip_utils.py b/tests/test_apex_ip_utils.py
new file mode 100644
index 00000000..0b44bdd0
--- /dev/null
+++ b/tests/test_apex_ip_utils.py
@@ -0,0 +1,95 @@
+##############################################################################
+# 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
+
+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 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)
+ 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):
+ assert_equal(get_ip(1, cidr="10.10.10.0/24"), "0")
+ 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)
diff --git a/tests/test_apex_network_environment.py b/tests/test_apex_network_environment.py
new file mode 100644
index 00000000..90c89073
--- /dev/null
+++ b/tests/test_apex_network_environment.py
@@ -0,0 +1,42 @@
+##############################################################################
+# 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.network_settings import NetworkSettings
+from apex.network_environment import NetworkEnvironment
+from apex.network_environment import NetworkEnvException
+
+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"""
+
+ @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_get_netenv_settings(self):
+ ns = NetworkSettings('../config/network/network_settings.yaml', True)
+ ne = NetworkEnvironment(ns, '../build/network-environment.yaml')
+ assert_is_instance(ne.get_netenv_settings(), dict)
+ assert_not_equal(ne.get_netenv_settings(), {})
diff --git a/tests/test_apex_network_settings.py b/tests/test_apex_network_settings.py
new file mode 100644
index 00000000..a891473f
--- /dev/null
+++ b/tests/test_apex_network_settings.py
@@ -0,0 +1,45 @@
+##############################################################################
+# 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.network_settings import NetworkSettings
+
+from nose.tools import assert_equal
+from nose.tools import assert_is_instance
+
+
+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):
+ ns = NetworkSettings('../config/network/network_settings.yaml', True)
+
+ def test_dump_bash(self):
+ ns = NetworkSettings('../config/network/network_settings.yaml', True)
+ 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', True)
+ assert_is_instance(ns.get_network_settings(), dict)
+
+ def test_get_enabled_networks(self):
+ ns = NetworkSettings('../config/network/network_settings.yaml', True)
+ assert_is_instance(ns.get_enabled_networks(), list)