aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.coveragerc2
-rw-r--r--ansible/roles/configure_uwsgi/templates/yardstick.ini.j22
-rw-r--r--ansible/roles/install_dpdk/tasks/main.yml9
-rw-r--r--docker/Dockerfile2
-rw-r--r--docker/Dockerfile.aarch64.patch7
-rw-r--r--samples/vnf_samples/nsut/acl/acl_rules.yaml.sample (renamed from samples/vnf_samples/nsut/acl/acl_rules.yaml)10
-rw-r--r--yardstick/benchmark/contexts/__init__.py20
-rw-r--r--yardstick/benchmark/contexts/dummy.py7
-rw-r--r--yardstick/benchmark/contexts/heat.py3
-rw-r--r--yardstick/benchmark/contexts/kubernetes.py29
-rw-r--r--yardstick/benchmark/contexts/node.py4
-rw-r--r--yardstick/benchmark/contexts/standalone/ovs_dpdk.py9
-rw-r--r--yardstick/benchmark/contexts/standalone/sriov.py9
-rw-r--r--yardstick/benchmark/core/task.py36
-rw-r--r--yardstick/common/constants.py8
-rw-r--r--yardstick/common/exceptions.py8
-rw-r--r--yardstick/common/httpClient.py4
-rw-r--r--yardstick/network_services/collector/subscriber.py11
-rw-r--r--yardstick/network_services/vnf_generic/vnf/base.py2
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py3
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py3
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_kubernetes.py11
-rw-r--r--yardstick/tests/unit/benchmark/core/test_task.py8
-rw-r--r--yardstick/tests/unit/network_services/collector/test_subscriber.py43
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py2
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py6
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py5
27 files changed, 176 insertions, 87 deletions
diff --git a/.coveragerc b/.coveragerc
index f67853192..3ad7f68a6 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -14,4 +14,4 @@ source = yardstick
[report]
ignore_errors = True
precision = 3
-omit = yardstick/vTC/*
+omit = yardstick/vTC/*,yardstick/tests/functional/*
diff --git a/ansible/roles/configure_uwsgi/templates/yardstick.ini.j2 b/ansible/roles/configure_uwsgi/templates/yardstick.ini.j2
index 044f42acb..495febb19 100644
--- a/ansible/roles/configure_uwsgi/templates/yardstick.ini.j2
+++ b/ansible/roles/configure_uwsgi/templates/yardstick.ini.j2
@@ -12,7 +12,7 @@ chmod-socket = 666
callable = app_wrapper
enable-threads = true
close-on-exec = 1
-daemonize = {{ log_dir }}uwsgi.log
+logto = {{ log_dir }}/uwsgi.log
socket = {{ socket_file }}
{# If virtual environment, we need to add:
virtualenv = <virtual_env> #}
diff --git a/ansible/roles/install_dpdk/tasks/main.yml b/ansible/roles/install_dpdk/tasks/main.yml
index 5bcfb50b1..f89a43cae 100644
--- a/ansible/roles/install_dpdk/tasks/main.yml
+++ b/ansible/roles/install_dpdk/tasks/main.yml
@@ -114,9 +114,16 @@
path: "{{ INSTALL_BIN_PATH }}"
state: directory
+- set_fact:
+ major: "{{ dpdk_version.split('.')[0] }}"
+ minor: "{{ dpdk_version.split('.')[1] }}"
+
+- set_fact:
+ major_minor_version: "{{ major }}.{{ minor }}"
+
- name: copy dpdk-devbind.py to correct location
copy:
- src: "{{ dpdk_devbind_usertools if dpdk_version|float >= 17.02 else dpdk_devbind_tools }}"
+ src: "{{ dpdk_devbind_usertools if major_minor_version|float >= 17.02 else dpdk_devbind_tools }}"
dest: "{{ INSTALL_BIN_PATH }}/dpdk-devbind.py"
remote_src: yes
force: yes
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 097bc3c3f..71ce6b584 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -51,6 +51,8 @@ EXPOSE 5000 5672
ADD http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img ${IMAGE_DIR}
ADD http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img ${IMAGE_DIR}
+# For developers: when `docker build ...` is running from YARDSTICK_REPO_DIR, please change
+# path `./exec_tests.sh` -> `./docker/exec_tests.sh``.
COPY ./exec_tests.sh /usr/local/bin/
ENV NSB_DIR="/opt/nsb_bin"
diff --git a/docker/Dockerfile.aarch64.patch b/docker/Dockerfile.aarch64.patch
index ef41cba03..472310f96 100644
--- a/docker/Dockerfile.aarch64.patch
+++ b/docker/Dockerfile.aarch64.patch
@@ -8,7 +8,7 @@ Signed-off-by: ting wu <ting.wu@enea.com>
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/docker/Dockerfile b/docker/Dockerfile
-index 62ea0d0..f2f41771 100644
+index 71ce6b58..952d0f78 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -7,9 +7,9 @@
@@ -42,6 +42,5 @@ index 62ea0d0..f2f41771 100644
+ADD http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-disk.img ${IMAGE_DIR}
+ADD http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-arm64-disk1.img ${IMAGE_DIR}
- COPY ./exec_tests.sh /usr/local/bin/
-
-
+ # For developers: when `docker build ...` is running from YARDSTICK_REPO_DIR, please change
+ # path `./exec_tests.sh` -> `./docker/exec_tests.sh``.
diff --git a/samples/vnf_samples/nsut/acl/acl_rules.yaml b/samples/vnf_samples/nsut/acl/acl_rules.yaml.sample
index 49066e924..4c425d44f 100644
--- a/samples/vnf_samples/nsut/acl/acl_rules.yaml
+++ b/samples/vnf_samples/nsut/acl/acl_rules.yaml.sample
@@ -14,7 +14,12 @@
---
access-list-entries:
-
- actions: [drop,count]
+ actions:
+ - count
+ - nat:
+ port: 1
+ - fwd:
+ port: 0
matches:
destination-ipv4-network: 152.16.40.20/24
destination-port-range:
@@ -24,6 +29,9 @@ access-list-entries:
source-port-range:
lower-port: 0
upper-port: 65535
+ protocol-mask: 255
+ protocol: 127
+ priority: 1
rule-name: rule1588
-
actions: [drop,count]
diff --git a/yardstick/benchmark/contexts/__init__.py b/yardstick/benchmark/contexts/__init__.py
index e69de29bb..d50f08cc3 100644
--- a/yardstick/benchmark/contexts/__init__.py
+++ b/yardstick/benchmark/contexts/__init__.py
@@ -0,0 +1,20 @@
+# Copyright (c) 2016-2017 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.
+
+CONTEXT_DUMMY = "Dummy"
+CONTEXT_HEAT = "Heat"
+CONTEXT_KUBERNETES = "Kubernetes"
+CONTEXT_NODE = "Node"
+CONTEXT_STANDALONEOVSDPDK = "StandaloneOvsDpdk"
+CONTEXT_STANDALONESRIOV = "StandaloneSriov"
diff --git a/yardstick/benchmark/contexts/dummy.py b/yardstick/benchmark/contexts/dummy.py
index 36e8854e8..9faca4c63 100644
--- a/yardstick/benchmark/contexts/dummy.py
+++ b/yardstick/benchmark/contexts/dummy.py
@@ -7,17 +7,18 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from yardstick.benchmark.contexts.base import Context
+from yardstick.benchmark import contexts
+from yardstick.benchmark.contexts import base
-class DummyContext(Context):
+class DummyContext(base.Context):
"""Class that handle dummy info.
This class is also used to test the abstract class Context because it
provides a minimal concrete implementation of a subclass.
"""
- __context_type__ = "Dummy"
+ __context_type__ = contexts.CONTEXT_DUMMY
def deploy(self):
"""Don't need to deploy"""
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py
index ac85b6ffe..f118ffc32 100644
--- a/yardstick/benchmark/contexts/heat.py
+++ b/yardstick/benchmark/contexts/heat.py
@@ -16,6 +16,7 @@ from collections import OrderedDict
import ipaddress
import pkg_resources
+from yardstick.benchmark import contexts
from yardstick.benchmark.contexts.base import Context
from yardstick.benchmark.contexts.model import Network
from yardstick.benchmark.contexts.model import PlacementGroup, ServerGroup
@@ -47,7 +48,7 @@ def h_join(*args):
class HeatContext(Context):
"""Class that represents a context in the logical model"""
- __context_type__ = "Heat"
+ __context_type__ = contexts.CONTEXT_HEAT
def __init__(self):
self.stack = None
diff --git a/yardstick/benchmark/contexts/kubernetes.py b/yardstick/benchmark/contexts/kubernetes.py
index 4ba9eee36..a6b3ebad8 100644
--- a/yardstick/benchmark/contexts/kubernetes.py
+++ b/yardstick/benchmark/contexts/kubernetes.py
@@ -7,15 +7,17 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import absolute_import
import logging
import time
import pkg_resources
import paramiko
+from yardstick.benchmark import contexts
from yardstick.benchmark.contexts.base import Context
from yardstick.orchestrator import kubernetes
+from yardstick.common import constants
+from yardstick.common import exceptions
from yardstick.common import kubernetes_utils as k8s_utils
from yardstick.common import utils
@@ -26,7 +28,7 @@ BITS_LENGTH = 2048
class KubernetesContext(Context):
"""Class that handle nodes info"""
- __context_type__ = "Kubernetes"
+ __context_type__ = contexts.CONTEXT_KUBERNETES
def __init__(self):
self.ssh_key = ''
@@ -156,19 +158,26 @@ class KubernetesContext(Context):
def _get_server(self, name):
service_name = '{}-service'.format(name)
- service = k8s_utils.get_service_by_name(service_name).ports[0]
-
- host = {
- 'name': service.name,
+ service = k8s_utils.get_service_by_name(service_name)
+ if not service:
+ raise exceptions.KubernetesServiceObjectNotDefined()
+
+ for sn_port in (sn_port for sn_port in service.ports
+ if sn_port.port == constants.SSH_PORT):
+ node_port = sn_port.node_port
+ break
+ else:
+ raise exceptions.KubernetesSSHPortNotDefined()
+
+ return {
+ 'name': name,
'ip': self._get_node_ip(),
'private_ip': k8s_utils.get_pod_by_name(name).status.pod_ip,
- 'ssh_port': service.node_port,
+ 'ssh_port': node_port,
'user': 'root',
- 'key_filename': self.key_path,
+ 'key_filename': self.key_path
}
- return host
-
def _get_node_ip(self):
return k8s_utils.get_node_list().items[0].status.addresses[0].address
diff --git a/yardstick/benchmark/contexts/node.py b/yardstick/benchmark/contexts/node.py
index d3af98920..d233e02ae 100644
--- a/yardstick/benchmark/contexts/node.py
+++ b/yardstick/benchmark/contexts/node.py
@@ -7,7 +7,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import absolute_import
import subprocess
import os
import collections
@@ -18,6 +17,7 @@ import six
import pkg_resources
from yardstick import ssh
+from yardstick.benchmark import contexts
from yardstick.benchmark.contexts.base import Context
from yardstick.common.constants import ANSIBLE_DIR, YARDSTICK_ROOT_PATH
from yardstick.common.ansible_common import AnsibleCommon
@@ -31,7 +31,7 @@ DEFAULT_DISPATCH = 'script'
class NodeContext(Context):
"""Class that handle nodes info"""
- __context_type__ = "Node"
+ __context_type__ = contexts.CONTEXT_NODE
def __init__(self):
self.file_path = None
diff --git a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
index e6a6f99e4..88ad598c3 100644
--- a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
+++ b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
@@ -20,11 +20,12 @@ import re
import time
from yardstick import ssh
-from yardstick.network_services.utils import get_nsb_option
-from yardstick.benchmark.contexts.base import Context
+from yardstick.benchmark import contexts
+from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts.standalone import model
from yardstick.common import exceptions
from yardstick.network_services import utils
+from yardstick.network_services.utils import get_nsb_option
LOG = logging.getLogger(__name__)
@@ -32,12 +33,12 @@ LOG = logging.getLogger(__name__)
MAIN_BRIDGE = 'br0'
-class OvsDpdkContext(Context):
+class OvsDpdkContext(base.Context):
""" This class handles OVS standalone nodes - VM running on Non-Managed NFVi
Configuration: ovs_dpdk
"""
- __context_type__ = "StandaloneOvsDpdk"
+ __context_type__ = contexts.CONTEXT_STANDALONEOVSDPDK
SUPPORTED_OVS_TO_DPDK_MAP = {
'2.6.0': '16.07.1',
diff --git a/yardstick/benchmark/contexts/standalone/sriov.py b/yardstick/benchmark/contexts/standalone/sriov.py
index 05fac0218..3da12a9a8 100644
--- a/yardstick/benchmark/contexts/standalone/sriov.py
+++ b/yardstick/benchmark/contexts/standalone/sriov.py
@@ -18,20 +18,21 @@ import logging
import collections
from yardstick import ssh
-from yardstick.network_services.utils import get_nsb_option
-from yardstick.benchmark.contexts.base import Context
+from yardstick.benchmark import contexts
+from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts.standalone import model
+from yardstick.network_services.utils import get_nsb_option
from yardstick.network_services.utils import PciAddress
LOG = logging.getLogger(__name__)
-class SriovContext(Context):
+class SriovContext(base.Context):
""" This class handles SRIOV standalone nodes - VM running on Non-Managed NFVi
Configuration: sr-iov
"""
- __context_type__ = "StandaloneSriov"
+ __context_type__ = contexts.CONTEXT_STANDALONESRIOV
def __init__(self):
self.file_path = None
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py
index f050e8d0f..1dfd6c31e 100644
--- a/yardstick/benchmark/core/task.py
+++ b/yardstick/benchmark/core/task.py
@@ -22,7 +22,8 @@ import collections
from six.moves import filter
from jinja2 import Environment
-from yardstick.benchmark.contexts.base import Context
+from yardstick.benchmark import contexts
+from yardstick.benchmark.contexts import base as base_context
from yardstick.benchmark.runners import base as base_runner
from yardstick.common.constants import CONF_FILE
from yardstick.common.yaml_loader import yaml_load
@@ -359,7 +360,7 @@ class Task(object): # pragma: no cover
if is_ip_addr(target):
context_cfg['target'] = {"ipaddr": target}
else:
- context_cfg['target'] = Context.get_server(target)
+ context_cfg['target'] = base_context.Context.get_server(target)
if self._is_same_context(cfg["host"], target):
context_cfg['target']["ipaddr"] = context_cfg['target']["private_ip"]
else:
@@ -367,7 +368,7 @@ class Task(object): # pragma: no cover
host_name = server_name.get('host', scenario_cfg.get('host'))
if host_name:
- context_cfg['host'] = Context.get_server(host_name)
+ context_cfg['host'] = base_context.Context.get_server(host_name)
for item in [server_name, scenario_cfg]:
try:
@@ -384,7 +385,8 @@ class Task(object): # pragma: no cover
ip_list.append(target)
context_cfg['target'] = {}
else:
- context_cfg['target'] = Context.get_server(target)
+ context_cfg['target'] = (
+ base_context.Context.get_server(target))
if self._is_same_context(scenario_cfg["host"],
target):
ip_list.append(context_cfg["target"]["private_ip"])
@@ -412,7 +414,8 @@ class Task(object): # pragma: no cover
with attribute name mapping when using external heat templates
"""
for context in self.contexts:
- if context.__context_type__ not in {"Heat", "Kubernetes"}:
+ if context.__context_type__ not in {contexts.CONTEXT_HEAT,
+ contexts.CONTEXT_KUBERNETES}:
continue
host = context._get_server(host_attr)
@@ -553,19 +556,19 @@ class TaskParser(object): # pragma: no cover
elif "contexts" in cfg:
context_cfgs = cfg["contexts"]
else:
- context_cfgs = [{"type": "Dummy"}]
+ context_cfgs = [{"type": contexts.CONTEXT_DUMMY}]
- contexts = []
+ _contexts = []
for cfg_attrs in context_cfgs:
cfg_attrs['task_id'] = task_id
# default to Heat context because we are testing OpenStack
- context_type = cfg_attrs.get("type", "Heat")
- context = Context.get(context_type)
+ context_type = cfg_attrs.get("type", contexts.CONTEXT_HEAT)
+ context = base_context.Context.get(context_type)
context.init(cfg_attrs)
# Update the name in case the context has used the name_suffix
cfg_attrs['name'] = context.name
- contexts.append(context)
+ _contexts.append(context)
run_in_parallel = cfg.get("run_in_parallel", False)
@@ -578,17 +581,17 @@ class TaskParser(object): # pragma: no cover
# relative to task path
scenario["task_path"] = os.path.dirname(self.path)
- self._change_node_names(scenario, contexts)
+ self._change_node_names(scenario, _contexts)
# TODO we need something better here, a class that represent the file
return {'scenarios': cfg['scenarios'],
'run_in_parallel': run_in_parallel,
'meet_precondition': meet_precondition,
- 'contexts': contexts,
+ 'contexts': _contexts,
'rendered': rendered}
@staticmethod
- def _change_node_names(scenario, contexts):
+ def _change_node_names(scenario, _contexts):
"""Change the node names in a scenario, depending on the context config
The nodes (VMs or physical servers) are referred in the context section
@@ -627,7 +630,7 @@ class TaskParser(object): # pragma: no cover
target: target-k8s
"""
def qualified_name(name):
- for context in contexts:
+ for context in _contexts:
host_name, ctx_name = context.split_host_name(name)
if context.assigned_name == ctx_name:
return '{}{}{}'.format(host_name,
@@ -718,7 +721,8 @@ def _is_background_scenario(scenario):
def parse_nodes_with_context(scenario_cfg):
"""parse the 'nodes' fields in scenario """
# ensure consistency in node instantiation order
- return OrderedDict((nodename, Context.get_server(scenario_cfg["nodes"][nodename]))
+ return OrderedDict((nodename, base_context.Context.get_server(
+ scenario_cfg["nodes"][nodename]))
for nodename in sorted(scenario_cfg["nodes"]))
@@ -734,7 +738,7 @@ def get_networks_from_nodes(nodes):
network_name = interface.get('network_name')
if not network_name:
continue
- network = Context.get_network(network_name)
+ network = base_context.Context.get_network(network_name)
if network:
networks[network['name']] = network
return networks
diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py
index 2f14d4bc4..4ed40f8af 100644
--- a/yardstick/common/constants.py
+++ b/yardstick/common/constants.py
@@ -6,7 +6,6 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import absolute_import
import errno
import os
@@ -14,11 +13,9 @@ from functools import reduce
import pkg_resources
-# this module must only import other modules that do
-# not require loggers to be created, so this cannot
-# include yardstick.common.utils
from yardstick.common.yaml_loader import yaml_load
+
dirname = os.path.dirname
abspath = os.path.abspath
join = os.path.join
@@ -175,3 +172,6 @@ OS_CLOUD_DEFAULT_CONFIG = {'verify': False}
# Kubernetes
SCOPE_NAMESPACED = 'Namespaced'
SCOPE_CLUSTER = 'Cluster'
+
+# VNF definition
+SSH_PORT = 22
diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py
index 641c4e1c4..c25acbaf8 100644
--- a/yardstick/common/exceptions.py
+++ b/yardstick/common/exceptions.py
@@ -223,6 +223,14 @@ class KubernetesTemplateInvalidVolumeType(YardstickException):
message = 'No valid "volume" types present in %(volume)s'
+class KubernetesSSHPortNotDefined(YardstickException):
+ message = 'Port 22 needs to be defined'
+
+
+class KubernetesServiceObjectNotDefined(YardstickException):
+ message = 'ServiceObject is not defined'
+
+
class KubernetesCRDObjectDefinitionError(YardstickException):
message = ('Kubernetes Custom Resource Definition Object error, missing '
'parameters: %(missing_parameters)s')
diff --git a/yardstick/common/httpClient.py b/yardstick/common/httpClient.py
index 54f7be670..5b7831144 100644
--- a/yardstick/common/httpClient.py
+++ b/yardstick/common/httpClient.py
@@ -26,10 +26,11 @@ class HttpClient(object):
while True:
try:
response = requests.post(url, data=data, headers=headers)
+ response.raise_for_status()
result = response.json()
logger.debug('The result is: %s', result)
return result
- except Exception:
+ except Exception: # pylint: disable=broad-except
if time.time() > t_end:
logger.exception('')
raise
@@ -37,4 +38,5 @@ class HttpClient(object):
def get(self, url):
response = requests.get(url)
+ response.raise_for_status()
return response.json()
diff --git a/yardstick/network_services/collector/subscriber.py b/yardstick/network_services/collector/subscriber.py
index 937c266a6..0c6d97771 100644
--- a/yardstick/network_services/collector/subscriber.py
+++ b/yardstick/network_services/collector/subscriber.py
@@ -11,7 +11,7 @@
# 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.
-"""This module implements stub for publishing results in yardstick format."""
+
import logging
from yardstick.network_services.nfvi.resource import ResourceProfile
@@ -31,12 +31,13 @@ class Collector(object):
self.bin_path = get_nsb_option('bin_path', '')
self.resource_profiles = {}
- for ctx_name, nodes in contexts_nodes.items():
- for node in (node for node in nodes if node.get('collectd')):
+ for ctx_name, nodes in ((ctx_name, nodes) for (ctx_name, nodes)
+ in contexts_nodes.items() if nodes):
+ for node in (node for node in nodes
+ if node and node.get('collectd')):
name = ".".join([node['name'], ctx_name])
self.resource_profiles.update(
- {name: ResourceProfile.make_from_node(node, timeout)}
- )
+ {name: ResourceProfile.make_from_node(node, timeout)})
def start(self):
for resource in self.resource_profiles.values():
diff --git a/yardstick/network_services/vnf_generic/vnf/base.py b/yardstick/network_services/vnf_generic/vnf/base.py
index fb41a4e4a..45a6160c2 100644
--- a/yardstick/network_services/vnf_generic/vnf/base.py
+++ b/yardstick/network_services/vnf_generic/vnf/base.py
@@ -335,4 +335,4 @@ class GenericTrafficGen(GenericVNF):
def get_mq_producer_id(self):
"""Return the MQ producer ID if initialized"""
if self._mq_producer:
- return self._mq_producer.get_id()
+ return self._mq_producer.id
diff --git a/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
index a4a8359d5..69779d3e0 100644
--- a/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
@@ -19,6 +19,7 @@ import mock
import six
import unittest
+from yardstick.benchmark import contexts
from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts.standalone import model
from yardstick.benchmark.contexts.standalone import ovs_dpdk
@@ -82,7 +83,7 @@ class OvsDpdkContextTestCase(unittest.TestCase):
def test_init(self):
ATTRS = {
- 'name': 'StandaloneOvsDpdk',
+ 'name': contexts.CONTEXT_STANDALONEOVSDPDK,
'task_id': '1234567890',
'file': 'pod',
'flavor': {},
diff --git a/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
index 169084607..74c31569c 100644
--- a/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
@@ -18,6 +18,7 @@ import mock
import unittest
from yardstick import ssh
+from yardstick.benchmark import contexts
from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts.standalone import model
from yardstick.benchmark.contexts.standalone import sriov
@@ -30,7 +31,7 @@ class SriovContextTestCase(unittest.TestCase):
NODES_DUPLICATE_SAMPLE = "nodes_duplicate_sample.yaml"
ATTRS = {
- 'name': 'StandaloneSriov',
+ 'name': contexts.CONTEXT_STANDALONESRIOV,
'task_id': '1234567890',
'file': 'pod',
'flavor': {},
diff --git a/yardstick/tests/unit/benchmark/contexts/test_kubernetes.py b/yardstick/tests/unit/benchmark/contexts/test_kubernetes.py
index 3957aab91..b070b24a9 100644
--- a/yardstick/tests/unit/benchmark/contexts/test_kubernetes.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_kubernetes.py
@@ -10,13 +10,15 @@
import mock
import unittest
+from yardstick.benchmark import contexts
from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts import kubernetes
+from yardstick.common import constants
from yardstick.orchestrator import kubernetes as orchestrator_kubernetes
CONTEXT_CFG = {
- 'type': 'Kubernetes',
+ 'type': contexts.CONTEXT_KUBERNETES,
'name': 'k8s',
'task_id': '1234567890',
'servers': {
@@ -117,8 +119,8 @@ class KubernetesTestCase(unittest.TestCase):
mock_get_pod_by_name):
class Service(object):
def __init__(self):
- self.name = 'yardstick'
self.node_port = 30000
+ self.port = constants.SSH_PORT
class Services(object):
def __init__(self):
@@ -135,8 +137,9 @@ class KubernetesTestCase(unittest.TestCase):
mock_get_service_by_name.return_value = Services()
mock_get_pod_by_name.return_value = Pod()
mock_get_node_ip.return_value = '172.16.10.131'
-
- self.assertIsNotNone(self.k8s_context._get_server('server'))
+ server = self.k8s_context._get_server('server_name')
+ self.assertEqual('server_name', server['name'])
+ self.assertEqual(30000, server['ssh_port'])
@mock.patch.object(kubernetes.KubernetesContext, '_create_rc')
def test_create_rcs(self, mock_create_rc):
diff --git a/yardstick/tests/unit/benchmark/core/test_task.py b/yardstick/tests/unit/benchmark/core/test_task.py
index 0424c77a3..35236637d 100644
--- a/yardstick/tests/unit/benchmark/core/test_task.py
+++ b/yardstick/tests/unit/benchmark/core/test_task.py
@@ -28,7 +28,7 @@ from yardstick.common import utils
class TaskTestCase(unittest.TestCase):
- @mock.patch.object(task, 'Context')
+ @mock.patch.object(base, 'Context')
def test_parse_nodes_with_context_same_context(self, mock_context):
scenario_cfg = {
"nodes": {
@@ -69,7 +69,7 @@ class TaskTestCase(unittest.TestCase):
dispatcher2])
self.assertIsNone(t._do_output(output_config, {}))
- @mock.patch.object(task, 'Context')
+ @mock.patch.object(base, 'Context')
def test_parse_networks_from_nodes(self, mock_context):
nodes = {
'node1': {
@@ -133,7 +133,7 @@ class TaskTestCase(unittest.TestCase):
self.assertEqual(mock_context.get_network.call_count, expected_get_network_calls)
self.assertDictEqual(networks, expected)
- @mock.patch.object(task, 'Context')
+ @mock.patch.object(base, 'Context')
@mock.patch.object(task, 'base_runner')
def test_run(self, mock_base_runner, *args):
scenario = {
@@ -156,7 +156,7 @@ class TaskTestCase(unittest.TestCase):
t._run([scenario], False, "yardstick.out")
runner.run.assert_called_once()
- @mock.patch.object(task, 'Context')
+ @mock.patch.object(base, 'Context')
@mock.patch.object(task, 'base_runner')
def test_run_ProxDuration(self, mock_base_runner, *args):
scenario = {
diff --git a/yardstick/tests/unit/network_services/collector/test_subscriber.py b/yardstick/tests/unit/network_services/collector/test_subscriber.py
index 4271f852c..cffa4d492 100644
--- a/yardstick/tests/unit/network_services/collector/test_subscriber.py
+++ b/yardstick/tests/unit/network_services/collector/test_subscriber.py
@@ -11,10 +11,10 @@
# 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 copy
import mock
+import unittest
from yardstick.network_services.collector import subscriber
from yardstick import ssh
@@ -38,14 +38,15 @@ class MockVnfAprrox(object):
class CollectorTestCase(unittest.TestCase):
- NODES = {'context1': [{'name': 'node1',
- 'ip': '1.2.3.4',
- 'collectd': {
- 'plugins': {'abc': 12, 'def': 34},
- 'interval': 987
- },
- }]
- }
+ NODES = {
+ 'context1': [{'name': 'node1',
+ 'ip': '1.2.3.4',
+ 'collectd': {
+ 'plugins': {'abc': 12, 'def': 34},
+ 'interval': 987}
+ }
+ ]
+ }
def setUp(self):
vnf = MockVnfAprrox()
@@ -61,13 +62,29 @@ class CollectorTestCase(unittest.TestCase):
def tearDown(self):
self.ssh_patch.stop()
- def test___init__(self, *_):
+ def test___init__(self, *args):
vnf = MockVnfAprrox()
collector = subscriber.Collector([vnf], self.NODES)
self.assertEqual(len(collector.vnfs), 1)
self.assertEqual(len(collector.nodes), 1)
- def test_start(self, *_):
+ def test___init__no_node_information(self, *args):
+ vnf = MockVnfAprrox()
+ nodes = copy.deepcopy(self.NODES)
+ nodes['context1'].append(None)
+ collector = subscriber.Collector([vnf], nodes)
+ self.assertEqual(len(collector.vnfs), 1)
+ self.assertEqual(len(collector.nodes), 1)
+
+ def test___init__no_node_information_in_context(self, *args):
+ vnf = MockVnfAprrox()
+ nodes = copy.deepcopy(self.NODES)
+ nodes['context1'] = None
+ collector = subscriber.Collector([vnf], nodes)
+ self.assertEqual(len(collector.vnfs), 1)
+ self.assertEqual(len(collector.nodes), 1)
+
+ def test_start(self, *args):
resource_profile = mock.MagicMock()
self.collector.resource_profiles = {'key': resource_profile}
self.collector.bin_path = 'path'
@@ -92,7 +109,7 @@ class CollectorTestCase(unittest.TestCase):
for resource in self.collector.resource_profiles.values():
resource.stop.assert_called_once()
- def test_get_kpi(self, *_):
+ def test_get_kpi(self, *args):
result = self.collector.get_kpi()
self.assertEqual(2, len(result))
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py
index 43e5ac839..ce8205a47 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py
@@ -264,7 +264,7 @@ class GenericTrafficGenTestCase(unittest.TestCase):
}
tg = _DummyGenericTrafficGen('name', vnfd)
tg._mq_producer = mock.Mock()
- tg._mq_producer.get_id.return_value = 'fake_id'
+ tg._mq_producer.id = 'fake_id'
self.assertEqual('fake_id', tg.get_mq_producer_id())
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
index 4ade157a3..f34faaec7 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
@@ -18,10 +18,11 @@ import mock
import six
import unittest
+from yardstick.benchmark import contexts
+from yardstick.benchmark.contexts import base as ctx_base
from yardstick.network_services.libs.ixia_libs.ixnet import ixnet_api
from yardstick.network_services.traffic_profile import base as tp_base
from yardstick.network_services.vnf_generic.vnf import tg_rfc2544_ixia
-from yardstick.benchmark.contexts import base as ctx_base
TEST_FILE_YAML = 'nsb_test_case.yaml'
@@ -162,7 +163,8 @@ class TestIXIATrafficGen(unittest.TestCase):
'nodes': {'tg__1': 'trafficgen_1.yardstick',
'vnf__1': 'vnf.yardstick'},
'topology': 'vpe_vnf_topology.yaml'}],
- 'context': {'nfvi_type': 'baremetal', 'type': 'Node',
+ 'context': {'nfvi_type': 'baremetal',
+ 'type': contexts.CONTEXT_NODE,
'name': 'yardstick',
'file': '/etc/yardstick/nodes/pod.yaml'},
'schema': 'yardstick:task:0.1'}
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
index 4d3e4ff0b..ba90dc94a 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
@@ -15,10 +15,11 @@
import mock
import unittest
+from yardstick.benchmark import contexts
+from yardstick.benchmark.contexts import base as ctx_base
from yardstick.network_services.traffic_profile import base as tp_base
from yardstick.network_services.vnf_generic.vnf import sample_vnf
from yardstick.network_services.vnf_generic.vnf import tg_rfc2544_trex
-from yardstick.benchmark.contexts import base as ctx_base
class TestTrexRfcResouceHelper(unittest.TestCase):
@@ -206,7 +207,7 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
],
'context': {
'nfvi_type': 'baremetal',
- 'type': 'Node',
+ 'type': contexts.CONTEXT_NODE,
'name': 'yardstick',
'file': '/etc/yardstick/nodes/pod.yaml',
},