summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmma Foley <emma.l.foley@intel.com>2017-11-29 22:56:21 +0000
committerEmma Foley <emma.l.foley@intel.com>2018-02-12 16:57:56 +0000
commitba4e9e6e47bd10ecc803bab920178ea973c2fa86 (patch)
tree54576c199cabe8ccc29d04eedfe0e4f88b2bd598
parentbabe3cc2882e19c6dafdbf41d502d7ba5560635a (diff)
Move tests: unit/benchmark
* Fix pylint errors * Add TODOs Some errors are ignored locally, as they were a symptom of other problems. These issues have been flagged with a TODO, and should be fixed later. Change-Id: I30eb4b0aafe0575d0cddbc946108291f21a98ed8 Jira: YARDSTICK-837 Signed-off-by: Emma Foley <emma.l.foley@intel.com> Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py244
-rw-r--r--yardstick/tests/unit/benchmark/__init__.py (renamed from tests/unit/benchmark/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/__init__.py (renamed from tests/unit/benchmark/contexts/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/nodes_duplicate_sample.yaml (renamed from tests/unit/benchmark/contexts/nodes_duplicate_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/nodes_duplicate_sample_new.yaml (renamed from tests/unit/benchmark/contexts/nodes_duplicate_sample_new.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/nodes_duplicate_sample_ovs.yaml (renamed from tests/unit/benchmark/contexts/nodes_duplicate_sample_ovs.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/nodes_sample.yaml (renamed from tests/unit/benchmark/contexts/nodes_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/nodes_sample_new.yaml (renamed from tests/unit/benchmark/contexts/nodes_sample_new.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/nodes_sample_new_sriov.yaml (renamed from tests/unit/benchmark/contexts/nodes_sample_new_sriov.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/nodes_sample_ovs.yaml (renamed from tests/unit/benchmark/contexts/nodes_sample_ovs.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/nodes_sample_ovsdpdk.yaml (renamed from tests/unit/benchmark/contexts/nodes_sample_ovsdpdk.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/__init__.py (renamed from tests/unit/benchmark/contexts/standalone/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml (renamed from tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml (renamed from tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/nodes_sample.yaml (renamed from tests/unit/benchmark/contexts/standalone/nodes_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml (renamed from tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_model.py (renamed from tests/unit/benchmark/contexts/standalone/test_model.py)83
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py (renamed from tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py)105
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py (renamed from tests/unit/benchmark/contexts/standalone/test_sriov.py)72
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone_duplicate_sample.yaml (renamed from tests/unit/benchmark/contexts/standalone_duplicate_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone_sample.yaml (renamed from tests/unit/benchmark/contexts/standalone_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_dummy.py (renamed from tests/unit/benchmark/contexts/test_dummy.py)0
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_heat.py (renamed from tests/unit/benchmark/contexts/test_heat.py)52
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_kubernetes.py (renamed from tests/unit/benchmark/contexts/test_kubernetes.py)121
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_model.py (renamed from tests/unit/benchmark/contexts/test_model.py)2
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_node.py (renamed from tests/unit/benchmark/contexts/test_node.py)5
-rw-r--r--yardstick/tests/unit/benchmark/core/__init__.py (renamed from tests/unit/benchmark/core/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml (renamed from tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml (renamed from tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/core/test_plugin.py (renamed from tests/unit/benchmark/core/test_plugin.py)2
-rw-r--r--yardstick/tests/unit/benchmark/core/test_report.py (renamed from tests/unit/benchmark/core/test_report.py)4
-rw-r--r--yardstick/tests/unit/benchmark/core/test_task.py (renamed from tests/unit/benchmark/core/test_task.py)4
-rw-r--r--yardstick/tests/unit/benchmark/core/test_testcase.py (renamed from tests/unit/benchmark/core/test_testcase.py)0
-rw-r--r--yardstick/tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml (renamed from tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml (renamed from tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/runner/__init__.py (renamed from tests/unit/benchmark/runner/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/runner/test_base.py (renamed from tests/unit/benchmark/runner/test_base.py)40
-rw-r--r--yardstick/tests/unit/benchmark/runner/test_search.py (renamed from tests/unit/benchmark/runner/test_search.py)31
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/__init__.py (renamed from tests/unit/benchmark/scenarios/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/__init__.py (renamed from tests/unit/benchmark/scenarios/availability/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py (renamed from tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py)8
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_attacker_general.py (renamed from tests/unit/benchmark/scenarios/availability/test_attacker_general.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_attacker_process.py (renamed from tests/unit/benchmark/scenarios/availability/test_attacker_process.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_basemonitor.py (renamed from tests/unit/benchmark/scenarios/availability/test_basemonitor.py)28
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_baseoperation.py (renamed from tests/unit/benchmark/scenarios/availability/test_baseoperation.py)38
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py (renamed from tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py)54
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_director.py (renamed from tests/unit/benchmark/scenarios/availability/test_director.py)4
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_command.py (renamed from tests/unit/benchmark/scenarios/availability/test_monitor_command.py)55
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_general.py (renamed from tests/unit/benchmark/scenarios/availability/test_monitor_general.py)4
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py (renamed from tests/unit/benchmark/scenarios/availability/test_monitor_multi.py)12
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_process.py (renamed from tests/unit/benchmark/scenarios/availability/test_monitor_process.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_operation_general.py (renamed from tests/unit/benchmark/scenarios/availability/test_operation_general.py)4
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py (renamed from tests/unit/benchmark/scenarios/availability/test_result_checker_general.py)4
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_scenario_general.py (renamed from tests/unit/benchmark/scenarios/availability/test_scenario_general.py)52
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_serviceha.py (renamed from tests/unit/benchmark/scenarios/availability/test_serviceha.py)35
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_util.py (renamed from tests/unit/benchmark/scenarios/availability/test_util.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/__init__.py (renamed from tests/unit/benchmark/scenarios/compute/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/cachestat_sample_output.txt (renamed from tests/unit/benchmark/scenarios/compute/cachestat_sample_output.txt)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/cpuload_sample_output1.txt (renamed from tests/unit/benchmark/scenarios/compute/cpuload_sample_output1.txt)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/cpuload_sample_output2.txt (renamed from tests/unit/benchmark/scenarios/compute/cpuload_sample_output2.txt)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/memload_sample_output.txt (renamed from tests/unit/benchmark/scenarios/compute/memload_sample_output.txt)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_cachestat.py (renamed from tests/unit/benchmark/scenarios/compute/test_cachestat.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_computecapacity.py (renamed from tests/unit/benchmark/scenarios/compute/test_computecapacity.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_cpuload.py (renamed from tests/unit/benchmark/scenarios/compute/test_cpuload.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_cyclictest.py (renamed from tests/unit/benchmark/scenarios/compute/test_cyclictest.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_lmbench.py (renamed from tests/unit/benchmark/scenarios/compute/test_lmbench.py)4
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_memload.py (renamed from tests/unit/benchmark/scenarios/compute/test_memload.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_plugintest.py (renamed from tests/unit/benchmark/scenarios/compute/test_plugintest.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py (renamed from tests/unit/benchmark/scenarios/compute/test_qemumigrate.py)1
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_ramspeed.py (renamed from tests/unit/benchmark/scenarios/compute/test_ramspeed.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_spec_cpu.py (renamed from tests/unit/benchmark/scenarios/compute/test_spec_cpu.py)5
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_spec_cpu_for_vm.py (renamed from tests/unit/benchmark/scenarios/compute/test_spec_cpu_for_vm.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/compute/test_unixbench.py (renamed from tests/unit/benchmark/scenarios/compute/test_unixbench.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/dummy/__init__.py (renamed from tests/unit/benchmark/scenarios/dummy/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/dummy/test_dummy.py (renamed from tests/unit/benchmark/scenarios/dummy/test_dummy.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/__init__.py (renamed from tests/unit/benchmark/scenarios/lib/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_add_memory_load.py (renamed from tests/unit/benchmark/scenarios/lib/test_add_memory_load.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_attach_volume.py (renamed from tests/unit/benchmark/scenarios/lib/test_attach_volume.py)5
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py (renamed from tests/unit/benchmark/scenarios/lib/test_check_connectivity.py)14
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py (renamed from tests/unit/benchmark/scenarios/lib/test_check_numa_info.py)7
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_check_value.py (renamed from tests/unit/benchmark/scenarios/lib/test_check_value.py)24
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_flavor.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_flavor.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_floating_ip.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_floating_ip.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_image.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_image.py)30
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_keypair.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_keypair.py)17
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_network.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_network.py)9
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_port.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_port.py)7
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_router.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_router.py)9
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_sec_group.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_sec_group.py)9
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_server.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_server.py)8
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_subnet.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_subnet.py)13
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_create_volume.py (renamed from tests/unit/benchmark/scenarios/lib/test_create_volume.py)41
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_flavor.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_flavor.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_floating_ip.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_floating_ip.py)1
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_image.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_image.py)3
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_keypair.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_keypair.py)1
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_network.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_network.py)1
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_port.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_port.py)1
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_router.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_router.py)1
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py)1
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py)1
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_server.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_server.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_delete_volume.py (renamed from tests/unit/benchmark/scenarios/lib/test_delete_volume.py)1
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_detach_volume.py (renamed from tests/unit/benchmark/scenarios/lib/test_detach_volume.py)1
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_get_flavor.py (renamed from tests/unit/benchmark/scenarios/lib/test_get_flavor.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_get_migrate_target_host.py (renamed from tests/unit/benchmark/scenarios/lib/test_get_migrate_target_host.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_get_numa_info.py (renamed from tests/unit/benchmark/scenarios/lib/test_get_numa_info.py)5
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_get_server.py (renamed from tests/unit/benchmark/scenarios/lib/test_get_server.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/lib/test_get_server_ip.py (renamed from tests/unit/benchmark/scenarios/lib/test_get_server_ip.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/__init__.py (renamed from tests/unit/benchmark/scenarios/networking/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/imix_voice.yaml (renamed from tests/unit/benchmark/scenarios/networking/imix_voice.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/iperf3_sample_output.json (renamed from tests/unit/benchmark/scenarios/networking/iperf3_sample_output.json)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/iperf3_sample_output_udp.json (renamed from tests/unit/benchmark/scenarios/networking/iperf3_sample_output_udp.json)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/ipv4_1flow_Packets_vpe.yaml (renamed from tests/unit/benchmark/scenarios/networking/ipv4_1flow_Packets_vpe.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml (renamed from tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml)0
-rwxr-xr-xyardstick/tests/unit/benchmark/scenarios/networking/netperf_sample_output.json (renamed from tests/unit/benchmark/scenarios/networking/netperf_sample_output.json)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/netutilization_sample_output1.txt (renamed from tests/unit/benchmark/scenarios/networking/netutilization_sample_output1.txt)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/netutilization_sample_output2.txt (renamed from tests/unit/benchmark/scenarios/networking/netutilization_sample_output2.txt)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_iperf3.py (renamed from tests/unit/benchmark/scenarios/networking/test_iperf3.py)0
-rwxr-xr-xyardstick/tests/unit/benchmark/scenarios/networking/test_netperf.py (renamed from tests/unit/benchmark/scenarios/networking/test_netperf.py)0
-rwxr-xr-xyardstick/tests/unit/benchmark/scenarios/networking/test_netperf_node.py (renamed from tests/unit/benchmark/scenarios/networking/test_netperf_node.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_netutilization.py (renamed from tests/unit/benchmark/scenarios/networking/test_netutilization.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py (renamed from tests/unit/benchmark/scenarios/networking/test_networkcapacity.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_nstat.py (renamed from tests/unit/benchmark/scenarios/networking/test_nstat.py)9
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_ping.py (renamed from tests/unit/benchmark/scenarios/networking/test_ping.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_ping6.py (renamed from tests/unit/benchmark/scenarios/networking/test_ping6.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen.py (renamed from tests/unit/benchmark/scenarios/networking/test_pktgen.py)149
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py (renamed from tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py)8
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py (renamed from tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py)6
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_sfc.py (renamed from tests/unit/benchmark/scenarios/networking/test_sfc.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py (renamed from tests/unit/benchmark/scenarios/networking/test_vnf_generic.py)63
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf.py (renamed from tests/unit/benchmark/scenarios/networking/test_vsperf.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py221
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/tg_trex_tpl.yaml (renamed from tests/unit/benchmark/scenarios/networking/tg_trex_tpl.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml (renamed from tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/parser/__init__.py (renamed from tests/unit/benchmark/scenarios/parser/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/parser/test_parser.py (renamed from tests/unit/benchmark/scenarios/parser/test_parser.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/storage/__init__.py (renamed from tests/unit/benchmark/scenarios/storage/__init__.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/storage/fio_read_sample_output.json (renamed from tests/unit/benchmark/scenarios/storage/fio_read_sample_output.json)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/storage/fio_rw_sample_output.json (renamed from tests/unit/benchmark/scenarios/storage/fio_rw_sample_output.json)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/storage/fio_write_sample_output.json (renamed from tests/unit/benchmark/scenarios/storage/fio_write_sample_output.json)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/storage/test_bonnie.py (renamed from tests/unit/benchmark/scenarios/storage/test_bonnie.py)3
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/storage/test_fio.py (renamed from tests/unit/benchmark/scenarios/storage/test_fio.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py (renamed from tests/unit/benchmark/scenarios/storage/test_storagecapacity.py)0
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/storage/test_storperf.py (renamed from tests/unit/benchmark/scenarios/storage/test_storperf.py)18
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/test_base.py (renamed from tests/unit/benchmark/scenarios/test_base.py)0
146 files changed, 832 insertions, 928 deletions
diff --git a/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py b/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
deleted file mode 100644
index fbe3ed804..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
+++ /dev/null
@@ -1,244 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2017 Nokia
-#
-# 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.
-
-# Unittest for yardstick.benchmark.scenarios.networking.vsperf.VsperfDPDK
-
-from __future__ import absolute_import
-try:
- from unittest import mock
-except ImportError:
- import mock
-import unittest
-
-from yardstick.benchmark.scenarios.networking import vsperf_dpdk
-
-
-@mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.subprocess')
-class VsperfDPDKTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- "host": {
- "ip": "10.229.47.137",
- "user": "ubuntu",
- "password": "ubuntu",
- },
- }
- self.args = {
- 'task_id': "1234-5678",
- 'options': {
- 'testname': 'pvp_tput',
- 'traffic_type': 'rfc2544_throughput',
- 'frame_size': '64',
- 'test_params': 'TRAFFICGEN_DURATION=30;',
- 'trafficgen_port1': 'ens4',
- 'trafficgen_port2': 'ens5',
- 'conf_file': 'vsperf-yardstick.conf',
- 'setup_script': 'setup_yardstick.sh',
- 'moongen_helper_file': '~/moongen.py',
- 'moongen_host_ip': '10.5.201.151',
- 'moongen_port1_mac': '8c:dc:d4:ae:7c:5c',
- 'moongen_port2_mac': '8c:dc:d4:ae:7c:5d',
- 'trafficgen_port1_nw': 'test2',
- 'trafficgen_port2_nw': 'test3',
- },
- 'sla': {
- 'metrics': 'throughput_rx_fps',
- 'throughput_rx_fps': 500000,
- 'action': 'monitor',
- }
- }
-
- self._mock_ssh = mock.patch(
- 'yardstick.benchmark.scenarios.networking.vsperf_dpdk.ssh')
- self.mock_ssh = self._mock_ssh.start()
-
- self.addCleanup(self._cleanup)
-
- def _cleanup(self):
- self._mock_ssh.stop()
-
- def test_vsperf_dpdk_setup(self, mock_subprocess):
- p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
-
- # setup() specific mocks
- mock_subprocess.call().execute.return_value = None
-
- p.setup()
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- def test_vsperf_dpdk_teardown(self, mock_subprocess):
- p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
-
- # setup() specific mocks
- mock_subprocess.call().execute.return_value = None
-
- p.setup()
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- p.teardown()
- self.assertFalse(p.setup_done)
-
- def test_vsperf_dpdk_is_dpdk_setup_no(self, mock_subprocess):
- p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
-
- # setup() specific mocks
- mock_subprocess.call().execute.return_value = None
-
- p.setup()
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- # is_dpdk_setup() specific mocks
- self.mock_ssh.SSH.from_node().execute.return_value = (0, 'dummy', '')
-
- result = p._is_dpdk_setup()
- self.assertFalse(result)
-
- def test_vsperf_dpdk_is_dpdk_setup_yes(self, mock_subprocess):
- p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
-
- # setup() specific mocks
- mock_subprocess.call().execute.return_value = None
-
- p.setup()
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- # is_dpdk_setup() specific mocks
- self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- result = p._is_dpdk_setup()
- self.assertTrue(result)
-
- @mock.patch('time.sleep')
- def test_vsperf_dpdk_dpdk_setup_first(self, _, mock_subprocess):
- p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
-
- # setup() specific mocks
- mock_subprocess.call().execute.return_value = None
-
- p.setup()
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- # is_dpdk_setup() specific mocks
- self.mock_ssh.SSH.from_node().execute.return_value = (0, 'dummy', '')
-
- p.dpdk_setup()
- self.assertFalse(p._is_dpdk_setup())
- self.assertTrue(p.dpdk_setup_done)
-
- @mock.patch('time.sleep')
- def test_vsperf_dpdk_dpdk_setup_next(self, _, mock_subprocess):
- p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
-
- # setup() specific mocks
- self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- mock_subprocess.call().execute.return_value = None
-
- p.setup()
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- p.dpdk_setup()
- self.assertTrue(p._is_dpdk_setup())
- self.assertTrue(p.dpdk_setup_done)
-
- @mock.patch('time.sleep')
- def test_vsperf_dpdk_dpdk_setup_fail(self, _, mock_subprocess):
- p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
-
- # setup() specific mocks
- self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- mock_subprocess.call().execute.return_value = None
-
- p.setup()
- self.assertIsNotNone(p.client)
- self.mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
- self.assertTrue(p.setup_done)
-
- self.assertRaises(RuntimeError, p.dpdk_setup)
-
- @mock.patch('time.sleep')
- def test_vsperf_dpdk_run_ok(self, _, mock_subprocess):
- p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
-
- # setup() specific mocks
- self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- mock_subprocess.call().execute.return_value = None
-
- p.setup()
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- # run() specific mocks
- mock_subprocess.call().execute.return_value = None
- self.mock_ssh.SSH.from_node().execute.return_value = (
- 0, 'throughput_rx_fps\r\n14797660.000\r\n', '')
-
- result = {}
- p.run(result)
-
- self.assertEqual(result['throughput_rx_fps'], '14797660.000')
-
- def test_vsperf_dpdk_run_falied_vsperf_execution(self, mock_subprocess):
- p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
-
- # setup() specific mocks
- self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- mock_subprocess.call().execute.return_value = None
-
- p.setup()
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- # run() specific mocks
- mock_subprocess.call().execute.return_value = None
- mock_subprocess.call().execute.return_value = None
- self.mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- result = {}
- self.assertRaises(RuntimeError, p.run, result)
-
- def test_vsperf_dpdk_run_falied_csv_report(self, mock_subprocess):
- p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
-
- # setup() specific mocks
- self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- mock_subprocess.call().execute.return_value = None
-
- p.setup()
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- # run() specific mocks
- mock_subprocess.call().execute.return_value = None
- mock_subprocess.call().execute.return_value = None
- self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- self.mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- result = {}
- self.assertRaises(RuntimeError, p.run, result)
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/__init__.py b/yardstick/tests/unit/benchmark/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/__init__.py
+++ b/yardstick/tests/unit/benchmark/__init__.py
diff --git a/tests/unit/benchmark/contexts/__init__.py b/yardstick/tests/unit/benchmark/contexts/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/contexts/__init__.py
+++ b/yardstick/tests/unit/benchmark/contexts/__init__.py
diff --git a/tests/unit/benchmark/contexts/nodes_duplicate_sample.yaml b/yardstick/tests/unit/benchmark/contexts/nodes_duplicate_sample.yaml
index dbdd3700d..dbdd3700d 100644
--- a/tests/unit/benchmark/contexts/nodes_duplicate_sample.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/nodes_duplicate_sample.yaml
diff --git a/tests/unit/benchmark/contexts/nodes_duplicate_sample_new.yaml b/yardstick/tests/unit/benchmark/contexts/nodes_duplicate_sample_new.yaml
index 306915ca1..306915ca1 100644
--- a/tests/unit/benchmark/contexts/nodes_duplicate_sample_new.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/nodes_duplicate_sample_new.yaml
diff --git a/tests/unit/benchmark/contexts/nodes_duplicate_sample_ovs.yaml b/yardstick/tests/unit/benchmark/contexts/nodes_duplicate_sample_ovs.yaml
index 65449c91c..65449c91c 100644
--- a/tests/unit/benchmark/contexts/nodes_duplicate_sample_ovs.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/nodes_duplicate_sample_ovs.yaml
diff --git a/tests/unit/benchmark/contexts/nodes_sample.yaml b/yardstick/tests/unit/benchmark/contexts/nodes_sample.yaml
index 8d50c3aea..8d50c3aea 100644
--- a/tests/unit/benchmark/contexts/nodes_sample.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/nodes_sample.yaml
diff --git a/tests/unit/benchmark/contexts/nodes_sample_new.yaml b/yardstick/tests/unit/benchmark/contexts/nodes_sample_new.yaml
index a400bec03..a400bec03 100644
--- a/tests/unit/benchmark/contexts/nodes_sample_new.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/nodes_sample_new.yaml
diff --git a/tests/unit/benchmark/contexts/nodes_sample_new_sriov.yaml b/yardstick/tests/unit/benchmark/contexts/nodes_sample_new_sriov.yaml
index 55ff2e778..55ff2e778 100644
--- a/tests/unit/benchmark/contexts/nodes_sample_new_sriov.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/nodes_sample_new_sriov.yaml
diff --git a/tests/unit/benchmark/contexts/nodes_sample_ovs.yaml b/yardstick/tests/unit/benchmark/contexts/nodes_sample_ovs.yaml
index b1da1ea9f..b1da1ea9f 100644
--- a/tests/unit/benchmark/contexts/nodes_sample_ovs.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/nodes_sample_ovs.yaml
diff --git a/tests/unit/benchmark/contexts/nodes_sample_ovsdpdk.yaml b/yardstick/tests/unit/benchmark/contexts/nodes_sample_ovsdpdk.yaml
index c02849a05..c02849a05 100644
--- a/tests/unit/benchmark/contexts/nodes_sample_ovsdpdk.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/nodes_sample_ovsdpdk.yaml
diff --git a/tests/unit/benchmark/contexts/standalone/__init__.py b/yardstick/tests/unit/benchmark/contexts/standalone/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/contexts/standalone/__init__.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/__init__.py
diff --git a/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml b/yardstick/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml
index 2e501a6af..2e501a6af 100644
--- a/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml
diff --git a/tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml b/yardstick/tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml
index 0f51dbe63..0f51dbe63 100644
--- a/tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml
diff --git a/tests/unit/benchmark/contexts/standalone/nodes_sample.yaml b/yardstick/tests/unit/benchmark/contexts/standalone/nodes_sample.yaml
index 8d50c3aea..8d50c3aea 100644
--- a/tests/unit/benchmark/contexts/standalone/nodes_sample.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/nodes_sample.yaml
diff --git a/tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml b/yardstick/tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml
index 1c43b8725..1c43b8725 100644
--- a/tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml
diff --git a/tests/unit/benchmark/contexts/standalone/test_model.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_model.py
index 6090356b6..18ea3c4e6 100644
--- a/tests/unit/benchmark/contexts/standalone/test_model.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_model.py
@@ -18,8 +18,6 @@ import unittest
import mock
from xml.etree import ElementTree
-
-from yardstick.benchmark.contexts.standalone.model import Libvirt
from yardstick.benchmark.contexts.standalone import model
from yardstick.network_services import utils
@@ -57,6 +55,9 @@ class ModelLibvirtTestCase(unittest.TestCase):
def _cleanup(self):
self._mock_write_xml.stop()
+ # TODO: Remove mocking of yardstick.ssh.SSH (here and elsewhere)
+ # In this case, we are mocking a param to be passed into other methods
+ # It can be a generic Mock() with return values set for the right methods
def test_check_if_vm_exists_and_delete(self):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
@@ -193,6 +194,8 @@ class ModelLibvirtTestCase(unittest.TestCase):
status = model.Libvirt.build_vm_xml(ssh_mock, {}, cfg_file, 'vm_0', 0)
self.assertEqual(status[0], result[0])
+ # TODO: Edit this test to test state instead of output
+ # update_interrupts_hugepages_perf does not return anything
def test_update_interrupts_hugepages_perf(self):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
@@ -203,9 +206,9 @@ class ModelLibvirtTestCase(unittest.TestCase):
# None, this check is trivial.
#status = Libvirt.update_interrupts_hugepages_perf(ssh_mock)
#self.assertIsNone(status)
- Libvirt.update_interrupts_hugepages_perf(ssh_mock)
+ model.Libvirt.update_interrupts_hugepages_perf(ssh_mock)
- @mock.patch("yardstick.benchmark.contexts.standalone.model.CpuSysCores")
+ @mock.patch.object(model, 'CpuSysCores')
@mock.patch.object(model.Libvirt, 'update_interrupts_hugepages_perf')
def test_pin_vcpu_for_perf(self, *args):
# NOTE(ralonsoh): test mocked methods/variables.
@@ -214,7 +217,7 @@ class ModelLibvirtTestCase(unittest.TestCase):
ssh_mock.execute = \
mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
- status = Libvirt.pin_vcpu_for_perf(ssh_mock, 4)
+ status = model.Libvirt.pin_vcpu_for_perf(ssh_mock, 4)
self.assertIsNotNone(status)
class StandaloneContextHelperTestCase(unittest.TestCase):
@@ -225,15 +228,15 @@ class StandaloneContextHelperTestCase(unittest.TestCase):
NETWORKS = {
'mgmt': {'cidr': '152.16.100.10/24'},
'private_0': {
- 'phy_port': "0000:05:00.0",
- 'vpci': "0000:00:07.0",
- 'cidr': '152.16.100.10/24',
- 'gateway_ip': '152.16.100.20'},
+ 'phy_port': "0000:05:00.0",
+ 'vpci': "0000:00:07.0",
+ 'cidr': '152.16.100.10/24',
+ 'gateway_ip': '152.16.100.20'},
'public_0': {
- 'phy_port': "0000:05:00.1",
- 'vpci': "0000:00:08.0",
- 'cidr': '152.16.40.10/24',
- 'gateway_ip': '152.16.100.20'}
+ 'phy_port': "0000:05:00.1",
+ 'vpci': "0000:00:08.0",
+ 'cidr': '152.16.40.10/24',
+ 'gateway_ip': '152.16.100.20'}
}
def setUp(self):
@@ -280,7 +283,7 @@ class StandaloneContextHelperTestCase(unittest.TestCase):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
- mock.Mock(return_value=(1, pattern, ""))
+ mock.Mock(return_value=(1, pattern, ""))
ssh.return_value = ssh_mock
# NOTE(ralonsoh): this test doesn't cover function execution. This test
# should also check mocked function calls.
@@ -333,7 +336,7 @@ class StandaloneContextHelperTestCase(unittest.TestCase):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
- mock.Mock(return_value=(1, "", ""))
+ mock.Mock(return_value=(1, "", ""))
ssh.return_value = ssh_mock
# NOTE(ralonsoh): this test doesn't cover function execution. This test
# should also check mocked function calls.
@@ -348,19 +351,19 @@ class ServerTestCase(unittest.TestCase):
NETWORKS = {
'mgmt': {'cidr': '152.16.100.10/24'},
'private_0': {
- 'phy_port': "0000:05:00.0",
- 'vpci': "0000:00:07.0",
- 'driver': 'i40e',
- 'mac': '',
- 'cidr': '152.16.100.10/24',
- 'gateway_ip': '152.16.100.20'},
+ 'phy_port': "0000:05:00.0",
+ 'vpci': "0000:00:07.0",
+ 'driver': 'i40e',
+ 'mac': '',
+ 'cidr': '152.16.100.10/24',
+ 'gateway_ip': '152.16.100.20'},
'public_0': {
- 'phy_port': "0000:05:00.1",
- 'vpci': "0000:00:08.0",
- 'driver': 'i40e',
- 'mac': '',
- 'cidr': '152.16.40.10/24',
- 'gateway_ip': '152.16.100.20'}
+ 'phy_port': "0000:05:00.1",
+ 'vpci': "0000:00:08.0",
+ 'driver': 'i40e',
+ 'mac': '',
+ 'cidr': '152.16.40.10/24',
+ 'gateway_ip': '152.16.100.20'}
}
def setUp(self):
@@ -392,25 +395,27 @@ class ServerTestCase(unittest.TestCase):
{}, self.NETWORKS, '1.1.1.1/24', 'vm_0', vnf, '00:00:00:00:00:01')
self.assertIsNotNone(status)
+
class OvsDeployTestCase(unittest.TestCase):
NETWORKS = {
'mgmt': {'cidr': '152.16.100.10/24'},
'private_0': {
- 'phy_port': "0000:05:00.0",
- 'vpci': "0000:00:07.0",
- 'driver': 'i40e',
- 'mac': '',
- 'cidr': '152.16.100.10/24',
- 'gateway_ip': '152.16.100.20'},
+ 'phy_port': "0000:05:00.0",
+ 'vpci': "0000:00:07.0",
+ 'driver': 'i40e',
+ 'mac': '',
+ 'cidr': '152.16.100.10/24',
+ 'gateway_ip': '152.16.100.20'},
'public_0': {
- 'phy_port': "0000:05:00.1",
- 'vpci': "0000:00:08.0",
- 'driver': 'i40e',
- 'mac': '',
- 'cidr': '152.16.40.10/24',
- 'gateway_ip': '152.16.100.20'}
+ 'phy_port': "0000:05:00.1",
+ 'vpci': "0000:00:08.0",
+ 'driver': 'i40e',
+ 'mac': '',
+ 'cidr': '152.16.40.10/24',
+ 'gateway_ip': '152.16.100.20'}
}
+
@mock.patch('yardstick.ssh.SSH')
def setUp(self, mock_ssh):
self.ovs_deploy = model.OvsDeploy(mock_ssh, '/tmp/dpdk-devbind.py', {})
diff --git a/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
index e39ecf4f2..02a85525a 100644
--- a/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
@@ -12,12 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Unittest for yardstick.benchmark.contexts.standalone.standaloneovs
-
-from __future__ import absolute_import
import os
-import unittest
+
import mock
+import unittest
from yardstick.benchmark.contexts.standalone import ovs_dpdk
@@ -39,28 +37,28 @@ class OvsDpdkContextTestCase(unittest.TestCase):
NETWORKS = {
'mgmt': {'cidr': '152.16.100.10/24'},
'private_0': {
- 'phy_port': "0000:05:00.0",
- 'vpci': "0000:00:07.0",
- 'cidr': '152.16.100.10/24',
- 'interface': 'if0',
- 'mac': "00:00:00:00:00:01",
- 'vf_pci': {'vf_pci': 0},
- 'gateway_ip': '152.16.100.20'},
+ 'phy_port': "0000:05:00.0",
+ 'vpci': "0000:00:07.0",
+ 'cidr': '152.16.100.10/24',
+ 'interface': 'if0',
+ 'mac': "00:00:00:00:00:01",
+ 'vf_pci': {'vf_pci': 0},
+ 'gateway_ip': '152.16.100.20'},
'public_0': {
- 'phy_port': "0000:05:00.1",
- 'vpci': "0000:00:08.0",
- 'cidr': '152.16.40.10/24',
- 'interface': 'if0',
- 'vf_pci': {'vf_pci': 0},
- 'mac': "00:00:00:00:00:01",
- 'gateway_ip': '152.16.100.20'},
+ 'phy_port': "0000:05:00.1",
+ 'vpci': "0000:00:08.0",
+ 'cidr': '152.16.40.10/24',
+ 'interface': 'if0',
+ 'vf_pci': {'vf_pci': 0},
+ 'mac': "00:00:00:00:00:01",
+ 'gateway_ip': '152.16.100.20'},
}
def setUp(self):
self.ovs_dpdk = ovs_dpdk.OvsDpdkContext()
- @mock.patch('yardstick.benchmark.contexts.standalone.model.StandaloneContextHelper')
@mock.patch('yardstick.benchmark.contexts.standalone.model.Server')
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.StandaloneContextHelper')
def test___init__(self, mock_helper, mock_server):
self.ovs_dpdk.helper = mock_helper
self.ovs_dpdk.vnf_node = mock_server
@@ -68,7 +66,8 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.assertTrue(self.ovs_dpdk.first_run)
def test_init(self):
- self.ovs_dpdk.helper.parse_pod_file = mock.Mock(return_value=[{}, {}, {}])
+ self.ovs_dpdk.helper.parse_pod_file = mock.Mock(
+ return_value=[{}, {}, {}])
self.assertIsNone(self.ovs_dpdk.init(self.ATTRS))
def test_setup_ovs(self):
@@ -108,19 +107,16 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.wait_for_vswitchd = 0
self.assertIsNone(self.ovs_dpdk.setup_ovs_bridge_add_flows())
- def test_cleanup_ovs_dpdk_env(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "a", ""))
- ssh.return_value = ssh_mock
- self.ovs_dpdk.connection = ssh_mock
- self.ovs_dpdk.networks = self.NETWORKS
- self.ovs_dpdk.ovs_properties = {
- 'version': {'ovs': '2.7.0'}
- }
- self.ovs_dpdk.wait_for_vswitchd = 0
- self.assertIsNone(self.ovs_dpdk.cleanup_ovs_dpdk_env())
+ @mock.patch("yardstick.ssh.SSH")
+ def test_cleanup_ovs_dpdk_env(self, mock_ssh):
+ mock_ssh.execute.return_value = 0, "a", ""
+ self.ovs_dpdk.connection = mock_ssh
+ self.ovs_dpdk.networks = self.NETWORKS
+ self.ovs_dpdk.ovs_properties = {
+ 'version': {'ovs': '2.7.0'}
+ }
+ self.ovs_dpdk.wait_for_vswitchd = 0
+ self.assertIsNone(self.ovs_dpdk.cleanup_ovs_dpdk_env())
@mock.patch('yardstick.benchmark.contexts.standalone.model.OvsDeploy')
def test_check_ovs_dpdk_env(self, mock_ovs):
@@ -132,7 +128,7 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.connection = ssh_mock
self.ovs_dpdk.networks = self.NETWORKS
self.ovs_dpdk.ovs_properties = {
- 'version': {'ovs': '2.7.0', 'dpdk': '16.11.1'}
+ 'version': {'ovs': '2.7.0', 'dpdk': '16.11.1'}
}
self.ovs_dpdk.wait_for_vswitchd = 0
self.ovs_dpdk.cleanup_ovs_dpdk_env = mock.Mock()
@@ -143,11 +139,12 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.wait_for_vswitchd = 0
self.cleanup_ovs_dpdk_env = mock.Mock()
mock_ovs.deploy = mock.Mock()
+ # NOTE(elfoley): Check for a specific Exception
self.assertRaises(Exception, self.ovs_dpdk.check_ovs_dpdk_env)
@mock.patch('yardstick.ssh.SSH')
- def test_deploy(self, ssh_mock):
- ssh_mock.execute.return_value = (0, "a", "")
+ def test_deploy(self, mock_ssh):
+ mock_ssh.execute.return_value = 0, "a", ""
self.ovs_dpdk.vm_deploy = False
self.assertIsNone(self.ovs_dpdk.deploy())
@@ -168,15 +165,15 @@ class OvsDpdkContextTestCase(unittest.TestCase):
@mock.patch('yardstick.benchmark.contexts.standalone.model.Libvirt')
@mock.patch('yardstick.ssh.SSH')
- def test_undeploy(self, ssh_mock, _):
- ssh_mock.execute.return_value = (0, "a", "")
+ def test_undeploy(self, mock_ssh, *args):
+ mock_ssh.execute.return_value = 0, "a", ""
self.ovs_dpdk.vm_deploy = False
self.assertIsNone(self.ovs_dpdk.undeploy())
self.ovs_dpdk.vm_deploy = True
+ self.ovs_dpdk.connection = mock_ssh
self.ovs_dpdk.vm_names = ['vm_0', 'vm_1']
- self.ovs_dpdk.connection = ssh_mock
self.ovs_dpdk.drivers = ['vm_0', 'vm_1']
self.ovs_dpdk.cleanup_ovs_dpdk_env = mock.Mock()
self.ovs_dpdk.networks = self.NETWORKS
@@ -208,7 +205,8 @@ class OvsDpdkContextTestCase(unittest.TestCase):
'file': self._get_file_abspath(self.NODES_ovs_dpdk_SAMPLE)
}
- self.ovs_dpdk.helper.parse_pod_file = mock.Mock(return_value=[{}, {}, {}])
+ self.ovs_dpdk.helper.parse_pod_file = mock.Mock(
+ return_value=[{}, {}, {}])
self.ovs_dpdk.init(attrs)
attr_name = 'bar.foo'
@@ -260,6 +258,8 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.assertEqual(result['user'], 'root')
self.assertEqual(result['key_filename'], '/root/.yardstick_key')
+ # TODO(elfoley): Split this test for networks that exist and networks that
+ # don't
def test__get_network(self):
network1 = {
'name': 'net_1',
@@ -277,6 +277,7 @@ class OvsDpdkContextTestCase(unittest.TestCase):
'b': network2,
}
+ # Tests for networks that do not exist
attr_name = {}
self.assertIsNone(self.ovs_dpdk._get_network(attr_name))
@@ -285,9 +286,11 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.assertIsNone(self.ovs_dpdk._get_network(None))
+ # TODO(elfoley): Split this test
attr_name = 'vld777'
self.assertIsNone(self.ovs_dpdk._get_network(attr_name))
+ # Tests for networks that exist
attr_name = {'vld_id': 'vld999'}
expected = {
"name": 'net_2',
@@ -319,8 +322,8 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.get_vf_datas = mock.Mock(return_value="")
self.assertIsNone(self.ovs_dpdk.configure_nics_for_ovs_dpdk())
- @mock.patch('yardstick.benchmark.contexts.standalone.model.Libvirt.add_ovs_interface')
- def test__enable_interfaces(self, _):
+ @mock.patch('yardstick.benchmark.contexts.standalone.ovs_dpdk.Libvirt')
+ def test__enable_interfaces(self, *args):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
@@ -332,11 +335,12 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.drivers = []
self.ovs_dpdk.networks = self.NETWORKS
self.ovs_dpdk.get_vf_datas = mock.Mock(return_value="")
- self.assertIsNone(self.ovs_dpdk._enable_interfaces(0, ["private_0"], 'test'))
+ self.assertIsNone(self.ovs_dpdk._enable_interfaces(
+ 0, ["private_0"], 'test'))
- @mock.patch('yardstick.benchmark.contexts.standalone.ovs_dpdk.Libvirt')
@mock.patch('yardstick.benchmark.contexts.standalone.model.Server')
- def test_setup_ovs_dpdk_context(self, _, mock_libvirt):
+ @mock.patch('yardstick.benchmark.contexts.standalone.ovs_dpdk.Libvirt')
+ def test_setup_ovs_dpdk_context(self, mock_libvirt, *args):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
@@ -361,10 +365,11 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.host_mgmt = {}
self.ovs_dpdk.flavor = {}
self.ovs_dpdk.configure_nics_for_ovs_dpdk = mock.Mock(return_value="")
- mock_libvirt.check_if_vm_exists_and_delete = mock.Mock(return_value="")
- mock_libvirt.build_vm_xml = mock.Mock(return_value=[6, "00:00:00:00:00:01"])
+ mock_libvirt.build_vm_xml.return_value = [6, "00:00:00:00:00:01"]
self.ovs_dpdk._enable_interfaces = mock.Mock(return_value="")
- mock_libvirt.virsh_create_vm = mock.Mock(return_value="")
- mock_libvirt.pin_vcpu_for_perf = mock.Mock(return_value="")
- self.ovs_dpdk.vnf_node.generate_vnf_instance = mock.Mock(return_value={})
+ mock_libvirt.virsh_create_vm.return_value = ""
+ mock_libvirt.pin_vcpu_for_perf.return_value = ""
+ self.ovs_dpdk.vnf_node.generate_vnf_instance = mock.Mock(
+ return_value={})
+
self.assertIsNotNone(self.ovs_dpdk.setup_ovs_dpdk_context())
diff --git a/tests/unit/benchmark/contexts/standalone/test_sriov.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
index 7f11a7d59..f323fcd3c 100644
--- a/tests/unit/benchmark/contexts/standalone/test_sriov.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
@@ -12,12 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Unittest for yardstick.benchmark.contexts.standalone.standalonesriov
-
-from __future__ import absolute_import
import os
-import unittest
+
import mock
+import unittest
from yardstick import ssh
from yardstick.benchmark.contexts.standalone import sriov
@@ -40,33 +38,31 @@ class SriovContextTestCase(unittest.TestCase):
NETWORKS = {
'mgmt': {'cidr': '152.16.100.10/24'},
'private_0': {
- 'phy_port': "0000:05:00.0",
- 'vpci': "0000:00:07.0",
- 'cidr': '152.16.100.10/24',
- 'interface': 'if0',
- 'mac': "00:00:00:00:00:01",
- 'vf_pci': {'vf_pci': 0},
- 'gateway_ip': '152.16.100.20'},
+ 'phy_port': "0000:05:00.0",
+ 'vpci': "0000:00:07.0",
+ 'cidr': '152.16.100.10/24',
+ 'interface': 'if0',
+ 'mac': "00:00:00:00:00:01",
+ 'vf_pci': {'vf_pci': 0},
+ 'gateway_ip': '152.16.100.20'},
'public_0': {
- 'phy_port': "0000:05:00.1",
- 'vpci': "0000:00:08.0",
- 'cidr': '152.16.40.10/24',
- 'interface': 'if0',
- 'vf_pci': {'vf_pci': 0},
- 'mac': "00:00:00:00:00:01",
- 'gateway_ip': '152.16.100.20'},
+ 'phy_port': "0000:05:00.1",
+ 'vpci': "0000:00:08.0",
+ 'cidr': '152.16.40.10/24',
+ 'interface': 'if0',
+ 'vf_pci': {'vf_pci': 0},
+ 'mac': "00:00:00:00:00:01",
+ 'gateway_ip': '152.16.100.20'},
}
def setUp(self):
self.sriov = sriov.SriovContext()
- @mock.patch('yardstick.benchmark.contexts.standalone.model.StandaloneContextHelper')
@mock.patch('yardstick.benchmark.contexts.standalone.sriov.Libvirt')
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.StandaloneContextHelper')
@mock.patch('yardstick.benchmark.contexts.standalone.model.Server')
- def test___init__(self, mock_helper, mock_libvirt, mock_server):
- # pylint: disable=unused-argument
+ def test___init__(self, mock_helper, mock_server, *args):
# NOTE(ralonsoh): this test doesn't cover function execution.
- # The pylint exception should be removed.
self.sriov.helper = mock_helper
self.sriov.vnf_node = mock_server
self.assertIsNone(self.sriov.file_path)
@@ -77,10 +73,8 @@ class SriovContextTestCase(unittest.TestCase):
self.assertIsNone(self.sriov.init(self.ATTRS))
@mock.patch.object(ssh, 'SSH', return_value=(0, "a", ""))
- def test_deploy(self, mock_ssh):
- # pylint: disable=unused-argument
+ def test_deploy(self, *args):
# NOTE(ralonsoh): this test doesn't cover function execution.
- # The pylint exception should be removed.
self.sriov.vm_deploy = False
self.assertIsNone(self.sriov.deploy())
@@ -92,11 +86,9 @@ class SriovContextTestCase(unittest.TestCase):
self.sriov.wait_for_vnfs_to_start = mock.Mock(return_value={})
self.assertIsNone(self.sriov.deploy())
- @mock.patch.object(ssh, 'SSH', return_value=(0, "a", ""))
@mock.patch('yardstick.benchmark.contexts.standalone.sriov.Libvirt')
- def test_undeploy(self, mock_libvirt, mock_ssh):
- # pylint: disable=unused-argument
- # NOTE(ralonsoh): the pylint exception should be removed.
+ @mock.patch.object(ssh, 'SSH', return_value=(0, "a", ""))
+ def test_undeploy(self, mock_ssh, *args):
self.sriov.vm_deploy = False
self.assertIsNone(self.sriov.undeploy())
@@ -184,6 +176,8 @@ class SriovContextTestCase(unittest.TestCase):
self.assertEqual(result['user'], 'root')
self.assertEqual(result['key_filename'], '/root/.yardstick_key')
+ # TODO(elfoley): Split this test
+ # There are at least two sets of inputs/outputs
def test__get_network(self):
network1 = {
'name': 'net_1',
@@ -243,24 +237,23 @@ class SriovContextTestCase(unittest.TestCase):
self.sriov._get_vf_data = mock.Mock(return_value="")
self.assertIsNone(self.sriov.configure_nics_for_sriov())
- @mock.patch.object(ssh, 'SSH', return_value=(0, "a", ""))
@mock.patch('yardstick.benchmark.contexts.standalone.sriov.Libvirt')
- def test__enable_interfaces(self, mock_libvirt, mock_ssh):
- # pylint: disable=unused-argument
- # NOTE(ralonsoh): the pylint exception should be removed.
+ @mock.patch.object(ssh, 'SSH')
+ def test__enable_interfaces(self, mock_ssh, *args):
+ mock_ssh.return_value = 0, "a", ""
+
self.sriov.vm_deploy = True
self.sriov.connection = mock_ssh
self.sriov.vm_names = ['vm_0', 'vm_1']
self.sriov.drivers = []
self.sriov.networks = self.NETWORKS
- self.sriov._get_vf_data = mock.Mock(return_value="")
- self.assertIsNone(self.sriov._enable_interfaces(0, 0, ["private_0"], 'test'))
+ self.sriov.get_vf_data = mock.Mock(return_value="")
+ self.assertIsNone(self.sriov._enable_interfaces(
+ 0, 0, ["private_0"], 'test'))
@mock.patch('yardstick.benchmark.contexts.standalone.model.Server')
@mock.patch('yardstick.benchmark.contexts.standalone.sriov.Libvirt')
- def test_setup_sriov_context(self, mock_libvirt, mock_server):
- # pylint: disable=unused-argument
- # NOTE(ralonsoh): the pylint exception should be removed.
+ def test_setup_sriov_context(self, mock_libvirt, *args):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
@@ -285,7 +278,8 @@ class SriovContextTestCase(unittest.TestCase):
self.sriov.host_mgmt = {}
self.sriov.flavor = {}
self.sriov.configure_nics_for_sriov = mock.Mock(return_value="")
- mock_libvirt.build_vm_xml = mock.Mock(return_value=[6, "00:00:00:00:00:01"])
+ mock_libvirt.build_vm_xml = mock.Mock(
+ return_value=[6, "00:00:00:00:00:01"])
self.sriov._enable_interfaces = mock.Mock(return_value="")
self.sriov.vnf_node.generate_vnf_instance = mock.Mock(return_value={})
self.assertIsNotNone(self.sriov.setup_sriov_context())
diff --git a/tests/unit/benchmark/contexts/standalone_duplicate_sample.yaml b/yardstick/tests/unit/benchmark/contexts/standalone_duplicate_sample.yaml
index e468d0465..e468d0465 100644
--- a/tests/unit/benchmark/contexts/standalone_duplicate_sample.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/standalone_duplicate_sample.yaml
diff --git a/tests/unit/benchmark/contexts/standalone_sample.yaml b/yardstick/tests/unit/benchmark/contexts/standalone_sample.yaml
index 95e12d62f..95e12d62f 100644
--- a/tests/unit/benchmark/contexts/standalone_sample.yaml
+++ b/yardstick/tests/unit/benchmark/contexts/standalone_sample.yaml
diff --git a/tests/unit/benchmark/contexts/test_dummy.py b/yardstick/tests/unit/benchmark/contexts/test_dummy.py
index 1a54035df..1a54035df 100644
--- a/tests/unit/benchmark/contexts/test_dummy.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_dummy.py
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/yardstick/tests/unit/benchmark/contexts/test_heat.py
index f2e725df2..4348bb052 100644
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_heat.py
@@ -9,22 +9,19 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.contexts.heat
-
-from __future__ import absolute_import
-
+from collections import OrderedDict
+from itertools import count
import logging
import os
-import unittest
import uuid
-from collections import OrderedDict
import mock
+import unittest
-from itertools import count
from yardstick.benchmark.contexts import heat
from yardstick.benchmark.contexts import model
+
LOG = logging.getLogger(__name__)
@@ -82,16 +79,16 @@ class HeatContextTestCase(unittest.TestCase):
pgs['pgrp1']['policy'])
mock_sg.assert_called_with('servergroup1', self.test_context,
sgs['servergroup1']['policy'])
- self.assertTrue(len(self.test_context.placement_groups) == 1)
- self.assertTrue(len(self.test_context.server_groups) == 1)
+ self.assertEqual(len(self.test_context.placement_groups), 1)
+ self.assertEqual(len(self.test_context.server_groups), 1)
mock_network.assert_called_with(
'bar', self.test_context, networks['bar'])
- self.assertTrue(len(self.test_context.networks) == 1)
+ self.assertEqual(len(self.test_context.networks), 1)
mock_server.assert_called_with('baz', self.test_context,
servers['baz'])
- self.assertTrue(len(self.test_context.servers) == 1)
+ self.assertEqual(len(self.test_context.servers), 1)
if os.path.exists(self.test_context.key_filename):
try:
@@ -119,15 +116,17 @@ class HeatContextTestCase(unittest.TestCase):
"2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b")
mock_template.add_security_group.assert_called_with("foo-secgroup")
# mock_template.add_network.assert_called_with("bar-fool-network", 'physnet1', None)
- mock_template.add_router.assert_called_with("bar-fool-network-router",
- netattrs["external_network"],
- "bar-fool-network-subnet")
- mock_template.add_router_interface.assert_called_with("bar-fool-network-router-if0",
- "bar-fool-network-router",
- "bar-fool-network-subnet")
+ mock_template.add_router.assert_called_with(
+ "bar-fool-network-router",
+ netattrs["external_network"],
+ "bar-fool-network-subnet")
+ mock_template.add_router_interface.assert_called_with(
+ "bar-fool-network-router-if0",
+ "bar-fool-network-router",
+ "bar-fool-network-subnet")
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test_attrs_get(self, mock_template):
+ def test_attrs_get(self, *args):
image, flavor, user = expected_tuple = 'foo1', 'foo2', 'foo3'
self.assertNotEqual(self.test_context.image, image)
self.assertNotEqual(self.test_context.flavor, flavor)
@@ -139,7 +138,7 @@ class HeatContextTestCase(unittest.TestCase):
self.assertEqual(attr_tuple, expected_tuple)
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test_attrs_set_negative(self, mock_template):
+ def test_attrs_set_negative(self, *args):
with self.assertRaises(AttributeError):
self.test_context.image = 'foo'
@@ -227,13 +226,13 @@ class HeatContextTestCase(unittest.TestCase):
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
@mock.patch('yardstick.benchmark.contexts.heat.os')
- def test_undeploy_key_filename(self, mock_template, mock_os):
+ def test_undeploy_key_filename(self, mock_os, mock_template):
self.test_context.stack = mock_template
mock_os.path.exists.return_value = True
self.assertIsNone(self.test_context.undeploy())
@mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
- def test__get_server_found_dict(self, mock_pkg_resources):
+ def test__get_server_found_dict(self, *args):
"""
Use HeatContext._get_server to get a server that matches
based on a dictionary input.
@@ -274,7 +273,7 @@ class HeatContextTestCase(unittest.TestCase):
self.assertEqual(result['private_ip'], '10.0.0.1')
@mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
- def test__get_server_found_dict_no_attrs(self, mock_pkg_resources):
+ def test__get_server_found_dict_no_attrs(self, *args):
"""
Use HeatContext._get_server to get a server that matches
based on a dictionary input.
@@ -313,7 +312,7 @@ class HeatContextTestCase(unittest.TestCase):
self.assertNotIn('ip', result)
@mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
- def test__get_server_found_not_dict(self, mock_pkg_resources):
+ def test__get_server_found_not_dict(self, *args):
"""
Use HeatContext._get_server to get a server that matches
based on a non-dictionary input
@@ -350,7 +349,7 @@ class HeatContextTestCase(unittest.TestCase):
self.assertNotIn('public_ip', result)
@mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
- def test__get_server_none_found_not_dict(self, mock_pkg_resources):
+ def test__get_server_none_found_not_dict(self, *args):
"""
Use HeatContext._get_server to not get a server due to
None value associated with the match to a non-dictionary
@@ -384,7 +383,7 @@ class HeatContextTestCase(unittest.TestCase):
self.assertIsNone(result)
@mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
- def test__get_server_not_found_dict(self, mock_pkg_resources):
+ def test__get_server_not_found_dict(self, *args):
"""
Use HeatContext._get_server to not get a server for lack
of a match to a dictionary input
@@ -420,7 +419,7 @@ class HeatContextTestCase(unittest.TestCase):
self.assertIsNone(result)
@mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
- def test__get_server_not_found_not_dict(self, mock_pkg_resources):
+ def test__get_server_not_found_not_dict(self, *args):
"""
Use HeatContext._get_server to not get a server for lack
of a match to a non-dictionary input
@@ -451,6 +450,7 @@ class HeatContextTestCase(unittest.TestCase):
result = self.test_context._get_server(attr_name)
self.assertIsNone(result)
+ # TODO: Split this into more granular tests
def test__get_network(self):
network1 = mock.MagicMock()
network1.name = 'net_1'
diff --git a/tests/unit/benchmark/contexts/test_kubernetes.py b/yardstick/tests/unit/benchmark/contexts/test_kubernetes.py
index 3a926f85c..e149e0d18 100644
--- a/tests/unit/benchmark/contexts/test_kubernetes.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_kubernetes.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
##############################################################################
# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
@@ -9,14 +7,11 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.contexts.kubernetes
-
-from __future__ import absolute_import
-import unittest
import mock
+import unittest
from yardstick.benchmark.contexts.base import Context
-from yardstick.benchmark.contexts.kubernetes import KubernetesContext
+from yardstick.benchmark.contexts import kubernetes
context_cfg = {
@@ -43,33 +38,35 @@ prefix = 'yardstick.benchmark.contexts.kubernetes'
class KubernetesTestCase(unittest.TestCase):
+ def setUp(self):
+ self.k8s_context = kubernetes.KubernetesContext()
+ self.k8s_context.init(context_cfg)
+
def tearDown(self):
# clear kubernetes contexts from global list so we don't break other tests
Context.list = []
- @mock.patch('{}.KubernetesContext._delete_services'.format(prefix))
- @mock.patch('{}.KubernetesContext._delete_ssh_key'.format(prefix))
- @mock.patch('{}.KubernetesContext._delete_rcs'.format(prefix))
- @mock.patch('{}.KubernetesContext._delete_pods'.format(prefix))
+ @mock.patch.object(kubernetes.KubernetesContext, '_delete_services')
+ @mock.patch.object(kubernetes.KubernetesContext, '_delete_ssh_key')
+ @mock.patch.object(kubernetes.KubernetesContext, '_delete_rcs')
+ @mock.patch.object(kubernetes.KubernetesContext, '_delete_pods')
def test_undeploy(self,
mock_delete_pods,
mock_delete_rcs,
mock_delete_ssh,
mock_delete_services):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context.undeploy()
+ self.k8s_context.undeploy()
self.assertTrue(mock_delete_ssh.called)
self.assertTrue(mock_delete_rcs.called)
self.assertTrue(mock_delete_pods.called)
self.assertTrue(mock_delete_services.called)
- @mock.patch('{}.KubernetesContext._create_services'.format(prefix))
- @mock.patch('{}.KubernetesContext._wait_until_running'.format(prefix))
- @mock.patch('{}.KubernetesTemplate.get_rc_pods'.format(prefix))
- @mock.patch('{}.KubernetesContext._create_rcs'.format(prefix))
- @mock.patch('{}.KubernetesContext._set_ssh_key'.format(prefix))
+ @mock.patch.object(kubernetes.KubernetesContext, '_create_services')
+ @mock.patch.object(kubernetes.KubernetesContext, '_wait_until_running')
+ @mock.patch.object(kubernetes.KubernetesTemplate, 'get_rc_pods')
+ @mock.patch.object(kubernetes.KubernetesContext, '_create_rcs')
+ @mock.patch.object(kubernetes.KubernetesContext, '_set_ssh_key')
def test_deploy(self,
mock_set_ssh_key,
mock_create_rcs,
@@ -77,44 +74,37 @@ class KubernetesTestCase(unittest.TestCase):
mock_wait_until_running,
mock_create_services):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
with mock.patch("yardstick.benchmark.contexts.kubernetes.time"):
- k8s_context.deploy()
+ self.k8s_context.deploy()
self.assertTrue(mock_set_ssh_key.called)
self.assertTrue(mock_create_rcs.called)
self.assertTrue(mock_create_services.called)
self.assertTrue(mock_get_rc_pods.called)
self.assertTrue(mock_wait_until_running.called)
- @mock.patch('{}.paramiko'.format(prefix), **{"resource_filename.return_value": ""})
- @mock.patch('{}.pkg_resources'.format(prefix), **{"resource_filename.return_value": ""})
- @mock.patch('{}.utils'.format(prefix))
- @mock.patch('{}.open'.format(prefix), create=True)
- @mock.patch('{}.k8s_utils.delete_config_map'.format(prefix))
- @mock.patch('{}.k8s_utils.create_config_map'.format(prefix))
- def test_ssh_key(self, mock_create, mock_delete, mock_open, mock_utils, mock_resources,
- mock_paramiko):
-
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._set_ssh_key()
- k8s_context._delete_ssh_key()
+ @mock.patch.object(kubernetes, 'paramiko', **{"resource_filename.return_value": ""})
+ @mock.patch.object(kubernetes, 'pkg_resources', **{"resource_filename.return_value": ""})
+ @mock.patch.object(kubernetes, 'utils')
+ @mock.patch.object(kubernetes, 'open', create=True)
+ @mock.patch.object(kubernetes.k8s_utils, 'delete_config_map')
+ @mock.patch.object(kubernetes.k8s_utils, 'create_config_map')
+ def test_ssh_key(self, mock_create, mock_delete, *args):
+ self.k8s_context._set_ssh_key()
+ self.k8s_context._delete_ssh_key()
+
self.assertTrue(mock_create.called)
self.assertTrue(mock_delete.called)
- @mock.patch('{}.k8s_utils.read_pod_status'.format(prefix))
+ @mock.patch.object(kubernetes.k8s_utils, 'read_pod_status')
def test_wait_until_running(self, mock_read_pod_status):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context.template.pods = ['server']
+ self.k8s_context.template.pods = ['server']
mock_read_pod_status.return_value = 'Running'
- k8s_context._wait_until_running()
+ self.k8s_context._wait_until_running()
- @mock.patch('{}.k8s_utils.get_pod_by_name'.format(prefix))
- @mock.patch('{}.KubernetesContext._get_node_ip'.format(prefix))
- @mock.patch('{}.k8s_utils.get_service_by_name'.format(prefix))
+ @mock.patch.object(kubernetes.k8s_utils, 'get_pod_by_name')
+ @mock.patch.object(kubernetes.KubernetesContext, '_get_node_ip')
+ @mock.patch.object(kubernetes.k8s_utils, 'get_service_by_name')
def test_get_server(self,
mock_get_service_by_name,
mock_get_node_ip,
@@ -136,64 +126,45 @@ class KubernetesTestCase(unittest.TestCase):
def __init__(self):
self.status = Status()
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
-
mock_get_service_by_name.return_value = Services()
mock_get_pod_by_name.return_value = Pod()
mock_get_node_ip.return_value = '172.16.10.131'
- server = k8s_context._get_server('server')
- self.assertIsNotNone(server)
+ self.assertIsNotNone(self.k8s_context._get_server('server'))
- @mock.patch('{}.KubernetesContext._create_rc'.format(prefix))
+ @mock.patch.object(kubernetes.KubernetesContext, '_create_rc')
def test_create_rcs(self, mock_create_rc):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._create_rcs()
+ self.k8s_context._create_rcs()
self.assertTrue(mock_create_rc.called)
- @mock.patch('{}.k8s_utils.create_replication_controller'.format(prefix))
+ @mock.patch.object(kubernetes.k8s_utils, 'create_replication_controller')
def test_create_rc(self, mock_create_replication_controller):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._create_rc({})
+ self.k8s_context._create_rc({})
self.assertTrue(mock_create_replication_controller.called)
- @mock.patch('{}.KubernetesContext._delete_rc'.format(prefix))
+ @mock.patch.object(kubernetes.KubernetesContext, '_delete_rc')
def test_delete_rcs(self, mock_delete_rc):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._delete_rcs()
+ self.k8s_context._delete_rcs()
self.assertTrue(mock_delete_rc.called)
- @mock.patch('{}.k8s_utils.delete_replication_controller'.format(prefix))
+ @mock.patch.object(kubernetes.k8s_utils, 'delete_replication_controller')
def test_delete_rc(self, mock_delete_replication_controller):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._delete_rc({})
+ self.k8s_context._delete_rc({})
self.assertTrue(mock_delete_replication_controller.called)
- @mock.patch('{}.k8s_utils.get_node_list'.format(prefix))
+ @mock.patch.object(kubernetes.k8s_utils, 'get_node_list')
def test_get_node_ip(self, mock_get_node_list):
-
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._get_node_ip()
+ self.k8s_context._get_node_ip()
self.assertTrue(mock_get_node_list.called)
@mock.patch('yardstick.orchestrator.kubernetes.ServiceObject.create')
def test_create_services(self, mock_create):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._create_services()
+ self.k8s_context._create_services()
self.assertTrue(mock_create.called)
@mock.patch('yardstick.orchestrator.kubernetes.ServiceObject.delete')
def test_delete_services(self, mock_delete):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._delete_services()
+ self.k8s_context._delete_services()
self.assertTrue(mock_delete.called)
diff --git a/tests/unit/benchmark/contexts/test_model.py b/yardstick/tests/unit/benchmark/contexts/test_model.py
index 53b035b82..28011d494 100644
--- a/tests/unit/benchmark/contexts/test_model.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_model.py
@@ -155,7 +155,7 @@ class NetworkTestCase(unittest.TestCase):
def test_find_external_network(self):
mock_network = mock.Mock()
- mock_network.router = mock.Mock()
+ mock_network.router = mock.Mock() #pylint ignore assignment-from-none
mock_network.router.external_gateway_info = 'ext_net'
model.Network.list = [mock_network]
diff --git a/tests/unit/benchmark/contexts/test_node.py b/yardstick/tests/unit/benchmark/contexts/test_node.py
index a2e2f7b9a..5329d30f4 100644
--- a/tests/unit/benchmark/contexts/test_node.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_node.py
@@ -21,6 +21,10 @@ from yardstick.common import constants as consts
from yardstick.benchmark.contexts import node
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
class NodeContextTestCase(unittest.TestCase):
PREFIX = 'yardstick.benchmark.contexts.node'
@@ -345,6 +349,7 @@ class NodeContextTestCase(unittest.TestCase):
result = self.test_context.get_context_from_server('my.vnf1')
self.assertIs(result, self.test_context)
+ # TODO: Split this into more granular tests
def test__get_network(self):
network1 = {
'name': 'net_1',
diff --git a/tests/unit/benchmark/core/__init__.py b/yardstick/tests/unit/benchmark/core/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/core/__init__.py
+++ b/yardstick/tests/unit/benchmark/core/__init__.py
diff --git a/tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml b/yardstick/tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml
index 44c4a31ff..44c4a31ff 100644
--- a/tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml
+++ b/yardstick/tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml
diff --git a/tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml b/yardstick/tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml
index ced13f19e..ced13f19e 100644
--- a/tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml
+++ b/yardstick/tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml
diff --git a/tests/unit/benchmark/core/test_plugin.py b/yardstick/tests/unit/benchmark/core/test_plugin.py
index f9c076159..1d6e80574 100644
--- a/tests/unit/benchmark/core/test_plugin.py
+++ b/yardstick/tests/unit/benchmark/core/test_plugin.py
@@ -29,7 +29,7 @@ class Arg(object):
# self.input_file = ('plugin/sample_config.yaml',)
self.input_file = [
os.path.join(os.path.abspath(
- dirname(dirname(dirname(dirname(dirname(__file__)))))),
+ dirname(dirname(dirname(dirname(dirname(dirname(__file__))))))),
'plugin/sample_config.yaml')]
diff --git a/tests/unit/benchmark/core/test_report.py b/yardstick/tests/unit/benchmark/core/test_report.py
index 69546928c..3d9a503b6 100644
--- a/tests/unit/benchmark/core/test_report.py
+++ b/yardstick/tests/unit/benchmark/core/test_report.py
@@ -55,10 +55,12 @@ class ReportTestCase(unittest.TestCase):
self.assertEqual(1, mock_tasks.call_count)
self.assertEqual(1, mock_keys.call_count)
+ # pylint: disable=deprecated-method
def test_invalid_yaml_name(self):
self.assertRaisesRegexp(ValueError, "yaml*", self.rep._validate,
'F@KE_NAME', FAKE_TASK_ID)
+ # pylint: disable=deprecated-method
def test_invalid_task_id(self):
self.assertRaisesRegexp(ValueError, "task*", self.rep._validate,
FAKE_YAML_NAME, DUMMY_TASK_ID)
@@ -68,5 +70,7 @@ class ReportTestCase(unittest.TestCase):
mock_query.return_value = []
self.rep.yaml_name = FAKE_YAML_NAME
self.rep.task_id = FAKE_TASK_ID
+ # pylint: disable=deprecated-method
self.assertRaisesRegexp(KeyError, "Task ID", self.rep._get_fieldkeys)
self.assertRaisesRegexp(KeyError, "Task ID", self.rep._get_tasks)
+ # pylint: enable=deprecated-method
diff --git a/tests/unit/benchmark/core/test_task.py b/yardstick/tests/unit/benchmark/core/test_task.py
index bed0bb6d8..3d9a10d88 100644
--- a/tests/unit/benchmark/core/test_task.py
+++ b/yardstick/tests/unit/benchmark/core/test_task.py
@@ -27,6 +27,10 @@ from yardstick.benchmark.core import task
from yardstick.common import constants as consts
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
class TaskTestCase(unittest.TestCase):
@mock.patch('yardstick.benchmark.core.task.Context')
diff --git a/tests/unit/benchmark/core/test_testcase.py b/yardstick/tests/unit/benchmark/core/test_testcase.py
index 1f5aad75e..1f5aad75e 100644
--- a/tests/unit/benchmark/core/test_testcase.py
+++ b/yardstick/tests/unit/benchmark/core/test_testcase.py
diff --git a/tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml b/yardstick/tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml
index 168d4b01a..168d4b01a 100644
--- a/tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml
+++ b/yardstick/tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml
diff --git a/tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml b/yardstick/tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml
index 299e5de56..299e5de56 100644
--- a/tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml
+++ b/yardstick/tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml
diff --git a/tests/unit/benchmark/runner/__init__.py b/yardstick/tests/unit/benchmark/runner/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/runner/__init__.py
+++ b/yardstick/tests/unit/benchmark/runner/__init__.py
diff --git a/tests/unit/benchmark/runner/test_base.py b/yardstick/tests/unit/benchmark/runner/test_base.py
index f47b88e95..0fdc42347 100644
--- a/tests/unit/benchmark/runner/test_base.py
+++ b/yardstick/tests/unit/benchmark/runner/test_base.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
##############################################################################
# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
#
@@ -9,16 +7,13 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import print_function
-from __future__ import absolute_import
-
-import unittest
import time
-from mock import mock
+import mock
+import unittest
from yardstick.benchmark.runners import base
-from yardstick.benchmark.runners.iteration import IterationRunner
+from yardstick.benchmark.runners import iteration
class ActionTestCase(unittest.TestCase):
@@ -44,40 +39,41 @@ class ActionTestCase(unittest.TestCase):
class RunnerTestCase(unittest.TestCase):
+ def setUp(self):
+ self.runner = iteration.IterationRunner({})
+
@mock.patch("yardstick.benchmark.runners.iteration.multiprocessing")
- def test_get_output(self, mock_process):
- runner = IterationRunner({})
- runner.output_queue.put({'case': 'opnfv_yardstick_tc002'})
- runner.output_queue.put({'criteria': 'PASS'})
+ def test_get_output(self, *args):
+ self.runner.output_queue.put({'case': 'opnfv_yardstick_tc002'})
+ self.runner.output_queue.put({'criteria': 'PASS'})
idle_result = {
'case': 'opnfv_yardstick_tc002',
'criteria': 'PASS'
}
- for retries in range(1000):
+ for _ in range(1000):
time.sleep(0.01)
- if not runner.output_queue.empty():
+ if not self.runner.output_queue.empty():
break
- actual_result = runner.get_output()
+ actual_result = self.runner.get_output()
self.assertEqual(idle_result, actual_result)
@mock.patch("yardstick.benchmark.runners.iteration.multiprocessing")
- def test_get_result(self, mock_process):
- runner = IterationRunner({})
- runner.result_queue.put({'case': 'opnfv_yardstick_tc002'})
- runner.result_queue.put({'criteria': 'PASS'})
+ def test_get_result(self, *args):
+ self.runner.result_queue.put({'case': 'opnfv_yardstick_tc002'})
+ self.runner.result_queue.put({'criteria': 'PASS'})
idle_result = [
{'case': 'opnfv_yardstick_tc002'},
{'criteria': 'PASS'}
]
- for retries in range(1000):
+ for _ in range(1000):
time.sleep(0.01)
- if not runner.result_queue.empty():
+ if not self.runner.result_queue.empty():
break
- actual_result = runner.get_result()
+ actual_result = self.runner.get_result()
self.assertEqual(idle_result, actual_result)
def test__run_benchmark(self):
diff --git a/tests/unit/benchmark/runner/test_search.py b/yardstick/tests/unit/benchmark/runner/test_search.py
index 8fab5a71f..1bc07448d 100644
--- a/tests/unit/benchmark/runner/test_search.py
+++ b/yardstick/tests/unit/benchmark/runner/test_search.py
@@ -11,14 +11,13 @@
# 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.
-#
-from __future__ import absolute_import
+import time
-import unittest
import mock
+import unittest
-from tests.unit import STL_MOCKS
+from yardstick.tests.unit import STL_MOCKS
STLClient = mock.MagicMock()
stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
@@ -40,7 +39,8 @@ class TestSearchRunnerHelper(unittest.TestCase):
benchmark = cls()
method = getattr(benchmark, 'my_method')
- helper = SearchRunnerHelper(cls, 'my_method', scenario_cfg, {}, aborted)
+ helper = SearchRunnerHelper(
+ cls, 'my_method', scenario_cfg, {}, aborted)
with helper.get_benchmark_instance():
helper()
@@ -54,22 +54,25 @@ class TestSearchRunnerHelper(unittest.TestCase):
'runner': {},
}
- helper = SearchRunnerHelper(cls, 'my_method', scenario_cfg, {}, aborted)
+ helper = SearchRunnerHelper(
+ cls, 'my_method', scenario_cfg, {}, aborted)
with self.assertRaises(RuntimeError):
helper()
- @mock.patch('yardstick.benchmark.runners.search.time')
- def test_is_not_done(self, mock_time):
+ @mock.patch.object(time, 'sleep')
+ @mock.patch.object(time, 'time')
+ def test_is_not_done(self, mock_time, *args):
cls = mock.MagicMock()
aborted = mock.MagicMock()
scenario_cfg = {
'runner': {},
}
- mock_time.time.side_effect = range(1000)
+ mock_time.side_effect = range(1000)
- helper = SearchRunnerHelper(cls, 'my_method', scenario_cfg, {}, aborted)
+ helper = SearchRunnerHelper(
+ cls, 'my_method', scenario_cfg, {}, aborted)
index = -1
for index in helper.is_not_done():
@@ -78,8 +81,8 @@ class TestSearchRunnerHelper(unittest.TestCase):
self.assertGreaterEqual(index, 10)
- @mock.patch('yardstick.benchmark.runners.search.time')
- def test_is_not_done_immediate_stop(self, mock_time):
+ @mock.patch.object(time, 'sleep')
+ def test_is_not_done_immediate_stop(self, *args):
cls = mock.MagicMock()
aborted = mock.MagicMock()
scenario_cfg = {
@@ -88,7 +91,8 @@ class TestSearchRunnerHelper(unittest.TestCase):
},
}
- helper = SearchRunnerHelper(cls, 'my_method', scenario_cfg, {}, aborted)
+ helper = SearchRunnerHelper(
+ cls, 'my_method', scenario_cfg, {}, aborted)
index = -1
for index in helper.is_not_done():
@@ -97,6 +101,7 @@ class TestSearchRunnerHelper(unittest.TestCase):
self.assertEqual(index, -1)
+
class TestSearchRunner(unittest.TestCase):
def test__worker_run_once(self):
diff --git a/tests/unit/benchmark/scenarios/__init__.py b/yardstick/tests/unit/benchmark/scenarios/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/scenarios/__init__.py
+++ b/yardstick/tests/unit/benchmark/scenarios/__init__.py
diff --git a/tests/unit/benchmark/scenarios/availability/__init__.py b/yardstick/tests/unit/benchmark/scenarios/availability/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/scenarios/availability/__init__.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/__init__.py
diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py
index cc179602e..f0921c0f6 100644
--- a/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py
@@ -20,20 +20,24 @@ from yardstick.benchmark.scenarios.availability.attacker import \
attacker_baremetal
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
@mock.patch('yardstick.benchmark.scenarios.availability.attacker.attacker_baremetal.subprocess')
class ExecuteShellTestCase(unittest.TestCase):
def test__fun_execute_shell_command_successful(self, mock_subprocess):
cmd = "env"
mock_subprocess.check_output.return_value = (0, 'unittest')
- exitcode, output = attacker_baremetal._execute_shell_command(cmd)
+ exitcode, _ = attacker_baremetal._execute_shell_command(cmd)
self.assertEqual(exitcode, 0)
@mock.patch('yardstick.benchmark.scenarios.availability.attacker.attacker_baremetal.LOG')
def test__fun_execute_shell_command_fail_cmd_exception(self, mock_log, mock_subprocess):
cmd = "env"
mock_subprocess.check_output.side_effect = RuntimeError
- exitcode, output = attacker_baremetal._execute_shell_command(cmd)
+ exitcode, _ = attacker_baremetal._execute_shell_command(cmd)
self.assertEqual(exitcode, -1)
mock_log.error.assert_called_once()
diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_general.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_attacker_general.py
index 612b5a662..612b5a662 100644
--- a/tests/unit/benchmark/scenarios/availability/test_attacker_general.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_attacker_general.py
diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_process.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
index 0a8e8322a..0a8e8322a 100644
--- a/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
diff --git a/tests/unit/benchmark/scenarios/availability/test_basemonitor.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
index 92ae8aa88..9bc04ebf4 100644
--- a/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
##############################################################################
# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
@@ -9,19 +7,12 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for
-# yardstick.benchmark.scenarios.availability.monitor.monitor_command
-
-from __future__ import absolute_import
import mock
import unittest
from yardstick.benchmark.scenarios.availability.monitor import basemonitor
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.monitor.basemonitor'
- '.BaseMonitor')
class MonitorMgrTestCase(unittest.TestCase):
def setUp(self):
@@ -52,19 +43,23 @@ class MonitorMgrTestCase(unittest.TestCase):
for mo in self.monitor_list:
mo._result = {"outage_time": 10}
- def test__MonitorMgr_setup_successful(self, mock_monitor):
+ @mock.patch.object(basemonitor, 'BaseMonitor')
+ def test__MonitorMgr_setup_successful(self, *args):
instance = basemonitor.MonitorMgr({"nova-api": 10})
instance.init_monitors(self.monitor_configs, None)
instance.start_monitors()
instance.wait_monitors()
- ret = instance.verify_SLA()
+ # TODO(elfoley): Check the return value
+ ret = instance.verify_SLA() # pylint: disable=unused-variable
- def test_MonitorMgr_getitem(self, mock_monitor):
+ @mock.patch.object(basemonitor, 'BaseMonitor')
+ def test_MonitorMgr_getitem(self, *args):
monitorMgr = basemonitor.MonitorMgr({"nova-api": 10})
monitorMgr.init_monitors(self.monitor_configs, None)
- def test_store_result(self, mock_monitor):
+ @mock.patch.object(basemonitor, 'BaseMonitor')
+ def test_store_result(self, *args):
expect = {'process_neutron-server_outage_time': 10,
'openstack-router-list_outage_time': 10}
result = {}
@@ -102,9 +97,7 @@ class BaseMonitorTestCase(unittest.TestCase):
ins.run()
ins.verify_SLA()
- @mock.patch(
- 'yardstick.benchmark.scenarios.availability.monitor.basemonitor'
- '.multiprocessing')
+ @mock.patch.object(basemonitor, 'multiprocessing')
def test__basemonitor_func_false(self, mock_multiprocess):
ins = self.MonitorSimple(self.monitor_cfg, None, {"nova-api": 10})
ins.setup()
@@ -112,11 +105,12 @@ class BaseMonitorTestCase(unittest.TestCase):
ins.run()
ins.verify_SLA()
+ # TODO(elfoley): fix this test to not throw an error
def test__basemonitor_getmonitorcls_successfule(self):
cls = None
try:
cls = basemonitor.BaseMonitor.get_monitor_cls(self.monitor_cfg)
- except Exception:
+ except Exception: # pylint: disable=broad-except
pass
self.assertIsNone(cls)
diff --git a/tests/unit/benchmark/scenarios/availability/test_baseoperation.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_baseoperation.py
index 03ec1492b..b7c9f62ff 100644
--- a/tests/unit/benchmark/scenarios/availability/test_baseoperation.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_baseoperation.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
##############################################################################
# Copyright (c) 2016 Huan Li and others
# lihuansse@tongji.edu.cn
@@ -9,19 +7,12 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for
-# yardstick.benchmark.scenarios.availability.operation.baseoperation
-
-from __future__ import absolute_import
import mock
import unittest
from yardstick.benchmark.scenarios.availability.operation import baseoperation
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.operation.baseoperation'
- '.BaseOperation')
class OperationMgrTestCase(unittest.TestCase):
def setUp(self):
@@ -33,17 +24,19 @@ class OperationMgrTestCase(unittest.TestCase):
self.operation_configs = []
self.operation_configs.append(config)
- def test_all_successful(self, mock_operation):
+ @mock.patch.object(baseoperation, 'BaseOperation')
+ def test_all_successful(self, *args):
mgr_ins = baseoperation.OperationMgr()
mgr_ins.init_operations(self.operation_configs, None)
- operation_ins = mgr_ins["service-status"]
+ _ = mgr_ins["service-status"]
mgr_ins.rollback()
- def test_getitem_fail(self, mock_operation):
+ @mock.patch.object(baseoperation, 'BaseOperation')
+ def test_getitem_fail(self, *args):
mgr_ins = baseoperation.OperationMgr()
mgr_ins.init_operations(self.operation_configs, None)
with self.assertRaises(KeyError):
- operation_ins = mgr_ins["operation-not-exist"]
+ _ = mgr_ins["operation-not-exist"]
class TestOperation(baseoperation.BaseOperation):
@@ -66,22 +59,21 @@ class BaseOperationTestCase(unittest.TestCase):
'operation_type': 'general-operation',
'key': 'service-status'
}
+ self.base_ins = baseoperation.BaseOperation(self.config, None)
def test_all_successful(self):
- base_ins = baseoperation.BaseOperation(self.config, None)
- base_ins.setup()
- base_ins.run()
- base_ins.rollback()
+ self.base_ins.setup()
+ self.base_ins.run()
+ self.base_ins.rollback()
def test_get_script_fullpath(self):
- base_ins = baseoperation.BaseOperation(self.config, None)
- base_ins.get_script_fullpath("ha_tools/test.bash")
+ self.base_ins.get_script_fullpath("ha_tools/test.bash")
+ # TODO(elfoley): Fix test to check on expected outputs
+ # pylint: disable=unused-variable
def test_get_operation_cls_successful(self):
- base_ins = baseoperation.BaseOperation(self.config, None)
- operation_ins = base_ins.get_operation_cls("test-operation")
+ operation_ins = self.base_ins.get_operation_cls("test-operation")
def test_get_operation_cls_fail(self):
- base_ins = baseoperation.BaseOperation(self.config, None)
with self.assertRaises(RuntimeError):
- operation_ins = base_ins.get_operation_cls("operation-not-exist")
+ self.base_ins.get_operation_cls("operation-not-exist")
diff --git a/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py
index 36ce900fb..ae74d241c 100644
--- a/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py
@@ -9,10 +9,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.scenarios.availability.result_checker
-# .baseresultchecker
-
-from __future__ import absolute_import
import mock
import unittest
@@ -20,8 +16,6 @@ from yardstick.benchmark.scenarios.availability.result_checker import \
baseresultchecker
-@mock.patch('yardstick.benchmark.scenarios.availability.result_checker'
- '.baseresultchecker.BaseResultChecker')
class ResultCheckerMgrTestCase(unittest.TestCase):
def setUp(self):
@@ -33,21 +27,27 @@ class ResultCheckerMgrTestCase(unittest.TestCase):
self.checker_configs = []
self.checker_configs.append(config)
- def test_ResultCheckerMgr_setup_successful(self, mock_basechacer):
- mgr_ins = baseresultchecker.ResultCheckerMgr()
- mgr_ins.init_ResultChecker(self.checker_configs, None)
- mgr_ins.verify()
+ self.mgr_ins = baseresultchecker.ResultCheckerMgr()
+
+ self._mock_basechecker = mock.patch.object(baseresultchecker,
+ 'BaseResultChecker')
+ self.mock_basechecker = self._mock_basechecker.start()
+ self.addCleanup(self._stop_mock)
+
+ def _stop_mock(self):
+ self._mock_basechecker.stop()
+
+ def test_ResultCheckerMgr_setup_successful(self):
+ self.mgr_ins.verify()
- def test_getitem_succeessful(self, mock_basechacer):
- mgr_ins = baseresultchecker.ResultCheckerMgr()
- mgr_ins.init_ResultChecker(self.checker_configs, None)
- checker_ins = mgr_ins["process-checker"]
+ def test_getitem_succeessful(self):
+ self.mgr_ins.init_ResultChecker(self.checker_configs, None)
+ _ = self.mgr_ins["process-checker"]
- def test_getitem_fail(self, mock_basechacer):
- mgr_ins = baseresultchecker.ResultCheckerMgr()
- mgr_ins.init_ResultChecker(self.checker_configs, None)
+ def test_getitem_fail(self):
+ self.mgr_ins.init_ResultChecker(self.checker_configs, None)
with self.assertRaises(KeyError):
- checker_ins = mgr_ins["checker-not-exist"]
+ _ = self.mgr_ins["checker-not-exist"]
class BaseResultCheckerTestCase(unittest.TestCase):
@@ -66,22 +66,20 @@ class BaseResultCheckerTestCase(unittest.TestCase):
'checker_type': 'general-result-checker',
'key': 'process-checker'
}
+ self.ins = baseresultchecker.BaseResultChecker(self.checker_cfg, None)
def test_baseresultchecker_setup_verify_successful(self):
- ins = baseresultchecker.BaseResultChecker(self.checker_cfg, None)
- ins.setup()
- ins.verify()
+ self.ins.setup()
+ self.ins.verify()
def test_baseresultchecker_verfiy_pass(self):
- ins = baseresultchecker.BaseResultChecker(self.checker_cfg, None)
- ins.setup()
- ins.actualResult = True
- ins.expectedResult = True
- ins.verify()
+ self.ins.setup()
+ self.ins.actualResult = True
+ self.ins.expectedResult = True
+ self.ins.verify()
def test_get_script_fullpath(self):
- ins = baseresultchecker.BaseResultChecker(self.checker_cfg, None)
- path = ins.get_script_fullpath("test.bash")
+ self.ins.get_script_fullpath("test.bash")
def test_get_resultchecker_cls_successful(self):
baseresultchecker.BaseResultChecker.get_resultchecker_cls(
diff --git a/tests/unit/benchmark/scenarios/availability/test_director.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_director.py
index d01a60e2d..72ce7b0d5 100644
--- a/tests/unit/benchmark/scenarios/availability/test_director.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_director.py
@@ -18,6 +18,10 @@ import unittest
from yardstick.benchmark.scenarios.availability.director import Director
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
@mock.patch('yardstick.benchmark.scenarios.availability.director.basemonitor')
@mock.patch('yardstick.benchmark.scenarios.availability.director.baseattacker')
@mock.patch(
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_command.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
index b84cef23c..1aebcc85b 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
##############################################################################
# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
@@ -9,36 +7,37 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for
-# yardstick.benchmark.scenarios.availability.monitor.monitor_command
-
-from __future__ import absolute_import
import mock
import unittest
from yardstick.benchmark.scenarios.availability.monitor import monitor_command
-@mock.patch('subprocess.check_output')
class ExecuteShellTestCase(unittest.TestCase):
- def test__fun_execute_shell_command_successful(self, mock_subprocess_check_output):
+ def setUp(self):
+ self._mock_subprocess = mock.patch.object(monitor_command, 'subprocess')
+ self.mock_subprocess = self._mock_subprocess.start()
+ self.addCleanup(self._stop_mock)
+
+ def _stop_mock(self):
+ self._mock_subprocess.stop()
+
+ def test__fun_execute_shell_command_successful(self):
cmd = "env"
- mock_subprocess_check_output.return_value = (0, 'unittest')
- exitcode, _ = monitor_command._execute_shell_command(cmd)
+ self.mock_subprocess.check_output.return_value = (0, 'unittest')
+ exitcode, _t = monitor_command._execute_shell_command(cmd)
self.assertEqual(exitcode, 0)
- @mock.patch('yardstick.benchmark.scenarios.availability.monitor.monitor_command.LOG')
- def test__fun_execute_shell_command_fail_cmd_exception(self, mock_log,
- mock_subprocess_check_output):
+ @mock.patch.object(monitor_command, 'LOG')
+ def test__fun_execute_shell_command_fail_cmd_exception(self, mock_log):
cmd = "env"
- mock_subprocess_check_output.side_effect = RuntimeError
+ self.mock_subprocess.check_output.side_effect = RuntimeError
exitcode, _ = monitor_command._execute_shell_command(cmd)
self.assertEqual(exitcode, -1)
mock_log.error.assert_called_once()
-@mock.patch('subprocess.check_output')
class MonitorOpenstackCmdTestCase(unittest.TestCase):
def setUp(self):
@@ -54,35 +53,39 @@ class MonitorOpenstackCmdTestCase(unittest.TestCase):
'monitor_time': 1,
'sla': {'max_outage_time': 5}
}
+ self._mock_subprocess = mock.patch.object(monitor_command, 'subprocess')
+ self.mock_subprocess = self._mock_subprocess.start()
+ self.addCleanup(self._stop_mock)
+
+ def _stop_mock(self):
+ self._mock_subprocess.stop()
- def test__monitor_command_monitor_func_successful(self, mock_subprocess_check_output):
+ def test__monitor_command_monitor_func_successful(self):
instance = monitor_command.MonitorOpenstackCmd(self.config, None, {"nova-api": 10})
instance.setup()
- mock_subprocess_check_output.return_value = (0, 'unittest')
+ self.mock_subprocess.check_output.return_value = (0, 'unittest')
ret = instance.monitor_func()
self.assertTrue(ret)
instance._result = {"outage_time": 0}
instance.verify_SLA()
- @mock.patch('yardstick.benchmark.scenarios.availability.monitor.monitor_command.LOG')
- def test__monitor_command_monitor_func_failure(self, mock_log, mock_subprocess_check_output):
- mock_subprocess_check_output.return_value = (1, 'unittest')
+ @mock.patch.object(monitor_command, 'LOG')
+ def test__monitor_command_monitor_func_failure(self, mock_log):
+ self.mock_subprocess.check_output.return_value = (1, 'unittest')
instance = monitor_command.MonitorOpenstackCmd(self.config, None, {"nova-api": 10})
instance.setup()
- mock_subprocess_check_output.side_effect = RuntimeError
+ self.mock_subprocess.check_output.side_effect = RuntimeError
ret = instance.monitor_func()
self.assertFalse(ret)
mock_log.error.assert_called_once()
instance._result = {"outage_time": 10}
instance.verify_SLA()
- @mock.patch(
- 'yardstick.benchmark.scenarios.availability.monitor.monitor_command'
- '.ssh')
- def test__monitor_command_ssh_monitor_successful(self, mock_ssh, mock_subprocess_check_output):
+ @mock.patch.object(monitor_command, 'ssh')
+ def test__monitor_command_ssh_monitor_successful(self, mock_ssh):
- mock_subprocess_check_output.return_value = (0, 'unittest')
+ self.mock_subprocess.check_output.return_value = (0, 'unittest')
self.config["host"] = "node1"
instance = monitor_command.MonitorOpenstackCmd(
self.config, self.context, {"nova-api": 10})
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
index c14f073ec..7022ea678 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
@@ -18,6 +18,10 @@ import unittest
from yardstick.benchmark.scenarios.availability.monitor import monitor_general
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
@mock.patch('yardstick.benchmark.scenarios.availability.monitor.'
'monitor_general.ssh')
@mock.patch('yardstick.benchmark.scenarios.availability.monitor.'
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py
index b59ec6cf1..0d61d9b15 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py
@@ -17,6 +17,11 @@ import mock
import unittest
from yardstick.benchmark.scenarios.availability.monitor import monitor_multi
+
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
@mock.patch('yardstick.benchmark.scenarios.availability.monitor.'
'monitor_general.ssh')
@mock.patch('yardstick.benchmark.scenarios.availability.monitor.'
@@ -42,7 +47,8 @@ class MultiMonitorServiceTestCase(unittest.TestCase):
}
def test__monitor_multi_all_successful(self, mock_open, mock_ssh):
- ins = monitor_multi.MultiMonitor(self.monitor_cfg, self.context, {"nova-api": 10})
+ ins = monitor_multi.MultiMonitor(
+ self.monitor_cfg, self.context, {"nova-api": 10})
mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
@@ -51,11 +57,11 @@ class MultiMonitorServiceTestCase(unittest.TestCase):
ins.verify_SLA()
def test__monitor_multi_all_fail(self, mock_open, mock_ssh):
- ins = monitor_multi.MultiMonitor(self.monitor_cfg, self.context, {"nova-api": 10})
+ ins = monitor_multi.MultiMonitor(
+ self.monitor_cfg, self.context, {"nova-api": 10})
mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
ins.start_monitor()
ins.wait_monitor()
ins.verify_SLA()
-
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_process.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
index 41ce5445e..41ce5445e 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
diff --git a/tests/unit/benchmark/scenarios/availability/test_operation_general.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_operation_general.py
index fb8ccb122..a965f7f64 100644
--- a/tests/unit/benchmark/scenarios/availability/test_operation_general.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_operation_general.py
@@ -19,6 +19,10 @@ from yardstick.benchmark.scenarios.availability.operation import \
operation_general
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
@mock.patch('yardstick.benchmark.scenarios.availability.operation.'
'operation_general.ssh')
@mock.patch('yardstick.benchmark.scenarios.availability.operation.'
diff --git a/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py
index d036bb0da..234adcb6e 100644
--- a/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py
@@ -21,6 +21,10 @@ from yardstick.benchmark.scenarios.availability.result_checker import \
result_checker_general
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
@mock.patch('yardstick.benchmark.scenarios.availability.result_checker.'
'result_checker_general.ssh')
@mock.patch('yardstick.benchmark.scenarios.availability.result_checker.'
diff --git a/tests/unit/benchmark/scenarios/availability/test_scenario_general.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
index 244a5e798..45840d569 100644
--- a/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
##############################################################################
# Copyright (c) 2016 Huan Li and others
# lihuansse@tongji.edu.cn
@@ -9,18 +7,11 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.scenarios.availability.scenario_general
-
-from __future__ import absolute_import
import mock
import unittest
-from yardstick.benchmark.scenarios.availability.scenario_general import \
- ScenarioGeneral
-
+from yardstick.benchmark.scenarios.availability import scenario_general
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.scenario_general.Director')
class ScenarioGeneralTestCase(unittest.TestCase):
def setUp(self):
@@ -44,28 +35,33 @@ class ScenarioGeneralTestCase(unittest.TestCase):
'index': 2}]
}
}
+ self.instance = scenario_general.ScenarioGeneral(self.scenario_cfg, None)
+
+ self._mock_director = mock.patch.object(scenario_general, 'Director')
+ self.mock_director = self._mock_director.start()
+ self.addCleanup(self._stop_mock)
+
+ def _stop_mock(self):
+ self._mock_director.stop()
- def test_scenario_general_all_successful(self, mock_director):
- ins = ScenarioGeneral(self.scenario_cfg, None)
- ins.setup()
- ins.run({})
- ins.teardown()
+ def test_scenario_general_all_successful(self):
+ self.instance.setup()
+ self.instance.run({})
+ self.instance.teardown()
- def test_scenario_general_exception(self, mock_director):
- ins = ScenarioGeneral(self.scenario_cfg, None)
+ def test_scenario_general_exception(self):
mock_obj = mock.Mock()
mock_obj.createActionPlayer.side_effect = KeyError('Wrong')
- ins.director = mock_obj
- ins.director.data = {}
- ins.run({})
- ins.teardown()
+ self.instance.director = mock_obj
+ self.instance.director.data = {}
+ self.instance.run({})
+ self.instance.teardown()
- def test_scenario_general_case_fail(self, mock_director):
- ins = ScenarioGeneral(self.scenario_cfg, None)
+ def test_scenario_general_case_fail(self):
mock_obj = mock.Mock()
mock_obj.verify.return_value = False
- ins.director = mock_obj
- ins.director.data = {}
- ins.run({})
- ins.pass_flag = True
- ins.teardown()
+ self.instance.director = mock_obj
+ self.instance.director.data = {}
+ self.instance.run({})
+ self.instance.pass_flag = True
+ self.instance.teardown()
diff --git a/tests/unit/benchmark/scenarios/availability/test_serviceha.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_serviceha.py
index 97d534894..6bb3ec63b 100644
--- a/tests/unit/benchmark/scenarios/availability/test_serviceha.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_serviceha.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
##############################################################################
# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
@@ -9,9 +7,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.scenarios.availability.serviceha
-
-from __future__ import absolute_import
import mock
import unittest
@@ -48,11 +43,11 @@ class ServicehaTestCase(unittest.TestCase):
sla = {"outage_time": 5}
self.args = {"options": options, "sla": sla}
- @mock.patch('yardstick.benchmark.scenarios.availability.serviceha.basemonitor')
- @mock.patch(
- 'yardstick.benchmark.scenarios.availability.serviceha.baseattacker')
- def test__serviceha_setup_run_successful(self, _,
- mock_monitor):
+ # NOTE(elfoley): This should be split into test_setup and test_run
+ # NOTE(elfoley): This should explicitly test outcomes and states
+ @mock.patch.object(serviceha, 'baseattacker')
+ @mock.patch.object(serviceha, 'basemonitor')
+ def test__serviceha_setup_run_successful(self, mock_monitor, *args):
p = serviceha.ServiceHA(self.args, self.ctx)
p.setup()
@@ -65,15 +60,15 @@ class ServicehaTestCase(unittest.TestCase):
p.setup()
self.assertTrue(p.setup_done)
-# def test__serviceha_run_sla_error(self, mock_attacker, mock_monitor):
-# p = serviceha.ServiceHA(self.args, self.ctx)
+ # def test__serviceha_run_sla_error(self, mock_attacker, mock_monitor):
+ # p = serviceha.ServiceHA(self.args, self.ctx)
-# p.setup()
-# self.assertTrue(p.setup_done)
-#
-# result = {}
-# result["outage_time"] = 10
-# mock_monitor.Monitor().get_result.return_value = result
+ # p.setup()
+ # self.assertEqual(p.setup_done, True)
+
+ # result = {}
+ # result["outage_time"] = 10
+ # mock_monitor.Monitor().get_result.return_value = result
-# ret = {}
-# self.assertRaises(AssertionError, p.run, ret)
+ # ret = {}
+ # self.assertRaises(AssertionError, p.run, ret)
diff --git a/tests/unit/benchmark/scenarios/availability/test_util.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_util.py
index 548efe91b..548efe91b 100644
--- a/tests/unit/benchmark/scenarios/availability/test_util.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_util.py
diff --git a/tests/unit/benchmark/scenarios/compute/__init__.py b/yardstick/tests/unit/benchmark/scenarios/compute/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/scenarios/compute/__init__.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/__init__.py
diff --git a/tests/unit/benchmark/scenarios/compute/cachestat_sample_output.txt b/yardstick/tests/unit/benchmark/scenarios/compute/cachestat_sample_output.txt
index e2c79a9b1..e2c79a9b1 100644
--- a/tests/unit/benchmark/scenarios/compute/cachestat_sample_output.txt
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/cachestat_sample_output.txt
diff --git a/tests/unit/benchmark/scenarios/compute/cpuload_sample_output1.txt b/yardstick/tests/unit/benchmark/scenarios/compute/cpuload_sample_output1.txt
index 723e64bcb..723e64bcb 100644
--- a/tests/unit/benchmark/scenarios/compute/cpuload_sample_output1.txt
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/cpuload_sample_output1.txt
diff --git a/tests/unit/benchmark/scenarios/compute/cpuload_sample_output2.txt b/yardstick/tests/unit/benchmark/scenarios/compute/cpuload_sample_output2.txt
index c66520a27..c66520a27 100644
--- a/tests/unit/benchmark/scenarios/compute/cpuload_sample_output2.txt
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/cpuload_sample_output2.txt
diff --git a/tests/unit/benchmark/scenarios/compute/memload_sample_output.txt b/yardstick/tests/unit/benchmark/scenarios/compute/memload_sample_output.txt
index 1793e2f10..1793e2f10 100644
--- a/tests/unit/benchmark/scenarios/compute/memload_sample_output.txt
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/memload_sample_output.txt
diff --git a/tests/unit/benchmark/scenarios/compute/test_cachestat.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_cachestat.py
index b0ddfc6b4..b0ddfc6b4 100644
--- a/tests/unit/benchmark/scenarios/compute/test_cachestat.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_cachestat.py
diff --git a/tests/unit/benchmark/scenarios/compute/test_computecapacity.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_computecapacity.py
index 7b9a5ad4a..7b9a5ad4a 100644
--- a/tests/unit/benchmark/scenarios/compute/test_computecapacity.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_computecapacity.py
diff --git a/tests/unit/benchmark/scenarios/compute/test_cpuload.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_cpuload.py
index 840ac7885..840ac7885 100644
--- a/tests/unit/benchmark/scenarios/compute/test_cpuload.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_cpuload.py
diff --git a/tests/unit/benchmark/scenarios/compute/test_cyclictest.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
index 51ffd2488..51ffd2488 100644
--- a/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
diff --git a/tests/unit/benchmark/scenarios/compute/test_lmbench.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_lmbench.py
index 65939c6ba..b3152d12c 100644
--- a/tests/unit/benchmark/scenarios/compute/test_lmbench.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_lmbench.py
@@ -21,6 +21,10 @@ from oslo_serialization import jsonutils
from yardstick.benchmark.scenarios.compute import lmbench
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
@mock.patch('yardstick.benchmark.scenarios.compute.lmbench.ssh')
class LmbenchTestCase(unittest.TestCase):
diff --git a/tests/unit/benchmark/scenarios/compute/test_memload.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_memload.py
index ebae9993d..ebae9993d 100644
--- a/tests/unit/benchmark/scenarios/compute/test_memload.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_memload.py
diff --git a/tests/unit/benchmark/scenarios/compute/test_plugintest.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_plugintest.py
index 680f6ad65..680f6ad65 100644
--- a/tests/unit/benchmark/scenarios/compute/test_plugintest.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_plugintest.py
diff --git a/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
index fb55b809f..26a26cdf7 100644
--- a/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
@@ -162,5 +162,6 @@ class QemuMigrateTestCase(unittest.TestCase):
def main():
unittest.main()
+
if __name__ == '__main__':
main()
diff --git a/tests/unit/benchmark/scenarios/compute/test_ramspeed.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_ramspeed.py
index 4f71fbb36..4f71fbb36 100644
--- a/tests/unit/benchmark/scenarios/compute/test_ramspeed.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_ramspeed.py
diff --git a/tests/unit/benchmark/scenarios/compute/test_spec_cpu.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_spec_cpu.py
index 40423b9da..74612d7b6 100644
--- a/tests/unit/benchmark/scenarios/compute/test_spec_cpu.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_spec_cpu.py
@@ -17,7 +17,6 @@ import unittest
import mock
-from yardstick.common import utils
from yardstick.benchmark.scenarios.compute import spec_cpu
@@ -39,7 +38,6 @@ class SpecCPUTestCase(unittest.TestCase):
options = {
"SPECint_benchmark": "perlbench",
- "runspec_tune": "all",
"output_format": "all",
"runspec_iterations": "1",
"runspec_tune": "base",
@@ -63,7 +61,6 @@ class SpecCPUTestCase(unittest.TestCase):
args = {"options": options}
s = spec_cpu.SpecCPU(args, self.ctx)
- sample_output = ''
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
s.run(self.result)
expected_result = {}
@@ -79,8 +76,10 @@ class SpecCPUTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, s.run, self.result)
+
def main():
unittest.main()
+
if __name__ == '__main__':
main()
diff --git a/tests/unit/benchmark/scenarios/compute/test_spec_cpu_for_vm.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_spec_cpu_for_vm.py
index c428e1fb8..c428e1fb8 100644
--- a/tests/unit/benchmark/scenarios/compute/test_spec_cpu_for_vm.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_spec_cpu_for_vm.py
diff --git a/tests/unit/benchmark/scenarios/compute/test_unixbench.py b/yardstick/tests/unit/benchmark/scenarios/compute/test_unixbench.py
index fec355b45..fec355b45 100644
--- a/tests/unit/benchmark/scenarios/compute/test_unixbench.py
+++ b/yardstick/tests/unit/benchmark/scenarios/compute/test_unixbench.py
diff --git a/tests/unit/benchmark/scenarios/dummy/__init__.py b/yardstick/tests/unit/benchmark/scenarios/dummy/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/scenarios/dummy/__init__.py
+++ b/yardstick/tests/unit/benchmark/scenarios/dummy/__init__.py
diff --git a/tests/unit/benchmark/scenarios/dummy/test_dummy.py b/yardstick/tests/unit/benchmark/scenarios/dummy/test_dummy.py
index bc5131806..bc5131806 100644
--- a/tests/unit/benchmark/scenarios/dummy/test_dummy.py
+++ b/yardstick/tests/unit/benchmark/scenarios/dummy/test_dummy.py
diff --git a/tests/unit/benchmark/scenarios/lib/__init__.py b/yardstick/tests/unit/benchmark/scenarios/lib/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/scenarios/lib/__init__.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/__init__.py
diff --git a/tests/unit/benchmark/scenarios/lib/test_add_memory_load.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_add_memory_load.py
index bda07f723..bda07f723 100644
--- a/tests/unit/benchmark/scenarios/lib/test_add_memory_load.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_add_memory_load.py
diff --git a/tests/unit/benchmark/scenarios/lib/test_attach_volume.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_attach_volume.py
index e69924072..25b911d5e 100644
--- a/tests/unit/benchmark/scenarios/lib/test_attach_volume.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_attach_volume.py
@@ -17,14 +17,15 @@ class AttachVolumeTestCase(unittest.TestCase):
@mock.patch('yardstick.common.openstack_utils.attach_server_volume')
def test_attach_volume(self, mock_attach_server_volume):
options = {
- 'volume_id': '123-456-000',
- 'server_id': '000-123-456'
+ 'volume_id': '123-456-000',
+ 'server_id': '000-123-456'
}
args = {"options": options}
obj = AttachVolume(args, {})
obj.run({})
self.assertTrue(mock_attach_server_volume.called)
+
def main():
unittest.main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py
index 1fb2f89ca..7188c29d5 100644
--- a/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py
@@ -30,7 +30,7 @@ class CheckConnectivityTestCase(unittest.TestCase):
'target': {
'ipaddr': '172.16.0.138'
}
- }
+ }
@mock.patch('yardstick.benchmark.scenarios.lib.check_connectivity.ssh')
def test_check_connectivity(self, mock_ssh):
@@ -43,18 +43,18 @@ class CheckConnectivityTestCase(unittest.TestCase):
'ssh_port': '22',
'ssh_timeout': 600,
'ping_parameter': "-s 2048"
- },
+ },
'sla': {'status': 'True',
'action': 'assert'}
}
- result = {}
+ # TODO(elfoley): Properly check the outputs
+ result = {} # pylint: disable=unused-variable
obj = check_connectivity.CheckConnectivity(args, {})
obj.setup()
mock_ssh.SSH.execute.return_value = (0, '100', '')
-
@mock.patch('yardstick.benchmark.scenarios.lib.check_connectivity.ssh')
def test_check_connectivity_key(self, mock_ssh):
@@ -64,18 +64,20 @@ class CheckConnectivityTestCase(unittest.TestCase):
'ssh_port': '22',
'ssh_timeout': 600,
'ping_parameter': "-s 2048"
- },
+ },
'sla': {'status': 'True',
'action': 'assert'}
}
- result = {}
+ # TODO(elfoley): Properly check the outputs
+ result = {} # pylint: disable=unused-variable
obj = check_connectivity.CheckConnectivity(args, self.ctx)
obj.setup()
mock_ssh.SSH.execute.return_value = (0, '100', '')
+
def main():
unittest.main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py
index 1dd461d41..f983f9c5b 100644
--- a/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py
@@ -6,17 +6,16 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import unittest
import mock
+import unittest
from yardstick.benchmark.scenarios.lib.check_numa_info import CheckNumaInfo
class CheckNumaInfoTestCase(unittest.TestCase):
- @mock.patch(
- 'yardstick.benchmark.scenarios.lib.check_numa_info.CheckNumaInfo._check_vm2_status')
- def test_check_numa_info(self, mock_check_vm2):
+ @mock.patch.object(CheckNumaInfo, '_check_vm2_status')
+ def test_run(self, mock_check_vm2):
scenario_cfg = {'info1': {}, 'info2': {}}
obj = CheckNumaInfo(scenario_cfg, {})
obj.run({})
diff --git a/tests/unit/benchmark/scenarios/lib/test_check_value.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_check_value.py
index 21e83f830..5a40e7d8f 100644
--- a/tests/unit/benchmark/scenarios/lib/test_check_value.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_check_value.py
@@ -10,33 +10,29 @@ import unittest
from yardstick.benchmark.scenarios.lib.check_value import CheckValue
-
class CheckValueTestCase(unittest.TestCase):
+ def setUp(self):
+ self.result = {}
+
def test_check_value_eq(self):
scenario_cfg = {'options': {'operator': 'eq', 'value1': 1, 'value2': 2}}
obj = CheckValue(scenario_cfg, {})
- try:
- obj.run({})
- except Exception as e:
- self.assertIsInstance(e, AssertionError)
+ self.assertRaises(AssertionError, obj.run, self.result)
+ self.assertEqual({}, self.result)
def test_check_value_eq_pass(self):
scenario_cfg = {'options': {'operator': 'eq', 'value1': 1, 'value2': 1}}
obj = CheckValue(scenario_cfg, {})
- try:
- obj.run({})
- except Exception as e:
- self.assertIsInstance(e, AssertionError)
+
+ obj.run(self.result)
+ self.assertEqual({}, self.result)
def test_check_value_ne(self):
scenario_cfg = {'options': {'operator': 'ne', 'value1': 1, 'value2': 1}}
obj = CheckValue(scenario_cfg, {})
- try:
- obj.run({})
- except Exception as e:
- self.assertIsInstance(e, AssertionError)
-
+ self.assertRaises(AssertionError, obj.run, self.result)
+ self.assertEqual({}, self.result)
def main():
unittest.main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_flavor.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_flavor.py
index 036ae952d..036ae952d 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_flavor.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_flavor.py
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_floating_ip.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_floating_ip.py
index a7286f5da..a7286f5da 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_floating_ip.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_floating_ip.py
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_image.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_image.py
index c213ceba0..b26957979 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_image.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_image.py
@@ -9,28 +9,30 @@
import unittest
import mock
-from yardstick.benchmark.scenarios.lib.create_image import CreateImage
-
+from yardstick.benchmark.scenarios.lib import create_image
+from yardstick.common import openstack_utils
+# NOTE(elfoley): There should be more tests here.
class CreateImageTestCase(unittest.TestCase):
- @mock.patch('yardstick.common.openstack_utils.create_image')
- @mock.patch('yardstick.common.openstack_utils.get_glance_client')
+ @mock.patch.object(openstack_utils, 'create_image')
+ @mock.patch.object(openstack_utils, 'get_glance_client')
def test_create_image(self, mock_get_glance_client, mock_create_image):
options = {
- 'image_name': 'yardstick_test_image_01',
- 'disk_format': 'qcow2',
- 'container_format': 'bare',
- 'min_disk': '1',
- 'min_ram': '512',
- 'protected': 'False',
- 'tags': '["yardstick automatic test image"]',
- 'file_path': '/home/opnfv/images/cirros-0.3.5-x86_64-disk.img'
+ 'image_name': 'yardstick_test_image_01',
+ 'disk_format': 'qcow2',
+ 'container_format': 'bare',
+ 'min_disk': '1',
+ 'min_ram': '512',
+ 'protected': 'False',
+ 'tags': '["yardstick automatic test image"]',
+ 'file_path': '/home/opnfv/images/cirros-0.3.5-x86_64-disk.img'
}
args = {"options": options}
- obj = CreateImage(args, {})
+ obj = create_image.CreateImage(args, {})
obj.run({})
- self.assertTrue(mock_create_image.called)
+ mock_create_image.assert_called_once()
+ mock_get_glance_client.assert_called_once()
def main():
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_keypair.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_keypair.py
index 4b9b72013..10e351b5e 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_keypair.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_keypair.py
@@ -6,26 +6,25 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import unittest
-import mock
-from yardstick.benchmark.scenarios.lib.create_keypair import CreateKeypair
+import mock
+import unittest
-PREFIX = "yardstick.benchmark.scenarios.lib.create_keypair"
+from yardstick.benchmark.scenarios.lib import create_keypair
class CreateKeypairTestCase(unittest.TestCase):
- @mock.patch('{}.paramiko'.format(PREFIX))
- @mock.patch('{}.op_utils'.format(PREFIX))
- def test_create_keypair(self, mock_op_utils, mock_paramiko):
+ @mock.patch.object(create_keypair, 'paramiko')
+ @mock.patch.object(create_keypair, 'op_utils')
+ def test_create_keypair(self, mock_op_utils, *args):
options = {
'key_name': 'yardstick_key',
'key_path': '/tmp/yardstick_key'
}
args = {"options": options}
- obj = CreateKeypair(args, {})
+ obj = create_keypair.CreateKeypair(args, {})
obj.run({})
- self.assertTrue(mock_op_utils.create_keypair.called)
+ mock_op_utils.create_keypair.assert_called_once()
def main():
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_network.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_network.py
index 8e7d8b5a1..e0382851f 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_network.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_network.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.create_network import CreateNetwork
@@ -19,10 +18,10 @@ class CreateNetworkTestCase(unittest.TestCase):
@mock.patch('yardstick.common.openstack_utils.create_neutron_net')
def test_create_network(self, mock_get_neutron_client, mock_create_neutron_net):
options = {
- 'openstack_paras': {
- 'name': 'yardstick_net',
- 'admin_state_up': 'True'
- }
+ 'openstack_paras': {
+ 'name': 'yardstick_net',
+ 'admin_state_up': 'True'
+ }
}
args = {"options": options}
obj = CreateNetwork(args, {})
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_port.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_port.py
index 3b2aa2247..0f15058da 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_port.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_port.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.create_port import CreatePort
@@ -18,9 +17,9 @@ class CreatePortTestCase(unittest.TestCase):
@mock.patch('yardstick.common.openstack_utils.get_neutron_client')
def test_create_port(self, mock_get_neutron_client):
options = {
- 'openstack_paras': {
- 'name': 'yardstick_port'
- }
+ 'openstack_paras': {
+ 'name': 'yardstick_port'
+ }
}
args = {"options": options}
obj = CreatePort(args, {})
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_router.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_router.py
index b956a3634..8f3914b83 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_router.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_router.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.create_router import CreateRouter
@@ -19,10 +18,10 @@ class CreateRouterTestCase(unittest.TestCase):
@mock.patch('yardstick.common.openstack_utils.create_neutron_router')
def test_create_router(self, mock_get_neutron_client, mock_create_neutron_router):
options = {
- 'openstack_paras': {
- 'admin_state_up': 'True',
- 'name': 'yardstick_router'
- }
+ 'openstack_paras': {
+ 'admin_state_up': 'True',
+ 'name': 'yardstick_router'
+ }
}
args = {"options": options}
obj = CreateRouter(args, {})
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_sec_group.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_sec_group.py
index b962f7f0e..c1c137cda 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_sec_group.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_sec_group.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.create_sec_group import CreateSecgroup
@@ -19,10 +18,10 @@ class CreateSecGroupTestCase(unittest.TestCase):
@mock.patch('yardstick.common.openstack_utils.create_security_group_full')
def test_create_sec_group(self, mock_get_neutron_client, mock_create_security_group_full):
options = {
- 'openstack_paras': {
- 'sg_name': 'yardstick_sec_group',
- 'description': 'security group for yardstick manual VM'
- }
+ 'openstack_paras': {
+ 'sg_name': 'yardstick_sec_group',
+ 'description': 'security group for yardstick manual VM'
+ }
}
args = {"options": options}
obj = CreateSecgroup(args, {})
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_server.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_server.py
index 7c4193132..74003b995 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_server.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_server.py
@@ -21,10 +21,10 @@ class CreateServerTestCase(unittest.TestCase):
def test_create_server(self, mock_get_nova_client, mock_get_neutron_client,
mock_get_glance_client, mock_create_instance_and_wait_for_active):
scenario_cfg = {
- 'options' : {
- 'openstack_paras': 'example'
- },
- 'output': 'server'
+ 'options': {
+ 'openstack_paras': 'example'
+ },
+ 'output': 'server'
}
obj = CreateServer(scenario_cfg, {})
obj.run({})
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_subnet.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_subnet.py
index 0154755c4..b7f29dfe4 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_subnet.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_subnet.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.create_subnet import CreateSubnet
@@ -19,12 +18,12 @@ class CreateSubnetTestCase(unittest.TestCase):
@mock.patch('yardstick.common.openstack_utils.create_neutron_subnet')
def test_create_subnet(self, mock_get_neutron_client, mock_create_neutron_subnet):
options = {
- 'openstack_paras': {
- 'network_id': '123-123-123',
- 'name': 'yardstick_subnet',
- 'cidr': '10.10.10.0/24',
- 'ip_version': '4'
- }
+ 'openstack_paras': {
+ 'network_id': '123-123-123',
+ 'name': 'yardstick_subnet',
+ 'cidr': '10.10.10.0/24',
+ 'ip_version': '4'
+ }
}
args = {"options": options}
obj = CreateSubnet(args, {})
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_volume.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_volume.py
index ef2c0ccaf..ca055db2f 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_volume.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_create_volume.py
@@ -6,10 +6,10 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import unittest
import mock
+import unittest
-import yardstick.benchmark.scenarios.lib.create_volume
+from yardstick.benchmark.scenarios.lib import create_volume
class CreateVolumeTestCase(unittest.TestCase):
@@ -32,10 +32,9 @@ class CreateVolumeTestCase(unittest.TestCase):
}
}
- self.scenario = (
- yardstick.benchmark.scenarios.lib.create_volume.CreateVolume(
- scenario_cfg=self.scenario_cfg,
- context_cfg={}))
+ self.scenario = create_volume.CreateVolume(
+ scenario_cfg=self.scenario_cfg,
+ context_cfg={})
def _stop_mock(self):
self._mock_cinder_client.stop()
@@ -50,10 +49,9 @@ class CreateVolumeTestCase(unittest.TestCase):
expected_im_name = self.scenario_cfg["options"]["image"]
expected_im_id = None
- scenario = (
- yardstick.benchmark.scenarios.lib.create_volume.CreateVolume(
- scenario_cfg=self.scenario_cfg,
- context_cfg={}))
+ scenario = create_volume.CreateVolume(
+ scenario_cfg=self.scenario_cfg,
+ context_cfg={})
self.assertEqual(expected_vol_name, scenario.volume_name)
self.assertEqual(expected_vol_size, scenario.volume_size)
@@ -75,13 +73,32 @@ class CreateVolumeTestCase(unittest.TestCase):
mock_image_id.assert_called_once()
mock_create_volume.assert_called_once()
- @mock.patch.object(
- yardstick.benchmark.scenarios.lib.create_volume.CreateVolume, 'setup')
+ @mock.patch.object(create_volume.CreateVolume, 'setup')
def test_run_no_setup(self, scenario_setup):
self.scenario.setup_done = False
self.scenario.run()
scenario_setup.assert_called_once()
+ @mock.patch('yardstick.common.openstack_utils.create_volume')
+ @mock.patch('yardstick.common.openstack_utils.get_image_id')
+ @mock.patch('yardstick.common.openstack_utils.get_cinder_client')
+ @mock.patch('yardstick.common.openstack_utils.get_glance_client')
+ def test_create_volume(self, mock_get_glance_client,
+ mock_get_cinder_client, mock_image_id,
+ mock_create_volume):
+ options = {
+ 'volume_name': 'yardstick_test_volume_01',
+ 'size': '256',
+ 'image': 'cirros-0.3.5'
+ }
+ args = {"options": options}
+ scenario = create_volume.CreateVolume(args, {})
+ scenario.run()
+ self.assertTrue(mock_create_volume.called)
+ self.assertTrue(mock_image_id.called)
+ self.assertTrue(mock_get_glance_client.called)
+ self.assertTrue(mock_get_cinder_client.called)
+
def main():
unittest.main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_flavor.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_flavor.py
index 4a91b8939..4a91b8939 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_flavor.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_flavor.py
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_floating_ip.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_floating_ip.py
index 7592c8070..df2321292 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_floating_ip.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_floating_ip.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.delete_floating_ip import DeleteFloatingIp
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_image.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_image.py
index 2bbf14d16..9edc2ff1d 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_image.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_image.py
@@ -19,7 +19,7 @@ class DeleteImageTestCase(unittest.TestCase):
@mock.patch('yardstick.common.openstack_utils.get_glance_client')
def test_delete_image(self, mock_get_glance_client, mock_image_id, mock_delete_image):
options = {
- 'image_name': 'yardstick_test_image_01'
+ 'image_name': 'yardstick_test_image_01'
}
args = {"options": options}
obj = DeleteImage(args, {})
@@ -28,6 +28,7 @@ class DeleteImageTestCase(unittest.TestCase):
self.assertTrue(mock_image_id.called)
self.assertTrue(mock_get_glance_client.called)
+
def main():
unittest.main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_keypair.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_keypair.py
index 9663fe9fb..73894a903 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_keypair.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_keypair.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.delete_keypair import DeleteKeypair
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_network.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_network.py
index 9ccaa8232..5f11713fa 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_network.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_network.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.delete_network import DeleteNetwork
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_port.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_port.py
index 77b9c7009..de3179b2d 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_port.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_port.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.delete_port import DeletePort
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_router.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_router.py
index ab1ad5d35..73cb81278 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_router.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_router.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.delete_router import DeleteRouter
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py
index 1150dccda..3cfc4ed21 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.delete_router_gateway import DeleteRouterGateway
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py
index 2cc9c9f37..67aff1091 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.delete_router_interface import DeleteRouterInterface
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_server.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_server.py
index 622ead5ac..622ead5ac 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_server.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_server.py
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_volume.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_volume.py
index a11d0121b..9438b077a 100644
--- a/tests/unit/benchmark/scenarios/lib/test_delete_volume.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_delete_volume.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.delete_volume import DeleteVolume
diff --git a/tests/unit/benchmark/scenarios/lib/test_detach_volume.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_detach_volume.py
index 0cffcba15..87af63a55 100644
--- a/tests/unit/benchmark/scenarios/lib/test_detach_volume.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_detach_volume.py
@@ -8,7 +8,6 @@
##############################################################################
import unittest
import mock
-import paramiko
from yardstick.benchmark.scenarios.lib.detach_volume import DetachVolume
diff --git a/tests/unit/benchmark/scenarios/lib/test_get_flavor.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_get_flavor.py
index bf12e0a32..bf12e0a32 100644
--- a/tests/unit/benchmark/scenarios/lib/test_get_flavor.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_get_flavor.py
diff --git a/tests/unit/benchmark/scenarios/lib/test_get_migrate_target_host.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_get_migrate_target_host.py
index f046c92ea..f046c92ea 100644
--- a/tests/unit/benchmark/scenarios/lib/test_get_migrate_target_host.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_get_migrate_target_host.py
diff --git a/tests/unit/benchmark/scenarios/lib/test_get_numa_info.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_get_numa_info.py
index 680692fdc..50d5238d7 100644
--- a/tests/unit/benchmark/scenarios/lib/test_get_numa_info.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_get_numa_info.py
@@ -11,6 +11,11 @@ import mock
from yardstick.benchmark.scenarios.lib.get_numa_info import GetNumaInfo
+
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
BASE = 'yardstick.benchmark.scenarios.lib.get_numa_info'
diff --git a/tests/unit/benchmark/scenarios/lib/test_get_server.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_get_server.py
index aebbf5416..aebbf5416 100644
--- a/tests/unit/benchmark/scenarios/lib/test_get_server.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_get_server.py
diff --git a/tests/unit/benchmark/scenarios/lib/test_get_server_ip.py b/yardstick/tests/unit/benchmark/scenarios/lib/test_get_server_ip.py
index 3d20d5439..3d20d5439 100644
--- a/tests/unit/benchmark/scenarios/lib/test_get_server_ip.py
+++ b/yardstick/tests/unit/benchmark/scenarios/lib/test_get_server_ip.py
diff --git a/tests/unit/benchmark/scenarios/networking/__init__.py b/yardstick/tests/unit/benchmark/scenarios/networking/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/scenarios/networking/__init__.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/__init__.py
diff --git a/tests/unit/benchmark/scenarios/networking/imix_voice.yaml b/yardstick/tests/unit/benchmark/scenarios/networking/imix_voice.yaml
index b8f8e5358..b8f8e5358 100644
--- a/tests/unit/benchmark/scenarios/networking/imix_voice.yaml
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/imix_voice.yaml
diff --git a/tests/unit/benchmark/scenarios/networking/iperf3_sample_output.json b/yardstick/tests/unit/benchmark/scenarios/networking/iperf3_sample_output.json
index b56009ba1..b56009ba1 100644
--- a/tests/unit/benchmark/scenarios/networking/iperf3_sample_output.json
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/iperf3_sample_output.json
diff --git a/tests/unit/benchmark/scenarios/networking/iperf3_sample_output_udp.json b/yardstick/tests/unit/benchmark/scenarios/networking/iperf3_sample_output_udp.json
index 8173c8f64..8173c8f64 100644
--- a/tests/unit/benchmark/scenarios/networking/iperf3_sample_output_udp.json
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/iperf3_sample_output_udp.json
diff --git a/tests/unit/benchmark/scenarios/networking/ipv4_1flow_Packets_vpe.yaml b/yardstick/tests/unit/benchmark/scenarios/networking/ipv4_1flow_Packets_vpe.yaml
index f3046f463..f3046f463 100644
--- a/tests/unit/benchmark/scenarios/networking/ipv4_1flow_Packets_vpe.yaml
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/ipv4_1flow_Packets_vpe.yaml
diff --git a/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml b/yardstick/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml
index 2123e4705..2123e4705 100644
--- a/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml
diff --git a/tests/unit/benchmark/scenarios/networking/netperf_sample_output.json b/yardstick/tests/unit/benchmark/scenarios/networking/netperf_sample_output.json
index bba76cfa5..bba76cfa5 100755
--- a/tests/unit/benchmark/scenarios/networking/netperf_sample_output.json
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/netperf_sample_output.json
diff --git a/tests/unit/benchmark/scenarios/networking/netutilization_sample_output1.txt b/yardstick/tests/unit/benchmark/scenarios/networking/netutilization_sample_output1.txt
index f90457cb3..f90457cb3 100644
--- a/tests/unit/benchmark/scenarios/networking/netutilization_sample_output1.txt
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/netutilization_sample_output1.txt
diff --git a/tests/unit/benchmark/scenarios/networking/netutilization_sample_output2.txt b/yardstick/tests/unit/benchmark/scenarios/networking/netutilization_sample_output2.txt
index 417613ec1..417613ec1 100644
--- a/tests/unit/benchmark/scenarios/networking/netutilization_sample_output2.txt
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/netutilization_sample_output2.txt
diff --git a/tests/unit/benchmark/scenarios/networking/test_iperf3.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_iperf3.py
index 4d3745230..4d3745230 100644
--- a/tests/unit/benchmark/scenarios/networking/test_iperf3.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_iperf3.py
diff --git a/tests/unit/benchmark/scenarios/networking/test_netperf.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_netperf.py
index d82a00931..d82a00931 100755
--- a/tests/unit/benchmark/scenarios/networking/test_netperf.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_netperf.py
diff --git a/tests/unit/benchmark/scenarios/networking/test_netperf_node.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_netperf_node.py
index 8be9bb94d..8be9bb94d 100755
--- a/tests/unit/benchmark/scenarios/networking/test_netperf_node.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_netperf_node.py
diff --git a/tests/unit/benchmark/scenarios/networking/test_netutilization.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_netutilization.py
index 1227e056e..1227e056e 100644
--- a/tests/unit/benchmark/scenarios/networking/test_netutilization.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_netutilization.py
diff --git a/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py
index 3e7a3c5ee..3e7a3c5ee 100644
--- a/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py
diff --git a/tests/unit/benchmark/scenarios/networking/test_nstat.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_nstat.py
index 4b58e06c1..7dd5351b1 100644
--- a/tests/unit/benchmark/scenarios/networking/test_nstat.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_nstat.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
##############################################################################
# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
#
@@ -9,13 +7,8 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.scenarios.networking.nstat.Nstat
-
-from __future__ import absolute_import
-
-import unittest
-
import mock
+import unittest
from yardstick.benchmark.scenarios.networking import nstat
diff --git a/tests/unit/benchmark/scenarios/networking/test_ping.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_ping.py
index 06353249a..06353249a 100644
--- a/tests/unit/benchmark/scenarios/networking/test_ping.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_ping.py
diff --git a/tests/unit/benchmark/scenarios/networking/test_ping6.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_ping6.py
index d2be6f576..d2be6f576 100644
--- a/tests/unit/benchmark/scenarios/networking/test_ping6.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_ping6.py
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen.py
index 005b53177..acd9027d3 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
#
@@ -9,13 +7,9 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.scenarios.networking.pktgen.Pktgen
-
-from __future__ import absolute_import
-
+import mock
import unittest
-import mock
from oslo_serialization import jsonutils
from yardstick.benchmark.scenarios.networking import pktgen
@@ -127,9 +121,7 @@ class PktgenTestCase(unittest.TestCase):
p.server = mock_ssh.SSH.from_node()
p.client = mock_ssh.SSH.from_node()
- mock_iptables_result = mock.Mock()
- mock_iptables_result.return_value = 149300
- p._iptables_get_result = mock_iptables_result
+ p._iptables_get_result = mock.Mock(return_value=149300)
sample_output = '{"packets_per_second": 9753, "errors": 0, \
"packets_sent": 149776, "packetsize": 60, "flows": 110, "ppm": 3179}'
@@ -154,9 +146,7 @@ class PktgenTestCase(unittest.TestCase):
p.server = mock_ssh.SSH.from_node()
p.client = mock_ssh.SSH.from_node()
- mock_iptables_result = mock.Mock()
- mock_iptables_result.return_value = 149300
- p._iptables_get_result = mock_iptables_result
+ p._iptables_get_result = mock.Mock(return_value=149300)
sample_output = '{"packets_per_second": 9753, "errors": 0, \
"packets_sent": 149776, "packetsize": 60, "flows": 110, "ppm": 3179}'
@@ -181,9 +171,7 @@ class PktgenTestCase(unittest.TestCase):
p.server = mock_ssh.SSH.from_node()
p.client = mock_ssh.SSH.from_node()
- mock_iptables_result = mock.Mock()
- mock_iptables_result.return_value = 149300
- p._iptables_get_result = mock_iptables_result
+ p._iptables_get_result = mock.Mock(return_value=149300)
sample_output = '{"packets_per_second": 9753, "errors": 0, \
"packets_sent": 149776, "packetsize": 60, "flows": 110}'
@@ -314,13 +302,8 @@ class PktgenTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '4', '')
- mock_result1 = mock.Mock()
- mock_result1.return_value = 1
- p._get_usable_queue_number = mock_result1
-
- mock_result2 = mock.Mock()
- mock_result2.return_value = 4
- p._get_available_queue_number = mock_result2
+ p._get_usable_queue_number = mock.Mock(return_value=1)
+ p._get_available_queue_number = mock.Mock(return_value=4)
p.queue_number = p._enable_ovs_multiqueue()
self.assertEqual(p.queue_number, 4)
@@ -335,13 +318,8 @@ class PktgenTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '1', '')
- mock_result1 = mock.Mock()
- mock_result1.return_value = 1
- p._get_usable_queue_number = mock_result1
-
- mock_result2 = mock.Mock()
- mock_result2.return_value = 1
- p._get_available_queue_number = mock_result2
+ p._get_usable_queue_number = mock.Mock(return_value=1)
+ p._get_available_queue_number = mock.Mock(return_value=1)
p.queue_number = p._enable_ovs_multiqueue()
self.assertEqual(p.queue_number, 1)
@@ -356,13 +334,8 @@ class PktgenTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
- mock_result1 = mock.Mock()
- mock_result1.return_value = 1
- p._get_usable_queue_number = mock_result1
-
- mock_result2 = mock.Mock()
- mock_result2.return_value = 4
- p._get_available_queue_number = mock_result2
+ p._get_usable_queue_number = mock.Mock(return_value=1)
+ p._get_available_queue_number = mock.Mock(return_value=4)
self.assertRaises(RuntimeError, p._enable_ovs_multiqueue)
@@ -536,21 +509,10 @@ class PktgenTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '4', '')
- mock_result1 = mock.Mock()
- mock_result1.return_value = False
- p._is_irqbalance_disabled = mock_result1
-
- mock_result2 = mock.Mock()
- mock_result2.return_value = "virtio_net"
- p._get_vnic_driver_name = mock_result2
-
- mock_result3 = mock.Mock()
- mock_result3.return_value = 1
- p._get_usable_queue_number = mock_result3
-
- mock_result4 = mock.Mock()
- mock_result4.return_value = 4
- p._get_available_queue_number = mock_result4
+ p._is_irqbalance_disabled = mock.Mock(return_value=False)
+ p._get_vnic_driver_name = mock.Mock(return_value="virtio_net")
+ p._get_usable_queue_number = mock.Mock(return_value=1)
+ p._get_available_queue_number = mock.Mock(return_value=4)
p.multiqueue_setup()
@@ -566,21 +528,10 @@ class PktgenTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '1', '')
- mock_result1 = mock.Mock()
- mock_result1.return_value = False
- p._is_irqbalance_disabled = mock_result1
-
- mock_result2 = mock.Mock()
- mock_result2.return_value = "virtio_net"
- p._get_vnic_driver_name = mock_result2
-
- mock_result3 = mock.Mock()
- mock_result3.return_value = 1
- p._get_usable_queue_number = mock_result3
-
- mock_result4 = mock.Mock()
- mock_result4.return_value = 1
- p._get_available_queue_number = mock_result4
+ p._is_irqbalance_disabled = mock.Mock(return_value=False)
+ p._get_vnic_driver_name = mock.Mock(return_value="virtio_net")
+ p._get_usable_queue_number = mock.Mock(return_value=1)
+ p._get_available_queue_number = mock.Mock(return_value=1)
p.multiqueue_setup()
@@ -596,13 +547,8 @@ class PktgenTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '2', '')
- mock_result1 = mock.Mock()
- mock_result1.return_value = False
- p._is_irqbalance_disabled = mock_result1
-
- mock_result2 = mock.Mock()
- mock_result2.return_value = "ixgbevf"
- p._get_vnic_driver_name = mock_result2
+ p._is_irqbalance_disabled = mock.Mock(return_value=False)
+ p._get_vnic_driver_name = mock.Mock(return_value="ixgbevf")
p.multiqueue_setup()
@@ -618,13 +564,8 @@ class PktgenTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '1', '')
- mock_result1 = mock.Mock()
- mock_result1.return_value = False
- p._is_irqbalance_disabled = mock_result1
-
- mock_result2 = mock.Mock()
- mock_result2.return_value = "ixgbevf"
- p._get_vnic_driver_name = mock_result2
+ p._is_irqbalance_disabled = mock.Mock(return_value=False)
+ p._get_vnic_driver_name = mock.Mock(return_value="ixgbevf")
p.multiqueue_setup()
@@ -677,28 +618,12 @@ class PktgenTestCase(unittest.TestCase):
p.server = mock_ssh.SSH.from_node()
p.client = mock_ssh.SSH.from_node()
- mock_result = mock.Mock()
- mock_result.return_value = "virtio_net"
- p._get_vnic_driver_name = mock_result
-
- mock_result1 = mock.Mock()
- mock_result1.return_value = 1
- p._get_usable_queue_number = mock_result1
-
- mock_result2 = mock.Mock()
- mock_result2.return_value = 4
- p._get_available_queue_number = mock_result2
-
- mock_result3 = mock.Mock()
- mock_result3.return_value = 4
- p._enable_ovs_multiqueue = mock_result3
-
- mock_result4 = mock.Mock()
- p._setup_irqmapping_ovs = mock_result4
-
- mock_iptables_result = mock.Mock()
- mock_iptables_result.return_value = 149300
- p._iptables_get_result = mock_iptables_result
+ p._get_vnic_driver_name = mock.Mock(return_value="virtio_net")
+ p._get_usable_queue_number = mock.Mock(return_value=1)
+ p._get_available_queue_number = mock.Mock(return_value=4)
+ p._enable_ovs_multiqueue = mock.Mock(return_value=4)
+ p._setup_irqmapping_ovs = mock.Mock()
+ p._iptables_get_result = mock.Mock(return_value=149300)
sample_output = '{"packets_per_second": 9753, "errors": 0, \
"packets_sent": 149300, "flows": 110, "ppm": 0}'
@@ -726,20 +651,10 @@ class PktgenTestCase(unittest.TestCase):
p.server = mock_ssh.SSH.from_node()
p.client = mock_ssh.SSH.from_node()
- mock_result1 = mock.Mock()
- mock_result1.return_value = "ixgbevf"
- p._get_vnic_driver_name = mock_result1
-
- mock_result2 = mock.Mock()
- mock_result2.return_value = 2
- p._get_sriov_queue_number = mock_result2
-
- mock_result3 = mock.Mock()
- p._setup_irqmapping_sriov = mock_result3
-
- mock_iptables_result = mock.Mock()
- mock_iptables_result.return_value = 149300
- p._iptables_get_result = mock_iptables_result
+ p._get_vnic_driver_name = mock.Mock(return_value="ixgbevf")
+ p._get_sriov_queue_number = mock.Mock(return_value=2)
+ p._setup_irqmapping_sriov = mock.Mock()
+ p._iptables_get_result = mock.Mock(return_value=149300)
sample_output = '{"packets_per_second": 9753, "errors": 0, \
"packets_sent": 149300, "flows": 110, "ppm": 0}'
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
index c9eec4b94..99399abdc 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
##############################################################################
# Copyright (c) 2015 ZTE and others.
#
@@ -9,12 +7,8 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.scenarios.networking.pktgen.Pktgen
-
-from __future__ import absolute_import
-import unittest
-
import mock
+import unittest
import yardstick.common.utils as utils
from yardstick.benchmark.scenarios.networking import pktgen_dpdk
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
index c2e35af75..1b12bd507 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
##############################################################################
# Copyright (c) 2017 Nokia and others.
#
@@ -6,7 +7,6 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-#!/usr/bin/env python
# Unittest for yardstick.benchmark.scenarios.networking.pktgen.PktgenDPDK
@@ -19,6 +19,10 @@ import mock
from yardstick.benchmark.scenarios.networking import pktgen_dpdk_throughput
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
@mock.patch('yardstick.benchmark.scenarios.networking.pktgen_dpdk_throughput.ssh')
class PktgenDPDKTestCase(unittest.TestCase):
diff --git a/tests/unit/benchmark/scenarios/networking/test_sfc.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_sfc.py
index 78c0352dd..78c0352dd 100644
--- a/tests/unit/benchmark/scenarios/networking/test_sfc.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_sfc.py
diff --git a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
index 016608a21..fb55b5ea0 100644
--- a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
@@ -26,7 +26,7 @@ import mock
from copy import deepcopy
-from tests.unit import STL_MOCKS
+from yardstick.tests.unit import STL_MOCKS
from yardstick.benchmark.scenarios.networking.vnf_generic import \
SshManager, NetworkServiceTestCase, IncorrectConfig, \
open_relative_file
@@ -35,6 +35,10 @@ from yardstick.network_services.vnf_generic.vnf.base import \
GenericTrafficGen, GenericVNF
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
COMPLETE_TREX_VNFD = {
'vnfd:vnfd-catalog': {
'vnfd': [
@@ -354,7 +358,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
ssh_mock.execute = \
mock.Mock(return_value=(0, SYS_CLASS_NET + IP_ADDR_SHOW, ""))
ssh.from_node.return_value = ssh_mock
- for node, node_dict in self.context_cfg["nodes"].items():
+ for _, node_dict in self.context_cfg["nodes"].items():
with SshManager(node_dict) as conn:
self.assertIsNotNone(conn)
@@ -365,7 +369,8 @@ class TestNetworkServiceTestCase(unittest.TestCase):
self.scenario_cfg["traffic_options"]["flow"] = \
self._get_file_abspath("ipv4_1flow_Packets_vpe.yaml")
result = '152.16.100.2-152.16.100.254'
- self.assertEqual(result, self.s._get_ip_flow_range('152.16.100.2-152.16.100.254'))
+ self.assertEqual(result, self.s._get_ip_flow_range(
+ '152.16.100.2-152.16.100.254'))
def test__get_ip_flow_range(self):
self.scenario_cfg["traffic_options"]["flow"] = \
@@ -397,21 +402,19 @@ class TestNetworkServiceTestCase(unittest.TestCase):
self.scenario_cfg["options"] = {}
self.scenario_cfg['options'] = {
'flow': {
- 'src_ip': [
- {
- 'tg__1': 'xe0',
- },
- ],
- 'dst_ip': [
- {
- 'tg__1': 'xe1',
- },
- ],
- 'public_ip': ['1.1.1.1'],
+ 'src_ip': [
+ {
+ 'tg__1': 'xe0',
+ },
+ ],
+ 'dst_ip': [
+ {
+ 'tg__1': 'xe1',
+ },
+ ],
+ 'public_ip': ['1.1.1.1'],
},
}
- result = {'flow': {'dst_ip0': '152.16.40.2-152.16.40.254',
- 'src_ip0': '152.16.100.2-152.16.100.254'}}
self.assertEqual({'flow': {}}, self.s._get_traffic_flow())
@@ -461,8 +464,10 @@ class TestNetworkServiceTestCase(unittest.TestCase):
self.s.map_topology_to_infrastructure()
nodes = self.context_cfg["nodes"]
- self.assertEqual("../../vnf_descriptors/tg_rfc2544_tpl.yaml", nodes['tg__1']['VNF model'])
- self.assertEqual("../../vnf_descriptors/vpe_vnf.yaml", nodes['vnf__1']['VNF model'])
+ self.assertEqual(
+ "../../vnf_descriptors/tg_rfc2544_tpl.yaml", nodes['tg__1']['VNF model'])
+ self.assertEqual("../../vnf_descriptors/vpe_vnf.yaml",
+ nodes['vnf__1']['VNF model'])
def test_map_topology_to_infrastructure_insufficient_nodes(self):
del self.context_cfg['nodes']['vnf__1']
@@ -499,7 +504,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
del interface['local_mac']
with mock.patch(
- "yardstick.benchmark.scenarios.networking.vnf_generic.LOG") as mock_log:
+ "yardstick.benchmark.scenarios.networking.vnf_generic.LOG"):
with self.assertRaises(IncorrectConfig) as raised:
self.s._resolve_topology()
@@ -514,7 +519,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
self.s.topology["vld"][0]['vnfd-connection-point-ref'][0])
with mock.patch(
- "yardstick.benchmark.scenarios.networking.vnf_generic.LOG") as mock_log:
+ "yardstick.benchmark.scenarios.networking.vnf_generic.LOG"):
with self.assertRaises(IncorrectConfig) as raised:
self.s._resolve_topology()
@@ -525,7 +530,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
self.s.topology["vld"][0]['vnfd-connection-point-ref'][:1]
with mock.patch(
- "yardstick.benchmark.scenarios.networking.vnf_generic.LOG") as mock_log:
+ "yardstick.benchmark.scenarios.networking.vnf_generic.LOG"):
with self.assertRaises(IncorrectConfig) as raised:
self.s._resolve_topology()
@@ -590,7 +595,8 @@ class TestNetworkServiceTestCase(unittest.TestCase):
tgen.name = "tgen__1"
vnf = mock.Mock(autospec=GenericVNF)
vnf.runs_traffic = False
- vnf.instantiate.side_effect = RuntimeError("error during instantiate")
+ vnf.instantiate.side_effect = RuntimeError(
+ "error during instantiate")
vnf.terminate = mock.Mock(return_value=True)
self.s.vnfs = [tgen, vnf]
self.s.traffic_profile = mock.Mock()
@@ -616,7 +622,8 @@ class TestNetworkServiceTestCase(unittest.TestCase):
def test___get_traffic_imix_exception(self):
with mock.patch.dict(self.scenario_cfg["traffic_options"], {'imix': ''}):
- self.assertEqual({'imix': {'64B': 100}}, self.s._get_traffic_imix())
+ self.assertEqual({'imix': {'64B': 100}},
+ self.s._get_traffic_imix())
def test__fill_traffic_profile(self):
with mock.patch.dict("sys.modules", STL_MOCKS):
@@ -641,7 +648,8 @@ class TestNetworkServiceTestCase(unittest.TestCase):
def test_teardown_exception(self):
vnf = mock.Mock(autospec=GenericVNF)
- vnf.terminate = mock.Mock(side_effect=RuntimeError("error duing terminate"))
+ vnf.terminate = mock.Mock(
+ side_effect=RuntimeError("error duing terminate"))
vnf.name = str(vnf)
self.s.vnfs = [vnf]
self.s.traffic_profile = mock.Mock()
@@ -737,6 +745,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
NetworkServiceTestCase._probe_missing_values(netdevs, network)
assert network['vpci'] == '0000:00:19.0'
+ # TODO: Split this into several tests, for different IOError sub-types
def test_open_relative_path(self):
mock_open = mock.mock_open()
mock_open_result = mock_open()
@@ -747,7 +756,8 @@ class TestNetworkServiceTestCase(unittest.TestCase):
# test
with mock.patch(module_name, mock_open, create=True):
- self.assertEqual(open_relative_file('foo', 'bar'), mock_open_result)
+ self.assertEqual(open_relative_file(
+ 'foo', 'bar'), mock_open_result)
mock_open_call_count += 1 # one more call expected
self.assertEqual(mock_open.call_count, mock_open_call_count)
@@ -760,7 +770,8 @@ class TestNetworkServiceTestCase(unittest.TestCase):
raise IOError(errno.ENOENT, 'not found')
mock_open.side_effect = open_effect
- self.assertEqual(open_relative_file('foo', 'bar'), mock_open_result)
+ self.assertEqual(open_relative_file(
+ 'foo', 'bar'), mock_open_result)
mock_open_call_count += 2 # two more calls expected
self.assertEqual(mock_open.call_count, mock_open_call_count)
diff --git a/tests/unit/benchmark/scenarios/networking/test_vsperf.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf.py
index be8ac55d0..be8ac55d0 100644
--- a/tests/unit/benchmark/scenarios/networking/test_vsperf.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf.py
diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
new file mode 100644
index 000000000..1923960e9
--- /dev/null
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
@@ -0,0 +1,221 @@
+# Copyright 2017 Nokia
+#
+# 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 subprocess
+import time
+
+import mock
+import unittest
+
+from yardstick.benchmark.scenarios.networking import vsperf_dpdk
+
+
+class VsperfDPDKTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.ctx = {
+ "host": {
+ "ip": "10.229.47.137",
+ "user": "ubuntu",
+ "password": "ubuntu",
+ },
+ }
+ self.args = {
+ 'task_id': "1234-5678",
+ 'options': {
+ 'testname': 'pvp_tput',
+ 'traffic_type': 'rfc2544_throughput',
+ 'frame_size': '64',
+ 'test_params': 'TRAFFICGEN_DURATION=30;',
+ 'trafficgen_port1': 'ens4',
+ 'trafficgen_port2': 'ens5',
+ 'conf_file': 'vsperf-yardstick.conf',
+ 'setup_script': 'setup_yardstick.sh',
+ 'moongen_helper_file': '~/moongen.py',
+ 'moongen_host_ip': '10.5.201.151',
+ 'moongen_port1_mac': '8c:dc:d4:ae:7c:5c',
+ 'moongen_port2_mac': '8c:dc:d4:ae:7c:5d',
+ 'trafficgen_port1_nw': 'test2',
+ 'trafficgen_port2_nw': 'test3',
+ },
+ 'sla': {
+ 'metrics': 'throughput_rx_fps',
+ 'throughput_rx_fps': 500000,
+ 'action': 'monitor',
+ }
+ }
+
+ self.scenario = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
+
+ self._mock_ssh = mock.patch(
+ 'yardstick.benchmark.scenarios.networking.vsperf_dpdk.ssh')
+ self.mock_ssh = self._mock_ssh.start()
+ self._mock_subprocess_call = mock.patch.object(subprocess, 'call')
+ self.mock_subprocess_call = self._mock_subprocess_call.start()
+
+ self.addCleanup(self._cleanup)
+
+ def _cleanup(self):
+ self._mock_ssh.stop()
+ self._mock_subprocess_call.stop()
+
+ def test_setup(self):
+ # setup() specific mocks
+ self.mock_subprocess_call().execute.return_value = None
+
+ self.scenario.setup()
+ self.assertIsNotNone(self.scenario.client)
+ self.assertTrue(self.scenario.setup_done)
+
+ def test_teardown(self):
+ # setup() specific mocks
+ self.mock_subprocess_call().execute.return_value = None
+
+ self.scenario.setup()
+ self.assertIsNotNone(self.scenario.client)
+ self.assertTrue(self.scenario.setup_done)
+
+ self.scenario.teardown()
+ self.assertFalse(self.scenario.setup_done)
+
+ def test_is_dpdk_setup_no(self):
+ # setup() specific mocks
+ self.mock_subprocess_call().execute.return_value = None
+
+ self.scenario.setup()
+ self.assertIsNotNone(self.scenario.client)
+ self.assertTrue(self.scenario.setup_done)
+
+ # is_dpdk_setup() specific mocks
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, 'dummy', '')
+
+ result = self.scenario._is_dpdk_setup()
+ self.assertFalse(result)
+
+ def test_is_dpdk_setup_yes(self):
+ # setup() specific mocks
+ self.mock_subprocess_call().execute.return_value = None
+
+ self.scenario.setup()
+ self.assertIsNotNone(self.scenario.client)
+ self.assertTrue(self.scenario.setup_done)
+
+ # is_dpdk_setup() specific mocks
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+
+ result = self.scenario._is_dpdk_setup()
+ self.assertTrue(result)
+
+ @mock.patch.object(time, 'sleep')
+ def test_dpdk_setup_first(self, *args):
+ # setup() specific mocks
+ self.mock_subprocess_call().execute.return_value = None
+
+ self.scenario.setup()
+ self.assertIsNotNone(self.scenario.client)
+ self.assertTrue(self.scenario.setup_done)
+
+ # is_dpdk_setup() specific mocks
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, 'dummy', '')
+
+ self.scenario.dpdk_setup()
+ self.assertFalse(self.scenario._is_dpdk_setup())
+ self.assertTrue(self.scenario.dpdk_setup_done)
+
+ @mock.patch.object(time, 'sleep')
+ def test_dpdk_setup_next(self, *args):
+ # setup() specific mocks
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_subprocess_call().execute.return_value = None
+
+ self.scenario.setup()
+ self.assertIsNotNone(self.scenario.client)
+ self.assertTrue(self.scenario.setup_done)
+
+ self.scenario.dpdk_setup()
+ self.assertTrue(self.scenario._is_dpdk_setup())
+ self.assertTrue(self.scenario.dpdk_setup_done)
+
+ @mock.patch.object(time, 'sleep')
+ def test_dpdk_setup_runtime_error(self, *args):
+
+ # setup specific mocks
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_subprocess_call().execute.return_value = None
+
+ self.scenario.setup()
+ self.assertIsNotNone(self.scenario.client)
+ self.mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
+ self.assertTrue(self.scenario.setup_done)
+
+ self.assertRaises(RuntimeError, self.scenario.dpdk_setup)
+
+ @mock.patch.object(subprocess, 'check_output')
+ @mock.patch('time.sleep')
+ def test_run_ok(self, *args):
+ # setup() specific mocks
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_subprocess_call().execute.return_value = None
+
+ self.scenario.setup()
+ self.assertIsNotNone(self.scenario.client)
+ self.assertTrue(self.scenario.setup_done)
+
+ # run() specific mocks
+ self.mock_subprocess_call().execute.return_value = None
+ self.mock_ssh.SSH.from_node().execute.return_value = (
+ 0, 'throughput_rx_fps\r\n14797660.000\r\n', '')
+
+ result = {}
+ self.scenario.run(result)
+
+ self.assertEqual(result['throughput_rx_fps'], '14797660.000')
+
+ def test_run_failed_vsperf_execution(self):
+ # setup() specific mocks
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_subprocess_call().execute.return_value = None
+
+ self.scenario.setup()
+ self.assertIsNotNone(self.scenario.client)
+ self.assertTrue(self.scenario.setup_done)
+
+ self.mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
+
+ result = {}
+ self.assertRaises(RuntimeError, self.scenario.run, result)
+
+ def test_run_falied_csv_report(self):
+ # setup() specific mocks
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_subprocess_call().execute.return_value = None
+
+ self.scenario.setup()
+ self.assertIsNotNone(self.scenario.client)
+ self.assertTrue(self.scenario.setup_done)
+
+ # run() specific mocks
+ self.mock_subprocess_call().execute.return_value = None
+ self.mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
+
+ result = {}
+ self.assertRaises(RuntimeError, self.scenario.run, result)
+
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/benchmark/scenarios/networking/tg_trex_tpl.yaml b/yardstick/tests/unit/benchmark/scenarios/networking/tg_trex_tpl.yaml
index b1641836b..b1641836b 100644
--- a/tests/unit/benchmark/scenarios/networking/tg_trex_tpl.yaml
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/tg_trex_tpl.yaml
diff --git a/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml b/yardstick/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml
index 1ac6c1f89..1ac6c1f89 100644
--- a/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml
diff --git a/tests/unit/benchmark/scenarios/parser/__init__.py b/yardstick/tests/unit/benchmark/scenarios/parser/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/scenarios/parser/__init__.py
+++ b/yardstick/tests/unit/benchmark/scenarios/parser/__init__.py
diff --git a/tests/unit/benchmark/scenarios/parser/test_parser.py b/yardstick/tests/unit/benchmark/scenarios/parser/test_parser.py
index ee2bbc07d..ee2bbc07d 100644
--- a/tests/unit/benchmark/scenarios/parser/test_parser.py
+++ b/yardstick/tests/unit/benchmark/scenarios/parser/test_parser.py
diff --git a/tests/unit/benchmark/scenarios/storage/__init__.py b/yardstick/tests/unit/benchmark/scenarios/storage/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/benchmark/scenarios/storage/__init__.py
+++ b/yardstick/tests/unit/benchmark/scenarios/storage/__init__.py
diff --git a/tests/unit/benchmark/scenarios/storage/fio_read_sample_output.json b/yardstick/tests/unit/benchmark/scenarios/storage/fio_read_sample_output.json
index e9f642aba..e9f642aba 100644
--- a/tests/unit/benchmark/scenarios/storage/fio_read_sample_output.json
+++ b/yardstick/tests/unit/benchmark/scenarios/storage/fio_read_sample_output.json
diff --git a/tests/unit/benchmark/scenarios/storage/fio_rw_sample_output.json b/yardstick/tests/unit/benchmark/scenarios/storage/fio_rw_sample_output.json
index 4c7501818..4c7501818 100644
--- a/tests/unit/benchmark/scenarios/storage/fio_rw_sample_output.json
+++ b/yardstick/tests/unit/benchmark/scenarios/storage/fio_rw_sample_output.json
diff --git a/tests/unit/benchmark/scenarios/storage/fio_write_sample_output.json b/yardstick/tests/unit/benchmark/scenarios/storage/fio_write_sample_output.json
index 7c760e8bc..7c760e8bc 100644
--- a/tests/unit/benchmark/scenarios/storage/fio_write_sample_output.json
+++ b/yardstick/tests/unit/benchmark/scenarios/storage/fio_write_sample_output.json
diff --git a/tests/unit/benchmark/scenarios/storage/test_bonnie.py b/yardstick/tests/unit/benchmark/scenarios/storage/test_bonnie.py
index b3524e9a7..b98dceae7 100644
--- a/tests/unit/benchmark/scenarios/storage/test_bonnie.py
+++ b/yardstick/tests/unit/benchmark/scenarios/storage/test_bonnie.py
@@ -17,7 +17,6 @@ import unittest
import mock
-from yardstick.common import utils
from yardstick.benchmark.scenarios.storage import bonnie
@@ -67,8 +66,10 @@ class BonnieTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, b.run, self.result)
+
def main():
unittest.main()
+
if __name__ == '__main__':
main()
diff --git a/tests/unit/benchmark/scenarios/storage/test_fio.py b/yardstick/tests/unit/benchmark/scenarios/storage/test_fio.py
index 0cffea224..0cffea224 100644
--- a/tests/unit/benchmark/scenarios/storage/test_fio.py
+++ b/yardstick/tests/unit/benchmark/scenarios/storage/test_fio.py
diff --git a/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py b/yardstick/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py
index 095674f72..095674f72 100644
--- a/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py
+++ b/yardstick/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py
diff --git a/tests/unit/benchmark/scenarios/storage/test_storperf.py b/yardstick/tests/unit/benchmark/scenarios/storage/test_storperf.py
index 7b16bb37d..52786d7cb 100644
--- a/tests/unit/benchmark/scenarios/storage/test_storperf.py
+++ b/yardstick/tests/unit/benchmark/scenarios/storage/test_storperf.py
@@ -21,8 +21,12 @@ from oslo_serialization import jsonutils
from yardstick.benchmark.scenarios.storage import storperf
+# pylint: disable=unused-argument
+# disable this for now because I keep forgetting mock patch arg ordering
+
+
def mocked_requests_config_post(*args, **kwargs):
- class MockResponseConfigPost:
+ class MockResponseConfigPost(object):
def __init__(self, json_data, status_code):
self.content = json_data
@@ -35,7 +39,7 @@ def mocked_requests_config_post(*args, **kwargs):
def mocked_requests_config_get(*args, **kwargs):
- class MockResponseConfigGet:
+ class MockResponseConfigGet(object):
def __init__(self, json_data, status_code):
self.content = json_data
@@ -48,7 +52,7 @@ def mocked_requests_config_get(*args, **kwargs):
def mocked_requests_job_get(*args, **kwargs):
- class MockResponseJobGet:
+ class MockResponseJobGet(object):
def __init__(self, json_data, status_code):
self.content = json_data
@@ -61,7 +65,7 @@ def mocked_requests_job_get(*args, **kwargs):
def mocked_requests_job_post(*args, **kwargs):
- class MockResponseJobPost:
+ class MockResponseJobPost(object):
def __init__(self, json_data, status_code):
self.content = json_data
@@ -72,7 +76,7 @@ def mocked_requests_job_post(*args, **kwargs):
def mocked_requests_job_delete(*args, **kwargs):
- class MockResponseJobDelete:
+ class MockResponseJobDelete(object):
def __init__(self, json_data, status_code):
self.content = json_data
@@ -82,7 +86,7 @@ def mocked_requests_job_delete(*args, **kwargs):
def mocked_requests_delete(*args, **kwargs):
- class MockResponseDelete:
+ class MockResponseDelete(object):
def __init__(self, json_data, status_code):
self.json_data = json_data
@@ -92,7 +96,7 @@ def mocked_requests_delete(*args, **kwargs):
def mocked_requests_delete_failed(*args, **kwargs):
- class MockResponseDeleteFailed:
+ class MockResponseDeleteFailed(object):
def __init__(self, json_data, status_code):
self.json_data = json_data
diff --git a/tests/unit/benchmark/scenarios/test_base.py b/yardstick/tests/unit/benchmark/scenarios/test_base.py
index a95e6bc86..a95e6bc86 100644
--- a/tests/unit/benchmark/scenarios/test_base.py
+++ b/yardstick/tests/unit/benchmark/scenarios/test_base.py