summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/ci/clean_images.sh2
-rwxr-xr-xtests/ci/load_images.sh43
-rwxr-xr-xtests/ci/prepare_env.sh50
-rwxr-xr-xtests/ci/yardstick-verify15
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml3
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc074.yaml2
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl_l3-ovs-ha_daily.yaml62
-rw-r--r--tests/opnfv/test_suites/opnfv_os-ovn-nofeature-noha_daily.yaml62
-rw-r--r--tests/unit/benchmark/contexts/test_heat.py7
-rw-r--r--tests/unit/benchmark/contexts/test_model.py25
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen.py6
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_storperf.py4
-rw-r--r--tests/unit/common/test_utils.py21
-rw-r--r--tests/unit/orchestrator/__init__.py0
-rw-r--r--tests/unit/orchestrator/test_heat.py59
15 files changed, 287 insertions, 74 deletions
diff --git a/tests/ci/clean_images.sh b/tests/ci/clean_images.sh
index 9e5e61edf..27da9e279 100755
--- a/tests/ci/clean_images.sh
+++ b/tests/ci/clean_images.sh
@@ -19,7 +19,7 @@ cleanup()
return
fi
- for image in $(openstack image list | grep -e cirros-0.3.5 -e yardstick-image -e Ubuntu-14.04 \
+ for image in $(openstack image list | grep -e cirros-0.3.5 -e yardstick-image -e Ubuntu-16.04 \
| awk '{print $2}'); do
echo "Deleting image $image..."
openstack image delete $image || true
diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh
index ec3ec4604..2e22b83c2 100755
--- a/tests/ci/load_images.sh
+++ b/tests/ci/load_images.sh
@@ -45,26 +45,30 @@ build_yardstick_image()
echo "========== Build yardstick cloud image =========="
if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
- local cmd
- cmd="sudo $(which yardstick-img-lxd-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
+ if [ ! -f "${RAW_IMAGE}" ];then
+ local cmd
+ cmd="sudo $(which yardstick-img-lxd-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
- # Build the image. Retry once if the build fails
- $cmd || $cmd
+ # Build the image. Retry once if the build fails
+ $cmd || $cmd
- if [ ! -f "${RAW_IMAGE}" ]; then
- echo "Failed building RAW image"
- exit 1
+ if [ ! -f "${RAW_IMAGE}" ]; then
+ echo "Failed building RAW image"
+ exit 1
+ fi
fi
else
- local cmd
- cmd="sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
+ if [ ! -f "${QCOW_IMAGE}" ];then
+ local cmd
+ cmd="sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
- # Build the image. Retry once if the build fails
- $cmd || $cmd
+ # Build the image. Retry once if the build fails
+ $cmd || $cmd
- if [ ! -f "${QCOW_IMAGE}" ]; then
- echo "Failed building QCOW image"
- exit 1
+ if [ ! -f "${QCOW_IMAGE}" ]; then
+ echo "Failed building QCOW image"
+ exit 1
+ fi
fi
fi
}
@@ -189,7 +193,7 @@ load_ubuntu_image()
echo
echo "========== Loading ubuntu cloud image =========="
- local ubuntu_image_file=/home/opnfv/images/trusty-server-cloudimg-amd64-disk1.img
+ local ubuntu_image_file=/home/opnfv/images/xenial-server-cloudimg-amd64-disk1.img
EXTRA_PARAMS=""
# VPP requires guest memory to be backed by large pages
@@ -202,7 +206,7 @@ load_ubuntu_image()
--container-format bare \
$EXTRA_PARAMS \
--file $ubuntu_image_file \
- Ubuntu-14.04)
+ Ubuntu-16.04)
echo "$output"
UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
@@ -245,6 +249,13 @@ main()
QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img"
RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz"
+ if [ -f /home/opnfv/images/yardstick-image.img ];then
+ QCOW_IMAGE='/home/opnfv/images/yardstick-image.img'
+ fi
+ if [ -f /home/opnfv/images/yardstick-image.tar.gz ];then
+ RAW_IMAGE='/home/opnfv/images/yardstick-image.tar.gz'
+ fi
+
build_yardstick_image
load_yardstick_image
if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
diff --git a/tests/ci/prepare_env.sh b/tests/ci/prepare_env.sh
index be59b7f37..e8f287bcd 100755
--- a/tests/ci/prepare_env.sh
+++ b/tests/ci/prepare_env.sh
@@ -21,35 +21,41 @@ export EXTERNAL_NETWORK=$(echo $EXTERNAL_NETWORK | cut -f1 -d \;)
# Create openstack credentials
echo "INFO: Creating openstack credentials .."
-OPENRC=/home/opnfv/openrc
+mkdir -p /etc/yardstick
+OPENRC=/etc/yardstick/openstack.creds
INSTALLERS=(apex compass fuel joid)
-if [ ! -f $OPENRC ]; then
- # credentials file is not given, check if environment variables are set
- # to get the creds using fetch_os_creds.sh later on
- echo "INFO: Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
- if [ -z ${INSTALLER_TYPE} ]; then
- echo "environment variable 'INSTALLER_TYPE' is not defined."
- exit 1
- elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
- echo "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
- else
- echo "Invalid env variable INSTALLER_TYPE=${INSTALLER_TYPE}"
- exit 1
- fi
+RC_VAR_EXIST=false
+if [ "${OS_AUTH_URL}" -a "${OS_USERNAME}" -a "${OS_PASSWORD}" -a "${EXTERNAL_NETWORK}" ];then
+ RC_VAR_EXIST=true
+fi
- if [ "$DEPLOY_TYPE" == "virt" ]; then
- FETCH_CRED_ARG="-v -d $OPENRC -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}"
- else
- FETCH_CRED_ARG="-d $OPENRC -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}"
- fi
+if [ "${RC_VAR_EXIST}" = false ]; then
+ if [ ! -f $OPENRC ];then
+ # credentials file is not given, check if environment variables are set
+ # to get the creds using fetch_os_creds.sh later on
+ echo "INFO: Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
+ if [ -z ${INSTALLER_TYPE} ]; then
+ echo "environment variable 'INSTALLER_TYPE' is not defined."
+ exit 1
+ elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
+ echo "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
+ else
+ echo "Invalid env variable INSTALLER_TYPE=${INSTALLER_TYPE}"
+ exit 1
+ fi
- $RELENG_REPO_DIR/utils/fetch_os_creds.sh $FETCH_CRED_ARG
+ if [ "$DEPLOY_TYPE" == "virt" ]; then
+ FETCH_CRED_ARG="-v -d $OPENRC -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}"
+ else
+ FETCH_CRED_ARG="-d $OPENRC -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}"
+ fi
+ $RELENG_REPO_DIR/utils/fetch_os_creds.sh $FETCH_CRED_ARG
+ fi
+ source $OPENRC
fi
-source $OPENRC
-
export EXTERNAL_NETWORK INSTALLER_TYPE DEPLOY_TYPE NODE_NAME
# Prepare a admin-rc file for StorPerf integration
diff --git a/tests/ci/yardstick-verify b/tests/ci/yardstick-verify
index 2986c9f2f..096ea534f 100755
--- a/tests/ci/yardstick-verify
+++ b/tests/ci/yardstick-verify
@@ -97,18 +97,6 @@ error_exit()
set -o errexit
set -o pipefail
-install_yardstick()
-{
- echo
- echo "========== Installing yardstick =========="
-
- # uninstall previous version
- pip uninstall -y yardstick || true
-
- # Install yardstick
- pip install .
-}
-
install_storperf()
{
# Install Storper on huawei-pod1
@@ -320,9 +308,6 @@ main()
echo " external network: $net"
done
- # install yardstick
- install_yardstick
-
source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh
trap "error_exit" EXIT SIGTERM
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml
index a9802346b..4c7fdab90 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml
@@ -65,3 +65,6 @@ context:
networks:
test:
cidr: '10.0.1.0/24'
+ #test-sriov:
+ #cidr: '10.0.1.0/24'
+ #provider: "sriov"
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc074.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc074.yaml
index 14604f844..326fdf53b 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc074.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc074.yaml
@@ -20,7 +20,7 @@ scenarios:
type: StorPerf
options:
agent_count: 1
- agent_image: "Ubuntu-14.04"
+ agent_image: "Ubuntu-16.04"
public_network: {{public_network}}
volume_size: 4
block_sizes: "4096"
diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l3-ovs-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l3-ovs-ha_daily.yaml
new file mode 100644
index 000000000..6d2bea5e8
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-odl_l3-ovs-ha_daily.yaml
@@ -0,0 +1,62 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# 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
+##############################################################################
+---
+# os-odl_l3-ovs-ha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-odl_l3-ovs-ha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc055.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC055"}'
+-
+ file_name: opnfv_yardstick_tc063.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC063"}'
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
+-
+ file_name: opnfv_yardstick_tc075.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node1.LF"}'
diff --git a/tests/opnfv/test_suites/opnfv_os-ovn-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-ovn-nofeature-noha_daily.yaml
new file mode 100644
index 000000000..9e20186bb
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-ovn-nofeature-noha_daily.yaml
@@ -0,0 +1,62 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# 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
+##############################################################################
+---
+# os-ovn-nofeature-noha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-ovn-nofeature-noha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc055.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC055"}'
+-
+ file_name: opnfv_yardstick_tc063.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC063"}'
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
+-
+ file_name: opnfv_yardstick_tc075.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node1.LF"}'
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py
index 8f4852ca8..b56d0c86d 100644
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ b/tests/unit/benchmark/contexts/test_heat.py
@@ -21,6 +21,7 @@ import uuid
import mock
from yardstick.benchmark.contexts import heat
+from yardstick.benchmark.contexts import model
LOG = logging.getLogger(__name__)
@@ -102,12 +103,18 @@ class HeatContextTestCase(unittest.TestCase):
self.test_context.keypair_name = "foo-key"
self.test_context.secgroup_name = "foo-secgroup"
self.test_context.key_uuid = "2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b"
+ netattrs = {'cidr': '10.0.0.0/24', 'provider': None, 'external_network': 'ext_net'}
+ self.mock_context.name = 'bar'
+ self.test_context.networks = [model.Network("fool-network", self.mock_context, netattrs)]
self.test_context._add_resources_to_template(mock_template)
mock_template.add_keypair.assert_called_with(
"foo-key",
"2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b")
mock_template.add_security_group.assert_called_with("foo-secgroup")
+ mock_template.add_network.assert_called_with("bar-fool-network", 'physnet1', None)
+ mock_template.add_router.assert_called_with("bar-fool-network-router", netattrs["external_network"], "bar-fool-network-subnet")
+ mock_template.add_router_interface.assert_called_with("bar-fool-network-router-if0", "bar-fool-network-router", "bar-fool-network-subnet")
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test_deploy(self, mock_template):
diff --git a/tests/unit/benchmark/contexts/test_model.py b/tests/unit/benchmark/contexts/test_model.py
index 6ae4e6dac..4a10761f7 100644
--- a/tests/unit/benchmark/contexts/test_model.py
+++ b/tests/unit/benchmark/contexts/test_model.py
@@ -170,6 +170,9 @@ class ServerTestCase(unittest.TestCase):
self.mock_context.keypair_name = 'some-keys'
self.mock_context.secgroup_name = 'some-secgroup'
self.mock_context.user = "some-user"
+ netattrs = {'cidr': '10.0.0.0/24', 'provider': None, 'external_network': 'ext_net'}
+ self.mock_context.networks = [model.Network("some-network", self.mock_context, netattrs)]
+
def test_construct_defaults(self):
@@ -208,13 +211,16 @@ class ServerTestCase(unittest.TestCase):
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test__add_instance(self, mock_template):
- attrs = {'image': 'some-image', 'flavor': 'some-flavor'}
+ attrs = {'image': 'some-image', 'flavor': 'some-flavor', 'floating_ip': '192.168.1.10', 'floating_ip_assoc': 'some-vm'}
test_server = model.Server('foo', self.mock_context, attrs)
mock_network = mock.Mock()
mock_network.name = 'some-network'
mock_network.stack_name = 'some-network-stack'
mock_network.subnet_stack_name = 'some-network-stack-subnet'
+ mock_network.provider = 'sriov'
+ mock_network.external_network = 'ext_net'
+ mock_network.router = model.Router('some-router', 'some-network', self.mock_context, 'ext_net')
test_server._add_instance(mock_template, 'some-server',
[mock_network], 'hints')
@@ -223,7 +229,22 @@ class ServerTestCase(unittest.TestCase):
'some-server-some-network-port',
mock_network.stack_name,
mock_network.subnet_stack_name,
- sec_group_id=self.mock_context.secgroup_name)
+ sec_group_id=self.mock_context.secgroup_name,
+ provider=mock_network.provider)
+
+ mock_template.add_floating_ip.assert_called_with(
+ 'some-server-fip',
+ mock_network.external_network,
+ 'some-server-some-network-port',
+ 'bar-some-network-some-router-if0',
+ 'some-secgroup'
+ )
+
+ mock_template.add_floating_ip_association.assert_called_with(
+ 'some-server-fip-assoc',
+ 'some-server-fip',
+ 'some-server-some-network-port'
+ )
mock_template.add_server.assert_called_with(
'some-server', 'some-image', 'some-flavor',
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen.py b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
index f50fa108c..989c5b712 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen.py
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
@@ -132,7 +132,7 @@ class PktgenTestCase(unittest.TestCase):
p._iptables_get_result = mock_iptables_result
sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "flows": 110}'
+ "packets_sent": 149776, "packetsize": 60, "flows": 110}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -158,7 +158,7 @@ class PktgenTestCase(unittest.TestCase):
p._iptables_get_result = mock_iptables_result
sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "flows": 110}'
+ "packets_sent": 149776, "packetsize": 60, "flows": 110}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -184,7 +184,7 @@ class PktgenTestCase(unittest.TestCase):
p._iptables_get_result = mock_iptables_result
sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "flows": 110}'
+ "packets_sent": 149776, "packetsize": 60, "flows": 110}'
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
self.assertRaises(AssertionError, p.run, result)
diff --git a/tests/unit/benchmark/scenarios/storage/test_storperf.py b/tests/unit/benchmark/scenarios/storage/test_storperf.py
index adc9d47c6..00054d531 100644
--- a/tests/unit/benchmark/scenarios/storage/test_storperf.py
+++ b/tests/unit/benchmark/scenarios/storage/test_storperf.py
@@ -55,7 +55,7 @@ def mocked_requests_job_get(*args, **kwargs):
self.status_code = status_code
return MockResponseJobGet(
- '{"status": "completed",\
+ '{"Status": "Completed",\
"_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}',
200)
@@ -171,7 +171,7 @@ class StorPerfTestCase(unittest.TestCase):
s = storperf.StorPerf(args, self.ctx)
s.setup_done = True
- sample_output = '{"status": "completed",\
+ sample_output = '{"Status": "Completed",\
"_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}'
expected_result = jsonutils.loads(sample_output)
diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py
index 267c71312..8f52b53b0 100644
--- a/tests/unit/common/test_utils.py
+++ b/tests/unit/common/test_utils.py
@@ -87,24 +87,21 @@ class ImportModulesFromPackageTestCase(unittest.TestCase):
class GetParaFromYaml(unittest.TestCase):
- def test_get_para_from_yaml_file_not_exist(self):
- file_path = '/etc/yardstick/hello.yaml'
- args = 'hello.world'
- para = utils.get_para_from_yaml(file_path, args)
- self.assertIsNone(para)
-
- def test_get_para_from_yaml_para_not_found(self):
+ @mock.patch('yardstick.common.utils.os.environ.get')
+ def test_get_param_para_not_found(self, get_env):
file_path = 'config_sample.yaml'
- file_path = self._get_file_abspath(file_path)
+ get_env.return_value = self._get_file_abspath(file_path)
args = 'releng.file'
- self.assertIsNone(utils.get_para_from_yaml(file_path, args))
+ default = 'hello'
+ self.assertTrue(utils.get_param(args, default), default)
- def test_get_para_from_yaml_para_exists(self):
+ @mock.patch('yardstick.common.utils.os.environ.get')
+ def test_get_param_para_exists(self, get_env):
file_path = 'config_sample.yaml'
- file_path = self._get_file_abspath(file_path)
+ get_env.return_value = self._get_file_abspath(file_path)
args = 'releng.dir'
para = '/home/opnfv/repos/releng'
- self.assertEqual(para, utils.get_para_from_yaml(file_path, args))
+ self.assertEqual(para, utils.get_param(args))
def _get_file_abspath(self, filename):
curr_path = os.path.dirname(os.path.abspath(__file__))
diff --git a/tests/unit/orchestrator/__init__.py b/tests/unit/orchestrator/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/unit/orchestrator/__init__.py
diff --git a/tests/unit/orchestrator/test_heat.py b/tests/unit/orchestrator/test_heat.py
index 97314c275..2f9c800aa 100644
--- a/tests/unit/orchestrator/test_heat.py
+++ b/tests/unit/orchestrator/test_heat.py
@@ -13,6 +13,7 @@
import unittest
import uuid
+import mock
from yardstick.orchestrator import heat
@@ -24,3 +25,61 @@ class HeatContextTestCase(unittest.TestCase):
k = heat.get_short_key_uuid(u)
self.assertEqual(heat.HEAT_KEY_UUID_LENGTH, len(k))
self.assertIn(k, str(u))
+
+class HeatTemplateTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.template = heat.HeatTemplate('test')
+
+ def test_add_tenant_network(self):
+ self.template.add_network('some-network')
+
+ self.assertEqual(self.template.resources['some-network']['type'], 'OS::Neutron::Net')
+
+ def test_add_provider_network(self):
+ self.template.add_network('some-network', 'physnet2', 'sriov')
+
+ self.assertEqual(self.template.resources['some-network']['type'], 'OS::Neutron::ProviderNet')
+ self.assertEqual(self.template.resources['some-network']['properties']['physical_network'], 'physnet2')
+
+ def test_add_subnet(self):
+ netattrs = {'cidr': '10.0.0.0/24', 'provider': None, 'external_network': 'ext_net'}
+ self.template.add_subnet('some-subnet', "some-network", netattrs['cidr'])
+
+ self.assertEqual(self.template.resources['some-subnet']['type'], 'OS::Neutron::Subnet')
+ self.assertEqual(self.template.resources['some-subnet']['properties']['cidr'], '10.0.0.0/24')
+
+ def test_add_router(self):
+ self.template.add_router('some-router', 'ext-net', 'some-subnet')
+
+ self.assertEqual(self.template.resources['some-router']['type'], 'OS::Neutron::Router')
+ self.assertIn('some-subnet', self.template.resources['some-router']['depends_on'])
+
+ def test_add_router_interface(self):
+ self.template.add_router_interface('some-router-if', 'some-router', 'some-subnet')
+
+ self.assertEqual(self.template.resources['some-router-if']['type'], 'OS::Neutron::RouterInterface')
+ self.assertIn('some-subnet', self.template.resources['some-router-if']['depends_on'])
+
+ def test_add_servergroup(self):
+ self.template.add_servergroup('some-server-group', 'anti-affinity')
+
+ self.assertEqual(self.template.resources['some-server-group']['type'], 'OS::Nova::ServerGroup')
+ self.assertEqual(self.template.resources['some-server-group']['properties']['policies'], ['anti-affinity'])
+
+class HeatStackTestCase(unittest.TestCase):
+
+ def test_delete_calls__delete_multiple_times(self):
+ stack = heat.HeatStack('test')
+ stack.uuid = 1
+ with mock.patch.object(stack, "_delete") as delete_mock:
+ stack.delete()
+ # call once and then call again if uuid is not none
+ self.assertGreater(delete_mock.call_count, 1)
+
+ def test_delete_all_calls_delete(self):
+ stack = heat.HeatStack('test')
+ stack.uuid = 1
+ with mock.patch.object(stack, "delete") as delete_mock:
+ stack.delete_all()
+ self.assertGreater(delete_mock.call_count, 0)