From 679b6d94288d801e84c0f22c6c0d712c08eb8458 Mon Sep 17 00:00:00 2001 From: "Mytnyk, Volodymyr" Date: Thu, 24 Jan 2019 17:46:04 +0200 Subject: NSB sync: clean-up draft IPC implementation (part 1) The existing implementation of IPC is not finished and isn't used by any of the VNFs/TG implementation. It is used in the code but does nothing from functionality perspective. New syncronization mechanism is going to be implemented by using different approach than it was designed before. Thus, the current IPC mechanism is not going to be re-used. So, removing it. The IPC consumer/producer implementation is left as it may be required for other purposes. - Remove SampleVNF MQ consumer class - Remove IterationIPC MQ producer for VNF control messages - Remove MQ producer from SampleVNFTrafficGen class - Remove TrafficGeneratorProducer class - Remove IterationIPC runner - Remove unused task_id form VNF Generic initialization as it is not required for synchronization of VNFs/TGs anymore. - Fix UT JIRA: YARDSTICK-1592 Change-Id: I65fe51bcbd1bfeea0c43eb79ca6fb2aab5b65ae7 Signed-off-by: Mytnyk, Volodymyr --- ...544_ipv4_1rule_1flow_64B_trex_iterationipc.yaml | 96 ---------- yardstick/benchmark/runners/base.py | 22 --- yardstick/benchmark/runners/iteration_ipc.py | 205 --------------------- yardstick/benchmark/scenarios/base.py | 4 - .../benchmark/scenarios/networking/vnf_generic.py | 8 +- yardstick/common/exceptions.py | 9 - yardstick/common/messaging/__init__.py | 27 ++- .../network_services/vnf_generic/vnf/acl_vnf.py | 7 +- .../vnf_generic/vnf/agnostic_vnf.py | 4 +- yardstick/network_services/vnf_generic/vnf/base.py | 89 +-------- .../network_services/vnf_generic/vnf/cgnapt_vnf.py | 8 +- .../network_services/vnf_generic/vnf/epc_vnf.py | 4 +- .../vnf_generic/vnf/prox_helpers.py | 2 +- .../network_services/vnf_generic/vnf/prox_irq.py | 14 +- .../network_services/vnf_generic/vnf/prox_vnf.py | 7 +- .../network_services/vnf_generic/vnf/router_vnf.py | 6 +- .../network_services/vnf_generic/vnf/sample_vnf.py | 35 ++-- .../network_services/vnf_generic/vnf/tg_ixload.py | 7 +- .../vnf_generic/vnf/tg_landslide.py | 4 +- .../network_services/vnf_generic/vnf/tg_ping.py | 10 +- .../network_services/vnf_generic/vnf/tg_pktgen.py | 23 +-- .../network_services/vnf_generic/vnf/tg_prox.py | 6 +- .../vnf_generic/vnf/tg_rfc2544_ixia.py | 10 +- .../vnf_generic/vnf/tg_rfc2544_trex.py | 8 +- .../network_services/vnf_generic/vnf/tg_trex.py | 9 +- .../network_services/vnf_generic/vnf/udp_replay.py | 9 +- .../network_services/vnf_generic/vnf/vfw_vnf.py | 7 +- .../network_services/vnf_generic/vnf/vpe_vnf.py | 7 +- .../tests/functional/network_services/__init__.py | 0 .../network_services/vnf_generic/__init__.py | 0 .../network_services/vnf_generic/vnf/__init__.py | 0 .../network_services/vnf_generic/vnf/test_base.py | 103 ----------- yardstick/tests/unit/benchmark/runner/test_base.py | 56 ------ .../unit/benchmark/runner/test_iteration_ipc.py | 136 -------------- .../scenarios/networking/test_vnf_generic.py | 6 +- .../vnf_generic/vnf/test_acl_vnf.py | 14 +- .../vnf_generic/vnf/test_agnostic_vnf.py | 4 +- .../network_services/vnf_generic/vnf/test_base.py | 116 +----------- .../vnf_generic/vnf/test_cgnapt_vnf.py | 16 +- .../vnf_generic/vnf/test_epc_vnf.py | 8 +- .../vnf_generic/vnf/test_prox_irq.py | 28 +-- .../vnf_generic/vnf/test_prox_vnf.py | 25 ++- .../vnf_generic/vnf/test_router_vnf.py | 10 +- .../vnf_generic/vnf/test_sample_vnf.py | 97 +++------- .../vnf_generic/vnf/test_tg_ixload.py | 23 ++- .../vnf_generic/vnf/test_tg_landslide.py | 11 +- .../vnf_generic/vnf/test_tg_ping.py | 12 +- .../vnf_generic/vnf/test_tg_pktgen.py | 27 +-- .../vnf_generic/vnf/test_tg_prox.py | 16 +- .../vnf_generic/vnf/test_tg_rfc2544_ixia.py | 20 +- .../vnf_generic/vnf/test_tg_rfc2544_trex.py | 12 +- .../vnf_generic/vnf/test_tg_trex.py | 32 ++-- .../vnf_generic/vnf/test_udp_replay.py | 23 +-- .../vnf_generic/vnf/test_vfw_vnf.py | 12 +- .../vnf_generic/vnf/test_vpe_vnf.py | 22 +-- 55 files changed, 256 insertions(+), 1220 deletions(-) delete mode 100644 samples/vnf_samples/nsut/vfw/tc_heat_rfc2544_ipv4_1rule_1flow_64B_trex_iterationipc.yaml delete mode 100644 yardstick/benchmark/runners/iteration_ipc.py delete mode 100644 yardstick/tests/functional/network_services/__init__.py delete mode 100644 yardstick/tests/functional/network_services/vnf_generic/__init__.py delete mode 100644 yardstick/tests/functional/network_services/vnf_generic/vnf/__init__.py delete mode 100644 yardstick/tests/functional/network_services/vnf_generic/vnf/test_base.py delete mode 100644 yardstick/tests/unit/benchmark/runner/test_iteration_ipc.py diff --git a/samples/vnf_samples/nsut/vfw/tc_heat_rfc2544_ipv4_1rule_1flow_64B_trex_iterationipc.yaml b/samples/vnf_samples/nsut/vfw/tc_heat_rfc2544_ipv4_1rule_1flow_64B_trex_iterationipc.yaml deleted file mode 100644 index 184ed6881..000000000 --- a/samples/vnf_samples/nsut/vfw/tc_heat_rfc2544_ipv4_1rule_1flow_64B_trex_iterationipc.yaml +++ /dev/null @@ -1,96 +0,0 @@ -# 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. - ---- -{% set provider = provider or none %} -{% set physical_networks = physical_networks or ['physnet1', 'physnet2'] %} -{% set segmentation_id = segmentation_id or none %} - -schema: yardstick:task:0.1 -scenarios: -- type: NSPerf - traffic_profile: ../../traffic_profiles/ipv4_throughput.yaml - topology: vfw-tg-topology.yaml - nodes: - tg__0: trafficgen_1.yardstick - vnf__0: vnf.yardstick - options: - hugepages_gb: 8 - framesize: - uplink: {64B: 100} - downlink: {64B: 100} - flow: - src_ip: [{'tg__0': 'xe0'}] - dst_ip: [{'tg__0': 'xe1'}] - count: 1 - traffic_type: 4 - rfc2544: - allowed_drop_rate: 0.0001 - 0.0001 - vnf__0: - rules: acl_1rule.yaml - vnf_config: {lb_config: 'SW', lb_count: 1, worker_config: '1C/1T', worker_threads: 1} - runner: - type: IterationIPC - iterations: 10 - timeout: 60 -context: - # put node context first, so we don't HEAT deploy if node has errors - name: yardstick - image: yardstick-samplevnfs - flavor: - vcpus: 10 - ram: 12288 - disk: 6 - extra_specs: - hw:cpu_sockets: 1 - hw:cpu_cores: 10 - hw:cpu_threads: 1 - user: ubuntu - placement_groups: - pgrp1: - policy: "availability" - servers: - vnf: - floating_ip: true - placement: "pgrp1" - trafficgen_1: - floating_ip: true - placement: "pgrp1" - networks: - mgmt: - cidr: '10.0.1.0/24' - xe0: - cidr: '10.0.2.0/24' - gateway_ip: 'null' - {% if provider %} - provider: {{ provider }} - physical_network: {{ physical_networks[0] }} - {% if segmentation_id %} - segmentation_id: {{ segmentation_id }} - {% endif %} - {% endif %} - port_security_enabled: False - enable_dhcp: 'false' - xe1: - cidr: '10.0.3.0/24' - gateway_ip: 'null' - {% if provider %} - provider: {{ provider }} - physical_network: {{ physical_networks[1] }} - {% if segmentation_id %} - segmentation_id: {{ segmentation_id }} - {% endif %} - {% endif %} - port_security_enabled: False - enable_dhcp: 'false' diff --git a/yardstick/benchmark/runners/base.py b/yardstick/benchmark/runners/base.py index af2557441..3878f20aa 100755 --- a/yardstick/benchmark/runners/base.py +++ b/yardstick/benchmark/runners/base.py @@ -25,9 +25,6 @@ import traceback from six import moves from yardstick.benchmark.scenarios import base as base_scenario -from yardstick.common import messaging -from yardstick.common.messaging import payloads -from yardstick.common.messaging import producer from yardstick.common import utils from yardstick.dispatcher.base import Base as DispatcherBase @@ -271,22 +268,3 @@ class Runner(object): dispatchers = DispatcherBase.get(self.config['output_config']) dispatcher = next((d for d in dispatchers if d.__dispatcher_type__ == 'Influxdb')) dispatcher.upload_one_record(record, self.case_name, '', task_id=self.task_id) - - -class RunnerProducer(producer.MessagingProducer): - """Class implementing the message producer for runners""" - - def __init__(self, _id): - super(RunnerProducer, self).__init__(messaging.TOPIC_RUNNER, _id=_id) - - def start_iteration(self, version=1, data=None): - data = {} if not data else data - self.send_message( - messaging.RUNNER_METHOD_START_ITERATION, - payloads.RunnerPayload(version=version, data=data)) - - def stop_iteration(self, version=1, data=None): - data = {} if not data else data - self.send_message( - messaging.RUNNER_METHOD_STOP_ITERATION, - payloads.RunnerPayload(version=version, data=data)) diff --git a/yardstick/benchmark/runners/iteration_ipc.py b/yardstick/benchmark/runners/iteration_ipc.py deleted file mode 100644 index a0335fdc7..000000000 --- a/yardstick/benchmark/runners/iteration_ipc.py +++ /dev/null @@ -1,205 +0,0 @@ -# Copyright 2018: Intel Corporation -# All Rights Reserved. -# -# 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. - -"""A runner that runs a configurable number of times before it returns. Each - iteration has a configurable timeout. The loop control depends on the - feedback received from the running VNFs. The context PIDs from the VNFs - to listen the messages from are given in the scenario "setup" method. -""" - -import logging -import multiprocessing -import time -import traceback - -import os - -from yardstick.benchmark.runners import base as base_runner -from yardstick.common import exceptions -from yardstick.common import messaging -from yardstick.common import utils -from yardstick.common.messaging import consumer -from yardstick.common.messaging import payloads - - -LOG = logging.getLogger(__name__) - -QUEUE_PUT_TIMEOUT = 10 -ITERATION_TIMEOUT = 180 - - -class RunnerIterationIPCEndpoint(consumer.NotificationHandler): - """Endpoint class for ``RunnerIterationIPCConsumer``""" - - def tg_method_started(self, ctxt, **kwargs): - if ctxt['id'] in self._ctx_ids: - self._queue.put( - {'id': ctxt['id'], - 'action': messaging.TG_METHOD_STARTED, - 'payload': payloads.TrafficGeneratorPayload.dict_to_obj( - kwargs)}, - QUEUE_PUT_TIMEOUT) - - def tg_method_finished(self, ctxt, **kwargs): - if ctxt['id'] in self._ctx_ids: - self._queue.put( - {'id': ctxt['id'], - 'action': messaging.TG_METHOD_FINISHED, - 'payload': payloads.TrafficGeneratorPayload.dict_to_obj( - kwargs)}) - - def tg_method_iteration(self, ctxt, **kwargs): - if ctxt['id'] in self._ctx_ids: - self._queue.put( - {'id': ctxt['id'], - 'action': messaging.TG_METHOD_ITERATION, - 'payload': payloads.TrafficGeneratorPayload.dict_to_obj( - kwargs)}) - - -class RunnerIterationIPCConsumer(consumer.MessagingConsumer): - """MQ consumer for "IterationIPC" runner""" - - def __init__(self, _id, ctx_ids): - self._id = _id - self._queue = multiprocessing.Queue() - endpoints = [RunnerIterationIPCEndpoint(_id, ctx_ids, self._queue)] - super(RunnerIterationIPCConsumer, self).__init__( - messaging.TOPIC_TG, ctx_ids, endpoints) - self._kpi_per_id = {ctx: [] for ctx in ctx_ids} - self.iteration_index = None - - def is_all_kpis_received_in_iteration(self): - """Check if all producers registered have sent the ITERATION msg - - During the present iteration, all producers (traffic generators) must - start and finish the traffic injection, and at the end of the traffic - injection a TG_METHOD_ITERATION must be sent. This function will check - all KPIs in the present iteration are received. E.g.: - self.iteration_index = 2 - - self._kpi_per_id = { - 'ctx1': [kpi0, kpi1, kpi2], - 'ctx2': [kpi0, kpi1]} --> return False - - self._kpi_per_id = { - 'ctx1': [kpi0, kpi1, kpi2], - 'ctx2': [kpi0, kpi1, kpi2]} --> return True - """ - while not self._queue.empty(): - msg = self._queue.get(True, 1) - if msg['action'] == messaging.TG_METHOD_ITERATION: - id_iter_list = self._kpi_per_id[msg['id']] - id_iter_list.append(msg['payload'].kpi) - - return all(len(id_iter_list) == self.iteration_index - for id_iter_list in self._kpi_per_id.values()) - - -def _worker_process(queue, cls, method_name, scenario_cfg, - context_cfg, aborted, output_queue): # pragma: no cover - runner_cfg = scenario_cfg['runner'] - - timeout = runner_cfg.get('timeout', ITERATION_TIMEOUT) - iterations = runner_cfg.get('iterations', 1) - run_step = runner_cfg.get('run_step', 'setup,run,teardown') - LOG.info('Worker START. Iterations %d times, class %s', iterations, cls) - - runner_cfg['runner_id'] = os.getpid() - - benchmark = cls(scenario_cfg, context_cfg) - method = getattr(benchmark, method_name) - - if 'setup' not in run_step: - raise exceptions.RunnerIterationIPCSetupActionNeeded() - benchmark.setup() - producer_ctxs = benchmark.get_mq_ids() - if not producer_ctxs: - raise exceptions.RunnerIterationIPCNoCtxs() - - mq_consumer = RunnerIterationIPCConsumer(os.getpid(), producer_ctxs) - mq_consumer.start_rpc_server() - mq_producer = base_runner.RunnerProducer(scenario_cfg['task_id']) - - iteration_index = 1 - while 'run' in run_step: - LOG.debug('runner=%(runner)s seq=%(sequence)s START', - {'runner': runner_cfg['runner_id'], - 'sequence': iteration_index}) - data = {} - result = None - errors = '' - mq_consumer.iteration_index = iteration_index - mq_producer.start_iteration() - - try: - utils.wait_until_true( - mq_consumer.is_all_kpis_received_in_iteration, - timeout=timeout, sleep=2) - result = method(data) - except Exception: # pylint: disable=broad-except - errors = traceback.format_exc() - LOG.exception(errors) - - mq_producer.stop_iteration() - - if result: - output_queue.put(result, True, QUEUE_PUT_TIMEOUT) - benchmark_output = {'timestamp': time.time(), - 'sequence': iteration_index, - 'data': data, - 'errors': errors} - queue.put(benchmark_output, True, QUEUE_PUT_TIMEOUT) - - LOG.debug('runner=%(runner)s seq=%(sequence)s END', - {'runner': runner_cfg['runner_id'], - 'sequence': iteration_index}) - - iteration_index += 1 - if iteration_index > iterations or aborted.is_set(): - LOG.info('"IterationIPC" worker END') - break - - if 'teardown' in run_step: - try: - benchmark.teardown() - except Exception: - LOG.exception('Exception during teardown process') - mq_consumer.stop_rpc_server() - raise SystemExit(1) - - LOG.debug('Data queue size = %s', queue.qsize()) - LOG.debug('Output queue size = %s', output_queue.qsize()) - mq_consumer.stop_rpc_server() - - -class IterationIPCRunner(base_runner.Runner): - """Run a scenario for a configurable number of times. - - Each iteration has a configurable timeout. The loop control depends on the - feedback received from the running VNFs. The context PIDs from the VNFs to - listen the messages from are given in the scenario "setup" method. - """ - __execution_type__ = 'IterationIPC' - - def _run_benchmark(self, cls, method, scenario_cfg, context_cfg): - name = '{}-{}-{}'.format( - self.__execution_type__, scenario_cfg.get('type'), os.getpid()) - self.process = multiprocessing.Process( - name=name, - target=_worker_process, - args=(self.result_queue, cls, method, scenario_cfg, - context_cfg, self.aborted, self.output_queue)) - self.process.start() diff --git a/yardstick/benchmark/scenarios/base.py b/yardstick/benchmark/scenarios/base.py index 1737bb942..ae8bfad71 100644 --- a/yardstick/benchmark/scenarios/base.py +++ b/yardstick/benchmark/scenarios/base.py @@ -122,7 +122,3 @@ class Scenario(object): except TypeError: dic[k] = v return dic - - def get_mq_ids(self): # pragma: no cover - """Return stored MQ producer IDs, if defined""" - pass diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py index 5ac51cdfc..daca9bafc 100644 --- a/yardstick/benchmark/scenarios/networking/vnf_generic.py +++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py @@ -61,7 +61,6 @@ class NetworkServiceTestCase(scenario_base.Scenario): self.traffic_profile = None self.node_netdevs = {} self.bin_path = get_nsb_option('bin_path', '') - self._mq_ids = [] def is_ended(self): return self.traffic_profile is not None and self.traffic_profile.is_ended() @@ -446,7 +445,7 @@ class NetworkServiceTestCase(scenario_base.Scenario): pass self.create_interfaces_from_node(vnfd, node) vnf_impl = self.get_vnf_impl(vnfd['id']) - vnf_instance = vnf_impl(node_name, vnfd, scenario_cfg['task_id']) + vnf_instance = vnf_impl(node_name, vnfd) vnfs.append(vnf_instance) self.vnfs = vnfs @@ -495,11 +494,6 @@ class NetworkServiceTestCase(scenario_base.Scenario): for traffic_gen in traffic_runners: LOG.info("Starting traffic on %s", traffic_gen.name) traffic_gen.run_traffic(self.traffic_profile) - self._mq_ids.append(traffic_gen.get_mq_producer_id()) - - def get_mq_ids(self): # pragma: no cover - """Return stored MQ producer IDs""" - return self._mq_ids def run(self, result): # yardstick API """ Yardstick calls run() at intervals defined in the yaml and diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py index f62f02f18..c8f5cb7cc 100644 --- a/yardstick/common/exceptions.py +++ b/yardstick/common/exceptions.py @@ -207,15 +207,6 @@ class TaskRenderError(YardstickException): message = 'Failed to render template:\n%(input_task)s' -class RunnerIterationIPCSetupActionNeeded(YardstickException): - message = ('IterationIPC needs the "setup" action to retrieve the VNF ' - 'handling processes PIDs to receive the messages sent') - - -class RunnerIterationIPCNoCtxs(YardstickException): - message = 'Benchmark "setup" action did not return any VNF process PID' - - class TimerTimeout(YardstickException): message = 'Timer timeout expired, %(timeout)s seconds' diff --git a/yardstick/common/messaging/__init__.py b/yardstick/common/messaging/__init__.py index bd700d9b1..089c99c9f 100644 --- a/yardstick/common/messaging/__init__.py +++ b/yardstick/common/messaging/__init__.py @@ -1,3 +1,14 @@ +# Copyright (c) 2018-2019 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. @@ -15,19 +26,3 @@ TRANSPORT_URL = (MQ_SERVICE + '://' + MQ_USER + ':' + MQ_PASS + '@' + SERVER + # RPC server. RPC_SERVER_EXECUTOR = 'threading' - -# Topics. -TOPIC_TG = 'topic_traffic_generator' -TOPIC_RUNNER = 'topic_runner' - -# Methods. -# Traffic generator consumers methods. Names must match the methods implemented -# in the consumer endpoint class. -TG_METHOD_STARTED = 'tg_method_started' -TG_METHOD_FINISHED = 'tg_method_finished' -TG_METHOD_ITERATION = 'tg_method_iteration' - -# Runner consumers methods. Names must match the methods implemented in the -# consumer endpoint class. -RUNNER_METHOD_START_ITERATION = "runner_method_start_iteration" -RUNNER_METHOD_STOP_ITERATION = "runner_method_stop_iteration" diff --git a/yardstick/network_services/vnf_generic/vnf/acl_vnf.py b/yardstick/network_services/vnf_generic/vnf/acl_vnf.py index 11a602472..e51d38748 100644 --- a/yardstick/network_services/vnf_generic/vnf/acl_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/acl_vnf.py @@ -246,9 +246,8 @@ class AclApproxVnf(SampleVNF): 'packets_dropped': 2, } - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if setup_env_helper_type is None: setup_env_helper_type = AclApproxSetupEnvSetupEnvHelper - super(AclApproxVnf, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + + super(AclApproxVnf, self).__init__(name, vnfd, setup_env_helper_type, resource_helper_type) diff --git a/yardstick/network_services/vnf_generic/vnf/agnostic_vnf.py b/yardstick/network_services/vnf_generic/vnf/agnostic_vnf.py index 115fddcf0..5856eb6e0 100644 --- a/yardstick/network_services/vnf_generic/vnf/agnostic_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/agnostic_vnf.py @@ -21,8 +21,8 @@ LOG = logging.getLogger(__name__) class AgnosticVnf(base.GenericVNF): """ AgnosticVnf implementation. """ - def __init__(self, name, vnfd, task_id): - super(AgnosticVnf, self).__init__(name, vnfd, task_id) + def __init__(self, name, vnfd): + super(AgnosticVnf, self).__init__(name, vnfd) def instantiate(self, scenario_cfg, context_cfg): pass diff --git a/yardstick/network_services/vnf_generic/vnf/base.py b/yardstick/network_services/vnf_generic/vnf/base.py index 0fb310075..1f49b22d5 100644 --- a/yardstick/network_services/vnf_generic/vnf/base.py +++ b/yardstick/network_services/vnf_generic/vnf/base.py @@ -17,10 +17,6 @@ import abc import logging import six -from yardstick.common import messaging -from yardstick.common.messaging import consumer -from yardstick.common.messaging import payloads -from yardstick.common.messaging import producer from yardstick.network_services.helpers.samplevnf_helper import PortPairs @@ -141,70 +137,6 @@ class VnfdHelper(dict): yield port_name, port_num -class TrafficGeneratorProducer(producer.MessagingProducer): - """Class implementing the message producer for traffic generators - - This message producer must be instantiated in the process created - "run_traffic" process. - """ - def __init__(self, _id): - super(TrafficGeneratorProducer, self).__init__(messaging.TOPIC_TG, - _id=_id) - - def tg_method_started(self, version=1): - """Send a message to inform the traffic generation has started""" - self.send_message( - messaging.TG_METHOD_STARTED, - payloads.TrafficGeneratorPayload(version=version, iteration=0, - kpi={})) - - def tg_method_finished(self, version=1): - """Send a message to inform the traffic generation has finished""" - self.send_message( - messaging.TG_METHOD_FINISHED, - payloads.TrafficGeneratorPayload(version=version, iteration=0, - kpi={})) - - def tg_method_iteration(self, iteration, version=1, kpi=None): - """Send a message, with KPI, once an iteration has finished""" - kpi = {} if kpi is None else kpi - self.send_message( - messaging.TG_METHOD_ITERATION, - payloads.TrafficGeneratorPayload(version=version, - iteration=iteration, kpi=kpi)) - - -@six.add_metaclass(abc.ABCMeta) -class GenericVNFEndpoint(consumer.NotificationHandler): - """Endpoint class for ``GenericVNFConsumer``""" - - @abc.abstractmethod - def runner_method_start_iteration(self, ctxt, **kwargs): - """Endpoint when RUNNER_METHOD_START_ITERATION is received - - :param ctxt: (dict) {'id': } - :param kwargs: (dict) ``payloads.RunnerPayload`` context - """ - - @abc.abstractmethod - def runner_method_stop_iteration(self, ctxt, **kwargs): - """Endpoint when RUNNER_METHOD_STOP_ITERATION is received - - :param ctxt: (dict) {'id': } - :param kwargs: (dict) ``payloads.RunnerPayload`` context - """ - - -class GenericVNFConsumer(consumer.MessagingConsumer): - """MQ consumer for ``GenericVNF`` derived classes""" - - def __init__(self, ctx_ids, endpoints): - if not isinstance(endpoints, list): - endpoints = [endpoints] - super(GenericVNFConsumer, self).__init__(messaging.TOPIC_RUNNER, - ctx_ids, endpoints) - - @six.add_metaclass(abc.ABCMeta) class GenericVNF(object): """Class providing file-like API for generic VNF implementation @@ -217,9 +149,8 @@ class GenericVNF(object): UPLINK = PortPairs.UPLINK DOWNLINK = PortPairs.DOWNLINK - def __init__(self, name, vnfd, task_id): + def __init__(self, name, vnfd): self.name = name - self._task_id = task_id self.vnfd_helper = VnfdHelper(vnfd) # List of statistics we can obtain from this VNF # - ETSI MANO 6.3.1.1 monitoring_parameter @@ -280,11 +211,10 @@ class GenericVNF(object): class GenericTrafficGen(GenericVNF): """Class providing file-like API for generic traffic generator""" - def __init__(self, name, vnfd, task_id): - super(GenericTrafficGen, self).__init__(name, vnfd, task_id) + def __init__(self, name, vnfd): + super(GenericTrafficGen, self).__init__(name, vnfd) self.runs_traffic = True self.traffic_finished = False - self._mq_producer = None @abc.abstractmethod def run_traffic(self, traffic_profile): @@ -355,16 +285,3 @@ class GenericTrafficGen(GenericVNF): :return: True/False """ pass - - @staticmethod - def _setup_mq_producer(id): - """Setup the TG MQ producer to send messages between processes - - :return: (derived class from ``MessagingProducer``) MQ producer object - """ - return TrafficGeneratorProducer(id) - - def get_mq_producer_id(self): - """Return the MQ producer ID if initialized""" - if self._mq_producer: - return self._mq_producer.id diff --git a/yardstick/network_services/vnf_generic/vnf/cgnapt_vnf.py b/yardstick/network_services/vnf_generic/vnf/cgnapt_vnf.py index 14f1e2e97..bfe628f09 100644 --- a/yardstick/network_services/vnf_generic/vnf/cgnapt_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/cgnapt_vnf.py @@ -85,12 +85,12 @@ class CgnaptApproxVnf(SampleVNF): "packets_dropped": 4, } - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if setup_env_helper_type is None: setup_env_helper_type = CgnaptApproxSetupEnvHelper - super(CgnaptApproxVnf, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + + super(CgnaptApproxVnf, self).__init__(name, vnfd, setup_env_helper_type, + resource_helper_type) def _vnf_up_post(self): super(CgnaptApproxVnf, self)._vnf_up_post() diff --git a/yardstick/network_services/vnf_generic/vnf/epc_vnf.py b/yardstick/network_services/vnf_generic/vnf/epc_vnf.py index 66d16d07f..1b06c59c1 100644 --- a/yardstick/network_services/vnf_generic/vnf/epc_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/epc_vnf.py @@ -21,8 +21,8 @@ LOG = logging.getLogger(__name__) class EPCVnf(base.GenericVNF): - def __init__(self, name, vnfd, task_id): - super(EPCVnf, self).__init__(name, vnfd, task_id) + def __init__(self, name, vnfd): + super(EPCVnf, self).__init__(name, vnfd) def instantiate(self, scenario_cfg, context_cfg): """Prepare VNF for operation and start the VNF process/VM diff --git a/yardstick/network_services/vnf_generic/vnf/prox_helpers.py b/yardstick/network_services/vnf_generic/vnf/prox_helpers.py index cd3035ef8..aeb41858f 100644 --- a/yardstick/network_services/vnf_generic/vnf/prox_helpers.py +++ b/yardstick/network_services/vnf_generic/vnf/prox_helpers.py @@ -1146,7 +1146,7 @@ class ProxResourceHelper(ClientResourceHelper): self._test_type = self.setup_helper.find_in_section('global', 'name', None) return self._test_type - def run_traffic(self, traffic_profile, *args): + def run_traffic(self, traffic_profile): self._queue.cancel_join_thread() self.lower = 0.0 self.upper = 100.0 diff --git a/yardstick/network_services/vnf_generic/vnf/prox_irq.py b/yardstick/network_services/vnf_generic/vnf/prox_irq.py index dda26b0fe..4cc8923cb 100644 --- a/yardstick/network_services/vnf_generic/vnf/prox_irq.py +++ b/yardstick/network_services/vnf_generic/vnf/prox_irq.py @@ -28,13 +28,13 @@ LOG = logging.getLogger(__name__) class ProxIrq(SampleVNFTrafficGen): - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): vnfd_cpy = copy.deepcopy(vnfd) - super(ProxIrq, self).__init__(name, vnfd_cpy, task_id) + super(ProxIrq, self).__init__(name, vnfd_cpy) self._vnf_wrapper = ProxApproxVnf( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + name, vnfd, setup_env_helper_type, resource_helper_type) self.bin_path = get_nsb_option('bin_path', '') self.name = self._vnf_wrapper.name self.ssh_helper = self._vnf_wrapper.ssh_helper @@ -83,9 +83,9 @@ class ProxIrqVNF(ProxIrq, SampleVNFTrafficGen): APP_NAME = 'ProxIrqVNF' - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): - ProxIrq.__init__(self, name, vnfd, task_id, setup_env_helper_type, + ProxIrq.__init__(self, name, vnfd, setup_env_helper_type, resource_helper_type) self.start_test_time = None @@ -150,9 +150,9 @@ class ProxIrqGen(ProxIrq, SampleVNFTrafficGen): APP_NAME = 'ProxIrqGen' - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): - ProxIrq.__init__(self, name, vnfd, task_id, setup_env_helper_type, + ProxIrq.__init__(self, name, vnfd, setup_env_helper_type, resource_helper_type) self.start_test_time = None self.end_test_time = None diff --git a/yardstick/network_services/vnf_generic/vnf/prox_vnf.py b/yardstick/network_services/vnf_generic/vnf/prox_vnf.py index c3b50369b..0d1360dd0 100644 --- a/yardstick/network_services/vnf_generic/vnf/prox_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/prox_vnf.py @@ -35,8 +35,7 @@ class ProxApproxVnf(SampleVNF): VNF_PROMPT = "PROX started" LUA_PARAMETER_NAME = "sut" - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if setup_env_helper_type is None: setup_env_helper_type = ProxDpdkVnfSetupEnvHelper @@ -47,8 +46,8 @@ class ProxApproxVnf(SampleVNF): self.prev_packets_sent = 0 self.prev_tsc = 0 self.tsc_hz = 0 - super(ProxApproxVnf, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + super(ProxApproxVnf, self).__init__(name, vnfd, setup_env_helper_type, + resource_helper_type) def _vnf_up_post(self): self.resource_helper.up_post() diff --git a/yardstick/network_services/vnf_generic/vnf/router_vnf.py b/yardstick/network_services/vnf_generic/vnf/router_vnf.py index e99de9cb3..90b7b215e 100644 --- a/yardstick/network_services/vnf_generic/vnf/router_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/router_vnf.py @@ -34,8 +34,7 @@ class RouterVNF(SampleVNF): WAIT_TIME = 1 - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if setup_env_helper_type is None: setup_env_helper_type = DpdkVnfSetupEnvHelper @@ -43,8 +42,7 @@ class RouterVNF(SampleVNF): vnfd['mgmt-interface'].pop("pkey", "") vnfd['mgmt-interface']['password'] = 'password' - super(RouterVNF, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + super(RouterVNF, self).__init__(name, vnfd, setup_env_helper_type, resource_helper_type) def instantiate(self, scenario_cfg, context_cfg): self.scenario_helper.scenario_cfg = scenario_cfg diff --git a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py index 8833b88f2..82a6eda33 100644 --- a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py @@ -18,7 +18,6 @@ from multiprocessing import Queue, Value, Process import os import posixpath import re -import uuid import subprocess import time @@ -397,13 +396,12 @@ class ClientResourceHelper(ResourceHelper): time.sleep(self.QUEUE_WAIT_TIME) self._queue.put(samples) - def run_traffic(self, traffic_profile, mq_producer): + def run_traffic(self, traffic_profile): # if we don't do this we can hang waiting for the queue to drain # have to do this in the subprocess self._queue.cancel_join_thread() # fixme: fix passing correct trex config file, # instead of searching the default path - mq_producer.tg_method_started() try: self._build_ports() self.client = self._connect() @@ -411,12 +409,9 @@ class ClientResourceHelper(ResourceHelper): self.client.remove_all_streams(self.all_ports) # remove all streams traffic_profile.register_generator(self) - iteration_index = 0 while self._terminated.value == 0: - iteration_index += 1 if self._run_traffic_once(traffic_profile): self._terminated.value = 1 - mq_producer.tg_method_iteration(iteration_index) self.client.stop(self.all_ports) self.client.disconnect() @@ -427,8 +422,6 @@ class ClientResourceHelper(ResourceHelper): return # return if trex/tg server is stopped. raise - mq_producer.tg_method_finished() - def terminate(self): self._terminated.value = 1 # stop client @@ -619,7 +612,6 @@ class ScenarioHelper(object): test_timeout = self.options.get('timeout', constants.DEFAULT_VNF_TIMEOUT) return test_duration if test_duration > test_timeout else test_timeout - class SampleVNF(GenericVNF): """ Class providing file-like API for generic VNF implementation """ @@ -629,9 +621,8 @@ class SampleVNF(GenericVNF): APP_NAME = "SampleVNF" # we run the VNF interactively, so the ssh command will timeout after this long - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): - super(SampleVNF, self).__init__(name, vnfd, task_id) + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): + super(SampleVNF, self).__init__(name, vnfd) self.bin_path = get_nsb_option('bin_path', '') self.scenario_helper = ScenarioHelper(self.name) @@ -862,9 +853,8 @@ class SampleVNFTrafficGen(GenericTrafficGen): APP_NAME = 'Sample' RUN_WAIT = 1 - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): - super(SampleVNFTrafficGen, self).__init__(name, vnfd, task_id) + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): + super(SampleVNFTrafficGen, self).__init__(name, vnfd) self.bin_path = get_nsb_option('bin_path', '') self.scenario_helper = ScenarioHelper(self.name) @@ -923,13 +913,12 @@ class SampleVNFTrafficGen(GenericTrafficGen): LOG.info("%s TG Server is up and running.", self.APP_NAME) return self._tg_process.exitcode - def _traffic_runner(self, traffic_profile, mq_id): + def _traffic_runner(self, traffic_profile): # always drop connections first thing in new processes # so we don't get paramiko errors self.ssh_helper.drop_connection() LOG.info("Starting %s client...", self.APP_NAME) - self._mq_producer = self._setup_mq_producer(mq_id) - self.resource_helper.run_traffic(traffic_profile, self._mq_producer) + self.resource_helper.run_traffic(traffic_profile) def run_traffic(self, traffic_profile): """ Generate traffic on the wire according to the given params. @@ -939,12 +928,10 @@ class SampleVNFTrafficGen(GenericTrafficGen): :param traffic_profile: :return: True/False """ - name = '{}-{}-{}-{}'.format(self.name, self.APP_NAME, - traffic_profile.__class__.__name__, + name = "{}-{}-{}-{}".format(self.name, self.APP_NAME, traffic_profile.__class__.__name__, os.getpid()) - self._traffic_process = Process( - name=name, target=self._traffic_runner, - args=(traffic_profile, uuid.uuid1().int)) + self._traffic_process = Process(name=name, target=self._traffic_runner, + args=(traffic_profile,)) self._traffic_process.start() # Wait for traffic process to start while self.resource_helper.client_started.value == 0: @@ -953,6 +940,8 @@ class SampleVNFTrafficGen(GenericTrafficGen): if not self._traffic_process.is_alive(): break + return self._traffic_process.is_alive() + def collect_kpi(self): # check if the tg processes have exited physical_node = Context.get_physical_node_from_server( diff --git a/yardstick/network_services/vnf_generic/vnf/tg_ixload.py b/yardstick/network_services/vnf_generic/vnf/tg_ixload.py index d25402740..97b36d708 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_ixload.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_ixload.py @@ -126,13 +126,12 @@ class IxLoadResourceHelper(sample_vnf.ClientResourceHelper): class IxLoadTrafficGen(sample_vnf.SampleVNFTrafficGen): - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if resource_helper_type is None: resource_helper_type = IxLoadResourceHelper - super(IxLoadTrafficGen, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + super(IxLoadTrafficGen, self).__init__(name, vnfd, setup_env_helper_type, + resource_helper_type) self._result = {} def update_gateways(self, links): diff --git a/yardstick/network_services/vnf_generic/vnf/tg_landslide.py b/yardstick/network_services/vnf_generic/vnf/tg_landslide.py index 2fba89b22..fb8c24752 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_landslide.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_landslide.py @@ -35,11 +35,11 @@ LOG = logging.getLogger(__name__) class LandslideTrafficGen(sample_vnf.SampleVNFTrafficGen): APP_NAME = 'LandslideTG' - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if resource_helper_type is None: resource_helper_type = LandslideResourceHelper - super(LandslideTrafficGen, self).__init__(name, vnfd, task_id, + super(LandslideTrafficGen, self).__init__(name, vnfd, setup_env_helper_type, resource_helper_type) diff --git a/yardstick/network_services/vnf_generic/vnf/tg_ping.py b/yardstick/network_services/vnf_generic/vnf/tg_ping.py index a3b5afa39..a989543f5 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_ping.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_ping.py @@ -71,7 +71,7 @@ class PingResourceHelper(ClientResourceHelper): self._queue = Queue() self._parser = PingParser(self._queue) - def run_traffic(self, traffic_profile, *args): + def run_traffic(self, traffic_profile): # drop the connection in order to force a new one self.ssh_helper.drop_connection() @@ -103,14 +103,14 @@ class PingTrafficGen(SampleVNFTrafficGen): APP_NAME = 'Ping' RUN_WAIT = 4 - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if setup_env_helper_type is None: setup_env_helper_type = PingSetupEnvHelper if resource_helper_type is None: resource_helper_type = PingResourceHelper - super(PingTrafficGen, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + + super(PingTrafficGen, self).__init__(name, vnfd, setup_env_helper_type, + resource_helper_type) self._result = {} def _check_status(self): diff --git a/yardstick/network_services/vnf_generic/vnf/tg_pktgen.py b/yardstick/network_services/vnf_generic/vnf/tg_pktgen.py index 9d452213f..e73cebc40 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_pktgen.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_pktgen.py @@ -13,9 +13,7 @@ # limitations under the License. import logging -import multiprocessing import time -import uuid from yardstick.common import constants from yardstick.common import exceptions @@ -26,8 +24,7 @@ from yardstick.network_services.vnf_generic.vnf import base as vnf_base LOG = logging.getLogger(__name__) -class PktgenTrafficGen(vnf_base.GenericTrafficGen, - vnf_base.GenericVNFEndpoint): +class PktgenTrafficGen(vnf_base.GenericTrafficGen): """DPDK Pktgen traffic generator Website: http://pktgen-dpdk.readthedocs.io/en/latest/index.html @@ -35,15 +32,8 @@ class PktgenTrafficGen(vnf_base.GenericTrafficGen, TIMEOUT = 30 - def __init__(self, name, vnfd, task_id): - vnf_base.GenericTrafficGen.__init__(self, name, vnfd, task_id) - self.queue = multiprocessing.Queue() - self._id = uuid.uuid1().int - self._mq_producer = self._setup_mq_producer(self._id) - vnf_base.GenericVNFEndpoint.__init__(self, self._id, [task_id], - self.queue) - self._consumer = vnf_base.GenericVNFConsumer([task_id], self) - self._consumer.start_rpc_server() + def __init__(self, name, vnfd): + vnf_base.GenericTrafficGen.__init__(self, name, vnfd) self._traffic_profile = None self._node_ip = vnfd['mgmt-interface'].get('ip') self._lua_node_port = self._get_lua_node_port( @@ -71,7 +61,7 @@ class PktgenTrafficGen(vnf_base.GenericTrafficGen, def wait_for_instantiate(self): # pragma: no cover pass - def runner_method_start_iteration(self, ctxt, **kwargs): + def runner_method_start_iteration(self): # pragma: no cover LOG.debug('Start method') # NOTE(ralonsoh): 'rate' should be modified between iterations. The @@ -81,11 +71,6 @@ class PktgenTrafficGen(vnf_base.GenericTrafficGen, self._traffic_profile.rate(self._rate) time.sleep(4) self._traffic_profile.stop() - self._mq_producer.tg_method_iteration(1, 1, {}) - - def runner_method_stop_iteration(self, ctxt, **kwargs): # pragma: no cover - # pragma: no cover - LOG.debug('Stop method') @staticmethod def _get_lua_node_port(service_ports): diff --git a/yardstick/network_services/vnf_generic/vnf/tg_prox.py b/yardstick/network_services/vnf_generic/vnf/tg_prox.py index d12c42ec8..61ff2e036 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_prox.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_prox.py @@ -29,13 +29,13 @@ class ProxTrafficGen(SampleVNFTrafficGen): LUA_PARAMETER_NAME = "gen" WAIT_TIME = 1 - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): vnfd_cpy = copy.deepcopy(vnfd) - super(ProxTrafficGen, self).__init__(name, vnfd_cpy, task_id) + super(ProxTrafficGen, self).__init__(name, vnfd_cpy) self._vnf_wrapper = ProxApproxVnf( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + name, vnfd, setup_env_helper_type, resource_helper_type) self.bin_path = get_nsb_option('bin_path', '') self.name = self._vnf_wrapper.name self.ssh_helper = self._vnf_wrapper.ssh_helper diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py index 4fbbf6a40..7fa864355 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py @@ -530,7 +530,7 @@ class IxiaResourceHelper(ClientResourceHelper): self._ix_scenario.apply_config() self._ix_scenario.create_traffic_model(traffic_profile) - def run_traffic(self, traffic_profile, *args): + def run_traffic(self, traffic_profile): if self._terminated.value: return @@ -588,12 +588,12 @@ class IxiaTrafficGen(SampleVNFTrafficGen): APP_NAME = 'Ixia' - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if resource_helper_type is None: resource_helper_type = IxiaResourceHelper - super(IxiaTrafficGen, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + + super(IxiaTrafficGen, self).__init__(name, vnfd, setup_env_helper_type, + resource_helper_type) self._ixia_traffic_gen = None self.ixia_file_name = '' self.vnf_port_pairs = [] diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py index 7ecb12478..7c2079101 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_trex.py @@ -65,9 +65,9 @@ class TrexTrafficGenRFC(tg_trex.TrexTrafficGen): traffic for rfc2544 testcase. """ - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if resource_helper_type is None: resource_helper_type = TrexRfcResourceHelper - super(TrexTrafficGenRFC, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + + super(TrexTrafficGenRFC, self).__init__(name, vnfd, setup_env_helper_type, + resource_helper_type) diff --git a/yardstick/network_services/vnf_generic/vnf/tg_trex.py b/yardstick/network_services/vnf_generic/vnf/tg_trex.py index 4296da84c..43ee82629 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_trex.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_trex.py @@ -200,14 +200,15 @@ class TrexTrafficGen(SampleVNFTrafficGen): APP_NAME = 'TRex' - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if resource_helper_type is None: resource_helper_type = TrexResourceHelper + if setup_env_helper_type is None: setup_env_helper_type = TrexDpdkVnfSetupEnvHelper - super(TrexTrafficGen, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + + super(TrexTrafficGen, self).__init__(name, vnfd, setup_env_helper_type, + resource_helper_type) def _check_status(self): return self.resource_helper.check_status() diff --git a/yardstick/network_services/vnf_generic/vnf/udp_replay.py b/yardstick/network_services/vnf_generic/vnf/udp_replay.py index e3fde1a79..fa92744d8 100644 --- a/yardstick/network_services/vnf_generic/vnf/udp_replay.py +++ b/yardstick/network_services/vnf_generic/vnf/udp_replay.py @@ -60,14 +60,15 @@ class UdpReplayApproxVnf(SampleVNF): PIPELINE_COMMAND = REPLAY_PIPELINE_COMMAND - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if resource_helper_type is None: resource_helper_type = UdpReplayResourceHelper + if setup_env_helper_type is None: setup_env_helper_type = UdpReplaySetupEnvHelper - super(UdpReplayApproxVnf, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + + super(UdpReplayApproxVnf, self).__init__(name, vnfd, setup_env_helper_type, + resource_helper_type) def _build_pipeline_kwargs(self): ports = self.vnfd_helper.port_pairs.all_ports diff --git a/yardstick/network_services/vnf_generic/vnf/vfw_vnf.py b/yardstick/network_services/vnf_generic/vnf/vfw_vnf.py index a1523dee3..432f30a0c 100644 --- a/yardstick/network_services/vnf_generic/vnf/vfw_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/vfw_vnf.py @@ -52,9 +52,8 @@ class FWApproxVnf(SampleVNF): 'packets_dropped': 3, } - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if setup_env_helper_type is None: setup_env_helper_type = FWApproxSetupEnvHelper - super(FWApproxVnf, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + + super(FWApproxVnf, self).__init__(name, vnfd, setup_env_helper_type, resource_helper_type) diff --git a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py index dd3221386..08fcb5e14 100644 --- a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py @@ -158,12 +158,11 @@ class VpeApproxVnf(SampleVNF): COLLECT_KPI = VPE_COLLECT_KPI WAIT_TIME = 20 - def __init__(self, name, vnfd, task_id, setup_env_helper_type=None, - resource_helper_type=None): + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): if setup_env_helper_type is None: setup_env_helper_type = VpeApproxSetupEnvHelper - super(VpeApproxVnf, self).__init__( - name, vnfd, task_id, setup_env_helper_type, resource_helper_type) + + super(VpeApproxVnf, self).__init__(name, vnfd, setup_env_helper_type, resource_helper_type) def get_stats(self, *args, **kwargs): raise NotImplementedError diff --git a/yardstick/tests/functional/network_services/__init__.py b/yardstick/tests/functional/network_services/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/yardstick/tests/functional/network_services/vnf_generic/__init__.py b/yardstick/tests/functional/network_services/vnf_generic/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/yardstick/tests/functional/network_services/vnf_generic/vnf/__init__.py b/yardstick/tests/functional/network_services/vnf_generic/vnf/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/yardstick/tests/functional/network_services/vnf_generic/vnf/test_base.py b/yardstick/tests/functional/network_services/vnf_generic/vnf/test_base.py deleted file mode 100644 index e57f8f51c..000000000 --- a/yardstick/tests/functional/network_services/vnf_generic/vnf/test_base.py +++ /dev/null @@ -1,103 +0,0 @@ -# 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 multiprocessing -import time -import uuid - -import mock - -from yardstick.common import messaging -from yardstick.common.messaging import payloads -from yardstick.common.messaging import producer -from yardstick.network_services.vnf_generic.vnf import base as vnf_base -from yardstick.tests.functional import base as ft_base - - -class _TrafficGenMQConsumer(vnf_base.GenericTrafficGen, - vnf_base.GenericVNFEndpoint): - - def __init__(self, name, vnfd, task_id): - vnf_base.GenericTrafficGen.__init__(self, name, vnfd, task_id) - self.queue = multiprocessing.Queue() - self._id = uuid.uuid1().int - vnf_base.GenericVNFEndpoint.__init__(self, self._id, [task_id], - self.queue) - self._consumer = vnf_base.GenericVNFConsumer([task_id], self) - self._consumer.start_rpc_server() - - def run_traffic(self, *args): - pass - - def terminate(self): - pass - - def collect_kpi(self): - pass - - def instantiate(self, *args): - pass - - def scale(self, flavor=''): - pass - - def runner_method_start_iteration(self, ctxt, **kwargs): - if ctxt['id'] in self._ctx_ids: - self._queue.put( - {'action': messaging.RUNNER_METHOD_START_ITERATION, - 'payload': payloads.RunnerPayload.dict_to_obj(kwargs)}) - - def runner_method_stop_iteration(self, ctxt, **kwargs): - if ctxt['id'] in self._ctx_ids: - self._queue.put( - {'action': messaging.RUNNER_METHOD_STOP_ITERATION, - 'payload': payloads.RunnerPayload.dict_to_obj(kwargs)}) - - -class _DummyProducer(producer.MessagingProducer): - pass - - -class GenericVNFMQConsumerTestCase(ft_base.BaseFunctionalTestCase): - - def test_fistro(self): - vnfd = {'benchmark': {'kpi': mock.ANY}, - 'vdu': [{'external-interface': 'ext_int'}] - } - task_id = uuid.uuid1().int - tg_obj = _TrafficGenMQConsumer('name_tg', vnfd, task_id) - producer = _DummyProducer(messaging.TOPIC_RUNNER, task_id) - - num_messages = 10 - for i in range(num_messages): - pload = payloads.RunnerPayload(version=10, data=i) - for method in (messaging.RUNNER_METHOD_START_ITERATION, - messaging.RUNNER_METHOD_STOP_ITERATION): - producer.send_message(method, pload) - - time.sleep(0.5) # Let consumers attend the calls - output = [] - while not tg_obj.queue.empty(): - data = tg_obj.queue.get(True, 1) - data_dict = {'action': data['action'], - 'payload': data['payload'].obj_to_dict()} - output.append(data_dict) - - self.assertEqual(num_messages * 2, len(output)) - for i in range(num_messages): - pload = payloads.RunnerPayload(version=10, data=i).obj_to_dict() - for method in (messaging.RUNNER_METHOD_START_ITERATION, - messaging.RUNNER_METHOD_STOP_ITERATION): - reg = {'action': method, 'payload': pload} - self.assertIn(reg, output) diff --git a/yardstick/tests/unit/benchmark/runner/test_base.py b/yardstick/tests/unit/benchmark/runner/test_base.py index 49ba1efe4..559c991f3 100644 --- a/yardstick/tests/unit/benchmark/runner/test_base.py +++ b/yardstick/tests/unit/benchmark/runner/test_base.py @@ -8,17 +8,12 @@ ############################################################################## import time -import uuid import mock -from oslo_config import cfg -import oslo_messaging import subprocess from yardstick.benchmark.runners import base as runner_base from yardstick.benchmark.runners import iteration -from yardstick.common import messaging -from yardstick.common.messaging import payloads from yardstick.tests.unit import base as ut_base @@ -99,54 +94,3 @@ class RunnerTestCase(ut_base.BaseUnitTestCase): with self.assertRaises(NotImplementedError): runner._run_benchmark(mock.Mock(), mock.Mock(), mock.Mock(), mock.Mock()) - - -class RunnerProducerTestCase(ut_base.BaseUnitTestCase): - - @mock.patch.object(oslo_messaging, 'Target', return_value='rpc_target') - @mock.patch.object(oslo_messaging, 'RPCClient') - @mock.patch.object(oslo_messaging, 'get_rpc_transport', - return_value='rpc_transport') - @mock.patch.object(cfg, 'CONF') - def test__init(self, mock_config, mock_transport, mock_rpcclient, - mock_target): - _id = uuid.uuid1().int - runner_producer = runner_base.RunnerProducer(_id) - mock_transport.assert_called_once_with( - mock_config, url='rabbit://yardstick:yardstick@localhost:5672/') - mock_target.assert_called_once_with(topic=messaging.TOPIC_RUNNER, - fanout=True, - server=messaging.SERVER) - mock_rpcclient.assert_called_once_with('rpc_transport', 'rpc_target') - self.assertEqual(_id, runner_producer._id) - self.assertEqual(messaging.TOPIC_RUNNER, runner_producer._topic) - - @mock.patch.object(oslo_messaging, 'Target', return_value='rpc_target') - @mock.patch.object(oslo_messaging, 'RPCClient') - @mock.patch.object(oslo_messaging, 'get_rpc_transport', - return_value='rpc_transport') - @mock.patch.object(payloads, 'RunnerPayload', return_value='runner_pload') - def test_start_iteration(self, mock_runner_payload, *args): - runner_producer = runner_base.RunnerProducer(uuid.uuid1().int) - with mock.patch.object(runner_producer, - 'send_message') as mock_message: - runner_producer.start_iteration(version=10) - - mock_message.assert_called_once_with( - messaging.RUNNER_METHOD_START_ITERATION, 'runner_pload') - mock_runner_payload.assert_called_once_with(version=10, data={}) - - @mock.patch.object(oslo_messaging, 'Target', return_value='rpc_target') - @mock.patch.object(oslo_messaging, 'RPCClient') - @mock.patch.object(oslo_messaging, 'get_rpc_transport', - return_value='rpc_transport') - @mock.patch.object(payloads, 'RunnerPayload', return_value='runner_pload') - def test_stop_iteration(self, mock_runner_payload, *args): - runner_producer = runner_base.RunnerProducer(uuid.uuid1().int) - with mock.patch.object(runner_producer, - 'send_message') as mock_message: - runner_producer.stop_iteration(version=15) - - mock_message.assert_called_once_with( - messaging.RUNNER_METHOD_STOP_ITERATION, 'runner_pload') - mock_runner_payload.assert_called_once_with(version=15, data={}) diff --git a/yardstick/tests/unit/benchmark/runner/test_iteration_ipc.py b/yardstick/tests/unit/benchmark/runner/test_iteration_ipc.py deleted file mode 100644 index 10d14a8a0..000000000 --- a/yardstick/tests/unit/benchmark/runner/test_iteration_ipc.py +++ /dev/null @@ -1,136 +0,0 @@ -# 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 multiprocessing -import time -import os -import uuid - -import mock - -from yardstick.benchmark.runners import iteration_ipc -from yardstick.common import messaging -from yardstick.common.messaging import payloads -from yardstick.tests.unit import base as ut_base - - -class RunnerIterationIPCEndpointTestCase(ut_base.BaseUnitTestCase): - - def setUp(self): - self._id = uuid.uuid1().int - self._ctx_ids = [uuid.uuid1().int, uuid.uuid1().int] - self._queue = multiprocessing.Queue() - self.runner = iteration_ipc.RunnerIterationIPCEndpoint( - self._id, self._ctx_ids, self._queue) - self._kwargs = {'version': 1, 'iteration': 10, 'kpi': {}} - self._pload_dict = payloads.TrafficGeneratorPayload.dict_to_obj( - self._kwargs).obj_to_dict() - - def test_tg_method_started(self): - self._queue.empty() - ctxt = {'id': self._ctx_ids[0]} - self.runner.tg_method_started(ctxt, **self._kwargs) - time.sleep(0.2) - - output = [] - while not self._queue.empty(): - output.append(self._queue.get(True, 1)) - - self.assertEqual(1, len(output)) - self.assertEqual(self._ctx_ids[0], output[0]['id']) - self.assertEqual(messaging.TG_METHOD_STARTED, output[0]['action']) - self.assertEqual(self._pload_dict, output[0]['payload'].obj_to_dict()) - - def test_tg_method_finished(self): - self._queue.empty() - ctxt = {'id': self._ctx_ids[0]} - self.runner.tg_method_finished(ctxt, **self._kwargs) - time.sleep(0.2) - - output = [] - while not self._queue.empty(): - output.append(self._queue.get(True, 1)) - - self.assertEqual(1, len(output)) - self.assertEqual(self._ctx_ids[0], output[0]['id']) - self.assertEqual(messaging.TG_METHOD_FINISHED, output[0]['action']) - self.assertEqual(self._pload_dict, output[0]['payload'].obj_to_dict()) - - def test_tg_method_iteration(self): - self._queue.empty() - ctxt = {'id': self._ctx_ids[0]} - self.runner.tg_method_iteration(ctxt, **self._kwargs) - time.sleep(0.2) - - output = [] - while not self._queue.empty(): - output.append(self._queue.get(True, 1)) - - self.assertEqual(1, len(output)) - self.assertEqual(self._ctx_ids[0], output[0]['id']) - self.assertEqual(messaging.TG_METHOD_ITERATION, output[0]['action']) - self.assertEqual(self._pload_dict, output[0]['payload'].obj_to_dict()) - - -class RunnerIterationIPCConsumerTestCase(ut_base.BaseUnitTestCase): - - def setUp(self): - self._id = uuid.uuid1().int - self._ctx_ids = [uuid.uuid1().int, uuid.uuid1().int] - self.consumer = iteration_ipc.RunnerIterationIPCConsumer( - self._id, self._ctx_ids) - self.consumer._queue = mock.Mock() - - def test__init(self): - self.assertEqual({self._ctx_ids[0]: [], self._ctx_ids[1]: []}, - self.consumer._kpi_per_id) - - def test_is_all_kpis_received_in_iteration(self): - payload = payloads.TrafficGeneratorPayload( - version=1, iteration=1, kpi={}) - msg1 = {'action': messaging.TG_METHOD_ITERATION, - 'id': self._ctx_ids[0], 'payload': payload} - msg2 = {'action': messaging.TG_METHOD_ITERATION, - 'id': self._ctx_ids[1], 'payload': payload} - self.consumer.iteration_index = 1 - - self.consumer._queue.empty.side_effect = [False, True] - self.consumer._queue.get.return_value = msg1 - self.assertFalse(self.consumer.is_all_kpis_received_in_iteration()) - - self.consumer._queue.empty.side_effect = [False, True] - self.consumer._queue.get.return_value = msg2 - self.assertTrue(self.consumer.is_all_kpis_received_in_iteration()) - - -class IterationIPCRunnerTestCase(ut_base.BaseUnitTestCase): - - @mock.patch.object(iteration_ipc, '_worker_process') - @mock.patch.object(os, 'getpid', return_value=12345678) - @mock.patch.object(multiprocessing, 'Process', return_value=mock.Mock()) - def test__run_benchmark(self, mock_process, mock_getpid, mock_worker): - method = 'method' - scenario_cfg = {'type': 'scenario_type'} - context_cfg = 'context_cfg' - name = '%s-%s-%s' % ('IterationIPC', 'scenario_type', 12345678) - runner = iteration_ipc.IterationIPCRunner(mock.ANY) - mock_getpid.reset_mock() - - runner._run_benchmark('class', method, scenario_cfg, context_cfg) - mock_process.assert_called_once_with( - name=name, - target=mock_worker, - args=(runner.result_queue, 'class', method, scenario_cfg, - context_cfg, runner.aborted, runner.output_queue)) - mock_getpid.assert_called_once() diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py index 8214782b2..addd72bd5 100644 --- a/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py +++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py @@ -450,7 +450,6 @@ class TestNetworkServiceTestCase(unittest.TestCase): self._get_file_abspath("tg_trex_tpl.yaml") self.context_cfg["nodes"]['vnf__1']['VNF model'] = \ self._get_file_abspath("tg_trex_tpl.yaml") - self.context_cfg['task_id'] = 'fake_task_id' vnf = mock.Mock(autospec=GenericVNF) self.s.get_vnf_impl = mock.Mock(return_value=vnf) @@ -568,7 +567,6 @@ class TestNetworkServiceTestCase(unittest.TestCase): tgen.verify_traffic = lambda x: verified_dict tgen.terminate = mock.Mock(return_value=True) tgen.name = "tgen__1" - tgen.run_traffic.return_value = 'tg_id' vnf = mock.Mock(autospec=GenericVNF) vnf.runs_traffic = False vnf.terminate = mock.Mock(return_value=True) @@ -581,6 +579,7 @@ class TestNetworkServiceTestCase(unittest.TestCase): self.s.load_vnf_models = mock.Mock(return_value=self.s.vnfs) self.s._fill_traffic_profile = \ mock.Mock(return_value=TRAFFIC_PROFILE) + self.assertIsNone(self.s.setup()) def test_setup_exception(self): with mock.patch("yardstick.ssh.SSH") as ssh: @@ -705,9 +704,6 @@ class TestNetworkServiceTestCase(unittest.TestCase): ) self.assertEqual(self.s.topology, 'fake_nsd') - def test_get_mq_ids(self): - self.assertEqual(self.s._mq_ids, self.s.get_mq_ids()) - def test_teardown(self): vnf = mock.Mock(autospec=GenericVNF) vnf.terminate = mock.Mock(return_value=True) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py index 69a5fb484..2d7ec195f 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py @@ -237,7 +237,7 @@ class TestAclApproxVnf(unittest.TestCase): def test___init__(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd, 'task_id') + acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd) self.assertIsNone(acl_approx_vnf._vnf_process) @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time") @@ -247,7 +247,7 @@ class TestAclApproxVnf(unittest.TestCase): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd, 'task_id') + acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd) acl_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {acl_approx_vnf.name: "mock"} } @@ -270,7 +270,7 @@ class TestAclApproxVnf(unittest.TestCase): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd, 'task_id') + acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd) acl_approx_vnf.q_in = mock.MagicMock() acl_approx_vnf.q_out = mock.MagicMock() acl_approx_vnf.q_out.qsize = mock.Mock(return_value=0) @@ -282,7 +282,7 @@ class TestAclApproxVnf(unittest.TestCase): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd, 'task_id') + acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd) acl_approx_vnf.q_in = mock.MagicMock() acl_approx_vnf.q_out = mock.MagicMock() acl_approx_vnf.q_out.qsize = mock.Mock(return_value=0) @@ -303,7 +303,7 @@ class TestAclApproxVnf(unittest.TestCase): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd, 'task_id') + acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd) acl_approx_vnf._build_config = mock.MagicMock() acl_approx_vnf.queue_wrapper = mock.MagicMock() acl_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg @@ -323,7 +323,7 @@ class TestAclApproxVnf(unittest.TestCase): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd, 'task_id') + acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd) acl_approx_vnf.deploy_helper = mock.MagicMock() acl_approx_vnf.resource_helper = mock.MagicMock() acl_approx_vnf._build_config = mock.MagicMock() @@ -341,7 +341,7 @@ class TestAclApproxVnf(unittest.TestCase): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd, 'task_id') + acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd) acl_approx_vnf._vnf_process = mock.MagicMock() acl_approx_vnf._vnf_process.terminate = mock.Mock() acl_approx_vnf.used_drivers = {"01:01.0": "i40e", diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_agnostic_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_agnostic_vnf.py index 3374cbe76..47e464da3 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_agnostic_vnf.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_agnostic_vnf.py @@ -13,7 +13,6 @@ # limitations under the License. import unittest -import uuid from yardstick.network_services.vnf_generic.vnf import agnostic_vnf @@ -44,9 +43,8 @@ VNFD = { class TestAgnosticVnf(unittest.TestCase): def setUp(self): - self._id = uuid.uuid1().int self.vnfd = VNFD['vnfd:vnfd-catalog']['vnfd'][0] - self.agnostic_vnf = agnostic_vnf.AgnosticVnf(NAME, self.vnfd, self._id) + self.agnostic_vnf = agnostic_vnf.AgnosticVnf(NAME, self.vnfd) def test_instantiate(self): self.assertIsNone(self.agnostic_vnf.instantiate({}, {})) 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 2ea13a5e0..ea2f84d98 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 @@ -14,15 +14,10 @@ import multiprocessing import os -import uuid import mock -from oslo_config import cfg -import oslo_messaging import unittest -from yardstick.common import messaging -from yardstick.common.messaging import payloads from yardstick.network_services.vnf_generic.vnf import base from yardstick.ssh import SSH from yardstick.tests.unit import base as ut_base @@ -145,24 +140,6 @@ VNFD = { } -class _DummyGenericTrafficGen(base.GenericTrafficGen): # pragma: no cover - - def run_traffic(self, *args): - pass - - def terminate(self): - pass - - def collect_kpi(self): - pass - - def instantiate(self, *args): - pass - - def scale(self, flavor=''): - pass - - class FileAbsPath(object): def __init__(self, module_file): super(FileAbsPath, self).__init__() @@ -235,8 +212,7 @@ class TestGenericVNF(ut_base.BaseUnitTestCase): """Make sure that the abstract class cannot be instantiated""" with self.assertRaises(TypeError) as exc: # pylint: disable=abstract-class-instantiated - base.GenericVNF('vnf1', VNFD['vnfd:vnfd-catalog']['vnfd'][0], - 'task_id') + base.GenericVNF('vnf1', VNFD['vnfd:vnfd-catalog']['vnfd'][0]) msg = ("Can't instantiate abstract class GenericVNF with abstract " "methods collect_kpi, instantiate, scale, start_collect, " @@ -253,96 +229,8 @@ class GenericTrafficGenTestCase(ut_base.BaseUnitTestCase): name = 'vnf1' with self.assertRaises(TypeError) as exc: # pylint: disable=abstract-class-instantiated - base.GenericTrafficGen(name, vnfd, 'task_id') + base.GenericTrafficGen(name, vnfd) msg = ("Can't instantiate abstract class GenericTrafficGen with " "abstract methods collect_kpi, instantiate, run_traffic, " "scale, terminate") self.assertEqual(msg, str(exc.exception)) - - def test_get_mq_producer_id(self): - vnfd = {'benchmark': {'kpi': mock.ANY}, - 'vdu': [{'external-interface': 'ext_int'}] - } - tg = _DummyGenericTrafficGen('name', vnfd, 'task_id') - tg._mq_producer = mock.Mock() - tg._mq_producer.id = 'fake_id' - self.assertEqual('fake_id', tg.get_mq_producer_id()) - - -class TrafficGeneratorProducerTestCase(ut_base.BaseUnitTestCase): - - @mock.patch.object(oslo_messaging, 'Target', return_value='rpc_target') - @mock.patch.object(oslo_messaging, 'RPCClient') - @mock.patch.object(oslo_messaging, 'get_rpc_transport', - return_value='rpc_transport') - @mock.patch.object(cfg, 'CONF') - def test__init(self, mock_config, mock_transport, mock_rpcclient, - mock_target): - _id = uuid.uuid1().int - tg_producer = base.TrafficGeneratorProducer(_id) - mock_transport.assert_called_once_with( - mock_config, url='rabbit://yardstick:yardstick@localhost:5672/') - mock_target.assert_called_once_with(topic=messaging.TOPIC_TG, - fanout=True, - server=messaging.SERVER) - mock_rpcclient.assert_called_once_with('rpc_transport', 'rpc_target') - self.assertEqual(_id, tg_producer._id) - self.assertEqual(messaging.TOPIC_TG, tg_producer._topic) - - @mock.patch.object(oslo_messaging, 'Target', return_value='rpc_target') - @mock.patch.object(oslo_messaging, 'RPCClient') - @mock.patch.object(oslo_messaging, 'get_rpc_transport', - return_value='rpc_transport') - @mock.patch.object(payloads, 'TrafficGeneratorPayload', - return_value='tg_pload') - def test_tg_method_started(self, mock_tg_payload, *args): - tg_producer = base.TrafficGeneratorProducer(uuid.uuid1().int) - with mock.patch.object(tg_producer, 'send_message') as mock_message: - tg_producer.tg_method_started(version=10) - - mock_message.assert_called_once_with(messaging.TG_METHOD_STARTED, - 'tg_pload') - mock_tg_payload.assert_called_once_with(version=10, iteration=0, - kpi={}) - - @mock.patch.object(oslo_messaging, 'Target', return_value='rpc_target') - @mock.patch.object(oslo_messaging, 'RPCClient') - @mock.patch.object(oslo_messaging, 'get_rpc_transport', - return_value='rpc_transport') - @mock.patch.object(payloads, 'TrafficGeneratorPayload', - return_value='tg_pload') - def test_tg_method_finished(self, mock_tg_payload, *args): - tg_producer = base.TrafficGeneratorProducer(uuid.uuid1().int) - with mock.patch.object(tg_producer, 'send_message') as mock_message: - tg_producer.tg_method_finished(version=20) - - mock_message.assert_called_once_with(messaging.TG_METHOD_FINISHED, - 'tg_pload') - mock_tg_payload.assert_called_once_with(version=20, iteration=0, - kpi={}) - - @mock.patch.object(oslo_messaging, 'Target', return_value='rpc_target') - @mock.patch.object(oslo_messaging, 'RPCClient') - @mock.patch.object(oslo_messaging, 'get_rpc_transport', - return_value='rpc_transport') - @mock.patch.object(payloads, 'TrafficGeneratorPayload', - return_value='tg_pload') - def test_tg_method_iteration(self, mock_tg_payload, *args): - tg_producer = base.TrafficGeneratorProducer(uuid.uuid1().int) - with mock.patch.object(tg_producer, 'send_message') as mock_message: - tg_producer.tg_method_iteration(100, version=30, kpi={'k': 'v'}) - - mock_message.assert_called_once_with(messaging.TG_METHOD_ITERATION, - 'tg_pload') - mock_tg_payload.assert_called_once_with(version=30, iteration=100, - kpi={'k': 'v'}) - - -class GenericVNFConsumerTestCase(ut_base.BaseUnitTestCase): - - def test__init(self): - endpoints = 'endpoint_1' - _ids = [uuid.uuid1().int] - gvnf_consumer = base.GenericVNFConsumer(_ids, endpoints) - self.assertEqual(_ids, gvnf_consumer._ids) - self.assertEqual([endpoints], gvnf_consumer._endpoints) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py index 32f5b758d..635ca41a2 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py @@ -318,14 +318,14 @@ class TestCgnaptApproxVnf(unittest.TestCase): def test___init__(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd, 'task_id') + cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd) self.assertIsNone(cgnapt_approx_vnf._vnf_process) @mock.patch.object(process, 'check_if_process_failed') @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node') def test_collect_kpi(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd, 'task_id') + cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd) cgnapt_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {cgnapt_approx_vnf.name: "mock"} } @@ -349,7 +349,7 @@ class TestCgnaptApproxVnf(unittest.TestCase): @mock.patch.object(time, 'sleep') def test_vnf_execute_command(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd, 'task_id') + cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd) cgnapt_approx_vnf.q_in = mock.Mock() cgnapt_approx_vnf.q_out = mock.Mock() cgnapt_approx_vnf.q_out.qsize = mock.Mock(return_value=0) @@ -357,7 +357,7 @@ class TestCgnaptApproxVnf(unittest.TestCase): def test_get_stats(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd, 'task_id') + cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd) with mock.patch.object(cgnapt_approx_vnf, 'vnf_execute') as mock_exec: mock_exec.return_value = 'output' self.assertEqual('output', cgnapt_approx_vnf.get_stats()) @@ -366,7 +366,7 @@ class TestCgnaptApproxVnf(unittest.TestCase): def test_run_vcgnapt(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd, 'task_id') + cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd) cgnapt_approx_vnf.ssh_helper = mock.Mock() cgnapt_approx_vnf.setup_helper = mock.Mock() with mock.patch.object(cgnapt_approx_vnf, '_build_config'), \ @@ -379,7 +379,7 @@ class TestCgnaptApproxVnf(unittest.TestCase): @mock.patch.object(ctx_base.Context, 'get_context_from_server') def test_instantiate(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd, 'task_id') + cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd) cgnapt_approx_vnf.deploy_helper = mock.MagicMock() cgnapt_approx_vnf.resource_helper = mock.MagicMock() cgnapt_approx_vnf._build_config = mock.MagicMock() @@ -396,7 +396,7 @@ class TestCgnaptApproxVnf(unittest.TestCase): def test__vnf_up_post(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] self.scenario_cfg['options'][name]['napt'] = 'static' - cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd, 'task_id') + cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd) cgnapt_approx_vnf.vnf_execute = mock.Mock() cgnapt_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg with mock.patch.object(cgnapt_approx_vnf, 'setup_helper') as \ @@ -407,6 +407,6 @@ class TestCgnaptApproxVnf(unittest.TestCase): def test__vnf_up_post_short(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd, 'task_id') + cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd) cgnapt_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg cgnapt_approx_vnf._vnf_up_post() diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_epc_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_epc_vnf.py index 6d14ddb54..c5bc3f59d 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_epc_vnf.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_epc_vnf.py @@ -14,7 +14,6 @@ import copy import unittest -import uuid from yardstick.network_services.vnf_generic.vnf import epc_vnf @@ -45,12 +44,11 @@ VNFD = { class TestEPCVnf(unittest.TestCase): def setUp(self): - self._id = uuid.uuid1().int self.vnfd = VNFD['vnfd:vnfd-catalog']['vnfd'][0] - self.epc_vnf = epc_vnf.EPCVnf(NAME, self.vnfd, self._id) + self.epc_vnf = epc_vnf.EPCVnf(NAME, self.vnfd) def test___init__(self, *args): - _epc_vnf = epc_vnf.EPCVnf(NAME, self.vnfd, self._id) + _epc_vnf = epc_vnf.EPCVnf(NAME, self.vnfd) for x in {'user', 'password', 'ip'}: self.assertEqual(self.vnfd['mgmt-interface'][x], _epc_vnf.vnfd_helper.mgmt_interface[x]) @@ -62,7 +60,7 @@ class TestEPCVnf(unittest.TestCase): def test___init__missing_ip(self, *args): _vnfd = copy.deepcopy(self.vnfd) _vnfd['mgmt-interface'].pop('ip') - _epc_vnf = epc_vnf.EPCVnf(NAME, _vnfd, self._id) + _epc_vnf = epc_vnf.EPCVnf(NAME, _vnfd) for x in {'user', 'password'}: self.assertEqual(_vnfd['mgmt-interface'][x], _epc_vnf.vnfd_helper.mgmt_interface[x]) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_irq.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_irq.py index 4eaa38c27..fd6f1712c 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_irq.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_irq.py @@ -312,7 +312,7 @@ class TestProxIrqVNF(unittest.TestCase): } def test___init__(self): - prox_irq_vnf = ProxIrqVNF('vnf1', self.VNFD_0, 'task_id') + prox_irq_vnf = ProxIrqVNF('vnf1', self.VNFD_0) self.assertEqual(prox_irq_vnf.name, 'vnf1') self.assertDictEqual(prox_irq_vnf.vnfd_helper, self.VNFD_0) @@ -342,7 +342,7 @@ class TestProxIrqVNF(unittest.TestCase): build_config_file = mock.MagicMock() build_config_file.return_value = None - prox_irq_vnf = ProxIrqVNF(VNF_NAME, vnfd, 'task_id') + prox_irq_vnf = ProxIrqVNF(VNF_NAME, vnfd) startup = ["global", [["eal", "-4"]]] master_0 = ["core 0", [["mode", "master"]]] @@ -371,7 +371,7 @@ class TestProxIrqVNF(unittest.TestCase): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - prox_irq_vnf = ProxIrqVNF(VNF_NAME, vnfd, 'task_id') + prox_irq_vnf = ProxIrqVNF(VNF_NAME, vnfd) prox_irq_vnf.resource_helper = resource_helper = mock.Mock() resource_helper.execute.side_effect = OSError(errno.EPIPE, "") @@ -391,7 +391,7 @@ class TestProxIrqVNF(unittest.TestCase): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] mock_ssh(ssh, exec_result=(1, "", "")) - prox_irq_vnf = ProxIrqVNF(VNF_NAME, vnfd, 'task_id') + prox_irq_vnf = ProxIrqVNF(VNF_NAME, vnfd) prox_irq_vnf._terminated = mock.MagicMock() prox_irq_vnf._traffic_process = mock.MagicMock() @@ -414,7 +414,7 @@ class TestProxIrqVNF(unittest.TestCase): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] mock_ssh(ssh, exec_result=(1, "", "")) - prox_irq_vnf = ProxIrqVNF(VNF_NAME, vnfd, 'task_id') + prox_irq_vnf = ProxIrqVNF(VNF_NAME, vnfd) prox_irq_vnf._terminated = mock.MagicMock() prox_irq_vnf._traffic_process = mock.MagicMock() @@ -714,18 +714,18 @@ class TestProxIrqGen(unittest.TestCase): def test__check_status(self): - prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0, 'task_id') + prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0) with self.assertRaises(NotImplementedError): prox_irq_gen._check_status() def test_listen_traffic(self): - prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0, 'task_id') + prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0) prox_irq_gen.listen_traffic(mock.Mock()) def test_verify_traffic(self): - prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0, 'task_id') + prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0) prox_irq_gen.verify_traffic(mock.Mock()) @@ -734,7 +734,7 @@ class TestProxIrqGen(unittest.TestCase): def test_terminate(self, ssh, *args): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - prox_traffic_gen = ProxIrqGen(VNF_NAME, vnfd, 'task_id') + prox_traffic_gen = ProxIrqGen(VNF_NAME, vnfd) prox_traffic_gen._terminated = mock.MagicMock() prox_traffic_gen._traffic_process = mock.MagicMock() prox_traffic_gen._traffic_process.terminate = mock.Mock() @@ -747,7 +747,7 @@ class TestProxIrqGen(unittest.TestCase): self.assertIsNone(prox_traffic_gen.terminate()) def test__wait_for_process(self): - prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0, 'task_id') + prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0) with mock.patch.object(prox_irq_gen, '_check_status', return_value=0) as mock_status, \ mock.patch.object(prox_irq_gen, '_tg_process') as mock_proc: @@ -758,14 +758,14 @@ class TestProxIrqGen(unittest.TestCase): mock_status.assert_called_once() def test__wait_for_process_not_alive(self): - prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0, 'task_id') + prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0) with mock.patch.object(prox_irq_gen, '_tg_process') as mock_proc: mock_proc.is_alive.return_value = False self.assertRaises(RuntimeError, prox_irq_gen._wait_for_process) mock_proc.is_alive.assert_called_once() def test__wait_for_process_delayed(self): - prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0, 'task_id') + prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0) with mock.patch.object(prox_irq_gen, '_check_status', side_effect=[1, 0]) as mock_status, \ mock.patch.object(prox_irq_gen, @@ -777,7 +777,7 @@ class TestProxIrqGen(unittest.TestCase): mock_status.assert_has_calls([mock.call(), mock.call()]) def test_scale(self): - prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0, 'task_id') + prox_irq_gen = ProxIrqGen('tg1', self.VNFD_0) self.assertRaises(y_exceptions.FunctionNotImplemented, prox_irq_gen.scale) @@ -804,7 +804,7 @@ class TestProxIrqGen(unittest.TestCase): build_config_file = mock.MagicMock() build_config_file.return_value = None - prox_irq_gen = ProxIrqGen(VNF_NAME, vnfd, 'task_id') + prox_irq_gen = ProxIrqGen(VNF_NAME, vnfd) startup = ["global", [["eal", "-4"]]] master_0 = ["core 0", [["mode", "master"]]] diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py index 62cbea0bb..de436a46e 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py @@ -317,7 +317,7 @@ class TestProxApproxVnf(unittest.TestCase): @mock.patch(SSH_HELPER) def test___init__(self, ssh, *args): mock_ssh(ssh) - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) self.assertIsNone(prox_approx_vnf._vnf_process) @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node') @@ -325,7 +325,7 @@ class TestProxApproxVnf(unittest.TestCase): def test_collect_kpi_no_client(self, ssh, *args): mock_ssh(ssh) - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {prox_approx_vnf.name: "mock"} } @@ -352,7 +352,7 @@ class TestProxApproxVnf(unittest.TestCase): [[0, 1, 2, 3, 4, 5], [1, 1, 2, 3, 4, 5]]) resource_helper.collect_collectd_kpi.return_value = {'core': {'result': 234}} - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {prox_approx_vnf.name: "mock"} } @@ -385,7 +385,7 @@ class TestProxApproxVnf(unittest.TestCase): [[0, 'A', 'B', 'C', 'D', 'E'], ['F', 1, 2, 3, 4, 5]]) - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {prox_approx_vnf.name: "mock"} } @@ -404,7 +404,7 @@ class TestProxApproxVnf(unittest.TestCase): [[0, 'A', 'B', 'C', 'D', 'E'], ['F', 1, 2, 3, 4, 5]]) - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {prox_approx_vnf.name: "mock"} } @@ -419,8 +419,7 @@ class TestProxApproxVnf(unittest.TestCase): mock_ssh(ssh) resource_helper = mock.MagicMock() - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, deepcopy(self.VNFD0), - 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, deepcopy(self.VNFD0)) prox_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {prox_approx_vnf.name: "mock"} } @@ -443,7 +442,7 @@ class TestProxApproxVnf(unittest.TestCase): def test_run_prox(self, ssh, *_): mock_ssh(ssh) - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.scenario_helper.scenario_cfg = self.SCENARIO_CFG prox_approx_vnf.ssh_helper.join_bin_path.return_value = '/tool_path12/tool_file34' prox_approx_vnf.setup_helper.remote_path = 'configs/file56.cfg' @@ -457,7 +456,7 @@ class TestProxApproxVnf(unittest.TestCase): @mock.patch(SSH_HELPER) def bad_test_instantiate(self, *args): - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.scenario_helper = mock.MagicMock() prox_approx_vnf.setup_helper = mock.MagicMock() # we can't mock super @@ -467,7 +466,7 @@ class TestProxApproxVnf(unittest.TestCase): @mock.patch(SSH_HELPER) def test_wait_for_instantiate_panic(self, ssh, *args): mock_ssh(ssh, exec_result=(1, "", "")) - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf._vnf_process = mock.MagicMock(**{"is_alive.return_value": True}) prox_approx_vnf._run_prox = mock.Mock(return_value=0) prox_approx_vnf.WAIT_TIME = 0 @@ -479,7 +478,7 @@ class TestProxApproxVnf(unittest.TestCase): @mock.patch(SSH_HELPER) def test_terminate(self, ssh, *args): mock_ssh(ssh) - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf._vnf_process = mock.MagicMock() prox_approx_vnf._vnf_process.terminate = mock.Mock() prox_approx_vnf.ssh_helper = mock.MagicMock() @@ -491,7 +490,7 @@ class TestProxApproxVnf(unittest.TestCase): @mock.patch(SSH_HELPER) def test__vnf_up_post(self, ssh, *args): mock_ssh(ssh) - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.resource_helper = resource_helper = mock.Mock() prox_approx_vnf._vnf_up_post() @@ -500,7 +499,7 @@ class TestProxApproxVnf(unittest.TestCase): @mock.patch(SSH_HELPER) def test_vnf_execute_oserror(self, ssh, *args): mock_ssh(ssh) - prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id') + prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.resource_helper = resource_helper = mock.Mock() resource_helper.execute.side_effect = OSError(errno.EPIPE, "") diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py index ad74145b4..3e21392be 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py @@ -199,7 +199,7 @@ class TestRouterVNF(unittest.TestCase): def test___init__(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - router_vnf = RouterVNF(name, vnfd, 'task_id') + router_vnf = RouterVNF(name, vnfd) self.assertIsNone(router_vnf._vnf_process) def test_get_stats(self): @@ -213,7 +213,7 @@ class TestRouterVNF(unittest.TestCase): m = mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - router_vnf = RouterVNF(name, vnfd, 'task_id') + router_vnf = RouterVNF(name, vnfd) router_vnf.scenario_helper.scenario_cfg = { 'nodes': {router_vnf.name: "mock"} } @@ -232,7 +232,7 @@ class TestRouterVNF(unittest.TestCase): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - router_vnf = RouterVNF(name, vnfd, 'task_id') + router_vnf = RouterVNF(name, vnfd) router_vnf.scenario_helper.scenario_cfg = self.scenario_cfg router_vnf._run() router_vnf.ssh_helper.drop_connection.assert_called_once() @@ -243,7 +243,7 @@ class TestRouterVNF(unittest.TestCase): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - router_vnf = RouterVNF(name, vnfd, 'task_id') + router_vnf = RouterVNF(name, vnfd) router_vnf.WAIT_TIME = 0 router_vnf.INTERFACE_WAIT = 0 self.scenario_cfg.update({"nodes": {"vnf__1": ""}}) @@ -256,7 +256,7 @@ class TestRouterVNF(unittest.TestCase): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - router_vnf = RouterVNF(name, vnfd, 'task_id') + router_vnf = RouterVNF(name, vnfd) router_vnf._vnf_process = mock.MagicMock() router_vnf._vnf_process.terminate = mock.Mock() self.assertIsNone(router_vnf.terminate()) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py index a1802aa55..405eeceb7 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py @@ -1062,58 +1062,6 @@ class TestClientResourceHelper(unittest.TestCase): self.assertIs(client_resource_helper._connect(client), client) - @mock.patch.object(ClientResourceHelper, '_build_ports') - @mock.patch.object(ClientResourceHelper, '_run_traffic_once', - return_value=(True, mock.ANY)) - def test_run_traffic(self, mock_run_traffic_once, mock_build_ports): - client_resource_helper = ClientResourceHelper(mock.Mock()) - client = mock.Mock() - traffic_profile = mock.Mock() - mq_producer = mock.Mock() - with mock.patch.object(client_resource_helper, '_connect') \ - as mock_connect, \ - mock.patch.object(client_resource_helper, '_terminated') \ - as mock_terminated: - mock_connect.return_value = client - type(mock_terminated).value = mock.PropertyMock( - side_effect=[0, 1, 1, lambda x: x]) - client_resource_helper.run_traffic(traffic_profile, mq_producer) - - mock_build_ports.assert_called_once() - traffic_profile.register_generator.assert_called_once() - mq_producer.tg_method_started.assert_called_once() - mq_producer.tg_method_finished.assert_called_once() - mq_producer.tg_method_iteration.assert_called_once_with(1) - mock_run_traffic_once.assert_called_once_with(traffic_profile) - - @mock.patch.object(ClientResourceHelper, '_build_ports') - @mock.patch.object(ClientResourceHelper, '_run_traffic_once', - side_effect=Exception) - def test_run_traffic_exception(self, mock_run_traffic_once, - mock_build_ports): - client_resource_helper = ClientResourceHelper(mock.Mock()) - client = mock.Mock() - traffic_profile = mock.Mock() - mq_producer = mock.Mock() - with mock.patch.object(client_resource_helper, '_connect') \ - as mock_connect, \ - mock.patch.object(client_resource_helper, '_terminated') \ - as mock_terminated: - mock_connect.return_value = client - type(mock_terminated).value = mock.PropertyMock(return_value=0) - mq_producer.reset_mock() - # NOTE(ralonsoh): "trex_stl_exceptions.STLError" is mocked - with self.assertRaises(Exception): - client_resource_helper.run_traffic(traffic_profile, - mq_producer) - - mock_build_ports.assert_called_once() - traffic_profile.register_generator.assert_called_once() - mock_run_traffic_once.assert_called_once_with(traffic_profile) - mq_producer.tg_method_started.assert_called_once() - mq_producer.tg_method_finished.assert_not_called() - mq_producer.tg_method_iteration.assert_not_called() - class TestRfc2544ResourceHelper(unittest.TestCase): @@ -1518,7 +1466,7 @@ class TestSampleVnf(unittest.TestCase): } def test___init__(self): - sample_vnf = SampleVNF('vnf1', self.VNFD_0, 'task_id') + sample_vnf = SampleVNF('vnf1', self.VNFD_0) self.assertEqual(sample_vnf.name, 'vnf1') self.assertDictEqual(sample_vnf.vnfd_helper, self.VNFD_0) @@ -1536,8 +1484,7 @@ class TestSampleVnf(unittest.TestCase): class MyResourceHelper(ResourceHelper): pass - sample_vnf = SampleVNF('vnf1', self.VNFD_0, 'task_id', - MySetupEnvHelper, MyResourceHelper) + sample_vnf = SampleVNF('vnf1', self.VNFD_0, MySetupEnvHelper, MyResourceHelper) self.assertEqual(sample_vnf.name, 'vnf1') self.assertDictEqual(sample_vnf.vnfd_helper, self.VNFD_0) @@ -1551,7 +1498,7 @@ class TestSampleVnf(unittest.TestCase): @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.Process') def test__start_vnf(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) sample_vnf._run = mock.Mock() self.assertIsNone(sample_vnf.queue_wrapper) @@ -1570,7 +1517,7 @@ class TestSampleVnf(unittest.TestCase): } vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) sample_vnf.scenario_helper.scenario_cfg = { 'nodes': {sample_vnf.name: 'mock'} } @@ -1614,7 +1561,7 @@ class TestSampleVnf(unittest.TestCase): 'plugin1': {'param': 1}}} vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf__0', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf__0', vnfd) sample_vnf._update_collectd_options(scenario_cfg, context_cfg) self.assertEqual(sample_vnf.setup_helper.collectd_options, expected) @@ -1641,7 +1588,7 @@ class TestSampleVnf(unittest.TestCase): 'plugin1': {'param': 1}}} vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) sample_vnf._update_options(options2, options1) self.assertEqual(options2, expected) @@ -1663,7 +1610,7 @@ class TestSampleVnf(unittest.TestCase): ] vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) sample_vnf.APP_NAME = 'sample1' sample_vnf.WAIT_TIME_FOR_SCRIPT = 0 sample_vnf._start_server = mock.Mock(return_value=0) @@ -1694,7 +1641,7 @@ class TestSampleVnf(unittest.TestCase): ] vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) sample_vnf.APP_NAME = 'sample1' sample_vnf.q_out = mock.Mock() sample_vnf.q_out.qsize.side_effect = iter(queue_size_list) @@ -1704,7 +1651,7 @@ class TestSampleVnf(unittest.TestCase): def test_terminate_without_vnf_process(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) sample_vnf.APP_NAME = 'sample1' sample_vnf.vnf_execute = mock.Mock() sample_vnf.ssh_helper = mock.Mock() @@ -1715,7 +1662,7 @@ class TestSampleVnf(unittest.TestCase): def test_get_stats(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) sample_vnf.APP_NAME = 'sample1' sample_vnf.APP_WORD = 'sample1' sample_vnf.vnf_execute = mock.Mock(return_value='the stats') @@ -1725,7 +1672,7 @@ class TestSampleVnf(unittest.TestCase): @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node') def test_collect_kpi(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) sample_vnf.scenario_helper.scenario_cfg = { 'nodes': {sample_vnf.name: "mock"} } @@ -1753,7 +1700,7 @@ class TestSampleVnf(unittest.TestCase): @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node') def test_collect_kpi_default(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) sample_vnf.scenario_helper.scenario_cfg = { 'nodes': {sample_vnf.name: "mock"} } @@ -1772,7 +1719,7 @@ class TestSampleVnf(unittest.TestCase): def test_scale(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) self.assertRaises(y_exceptions.FunctionNotImplemented, sample_vnf.scale) @@ -1780,7 +1727,7 @@ class TestSampleVnf(unittest.TestCase): test_cmd = 'test cmd' run_kwargs = {'arg1': 'val1', 'arg2': 'val2'} vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sample_vnf = SampleVNF('vnf1', vnfd, 'task_id') + sample_vnf = SampleVNF('vnf1', vnfd) sample_vnf.ssh_helper = mock.Mock() sample_vnf.setup_helper = mock.Mock() with mock.patch.object(sample_vnf, '_build_config', @@ -1916,30 +1863,30 @@ class TestSampleVNFTrafficGen(unittest.TestCase): } def test__check_status(self): - sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0, 'task_id') + sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0) with self.assertRaises(NotImplementedError): sample_vnf_tg._check_status() def test_listen_traffic(self): - sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0, 'task_id') + sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0) sample_vnf_tg.listen_traffic(mock.Mock()) def test_verify_traffic(self): - sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0, 'task_id') + sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0) sample_vnf_tg.verify_traffic(mock.Mock()) def test_terminate(self): - sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0, 'task_id') + sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0) sample_vnf_tg._traffic_process = mock.Mock() sample_vnf_tg._tg_process = mock.Mock() sample_vnf_tg.terminate() def test__wait_for_process(self): - sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0, 'task_id') + sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0) with mock.patch.object(sample_vnf_tg, '_check_status', return_value=0) as mock_status, \ mock.patch.object(sample_vnf_tg, '_tg_process') as mock_proc: @@ -1950,14 +1897,14 @@ class TestSampleVNFTrafficGen(unittest.TestCase): mock_status.assert_called_once() def test__wait_for_process_not_alive(self): - sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0, 'task_id') + sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0) with mock.patch.object(sample_vnf_tg, '_tg_process') as mock_proc: mock_proc.is_alive.return_value = False self.assertRaises(RuntimeError, sample_vnf_tg._wait_for_process) mock_proc.is_alive.assert_called_once() def test__wait_for_process_delayed(self): - sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0, 'task_id') + sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0) with mock.patch.object(sample_vnf_tg, '_check_status', side_effect=[1, 0]) as mock_status, \ mock.patch.object(sample_vnf_tg, @@ -1969,6 +1916,6 @@ class TestSampleVNFTrafficGen(unittest.TestCase): mock_status.assert_has_calls([mock.call(), mock.call()]) def test_scale(self): - sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0, 'task_id') + sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0) self.assertRaises(y_exceptions.FunctionNotImplemented, sample_vnf_tg.scale) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py index e7f6206eb..469e5113f 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py @@ -128,12 +128,12 @@ class TestIxLoadTrafficGen(ut_base.BaseUnitTestCase): def test___init__(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') + ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd) self.assertIsNone(ixload_traffic_gen.resource_helper.data) def test_update_gateways(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') + ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd) links = {'uplink_0': {'ip': {}}, 'downlink_1': {'ip': {}}} @@ -146,7 +146,7 @@ class TestIxLoadTrafficGen(ut_base.BaseUnitTestCase): return_value='mock_node') def test_collect_kpi(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') + ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd) ixload_traffic_gen.scenario_helper.scenario_cfg = { 'nodes': {ixload_traffic_gen.name: "mock"} } @@ -160,7 +160,7 @@ class TestIxLoadTrafficGen(ut_base.BaseUnitTestCase): def test_listen_traffic(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') + ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd) self.assertIsNone(ixload_traffic_gen.listen_traffic({})) @mock.patch.object(utils, 'find_relative_file') @@ -169,7 +169,7 @@ class TestIxLoadTrafficGen(ut_base.BaseUnitTestCase): @mock.patch.object(tg_ixload, 'shutil') def test_instantiate(self, mock_shutil, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') + ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd) scenario_cfg = {'tc': "nsb_test_case", 'ixia_profile': "ixload.cfg", 'task_path': "/path/to/task"} @@ -209,7 +209,7 @@ class TestIxLoadTrafficGen(ut_base.BaseUnitTestCase): vnfd['mgmt-interface'].update({'tg-config': {}}) vnfd['mgmt-interface']['tg-config'].update({'ixchassis': '1.1.1.1'}) vnfd['mgmt-interface']['tg-config'].update({'py_bin_path': '/root'}) - sut = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') + sut = tg_ixload.IxLoadTrafficGen(NAME, vnfd) sut.connection = mock.Mock() sut._traffic_runner = mock.Mock(return_value=0) result = sut.run_traffic(mock_traffic_profile) @@ -230,7 +230,7 @@ class TestIxLoadTrafficGen(ut_base.BaseUnitTestCase): vnfd['mgmt-interface'].update({'tg-config': {}}) vnfd['mgmt-interface']['tg-config'].update({'ixchassis': '1.1.1.1'}) vnfd['mgmt-interface']['tg-config'].update({'py_bin_path': '/root'}) - sut = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') + sut = tg_ixload.IxLoadTrafficGen(NAME, vnfd) sut.connection = mock.Mock() sut._traffic_runner = mock.Mock(return_value=0) subprocess.call(['touch', '/tmp/1.csv']) @@ -240,7 +240,7 @@ class TestIxLoadTrafficGen(ut_base.BaseUnitTestCase): def test_terminate(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') + ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd) self.assertIsNone(ixload_traffic_gen.terminate()) def test_parse_csv_read(self): @@ -253,7 +253,7 @@ class TestIxLoadTrafficGen(ut_base.BaseUnitTestCase): 'HTTP Transaction Rate': True, } http_reader = [kpi_data] - ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') + ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd) result = ixload_traffic_gen.resource_helper.result ixload_traffic_gen.resource_helper.parse_csv_read(http_reader) for k_left, k_right in tg_ixload.IxLoadResourceHelper.KPI_LIST.items(): @@ -268,7 +268,7 @@ class TestIxLoadTrafficGen(ut_base.BaseUnitTestCase): 'HTTP Connection Rate': 4, 'HTTP Transaction Rate': 5, }] - ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') + ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd) init_value = ixload_traffic_gen.resource_helper.result ixload_traffic_gen.resource_helper.parse_csv_read(http_reader) self.assertDictEqual(ixload_traffic_gen.resource_helper.result, @@ -282,7 +282,6 @@ class TestIxLoadTrafficGen(ut_base.BaseUnitTestCase): 'HTTP Concurrent Connections': 3, 'HTTP Transaction Rate': 5, }] - ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd, 'task_id') - + ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd) with self.assertRaises(KeyError): ixload_traffic_gen.resource_helper.parse_csv_read(http_reader) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_landslide.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_landslide.py index 1736d0f17..8c017d15e 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_landslide.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_landslide.py @@ -17,7 +17,6 @@ import mock import requests import time import unittest -import uuid from yardstick.benchmark.contexts import base as ctx_base from yardstick.common import exceptions @@ -399,8 +398,6 @@ class TestLandslideTrafficGen(unittest.TestCase): TEST_USER_ID = 11 def setUp(self): - self._id = uuid.uuid1().int - self.mock_lsapi = mock.patch.object(tg_landslide, 'LsApi') self.mock_lsapi.start() @@ -408,7 +405,7 @@ class TestLandslideTrafficGen(unittest.TestCase): self.mock_ssh_helper.start() self.vnfd = VNFD['vnfd:vnfd-catalog']['vnfd'][0] self.ls_tg = tg_landslide.LandslideTrafficGen( - NAME, self.vnfd, self._id) + NAME, self.vnfd) self.session_profile = copy.deepcopy(SESSION_PROFILE) self.ls_tg.session_profile = self.session_profile @@ -422,7 +419,7 @@ class TestLandslideTrafficGen(unittest.TestCase): def test___init__(self, mock_get_nsb_option, *args): _path_to_nsb = 'path/to/nsb' mock_get_nsb_option.return_value = _path_to_nsb - ls_tg = tg_landslide.LandslideTrafficGen(NAME, self.vnfd, self._id) + ls_tg = tg_landslide.LandslideTrafficGen(NAME, self.vnfd) self.assertIsInstance(ls_tg.resource_helper, tg_landslide.LandslideResourceHelper) mock_get_nsb_option.assert_called_once_with('bin_path') @@ -655,7 +652,7 @@ class TestLandslideTrafficGen(unittest.TestCase): def test__load_session_profile_unequal_num_of_cfg_blocks( self, mock_yaml_load, *args): vnfd = copy.deepcopy(VNFD['vnfd:vnfd-catalog']['vnfd'][0]) - ls_traffic_gen = tg_landslide.LandslideTrafficGen(NAME, vnfd, self._id) + ls_traffic_gen = tg_landslide.LandslideTrafficGen(NAME, vnfd) ls_traffic_gen.scenario_helper.scenario_cfg = self.SCENARIO_CFG mock_yaml_load.return_value = copy.deepcopy(SESSION_PROFILE) # Delete test_servers item from pod file to make it not valid @@ -670,7 +667,7 @@ class TestLandslideTrafficGen(unittest.TestCase): vnfd = copy.deepcopy(VNFD['vnfd:vnfd-catalog']['vnfd'][0]) # Swap test servers data in pod file vnfd['config'] = list(reversed(vnfd['config'])) - ls_tg = tg_landslide.LandslideTrafficGen(NAME, vnfd, self._id) + ls_tg = tg_landslide.LandslideTrafficGen(NAME, vnfd) ls_tg.scenario_helper.scenario_cfg = self.SCENARIO_CFG mock_yaml_load.return_value = SESSION_PROFILE with self.assertRaises(RuntimeError): diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py index 434a7b770..51f075e4a 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py @@ -226,7 +226,7 @@ class TestPingTrafficGen(unittest.TestCase): @mock.patch("yardstick.ssh.SSH") def test___init__(self, ssh): ssh.from_node.return_value.execute.return_value = 0, "success", "" - ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0, 'task_id') + ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0) self.assertIsInstance(ping_traffic_gen.setup_helper, PingSetupEnvHelper) self.assertIsInstance(ping_traffic_gen.resource_helper, PingResourceHelper) @@ -243,7 +243,7 @@ class TestPingTrafficGen(unittest.TestCase): (0, 'if_name_2', ''), ] ssh.from_node.return_value.execute.side_effect = iter(execute_result_data) - ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0, 'task_id') + ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0) ext_ifs = ping_traffic_gen.vnfd_helper.interfaces self.assertNotEqual(ext_ifs[0]['virtual-interface']['local_iface_name'], 'if_name_1') self.assertNotEqual(ext_ifs[1]['virtual-interface']['local_iface_name'], 'if_name_2') @@ -253,7 +253,7 @@ class TestPingTrafficGen(unittest.TestCase): def test_collect_kpi(self, ssh, *args): mock_ssh(ssh, exec_result=(0, "success", "")) - ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0, 'task_id') + ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0) ping_traffic_gen.scenario_helper.scenario_cfg = { 'nodes': {ping_traffic_gen.name: "mock"} } @@ -271,7 +271,7 @@ class TestPingTrafficGen(unittest.TestCase): @mock.patch(SSH_HELPER) def test_instantiate(self, ssh): mock_ssh(ssh, spec=VnfSshHelper, exec_result=(0, "success", "")) - ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0, 'task_id') + ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0) ping_traffic_gen.setup_helper.ssh_helper = mock.MagicMock( **{"execute.return_value": (0, "xe0_fake", "")}) self.assertIsInstance(ping_traffic_gen.ssh_helper, mock.Mock) @@ -286,7 +286,7 @@ class TestPingTrafficGen(unittest.TestCase): self.assertIsNotNone(ping_traffic_gen._result) def test_listen_traffic(self): - ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0, 'task_id') + ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0) self.assertIsNone(ping_traffic_gen.listen_traffic({})) @mock.patch("yardstick.ssh.SSH") @@ -294,5 +294,5 @@ class TestPingTrafficGen(unittest.TestCase): ssh.from_node.return_value.execute.return_value = 0, "success", "" ssh.from_node.return_value.run.return_value = 0, "success", "" - ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0, 'task_id') + ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0) self.assertIsNone(ping_traffic_gen.terminate()) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_pktgen.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_pktgen.py index d341b970b..34dd640ad 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_pktgen.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_pktgen.py @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import uuid - import mock from yardstick.common import constants @@ -33,23 +31,12 @@ class PktgenTrafficGenTestCase(ut_base.BaseUnitTestCase): 'benchmark': {'kpi': 'fake_kpi'} } - def setUp(self): - self._id = uuid.uuid1().int - self._mock_vnf_consumer = mock.patch.object(vnf_base, - 'GenericVNFConsumer') - self.mock_vnf_consumer = self._mock_vnf_consumer.start() - self.addCleanup(self._stop_mock) - - def _stop_mock(self): - self._mock_vnf_consumer.stop() - def test__init(self): - tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD, self._id) - self.assertTrue(isinstance(tg, (vnf_base.GenericTrafficGen, - vnf_base.GenericVNFEndpoint))) + tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD) + self.assertTrue(isinstance(tg, vnf_base.GenericTrafficGen)) def test_run_traffic(self): - tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD, self._id) + tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD) mock_tp = mock.Mock() with mock.patch.object(tg, '_is_running', return_value=True): tg.run_traffic(mock_tp) @@ -57,23 +44,23 @@ class PktgenTrafficGenTestCase(ut_base.BaseUnitTestCase): mock_tp.init.assert_called_once_with(tg._node_ip, tg._lua_node_port) def test__get_lua_node_port(self): - tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD, self._id) + tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD) service_ports = [{'port': constants.LUA_PORT, 'node_port': '12345'}] self.assertEqual(12345, tg._get_lua_node_port(service_ports)) def test__get_lua_node_port_no_lua_port(self): - tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD, self._id) + tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD) service_ports = [{'port': '333'}] self.assertIsNone(tg._get_lua_node_port(service_ports)) def test__is_running(self): - tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD, self._id) + tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD) with mock.patch.object(tg, '_traffic_profile'): self.assertTrue(tg._is_running()) def test__is_running_exception(self): - tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD, self._id) + tg = tg_pktgen.PktgenTrafficGen('name1', self.VNFD) with mock.patch.object(tg, '_traffic_profile') as mock_tp: mock_tp.help.side_effect = exceptions.PktgenActionError() self.assertFalse(tg._is_running()) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py index 935d3fa30..49df19378 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py @@ -314,16 +314,15 @@ class TestProxTrafficGen(unittest.TestCase): @mock.patch(SSH_HELPER) def test___init__(self, ssh, *args): mock_ssh(ssh) - prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0, 'task_id') + prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0) self.assertIsNone(prox_traffic_gen._tg_process) self.assertIsNone(prox_traffic_gen._traffic_process) - self.assertIsNone(prox_traffic_gen._mq_producer) @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node') @mock.patch(SSH_HELPER) def test_collect_kpi(self, ssh, *args): mock_ssh(ssh) - prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0, 'task_id') + prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0) prox_traffic_gen.scenario_helper.scenario_cfg = { 'nodes': {prox_traffic_gen.name: "mock"} } @@ -365,7 +364,7 @@ class TestProxTrafficGen(unittest.TestCase): mock_traffic_profile.params = self.TRAFFIC_PROFILE vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - prox_traffic_gen = ProxTrafficGen(NAME, vnfd, 'task_id') + prox_traffic_gen = ProxTrafficGen(NAME, vnfd) ssh_helper = mock.MagicMock( **{"execute.return_value": (0, "", ""), "bin_path": ""}) prox_traffic_gen.ssh_helper = ssh_helper @@ -407,22 +406,21 @@ class TestProxTrafficGen(unittest.TestCase): mock_traffic_profile.params = self.TRAFFIC_PROFILE vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sut = ProxTrafficGen(NAME, vnfd, 'task_id') + sut = ProxTrafficGen(NAME, vnfd) sut._get_socket = mock.MagicMock() sut.ssh_helper = mock.Mock() sut.ssh_helper.run = mock.Mock() sut.setup_helper.prox_config_dict = {} sut._connect_client = mock.Mock(autospec=mock.Mock()) sut._connect_client.get_stats = mock.Mock(return_value="0") - sut._setup_mq_producer = mock.Mock(return_value='mq_producer') - sut._traffic_runner(mock_traffic_profile, mock.ANY) + sut._traffic_runner(mock_traffic_profile) @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.socket') @mock.patch(SSH_HELPER) def test_listen_traffic(self, ssh, *args): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - prox_traffic_gen = ProxTrafficGen(NAME, vnfd, 'task_id') + prox_traffic_gen = ProxTrafficGen(NAME, vnfd) self.assertIsNone(prox_traffic_gen.listen_traffic(mock.Mock())) @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.socket') @@ -430,7 +428,7 @@ class TestProxTrafficGen(unittest.TestCase): def test_terminate(self, ssh, *args): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - prox_traffic_gen = ProxTrafficGen(NAME, vnfd, 'task_id') + prox_traffic_gen = ProxTrafficGen(NAME, vnfd) prox_traffic_gen._terminated = mock.MagicMock() prox_traffic_gen._traffic_process = mock.MagicMock() prox_traffic_gen._traffic_process.terminate = mock.Mock() 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 ab7a6a88e..bdd79f362 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 @@ -216,7 +216,7 @@ class TestIXIATrafficGen(unittest.TestCase): ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] # NOTE(ralonsoh): check the object returned. - tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd, 'task_id') + tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd) def test_listen_traffic(self, *args): with mock.patch("yardstick.ssh.SSH") as ssh: @@ -225,8 +225,7 @@ class TestIXIATrafficGen(unittest.TestCase): mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd, - 'task_id') + ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd) self.assertIsNone(ixnet_traffic_gen.listen_traffic({})) @mock.patch.object(ctx_base.Context, 'get_context_from_server', return_value='fake_context') @@ -239,8 +238,7 @@ class TestIXIATrafficGen(unittest.TestCase): mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd, - 'task_id') + ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd) scenario_cfg = {'tc': "nsb_test_case", "topology": ""} scenario_cfg.update( @@ -277,8 +275,7 @@ class TestIXIATrafficGen(unittest.TestCase): ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd, - 'task_id') + ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd) ixnet_traffic_gen.scenario_helper.scenario_cfg = { 'nodes': {ixnet_traffic_gen.name: "mock"} } @@ -298,7 +295,7 @@ class TestIXIATrafficGen(unittest.TestCase): mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen( - NAME, vnfd, 'task_id', resource_helper_type=mock.Mock()) + NAME, vnfd, resource_helper_type=mock.Mock()) ixnet_traffic_gen._terminated = mock.MagicMock() ixnet_traffic_gen._terminated.value = 0 ixnet_traffic_gen._ixia_traffic_gen = mock.MagicMock() @@ -314,7 +311,7 @@ class TestIXIATrafficGen(unittest.TestCase): def test__check_status(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - sut = tg_rfc2544_ixia.IxiaTrafficGen('vnf1', vnfd, 'task_id') + sut = tg_rfc2544_ixia.IxiaTrafficGen('vnf1', vnfd) sut._check_status() @mock.patch("yardstick.ssh.SSH") @@ -380,7 +377,7 @@ class TestIXIATrafficGen(unittest.TestCase): mock_traffic_profile.get_drop_percentage.return_value = [ 'Completed', samples] - sut = tg_rfc2544_ixia.IxiaTrafficGen(name, vnfd, 'task_id') + sut = tg_rfc2544_ixia.IxiaTrafficGen(name, vnfd) sut.vnf_port_pairs = [[[0], [1]]] sut.tc_file_name = self._get_file_abspath(TEST_FILE_YAML) sut.topology = "" @@ -424,8 +421,7 @@ class TestIXIATrafficGen(unittest.TestCase): mock.mock_open(), create=True) @mock.patch('yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.LOG.exception') def _traffic_runner(*args): - sut._setup_mq_producer = mock.Mock(return_value='mq_producer') - result = sut._traffic_runner(mock_traffic_profile, mock.ANY) + result = sut._traffic_runner(mock_traffic_profile) self.assertIsNone(result) _traffic_runner() 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 a5b9f258e..a9fa5f3c1 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 @@ -224,14 +224,12 @@ class TestTrexTrafficGenRFC(unittest.TestCase): self._mock_ssh_helper.stop() def test___init__(self): - trex_traffic_gen = tg_rfc2544_trex.TrexTrafficGenRFC( - 'vnf1', self.VNFD_0, 'task_id') + trex_traffic_gen = tg_rfc2544_trex.TrexTrafficGenRFC('vnf1', self.VNFD_0) self.assertIsNotNone(trex_traffic_gen.resource_helper._terminated.value) @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node') def test_collect_kpi(self, *args): - trex_traffic_gen = tg_rfc2544_trex.TrexTrafficGenRFC( - 'vnf1', self.VNFD_0, 'task_id') + trex_traffic_gen = tg_rfc2544_trex.TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen.scenario_helper.scenario_cfg = { 'nodes': {trex_traffic_gen.name: "mock"} } @@ -247,8 +245,7 @@ class TestTrexTrafficGenRFC(unittest.TestCase): mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE - trex_traffic_gen = tg_rfc2544_trex.TrexTrafficGenRFC( - 'vnf1', self.VNFD_0, 'task_id') + trex_traffic_gen = tg_rfc2544_trex.TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen._start_server = mock.Mock(return_value=0) trex_traffic_gen.resource_helper = mock.MagicMock() trex_traffic_gen.setup_helper.setup_vnf_environment = mock.MagicMock() @@ -283,8 +280,7 @@ class TestTrexTrafficGenRFC(unittest.TestCase): mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE - trex_traffic_gen = tg_rfc2544_trex.TrexTrafficGenRFC( - 'vnf1', self.VNFD_0, 'task_id') + trex_traffic_gen = tg_rfc2544_trex.TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen.resource_helper = mock.MagicMock() trex_traffic_gen.setup_helper.setup_vnf_environment = mock.MagicMock() scenario_cfg = { diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py index 9ed2abbb9..350ba8448 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py @@ -300,14 +300,14 @@ class TestTrexTrafficGen(unittest.TestCase): def test___init__(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) self.assertIsInstance(trex_traffic_gen.resource_helper, tg_trex.TrexResourceHelper) @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node') def test_collect_kpi(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) trex_traffic_gen.scenario_helper.scenario_cfg = { 'nodes': {trex_traffic_gen.name: "mock"} } @@ -321,13 +321,13 @@ class TestTrexTrafficGen(unittest.TestCase): def test_listen_traffic(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) self.assertIsNone(trex_traffic_gen.listen_traffic({})) @mock.patch.object(ctx_base.Context, 'get_context_from_server', return_value='fake_context') def test_instantiate(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) trex_traffic_gen._start_server = mock.Mock(return_value=0) trex_traffic_gen._tg_process = mock.MagicMock() trex_traffic_gen._tg_process.start = mock.Mock() @@ -342,7 +342,7 @@ class TestTrexTrafficGen(unittest.TestCase): @mock.patch.object(ctx_base.Context, 'get_context_from_server', return_value='fake_context') def test_instantiate_error(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) trex_traffic_gen._start_server = mock.Mock(return_value=0) trex_traffic_gen._tg_process = mock.MagicMock() trex_traffic_gen._tg_process.start = mock.Mock() @@ -355,7 +355,7 @@ class TestTrexTrafficGen(unittest.TestCase): def test__start_server(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) trex_traffic_gen.ssh_helper = mock.MagicMock() trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() trex_traffic_gen.scenario_helper.scenario_cfg = {} @@ -363,7 +363,7 @@ class TestTrexTrafficGen(unittest.TestCase): def test__start_server_multiple_queues(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) trex_traffic_gen.ssh_helper = mock.MagicMock() trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() trex_traffic_gen.scenario_helper.scenario_cfg = { @@ -377,7 +377,7 @@ class TestTrexTrafficGen(unittest.TestCase): mock_traffic_profile.params = self.TRAFFIC_PROFILE vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - self.sut = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + self.sut = tg_trex.TrexTrafficGen(NAME, vnfd) self.sut.ssh_helper = mock.Mock() self.sut.ssh_helper.run = mock.Mock() self.sut._connect_client = mock.Mock() @@ -387,13 +387,12 @@ class TestTrexTrafficGen(unittest.TestCase): # must generate cfg before we can run traffic so Trex port mapping is # created self.sut.resource_helper.generate_cfg() - self.sut._setup_mq_producer = mock.Mock() with mock.patch.object(self.sut.resource_helper, 'run_traffic'): - self.sut._traffic_runner(mock_traffic_profile, mock.ANY) + self.sut._traffic_runner(mock_traffic_profile) def test__generate_trex_cfg(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() self.assertIsNone(trex_traffic_gen.resource_helper.generate_cfg()) @@ -432,7 +431,7 @@ class TestTrexTrafficGen(unittest.TestCase): 'local_mac': '00:00:00:00:00:01'}, 'vnfd-connection-point-ref': 'xe1', 'name': 'xe1'}] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() trex_traffic_gen.resource_helper.generate_cfg() trex_traffic_gen.resource_helper._build_ports() @@ -449,24 +448,25 @@ class TestTrexTrafficGen(unittest.TestCase): mock_traffic_profile.params = self.TRAFFIC_PROFILE vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - self.sut = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + self.sut = tg_trex.TrexTrafficGen(NAME, vnfd) self.sut.ssh_helper = mock.Mock() self.sut.ssh_helper.run = mock.Mock() self.sut._traffic_runner = mock.Mock(return_value=0) self.sut.resource_helper.client_started.value = 1 - self.sut.run_traffic(mock_traffic_profile) + result = self.sut.run_traffic(mock_traffic_profile) self.sut._traffic_process.terminate() + self.assertIsNotNone(result) def test_terminate(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) trex_traffic_gen.ssh_helper = mock.MagicMock() trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() self.assertIsNone(trex_traffic_gen.terminate()) def test__connect_client(self): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id') + trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd) client = mock.Mock() client.connect = mock.Mock(return_value=0) self.assertIsNotNone(trex_traffic_gen.resource_helper._connect(client)) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py index 56c971da6..60f739543 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py @@ -317,8 +317,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase): } def test___init__(self, *args): - udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0, - 'task_id') + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) self.assertIsNone(udp_replay_approx_vnf._vnf_process) @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time") @@ -333,7 +332,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase): "Port\t\tRx Packet\t\tTx Packet\t\tRx Pkt Drop\t\tTx Pkt Drop \r\n"\ "0\t\t7374156\t\t7374136\t\t\t0\t\t\t0\r\n" \ "1\t\t7374316\t\t7374315\t\t\t0\t\t\t0\r\n\r\nReplay>\r\r\nReplay>" - udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, vnfd, 'task_id') + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) udp_replay_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {udp_replay_approx_vnf.name: "mock"} } @@ -355,8 +354,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase): def test_get_stats(self, ssh, *args): mock_ssh(ssh) - udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0, - 'task_id') + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) udp_replay_approx_vnf.q_in = mock.MagicMock() udp_replay_approx_vnf.q_out = mock.MagicMock() udp_replay_approx_vnf.q_out.qsize = mock.Mock(return_value=0) @@ -382,8 +380,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase): nfvi_context.attrs = {'nfvi_type': 'baremetal'} mock_get_ctx.return_value = nfvi_context - udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0, - 'task_id') + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) udp_replay_approx_vnf.queue_wrapper = mock.MagicMock() udp_replay_approx_vnf.nfvi_context = mock_get_ctx udp_replay_approx_vnf.nfvi_context.attrs = {'nfvi_type': 'baremetal'} @@ -408,8 +405,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase): nfvi_context.attrs = {'nfvi_type': "baremetal"} mock_get_ctx.return_value = nfvi_context - udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0, - 'task_id') + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) udp_replay_approx_vnf.setup_helper.bound_pci = ['0000:00:0.1', '0000:00:0.3'] udp_replay_approx_vnf.all_ports = ["xe0", "xe1"] udp_replay_approx_vnf.ssh_helper.provision_tool = mock.MagicMock(return_value="tool_path") @@ -431,8 +427,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase): def test_run_udp_replay(self, ssh, *args): mock_ssh(ssh) - udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0, - 'task_id') + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) udp_replay_approx_vnf._build_config = mock.MagicMock() udp_replay_approx_vnf.queue_wrapper = mock.MagicMock() udp_replay_approx_vnf.scenario_helper = mock.MagicMock() @@ -446,8 +441,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase): def test_instantiate(self, ssh, *args): mock_ssh(ssh) - udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0, - 'task_id') + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) udp_replay_approx_vnf.q_out.put("Replay>") udp_replay_approx_vnf.WAIT_TIME = 0 udp_replay_approx_vnf.setup_helper.setup_vnf_environment = mock.Mock() @@ -465,8 +459,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase): @mock.patch('yardstick.ssh.SSH') @mock.patch(SSH_HELPER) def test_instantiate_panic(self, *args): - udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0, - 'task_id') + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) udp_replay_approx_vnf.WAIT_TIME = 0 udp_replay_approx_vnf.q_out.put("some text PANIC some text") udp_replay_approx_vnf.setup_helper.setup_vnf_environment = mock.Mock() diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py index efbb7a856..5911948a3 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py @@ -232,7 +232,7 @@ class TestFWApproxVnf(unittest.TestCase): def test___init__(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - vfw_approx_vnf = FWApproxVnf(name, vnfd, 'task_id') + vfw_approx_vnf = FWApproxVnf(name, vnfd) self.assertIsNone(vfw_approx_vnf._vnf_process) STATS = """\ @@ -255,7 +255,7 @@ pipeline> def test_collect_kpi(self, ssh, *args): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - vfw_approx_vnf = FWApproxVnf(name, vnfd, 'task_id') + vfw_approx_vnf = FWApproxVnf(name, vnfd) vfw_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {vfw_approx_vnf.name: "mock"} } @@ -281,7 +281,7 @@ pipeline> mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - vfw_approx_vnf = FWApproxVnf(name, vnfd, 'task_id') + vfw_approx_vnf = FWApproxVnf(name, vnfd) vfw_approx_vnf.q_in = mock.MagicMock() vfw_approx_vnf.q_out = mock.MagicMock() vfw_approx_vnf.q_out.qsize = mock.Mock(return_value=0) @@ -293,7 +293,7 @@ pipeline> mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - vfw_approx_vnf = FWApproxVnf(name, vnfd, 'task_id') + vfw_approx_vnf = FWApproxVnf(name, vnfd) vfw_approx_vnf.q_in = mock.MagicMock() vfw_approx_vnf.q_out = mock.MagicMock() vfw_approx_vnf.q_out.qsize = mock.Mock(return_value=0) @@ -313,7 +313,7 @@ pipeline> mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - vfw_approx_vnf = FWApproxVnf(name, vnfd, 'task_id') + vfw_approx_vnf = FWApproxVnf(name, vnfd) vfw_approx_vnf._build_config = mock.MagicMock() vfw_approx_vnf.queue_wrapper = mock.MagicMock() vfw_approx_vnf.ssh_helper = mock.MagicMock() @@ -335,7 +335,7 @@ pipeline> mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - vfw_approx_vnf = FWApproxVnf(name, vnfd, 'task_id') + vfw_approx_vnf = FWApproxVnf(name, vnfd) vfw_approx_vnf.ssh_helper = ssh vfw_approx_vnf.deploy_helper = mock.MagicMock() vfw_approx_vnf.resource_helper = mock.MagicMock() diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py index 8d49cb3f4..7b67ecc37 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py @@ -476,7 +476,7 @@ class TestVpeApproxVnf(unittest.TestCase): self._mock_time_sleep.stop() def test___init__(self): - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) self.assertIsNone(vpe_approx_vnf._vnf_process) @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', @@ -490,7 +490,7 @@ class TestVpeApproxVnf(unittest.TestCase): resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234} resource.check_if_system_agent_running.return_value = (1, None) - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {vpe_approx_vnf.name: "mock"} } @@ -519,7 +519,7 @@ class TestVpeApproxVnf(unittest.TestCase): resource.check_if_system_agent_running.return_value = 0, '1234' resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234} - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf.scenario_helper.scenario_cfg = { 'nodes': {vpe_approx_vnf.name: "mock"} } @@ -541,7 +541,7 @@ class TestVpeApproxVnf(unittest.TestCase): @mock.patch.object(sample_vnf, 'VnfSshHelper') def test_vnf_execute(self, ssh): test_base.mock_ssh(ssh) - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf.q_in = mock.MagicMock() vpe_approx_vnf.q_out = mock.MagicMock() vpe_approx_vnf.q_out.qsize = mock.Mock(return_value=0) @@ -551,7 +551,7 @@ class TestVpeApproxVnf(unittest.TestCase): def test_run_vpe(self, ssh): test_base.mock_ssh(ssh) - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf.tc_file_name = get_file_abspath(TEST_FILE_YAML) vpe_approx_vnf.vnf_cfg = { 'lb_config': 'SW', @@ -634,7 +634,7 @@ class TestVpeApproxVnf(unittest.TestCase): mock_resource = mock.MagicMock() - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock_process vpe_approx_vnf.q_out = mock_q_out vpe_approx_vnf.queue_wrapper = mock.Mock( @@ -659,7 +659,7 @@ class TestVpeApproxVnf(unittest.TestCase): mock_resource = mock.MagicMock() - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock_process vpe_approx_vnf.q_out = mock_q_out vpe_approx_vnf.queue_wrapper = mock.Mock( @@ -678,7 +678,7 @@ class TestVpeApproxVnf(unittest.TestCase): mock_resource = mock.MagicMock() - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock_process vpe_approx_vnf.resource_helper.resource = mock_resource @@ -697,7 +697,7 @@ class TestVpeApproxVnf(unittest.TestCase): mock_resource = mock.MagicMock() - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock_process vpe_approx_vnf.resource_helper.resource = mock_resource @@ -722,7 +722,7 @@ class TestVpeApproxVnf(unittest.TestCase): mock_resource = mock.MagicMock() - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock_process vpe_approx_vnf.q_out = mock_q_out vpe_approx_vnf.resource_helper.resource = mock_resource @@ -736,7 +736,7 @@ class TestVpeApproxVnf(unittest.TestCase): def test_terminate(self, ssh): test_base.mock_ssh(ssh) - vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0, 'task_id') + vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock.MagicMock() vpe_approx_vnf._resource_collect_stop = mock.Mock() vpe_approx_vnf.resource_helper = mock.MagicMock() -- cgit 1.2.3-korg