ACL: vACL
FW: vFW
CGNAPT: vCGNAPT
- PE: vPE
UDP_Replay: UDP_Replay
PROX: DPPD-PROX
vnf_app_names:
ACL: vACL
FW: vFW
CGNAPT: vCGNAPT
- PE: vPE
UDP_Replay: UDP_Replay
PROX: prox
vnf_name: FW
- role: install_samplevnf
vnf_name: CGNAPT
- - role: install_samplevnf
- vnf_name: PE
# build shared DPDK for collectd only, required DPDK downloaded already
- install_dpdk_shared
- install_rabbitmq
vnf_name: FW
- role: install_samplevnf
vnf_name: CGNAPT
- - role: install_samplevnf
- vnf_name: PE
# build shared DPDK for collectd only, required DPDK downloaded already
- install_dpdk_shared
- install_rabbitmq
---
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:
source-port-range:
lower-port: 0
upper-port: 65535
+ protocol-mask: 255
+ protocol: 127
+ priority: 1
rule-name: rule1588
-
actions: [drop,count]
type: Duration
duration: 1
sla:
- action: monitor
+ action: assert
-
type: Duration
duration: 1
sla:
- action: monitor
+ action: assert
-
type: "GeneralHA"
type: Duration
duration: 1
sla:
- action: monitor
+ action: assert
contexts:
type: Duration
duration: 1
sla:
- action: monitor
+ action: assert
-
type: "GeneralHA"
type: Duration
duration: 1
sla:
- action: monitor
+ action: assert
-
type: "GeneralHA"
type: Duration
duration: 1
sla:
- action: monitor
+ action: assert
contexts:
type: Duration
duration: 1
sla:
- action: monitor
+ action: assert
-
type: Duration
duration: 1
sla:
- action: monitor
+ action: assert
-
type: "GeneralHA"
type: Duration
duration: 1
sla:
- action: monitor
+ action: assert
contexts:
+# 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"
# 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"""
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
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
# 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
class KubernetesContext(Context):
"""Class that handle nodes info"""
- __context_type__ = "Kubernetes"
+ __context_type__ = contexts.CONTEXT_KUBERNETES
def __init__(self):
self.ssh_key = ''
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
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import absolute_import
import subprocess
import os
import collections
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
class NodeContext(Context):
"""Class that handle nodes info"""
- __context_type__ = "Node"
+ __context_type__ = contexts.CONTEXT_NODE
def __init__(self):
self.file_path = None
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__)
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',
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
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
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:
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:
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"])
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)
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)
# 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
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,
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"]))
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
# 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
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
# Kubernetes
SCOPE_NAMESPACED = 'Namespaced'
SCOPE_CLUSTER = 'Cluster'
+
+# VNF definition
+SSH_PORT = 22
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')
# 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
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():
class VpeApproxSetupEnvHelper(DpdkVnfSetupEnvHelper):
- APP_NAME = 'vPE'
+ APP_NAME = 'vPE_vnf'
CFG_CONFIG = "/tmp/vpe_config"
CFG_SCRIPT = "/tmp/vpe_script"
TM_CONFIG = "/tmp/full_tm_profile_10G.cfg"
class VpeApproxVnf(SampleVNF):
""" This class handles vPE VNF model-driver definitions """
- APP_NAME = 'vPE'
+ APP_NAME = 'vPE_vnf'
APP_WORD = 'vpe'
COLLECT_KPI = VPE_COLLECT_KPI
WAIT_TIME = 20
class NetworkObject(object):
- MANDATORY_PARAMETERS = {'name', 'plugin', 'args'}
+ MANDATORY_PARAMETERS = {'plugin', 'args'}
KIND = 'Network'
- def __init__(self, **kwargs):
+ def __init__(self, name, **kwargs):
if not self.MANDATORY_PARAMETERS.issubset(kwargs):
missing_parameters = ', '.join(
str(param) for param in
raise exceptions.KubernetesNetworkObjectDefinitionError(
missing_parameters=missing_parameters)
- self._name = kwargs['name']
+ self._name = name
self._plugin = kwargs['plugin']
self._args = kwargs['args']
self._crd = None
context_cfg = copy.deepcopy(context_cfg)
servers_cfg = context_cfg.pop('servers', {})
crd_cfg = context_cfg.pop('custom_resources', [])
- networks_cfg = context_cfg.pop('networks', [])
+ networks_cfg = context_cfg.pop('networks', {})
self.name = name
self.ssh_key = '{}-key'.format(name)
for rc, cfg in self.rcs.items()]
self.crd = [CustomResourceDefinitionObject(self.name, **crd)
for crd in crd_cfg]
- self.network_objs = [NetworkObject(**nobj) for nobj in networks_cfg]
+ self.network_objs = [NetworkObject(net_name, **net_data)
+ for net_name, net_data in networks_cfg.items()]
self.pods = []
def _get_rc_name(self, rc_name):
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
def test_init(self):
ATTRS = {
- 'name': 'StandaloneOvsDpdk',
+ 'name': contexts.CONTEXT_STANDALONEOVSDPDK,
'task_id': '1234567890',
'file': 'pod',
'flavor': {},
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
NODES_DUPLICATE_SAMPLE = "nodes_duplicate_sample.yaml"
ATTRS = {
- 'name': 'StandaloneSriov',
+ 'name': contexts.CONTEXT_STANDALONESRIOV,
'task_id': '1234567890',
'file': 'pod',
'flavor': {},
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': {
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):
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):
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": {
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': {
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 = {
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 = {
# 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
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()
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'
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))
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'
'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'}
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):
],
'context': {
'nfvi_type': 'baremetal',
- 'type': 'Node',
+ 'type': contexts.CONTEXT_NODE,
'name': 'yardstick',
'file': '/etc/yardstick/nodes/pod.yaml',
},
def test__init_missing_parameter(self):
with self.assertRaises(
exceptions.KubernetesNetworkObjectDefinitionError):
- kubernetes.NetworkObject(name='name', plugin='plugin')
+ kubernetes.NetworkObject('network_name', plugin='plugin')
with self.assertRaises(
exceptions.KubernetesNetworkObjectDefinitionError):
- kubernetes.NetworkObject(name='name', args='args')
- with self.assertRaises(
- exceptions.KubernetesNetworkObjectDefinitionError):
- kubernetes.NetworkObject(args='args', plugin='plugin')
+ kubernetes.NetworkObject('network_name', args='args')
@mock.patch.object(kubernetes_utils, 'get_custom_resource_definition')
def test_crd(self, mock_get_crd):