summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INFO1
-rw-r--r--docs/testing/user/userguide/04-installation.rst16
-rw-r--r--requirements.txt2
-rw-r--r--yardstick/common/utils.py40
-rw-r--r--yardstick/tests/functional/common/__init__.py (renamed from tests/unit/dispatcher/__init__.py)0
-rw-r--r--yardstick/tests/functional/common/fake_module/__init__.py (renamed from tests/unit/orchestrator/__init__.py)0
-rw-r--r--yardstick/tests/functional/common/fake_module/fake_library.py17
-rw-r--r--yardstick/tests/functional/common/test_utils.py34
-rw-r--r--yardstick/tests/unit/common/test_utils.py11
-rw-r--r--yardstick/tests/unit/dispatcher/__init__.py0
-rw-r--r--yardstick/tests/unit/dispatcher/test_influxdb.py (renamed from tests/unit/dispatcher/test_influxdb.py)11
-rw-r--r--yardstick/tests/unit/dispatcher/test_influxdb_line_protocol.py (renamed from tests/unit/dispatcher/test_influxdb_line_protocol.py)1
-rw-r--r--yardstick/tests/unit/orchestrator/__init__.py0
-rw-r--r--yardstick/tests/unit/orchestrator/test_heat.py (renamed from tests/unit/orchestrator/test_heat.py)311
-rw-r--r--yardstick/tests/unit/orchestrator/test_kubernetes.py (renamed from tests/unit/orchestrator/test_kubernetes.py)4
15 files changed, 318 insertions, 130 deletions
diff --git a/INFO b/INFO
index c1d39e88f..35b282845 100644
--- a/INFO
+++ b/INFO
@@ -13,7 +13,6 @@ Repository: yardstick
Committers:
jorgen.w.karlsson@ericsson.com
jean.gaoliang@huawei.com
-vincenzo.m.riccobene@intel.com
lvjing5@huawei.com
wu.zhihui1@zte.com.cn
14_ykl@tongji.edu.cn
diff --git a/docs/testing/user/userguide/04-installation.rst b/docs/testing/user/userguide/04-installation.rst
index 828c49581..caebecc09 100644
--- a/docs/testing/user/userguide/04-installation.rst
+++ b/docs/testing/user/userguide/04-installation.rst
@@ -107,6 +107,12 @@ Run the Docker image to get a Yardstick container::
======================= ====================================================
--name yardstick The name for this container
+If the host is restarted
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+The yardstick container must be started if the host is rebooted::
+
+ docker start yardstick
Configure the Yardstick container environment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -301,12 +307,6 @@ Prerequisite preparation::
sudo -EH pip install appdirs==1.4.0
sudo -EH pip install virtualenv
-Create a virtual environment::
-
- virtualenv ~/yardstick_venv
- export YARDSTICK_VENV=~/yardstick_venv
- source ~/yardstick_venv/bin/activate
-
Download the source code and install Yardstick from it::
git clone https://gerrit.opnfv.org/gerrit/yardstick
@@ -314,6 +314,10 @@ Download the source code and install Yardstick from it::
cd ~/yardstick
sudo -EH ./install.sh
+If the host is ever restarted, nginx and uwsgi need to be restarted::
+
+ service nginx restart
+ uwsgi -i /etc/yardstick/yardstick.ini
Configure the Yardstick environment (**Todo**)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/requirements.txt b/requirements.txt
index 7fdd8f005..88c0e659a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -11,7 +11,7 @@ Babel==2.3.4 # BSD; OSI Approved BSD License
Jinja2==2.9.6 # BSD; OSI Approved BSD License
SQLAlchemy==1.1.12 # MIT License; OSI Approved MIT License
PTable==0.9.2 # BSD (3 clause); OSI Approved BSD License
-ansible==2.3.2 # GPLv3; OSI Approved GNU General Public License v3 or later (GPLv3+)
+ansible==2.4.2 # GPLv3; OSI Approved GNU General Public License v3 or later (GPLv3+)
backport-ipaddress==0.1; python_version <= "2.7" # OSI Approved Python Software Foundation License
chainmap==1.0.2 # Python Software Foundation License; OSI Approved Python Software Foundation License
django==1.8.17 # BSD; OSI Approved BSD License
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py
index 82e20bec7..8604e900f 100644
--- a/yardstick/common/utils.py
+++ b/yardstick/common/utils.py
@@ -13,27 +13,22 @@
# License for the specific language governing permissions and limitations
# under the License.
-# yardstick comment: this is a modified copy of rally/rally/common/utils.py
-
-from __future__ import absolute_import
-from __future__ import print_function
-
+import collections
+from contextlib import closing
import datetime
import errno
+import importlib
+import ipaddress
import logging
import os
+import random
+import socket
import subprocess
import sys
-import collections
-import socket
-import random
-import ipaddress
-from contextlib import closing
import six
from flask import jsonify
from six.moves import configparser
-from oslo_utils import importutils
from oslo_serialization import jsonutils
import yardstick
@@ -70,27 +65,28 @@ def itersubclasses(cls, _seen=None):
def import_modules_from_package(package):
- """Import modules from package and append into sys.modules
+ """Import modules given a package name
:param: package - Full package name. For example: rally.deploy.engines
"""
yardstick_root = os.path.dirname(os.path.dirname(yardstick.__file__))
- path = os.path.join(yardstick_root, *package.split("."))
+ path = os.path.join(yardstick_root, *package.split('.'))
for root, _, files in os.walk(path):
- matches = (filename for filename in files if filename.endswith(".py") and
- not filename.startswith("__"))
- new_package = os.path.relpath(root, yardstick_root).replace(os.sep, ".")
+ matches = (filename for filename in files if filename.endswith('.py')
+ and not filename.startswith('__'))
+ new_package = os.path.relpath(root, yardstick_root).replace(os.sep,
+ '.')
module_names = set(
- ("{}.{}".format(new_package, filename.rsplit(".py", 1)[0]) for filename in matches))
- # find modules which haven't already been imported
+ '{}.{}'.format(new_package, filename.rsplit('.py', 1)[0])
+ for filename in matches)
+ # Find modules which haven't already been imported
missing_modules = module_names.difference(sys.modules)
- logger.debug("importing %s", missing_modules)
- # we have already checked for already imported modules, so we don't need to check again
+ logger.debug('Importing modules: %s', missing_modules)
for module_name in missing_modules:
try:
- sys.modules[module_name] = importutils.import_module(module_name)
+ importlib.import_module(module_name)
except (ImportError, SyntaxError):
- logger.exception("unable to import %s", module_name)
+ logger.exception('Unable to import module %s', module_name)
def makedirs(d):
diff --git a/tests/unit/dispatcher/__init__.py b/yardstick/tests/functional/common/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/dispatcher/__init__.py
+++ b/yardstick/tests/functional/common/__init__.py
diff --git a/tests/unit/orchestrator/__init__.py b/yardstick/tests/functional/common/fake_module/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/orchestrator/__init__.py
+++ b/yardstick/tests/functional/common/fake_module/__init__.py
diff --git a/yardstick/tests/functional/common/fake_module/fake_library.py b/yardstick/tests/functional/common/fake_module/fake_library.py
new file mode 100644
index 000000000..28c7dc694
--- /dev/null
+++ b/yardstick/tests/functional/common/fake_module/fake_library.py
@@ -0,0 +1,17 @@
+# Copyright (c) 2018 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+class FakeClassToBeImported(object):
+ pass
diff --git a/yardstick/tests/functional/common/test_utils.py b/yardstick/tests/functional/common/test_utils.py
new file mode 100644
index 000000000..b5333bbde
--- /dev/null
+++ b/yardstick/tests/functional/common/test_utils.py
@@ -0,0 +1,34 @@
+# Copyright (c) 2018 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import unittest
+import sys
+
+from yardstick.common import utils
+
+
+class ImportModulesFromPackageTestCase(unittest.TestCase):
+
+ def test_import_package(self):
+ module_name = 'yardstick.tests.functional.common.fake_module'
+ library_name = 'fake_library'
+ class_name = 'FakeClassToBeImported'
+ self.assertNotIn(module_name, sys.modules)
+
+ utils.import_modules_from_package(module_name)
+ self.assertIn(module_name, sys.modules)
+ module_obj = sys.modules[module_name]
+ library_obj = getattr(module_obj, library_name)
+ class_obj = getattr(library_obj, class_name)
+ self.assertEqual(class_name, class_obj().__class__.__name__)
diff --git a/yardstick/tests/unit/common/test_utils.py b/yardstick/tests/unit/common/test_utils.py
index 452b93a56..033bb0243 100644
--- a/yardstick/tests/unit/common/test_utils.py
+++ b/yardstick/tests/unit/common/test_utils.py
@@ -7,12 +7,9 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.common.utils
-
-from __future__ import absolute_import
-
from copy import deepcopy
import errno
+import importlib
import ipaddress
from itertools import product, chain
import mock
@@ -60,8 +57,8 @@ class ImportModulesFromPackageTestCase(unittest.TestCase):
utils.import_modules_from_package('foo.bar')
@mock.patch('yardstick.common.utils.os.walk')
- @mock.patch('yardstick.common.utils.importutils')
- def test_import_modules_from_package(self, mock_importutils, mock_walk):
+ @mock.patch.object(importlib, 'import_module')
+ def test_import_modules_from_package(self, mock_import_module, mock_walk):
yardstick_root = os.path.dirname(os.path.dirname(yardstick.__file__))
mock_walk.return_value = ([
@@ -69,7 +66,7 @@ class ImportModulesFromPackageTestCase(unittest.TestCase):
])
utils.import_modules_from_package('foo.bar')
- mock_importutils.import_module.assert_called_with('bar.baz')
+ mock_import_module.assert_called_once_with('bar.baz')
class GetParaFromYaml(unittest.TestCase):
diff --git a/yardstick/tests/unit/dispatcher/__init__.py b/yardstick/tests/unit/dispatcher/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/yardstick/tests/unit/dispatcher/__init__.py
diff --git a/tests/unit/dispatcher/test_influxdb.py b/yardstick/tests/unit/dispatcher/test_influxdb.py
index 7ebe8c90b..bca94e385 100644
--- a/tests/unit/dispatcher/test_influxdb.py
+++ b/yardstick/tests/unit/dispatcher/test_influxdb.py
@@ -11,20 +11,15 @@
# Unittest for yardstick.dispatcher.influxdb
-from __future__ import absolute_import
+import mock
import unittest
+from yardstick.dispatcher.influxdb import InfluxdbDispatcher
+from yardstick import _init_logging
-try:
- from unittest import mock
-except ImportError:
- import mock
-from yardstick import _init_logging
_init_logging()
-from yardstick.dispatcher.influxdb import InfluxdbDispatcher
-
class InfluxdbDispatcherTestCase(unittest.TestCase):
diff --git a/tests/unit/dispatcher/test_influxdb_line_protocol.py b/yardstick/tests/unit/dispatcher/test_influxdb_line_protocol.py
index 51dc39e3c..641e97fae 100644
--- a/tests/unit/dispatcher/test_influxdb_line_protocol.py
+++ b/yardstick/tests/unit/dispatcher/test_influxdb_line_protocol.py
@@ -11,7 +11,6 @@
# yardstick comment: this file is a modified copy of
# influxdb-python/influxdb/tests/test_line_protocol.py
-from __future__ import absolute_import
import unittest
from third_party.influxdb.influxdb_line_protocol import make_lines
diff --git a/yardstick/tests/unit/orchestrator/__init__.py b/yardstick/tests/unit/orchestrator/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/yardstick/tests/unit/orchestrator/__init__.py
diff --git a/tests/unit/orchestrator/test_heat.py b/yardstick/tests/unit/orchestrator/test_heat.py
index c34ea53fc..faf70cdbc 100644
--- a/tests/unit/orchestrator/test_heat.py
+++ b/yardstick/tests/unit/orchestrator/test_heat.py
@@ -13,10 +13,11 @@
from contextlib import contextmanager
from itertools import count
from tempfile import NamedTemporaryFile
-import unittest
-import uuid
import time
+import uuid
+
import mock
+import unittest
from yardstick.benchmark.contexts import node
from yardstick.orchestrator import heat
@@ -65,6 +66,7 @@ class HeatContextTestCase(unittest.TestCase):
self.assertEqual(heat.HEAT_KEY_UUID_LENGTH, len(k))
self.assertIn(k, str(u))
+
class HeatTemplateTestCase(unittest.TestCase):
def setUp(self):
@@ -73,38 +75,63 @@ class HeatTemplateTestCase(unittest.TestCase):
def test_add_tenant_network(self):
self.template.add_network('some-network')
- self.assertEqual(self.template.resources['some-network']['type'], 'OS::Neutron::Net')
+ 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')
+ 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')
+ 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'])
+ 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.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'])
+ 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'])
+ self.assertEqual(
+ self.template.resources['some-server-group']['type'],
+ 'OS::Nova::ServerGroup')
+ self.assertEqual(
+ self.template.resources['some-server-group']['properties']['policies'],
+ ['anti-affinity'])
def test__add_resources_to_template_raw(self):
test_context = node.NodeContext()
@@ -136,49 +163,136 @@ class HeatTemplateTestCase(unittest.TestCase):
heat_template.add_router("router1", "gw1", "subnet1")
heat_template.add_router_interface("router_if1", "router1", "subnet1")
heat_template.add_port("port1", "network1", "subnet1", "normal")
- heat_template.add_port("port2", "network2", "subnet2", "normal", sec_group_id="sec_group1",provider="not-sriov")
- heat_template.add_port("port3", "network2", "subnet2", "normal", sec_group_id="sec_group1",provider="sriov")
- heat_template.add_floating_ip("floating_ip1", "network1", "port1", "router_if1")
- heat_template.add_floating_ip("floating_ip2", "network2", "port2", "router_if2", "foo-secgroup")
- heat_template.add_floating_ip_association("floating_ip1_association", "floating_ip1", "port1")
+ heat_template.add_port(
+ "port2",
+ "network2",
+ "subnet2",
+ "normal",
+ sec_group_id="sec_group1",
+ provider="not-sriov")
+ heat_template.add_port(
+ "port3",
+ "network2",
+ "subnet2",
+ "normal",
+ sec_group_id="sec_group1",
+ provider="sriov")
+ heat_template.add_floating_ip(
+ "floating_ip1", "network1", "port1", "router_if1")
+ heat_template.add_floating_ip(
+ "floating_ip2", "network2", "port2", "router_if2", "foo-secgroup")
+ heat_template.add_floating_ip_association(
+ "floating_ip1_association", "floating_ip1", "port1")
heat_template.add_servergroup("server_grp2", "affinity")
heat_template.add_servergroup("server_grp3", "anti-affinity")
heat_template.add_security_group("security_group")
- heat_template.add_server(name="server1", image="image1", flavor="flavor1", flavors=[])
- heat_template.add_server_group(name="servergroup", policies=["policy1","policy2"])
+ heat_template.add_server(
+ name="server1", image="image1", flavor="flavor1", flavors=[])
+ heat_template.add_server_group(
+ name="servergroup", policies=["policy1", "policy2"])
heat_template.add_server_group(name="servergroup", policies="policy1")
- heat_template.add_server(name="server2", image="image1", flavor="flavor1", flavors=[], ports=["port1", "port2"],
- networks=["network1", "network2"], scheduler_hints="hints1", user="user1",
- key_name="foo-key", user_data="user", metadata={"cat": 1, "doc": 2},
- additional_properties={"prop1": 1, "prop2": 2})
- heat_template.add_server(name="server2", image="image1", flavor="flavor1", flavors=["flavor1", "flavor2"],
- ports=["port1", "port2"],
- networks=["network1", "network2"], scheduler_hints="hints1", user="user1",
- key_name="foo-key", user_data="user", metadata={"cat": 1, "doc": 2},
- additional_properties={"prop1": 1, "prop2": 2} )
- heat_template.add_server(name="server2", image="image1", flavor="flavor1", flavors=["flavor3", "flavor4"],
- ports=["port1", "port2"],
- networks=["network1", "network2"], scheduler_hints="hints1", user="user1",
- key_name="foo-key", user_data="user", metadata={"cat": 1, "doc": 2},
- additional_properties={"prop1": 1, "prop2": 2})
- heat_template.add_flavor(name="flavor1", vcpus=1, ram=2048, disk=1,extra_specs={"cat": 1, "dog": 2})
+ heat_template.add_server(
+ name="server2",
+ image="image1",
+ flavor="flavor1",
+ flavors=[],
+ ports=[
+ "port1",
+ "port2"],
+ networks=[
+ "network1",
+ "network2"],
+ scheduler_hints="hints1",
+ user="user1",
+ key_name="foo-key",
+ user_data="user",
+ metadata={
+ "cat": 1,
+ "doc": 2},
+ additional_properties={
+ "prop1": 1,
+ "prop2": 2})
+ heat_template.add_server(
+ name="server2",
+ image="image1",
+ flavor="flavor1",
+ flavors=[
+ "flavor1",
+ "flavor2"],
+ ports=[
+ "port1",
+ "port2"],
+ networks=[
+ "network1",
+ "network2"],
+ scheduler_hints="hints1",
+ user="user1",
+ key_name="foo-key",
+ user_data="user",
+ metadata={
+ "cat": 1,
+ "doc": 2},
+ additional_properties={
+ "prop1": 1,
+ "prop2": 2})
+ heat_template.add_server(
+ name="server2",
+ image="image1",
+ flavor="flavor1",
+ flavors=[
+ "flavor3",
+ "flavor4"],
+ ports=[
+ "port1",
+ "port2"],
+ networks=[
+ "network1",
+ "network2"],
+ scheduler_hints="hints1",
+ user="user1",
+ key_name="foo-key",
+ user_data="user",
+ metadata={
+ "cat": 1,
+ "doc": 2},
+ additional_properties={
+ "prop1": 1,
+ "prop2": 2})
+ heat_template.add_flavor(
+ name="flavor1",
+ vcpus=1,
+ ram=2048,
+ disk=1,
+ extra_specs={
+ "cat": 1,
+ "dog": 2})
heat_template.add_flavor(name=None, vcpus=1, ram=2048)
- heat_template.add_server(name="server1",
- image="image1",
- flavor="flavor1",
- flavors=[],
- ports=["port1", "port2"],
- networks=["network1", "network2"],
- scheduler_hints="hints1",
- user="user1",
- key_name="foo-key",
- user_data="user",
- metadata={"cat": 1, "doc": 2},
- additional_properties= {"prop1": 1, "prop2": 2} )
+ heat_template.add_server(
+ name="server1",
+ image="image1",
+ flavor="flavor1",
+ flavors=[],
+ ports=[
+ "port1",
+ "port2"],
+ networks=[
+ "network1",
+ "network2"],
+ scheduler_hints="hints1",
+ user="user1",
+ key_name="foo-key",
+ user_data="user",
+ metadata={
+ "cat": 1,
+ "doc": 2},
+ additional_properties={
+ "prop1": 1,
+ "prop2": 2})
heat_template.add_network("network1")
heat_template.add_flavor("test")
- self.assertEqual(heat_template.resources['test']['type'], 'OS::Nova::Flavor')
+ self.assertEqual(
+ heat_template.resources['test']['type'], 'OS::Nova::Flavor')
@mock_patch_target_module('op_utils')
@mock_patch_target_module('heatclient')
@@ -197,18 +311,25 @@ class HeatTemplateTestCase(unittest.TestCase):
with mock.patch.object(self.template, 'status', return_value=None) as mock_status:
# block with timeout hit
timeout = 0
- with self.assertRaises(RuntimeError) as raised, timer() as time_data:
+ with self.assertRaises(RuntimeError) as raised, timer():
self.template.create(block=True, timeout=timeout)
# ensure op_utils was used
expected_op_utils_usage += 1
- self.assertEqual(mock_op_utils.get_session.call_count, expected_op_utils_usage)
- self.assertEqual(mock_op_utils.get_endpoint.call_count, expected_op_utils_usage)
- self.assertEqual(mock_op_utils.get_heat_api_version.call_count, expected_op_utils_usage)
+ self.assertEqual(
+ mock_op_utils.get_session.call_count, expected_op_utils_usage)
+ self.assertEqual(
+ mock_op_utils.get_endpoint.call_count, expected_op_utils_usage)
+ self.assertEqual(
+ mock_op_utils.get_heat_api_version.call_count,
+ expected_op_utils_usage)
# ensure the constructor and instance were used
- self.assertEqual(mock_heat_client_class.call_count, expected_constructor_calls)
- self.assertEqual(mock_heat_client.stacks.create.call_count, expected_create_calls)
+ self.assertEqual(mock_heat_client_class.call_count,
+ expected_constructor_calls)
+ self.assertEqual(
+ mock_heat_client.stacks.create.call_count,
+ expected_create_calls)
# ensure that the status was used
self.assertGreater(mock_status.call_count, expected_status_calls)
@@ -222,22 +343,33 @@ class HeatTemplateTestCase(unittest.TestCase):
# block with create failed
timeout = 10
mock_status.side_effect = iter([None, None, u'CREATE_FAILED'])
- with self.assertRaises(RuntimeError) as raised, timer() as time_data:
+ with self.assertRaises(RuntimeError) as raised, timer():
self.template.create(block=True, timeout=timeout)
- # ensure the existing heat_client was used and op_utils was used again
- self.assertEqual(mock_op_utils.get_session.call_count, expected_op_utils_usage)
- self.assertEqual(mock_op_utils.get_endpoint.call_count, expected_op_utils_usage)
- self.assertEqual(mock_op_utils.get_heat_api_version.call_count, expected_op_utils_usage)
+ # ensure the existing heat_client was used and op_utils was used
+ # again
+ self.assertEqual(
+ mock_op_utils.get_session.call_count, expected_op_utils_usage)
+ self.assertEqual(
+ mock_op_utils.get_endpoint.call_count, expected_op_utils_usage)
+ self.assertEqual(
+ mock_op_utils.get_heat_api_version.call_count,
+ expected_op_utils_usage)
# ensure the constructor was not used but the instance was used
- self.assertEqual(mock_heat_client_class.call_count, expected_constructor_calls)
- self.assertEqual(mock_heat_client.stacks.create.call_count, expected_create_calls)
+ self.assertEqual(mock_heat_client_class.call_count,
+ expected_constructor_calls)
+ self.assertEqual(
+ mock_heat_client.stacks.create.call_count,
+ expected_create_calls)
# ensure that the status was used three times
expected_status_calls += 3
self.assertEqual(mock_status.call_count, expected_status_calls)
+ # NOTE(elfoley): This needs to be split into multiple tests.
+ # The lines where the template is reset should serve as a guide for where
+ # to split.
@mock_patch_target_module('op_utils')
@mock_patch_target_module('heatclient')
def test_create(self, mock_heat_client_class, mock_op_utils):
@@ -250,7 +382,7 @@ class HeatTemplateTestCase(unittest.TestCase):
{'output_key': 'key2', 'output_value': 'value2'},
{'output_key': 'key3', 'output_value': 'value3'},
]
- expected_outputs = {
+ expected_outputs = { # pylint: disable=unused-variable
'key1': 'value1',
'key2': 'value2',
'key3': 'value3',
@@ -266,17 +398,25 @@ class HeatTemplateTestCase(unittest.TestCase):
mock_status.return_value = None
# no block
- self.assertIsInstance(self.template.create(block=False, timeout=2), heat.HeatStack)
+ self.assertIsInstance(self.template.create(
+ block=False, timeout=2), heat.HeatStack)
# ensure op_utils was used
expected_op_utils_usage += 1
- self.assertEqual(mock_op_utils.get_session.call_count, expected_op_utils_usage)
- self.assertEqual(mock_op_utils.get_endpoint.call_count, expected_op_utils_usage)
- self.assertEqual(mock_op_utils.get_heat_api_version.call_count, expected_op_utils_usage)
+ self.assertEqual(
+ mock_op_utils.get_session.call_count, expected_op_utils_usage)
+ self.assertEqual(
+ mock_op_utils.get_endpoint.call_count, expected_op_utils_usage)
+ self.assertEqual(
+ mock_op_utils.get_heat_api_version.call_count,
+ expected_op_utils_usage)
# ensure the constructor and instance were used
- self.assertEqual(mock_heat_client_class.call_count, expected_constructor_calls)
- self.assertEqual(mock_heat_client.stacks.create.call_count, expected_create_calls)
+ self.assertEqual(mock_heat_client_class.call_count,
+ expected_constructor_calls)
+ self.assertEqual(
+ mock_heat_client.stacks.create.call_count,
+ expected_create_calls)
# ensure that the status was not used
self.assertEqual(mock_status.call_count, expected_status_calls)
@@ -288,11 +428,15 @@ class HeatTemplateTestCase(unittest.TestCase):
self.template.name = 'block, immediate complete test'
mock_status.return_value = self.template.HEAT_CREATE_COMPLETE_STATUS
- self.assertIsInstance(self.template.create(block=True, timeout=2), heat.HeatStack)
+ self.assertIsInstance(self.template.create(
+ block=True, timeout=2), heat.HeatStack)
# ensure existing instance was re-used and op_utils was not used
- self.assertEqual(mock_heat_client_class.call_count, expected_constructor_calls)
- self.assertEqual(mock_heat_client.stacks.create.call_count, expected_create_calls)
+ self.assertEqual(mock_heat_client_class.call_count,
+ expected_constructor_calls)
+ self.assertEqual(
+ mock_heat_client.stacks.create.call_count,
+ expected_create_calls)
# ensure status was checked once
expected_status_calls += 1
@@ -305,13 +449,17 @@ class HeatTemplateTestCase(unittest.TestCase):
self.template.name = 'block, delayed complete test'
success_index = 2
- mock_status.side_effect = index_value_iter(success_index,
- self.template.HEAT_CREATE_COMPLETE_STATUS)
- self.assertIsInstance(self.template.create(block=True, timeout=2), heat.HeatStack)
+ mock_status.side_effect = index_value_iter(
+ success_index, self.template.HEAT_CREATE_COMPLETE_STATUS)
+ self.assertIsInstance(self.template.create(
+ block=True, timeout=2), heat.HeatStack)
# ensure existing instance was re-used and op_utils was not used
- self.assertEqual(mock_heat_client_class.call_count, expected_constructor_calls)
- self.assertEqual(mock_heat_client.stacks.create.call_count, expected_create_calls)
+ self.assertEqual(mock_heat_client_class.call_count,
+ expected_constructor_calls)
+ self.assertEqual(
+ mock_heat_client.stacks.create.call_count,
+ expected_create_calls)
# ensure status was checked three more times
expected_status_calls += 1 + success_index
@@ -328,8 +476,7 @@ class HeatStackTestCase(unittest.TestCase):
# call once and then call again if uuid is not none
self.assertGreater(delete_mock.call_count, 1)
- @mock.patch('yardstick.orchestrator.heat.op_utils')
- def test_delete_all_calls_delete(self, mock_op):
+ def test_delete_all_calls_delete(self):
# we must patch the object before we create an instance
# so we can override delete() in all the instances
with mock.patch.object(heat.HeatStack, "delete") as delete_mock:
diff --git a/tests/unit/orchestrator/test_kubernetes.py b/yardstick/tests/unit/orchestrator/test_kubernetes.py
index 1a3291c89..33fa1dca6 100644
--- a/tests/unit/orchestrator/test_kubernetes.py
+++ b/yardstick/tests/unit/orchestrator/test_kubernetes.py
@@ -64,7 +64,7 @@ service ssh restart;while true ; do sleep 10000; done"
}
],
"nodeSelector": {
- "kubernetes.io/hostname": "node-01"
+ "kubernetes.io/hostname": "node-01"
}
}
}
@@ -75,7 +75,7 @@ service ssh restart;while true ; do sleep 10000; done"
'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
service ssh restart;while true ; do sleep 10000; done'],
'ssh_key': 'k8s-86096c30-key',
- 'nodeSelector': { 'kubernetes.io/hostname': 'node-01'}
+ 'nodeSelector': {'kubernetes.io/hostname': 'node-01'}
}
name = 'host-k8s-86096c30'
output_r = KubernetesObject(name, **input_s).get_template()