aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/ci/prepare_env.sh27
-rw-r--r--tests/unit/benchmark/__init__.py0
-rw-r--r--tests/unit/benchmark/contexts/__init__.py0
-rw-r--r--tests/unit/benchmark/contexts/nodes_duplicate_sample.yaml21
-rw-r--r--tests/unit/benchmark/contexts/nodes_duplicate_sample_new.yaml32
-rw-r--r--tests/unit/benchmark/contexts/nodes_duplicate_sample_ovs.yaml63
-rw-r--r--tests/unit/benchmark/contexts/nodes_sample.yaml33
-rw-r--r--tests/unit/benchmark/contexts/nodes_sample_new.yaml96
-rw-r--r--tests/unit/benchmark/contexts/nodes_sample_new_sriov.yaml82
-rw-r--r--tests/unit/benchmark/contexts/nodes_sample_ovs.yaml104
-rw-r--r--tests/unit/benchmark/contexts/nodes_sample_ovsdpdk.yaml104
-rw-r--r--tests/unit/benchmark/contexts/standalone/__init__.py0
-rw-r--r--tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml37
-rw-r--r--tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml40
-rw-r--r--tests/unit/benchmark/contexts/standalone/nodes_sample.yaml33
-rw-r--r--tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml40
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_model.py435
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py370
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_sriov.py318
-rw-r--r--tests/unit/benchmark/contexts/standalone_duplicate_sample.yaml135
-rw-r--r--tests/unit/benchmark/contexts/standalone_sample.yaml112
-rw-r--r--tests/unit/benchmark/contexts/test_dummy.py32
-rw-r--r--tests/unit/benchmark/contexts/test_heat.py503
-rw-r--r--tests/unit/benchmark/contexts/test_kubernetes.py205
-rw-r--r--tests/unit/benchmark/contexts/test_model.py589
-rw-r--r--tests/unit/benchmark/contexts/test_node.py398
-rw-r--r--tests/unit/benchmark/core/__init__.py0
-rw-r--r--tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml21
-rw-r--r--tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml23
-rw-r--r--tests/unit/benchmark/core/test_plugin.py102
-rw-r--r--tests/unit/benchmark/core/test_report.py72
-rw-r--r--tests/unit/benchmark/core/test_task.py314
-rw-r--r--tests/unit/benchmark/core/test_testcase.py45
-rw-r--r--tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml24
-rw-r--r--tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml26
-rw-r--r--tests/unit/benchmark/runner/__init__.py0
-rw-r--r--tests/unit/benchmark/runner/test_base.py95
-rw-r--r--tests/unit/benchmark/runner/test_search.py204
-rw-r--r--tests/unit/benchmark/scenarios/__init__.py0
-rw-r--r--tests/unit/benchmark/scenarios/availability/__init__.py0
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py84
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_attacker_general.py58
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_attacker_process.py55
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_basemonitor.py125
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_baseoperation.py87
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py93
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_director.py104
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_command.py92
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_general.py80
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_multi.py61
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_process.py59
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_operation_general.py72
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_result_checker_general.py116
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_scenario_general.py71
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_serviceha.py79
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_util.py58
-rw-r--r--tests/unit/benchmark/scenarios/compute/__init__.py0
-rw-r--r--tests/unit/benchmark/scenarios/compute/cachestat_sample_output.txt5
-rw-r--r--tests/unit/benchmark/scenarios/compute/cpuload_sample_output1.txt9
-rw-r--r--tests/unit/benchmark/scenarios/compute/cpuload_sample_output2.txt2
-rw-r--r--tests/unit/benchmark/scenarios/compute/memload_sample_output.txt3
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_cachestat.py97
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_computecapacity.py66
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_cpuload.py264
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_cyclictest.py175
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_lmbench.py198
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_memload.py119
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_plugintest.py62
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_qemumigrate.py166
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_ramspeed.py244
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_spec_cpu.py86
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_spec_cpu_for_vm.py84
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_unixbench.py171
-rw-r--r--tests/unit/benchmark/scenarios/dummy/__init__.py0
-rw-r--r--tests/unit/benchmark/scenarios/dummy/test_dummy.py34
-rw-r--r--tests/unit/benchmark/scenarios/lib/__init__.py0
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_add_memory_load.py65
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_attach_volume.py33
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_check_connectivity.py84
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_check_numa_info.py85
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_check_value.py46
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_flavor.py37
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_floating_ip.py34
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_image.py41
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_keypair.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_network.py39
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_port.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_router.py39
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_sec_group.py39
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_server.py42
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_subnet.py41
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_volume.py91
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_flavor.py35
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_floating_ip.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_image.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_keypair.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_network.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_port.py34
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_router.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py37
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_server.py35
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_volume.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_detach_volume.py35
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_get_flavor.py33
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_get_migrate_target_host.py51
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_get_numa_info.py106
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_get_server.py50
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_get_server_ip.py41
-rw-r--r--tests/unit/benchmark/scenarios/networking/__init__.py0
-rw-r--r--tests/unit/benchmark/scenarios/networking/imix_voice.yaml41
-rw-r--r--tests/unit/benchmark/scenarios/networking/iperf3_sample_output.json1
-rw-r--r--tests/unit/benchmark/scenarios/networking/iperf3_sample_output_udp.json1
-rw-r--r--tests/unit/benchmark/scenarios/networking/ipv4_1flow_Packets_vpe.yaml18
-rw-r--r--tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml101
-rwxr-xr-xtests/unit/benchmark/scenarios/networking/netperf_sample_output.json1
-rw-r--r--tests/unit/benchmark/scenarios/networking/netutilization_sample_output1.txt9
-rw-r--r--tests/unit/benchmark/scenarios/networking/netutilization_sample_output2.txt13
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_iperf3.py202
-rwxr-xr-xtests/unit/benchmark/scenarios/networking/test_netperf.py130
-rwxr-xr-xtests/unit/benchmark/scenarios/networking/test_netperf_node.py130
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_netutilization.py227
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_networkcapacity.py61
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_nstat.py120
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_ping.py101
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_ping6.py125
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen.py760
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py192
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py198
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_sfc.py77
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vnf_generic.py787
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vsperf.py136
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py244
-rw-r--r--tests/unit/benchmark/scenarios/networking/tg_trex_tpl.yaml75
-rw-r--r--tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml50
-rw-r--r--tests/unit/benchmark/scenarios/parser/__init__.py0
-rw-r--r--tests/unit/benchmark/scenarios/parser/test_parser.py79
-rw-r--r--tests/unit/benchmark/scenarios/storage/__init__.py0
-rw-r--r--tests/unit/benchmark/scenarios/storage/fio_read_sample_output.json1
-rw-r--r--tests/unit/benchmark/scenarios/storage/fio_rw_sample_output.json1
-rw-r--r--tests/unit/benchmark/scenarios/storage/fio_write_sample_output.json1
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_bonnie.py74
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_fio.py273
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_storagecapacity.py108
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_storperf.py238
-rw-r--r--tests/unit/benchmark/scenarios/test_base.py53
-rw-r--r--tests/unit/network_services/helpers/test_dpdkbindnic_helper.py2
-rw-r--r--tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py58
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_binsearch.py94
-rw-r--r--tests/unit/network_services/traffic_profile/test_traffic_profile.py237
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py16
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py26
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py10
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py53
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py11
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py12
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py15
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py7
159 files changed, 332 insertions, 14150 deletions
diff --git a/tests/ci/prepare_env.sh b/tests/ci/prepare_env.sh
index 262b74c09..caef8acce 100755
--- a/tests/ci/prepare_env.sh
+++ b/tests/ci/prepare_env.sh
@@ -85,37 +85,36 @@ verify_connectivity() {
ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
if [ "$INSTALLER_TYPE" == "fuel" ]; then
- #ip_fuel="10.20.0.2"
+
+ # check the connection
verify_connectivity $INSTALLER_IP
+ pod_yaml="$YARDSTICK_REPO_DIR/etc/yardstick/nodes/fuel_baremetal/pod.yaml"
+
+ # update "ip" according to the CI env
ssh -l ubuntu ${INSTALLER_IP} -i ${SSH_KEY} ${ssh_options} \
"sudo salt -C 'ctl* or cmp*' grains.get fqdn_ip4 --out yaml">node_info
- # update node ip info according to the CI env
controller_ips=($(cat node_info|awk '/ctl/{getline; print $2}'))
compute_ips=($(cat node_info|awk '/cmp/{getline; print $2}'))
- pod_yaml="./etc/yardstick/nodes/fuel_baremetal/pod.yaml"
- node_line_num=($(grep -n node[1-5] $pod_yaml | awk -F: '{print $1}'))
- node_ID=0;
-
- # update 'user' and 'key_filename' according to CI env
- sed -i "s|node_username|${USER_NAME}|;s|node_keyfile|${SSH_KEY}|" $pod_yaml;
-
if [[ ${controller_ips[0]} ]]; then
- sed -i "${node_line_num[0]}s/node1/node$((++node_ID))/;s/ip1/${controller_ips[0]}/" $pod_yaml;
+ sed -i "s|ip1|${controller_ips[0]}|" $pod_yaml;
fi
if [[ ${controller_ips[1]} ]]; then
- sed -i "${node_line_num[1]}s/node2/node$((++node_ID))/;s/ip2/${controller_ips[1]}/" $pod_yaml;
+ sed -i "s|ip2|${controller_ips[1]}|" $pod_yaml;
fi
if [[ ${controller_ips[2]} ]]; then
- sed -i "${node_line_num[2]}s/node3/node$((++node_ID))/;s/ip3/${controller_ips[2]}/" $pod_yaml;
+ sed -i "s|ip3|${controller_ips[2]}|" $pod_yaml;
fi
if [[ ${compute_ips[0]} ]]; then
- sed -i "${node_line_num[3]}s/node4/node$((++node_ID))/;s/ip4/${compute_ips[0]}/" $pod_yaml;
+ sed -i "s|ip4|${compute_ips[0]}|" $pod_yaml;
fi
if [[ ${compute_ips[1]} ]]; then
- sed -i "${node_line_num[4]}s/node5/node$((++node_ID))/;s/ip5/${compute_ips[1]}/" $pod_yaml;
+ sed -i "s|ip5|${compute_ips[1]}|" $pod_yaml;
fi
+ # update 'user' and 'key_filename' according to the CI env
+ sed -i "s|node_username|${USER_NAME}|;s|node_keyfile|${SSH_KEY}|" $pod_yaml;
+
fi
diff --git a/tests/unit/benchmark/__init__.py b/tests/unit/benchmark/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/contexts/__init__.py b/tests/unit/benchmark/contexts/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/contexts/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/contexts/nodes_duplicate_sample.yaml b/tests/unit/benchmark/contexts/nodes_duplicate_sample.yaml
deleted file mode 100644
index dbdd3700d..000000000
--- a/tests/unit/benchmark/contexts/nodes_duplicate_sample.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-nodes:
--
- name: node1
- role: Controller
- ip: 10.229.47.137
- user: root
- key_filename: /root/.yardstick_key
--
- name: node1
- role: Controller
- ip: 10.229.47.138
- user: root
- key_filename: /root/.yardstick_key
diff --git a/tests/unit/benchmark/contexts/nodes_duplicate_sample_new.yaml b/tests/unit/benchmark/contexts/nodes_duplicate_sample_new.yaml
deleted file mode 100644
index 306915ca1..000000000
--- a/tests/unit/benchmark/contexts/nodes_duplicate_sample_new.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-nodes:
--
- name: sriov
- role: Sriov1
- ip: 10.123.123.122
- user: root
- auth_type: password
- password: password
- vf_macs:
- - "00:00:00:00:00:00"
- - "00:00:00:00:00:00"
- phy_ports: # Physical ports to configure sriov
- - "0000:06:00.0"
- - "0000:06:00.1"
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu1.img"
--
- name: sriov
- role: Sriov1
- ip: 10.123.123.111
- user: root
- auth_type: password
- password: password
- vf_macs:
- - "00:00:00:00:00:00"
- - "00:00:00:00:00:00"
- phy_ports: # Physical ports to configure sriov
- - "0000:06:00.0"
- - "0000:06:00.1"
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu1.img"
-
diff --git a/tests/unit/benchmark/contexts/nodes_duplicate_sample_ovs.yaml b/tests/unit/benchmark/contexts/nodes_duplicate_sample_ovs.yaml
deleted file mode 100644
index 65449c91c..000000000
--- a/tests/unit/benchmark/contexts/nodes_duplicate_sample_ovs.yaml
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright (c) 2016 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-nodes:
--
- name: ovs
- role: test
- ip: 10.223.197.222
- user: root
- auth_type: password
- password: intel123
- vpath: "/usr/local/"
- vports:
- - dpdkvhostuser0
- - dpdkvhostuser1
- vports_mac:
- - "00:00:00:00:00:03"
- - "00:00:00:00:00:04"
- phy_ports: # Physical ports to configure ovs
- - "0000:06:00.0"
- - "0000:06:00.1"
- flow:
- - ovs-ofctl add-flow br0 in_port=1,action=output:3
- - ovs-ofctl add-flow br0 in_port=3,action=output:1
- - ovs-ofctl add-flow br0 in_port=4,action=output:2
- - ovs-ofctl add-flow br0 in_port=2,action=output:4
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu1.img"
--
- name: ovs
- role: test
- ip: 10.223.197.112
- user: root
- auth_type: password
- password: intel123
- vpath: "/usr/local/"
- vports:
- - dpdkvhostuser0
- - dpdkvhostuser1
- vports_mac:
- - "00:00:00:00:00:03"
- - "00:00:00:00:00:04"
- phy_ports: # Physical ports to configure ovs
- - "0000:06:00.0"
- - "0000:06:00.1"
- flow:
- - ovs-ofctl add-flow br0 in_port=1,action=output:3
- - ovs-ofctl add-flow br0 in_port=3,action=output:1
- - ovs-ofctl add-flow br0 in_port=4,action=output:2
- - ovs-ofctl add-flow br0 in_port=2,action=output:4
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu1.img"
-
diff --git a/tests/unit/benchmark/contexts/nodes_sample.yaml b/tests/unit/benchmark/contexts/nodes_sample.yaml
deleted file mode 100644
index 8d50c3aea..000000000
--- a/tests/unit/benchmark/contexts/nodes_sample.yaml
+++ /dev/null
@@ -1,33 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-nodes:
--
- name: node1
- role: Controller
- ip: 10.229.47.137
- user: root
- key_filename: /root/.yardstick_key
--
- name: node2
- role: Controller
- ip: 10.229.47.138
- user: root
- key_filename: /root/.yardstick_key
--
- name: node3
- role: Compute
- ip: 10.229.47.139
- user: root
- key_filename: /root/.yardstick_key
--
- name: node4
- role: Baremetal
- ip: 10.229.47.140
- user: root
- key_filename: /root/.yardstick_key
diff --git a/tests/unit/benchmark/contexts/nodes_sample_new.yaml b/tests/unit/benchmark/contexts/nodes_sample_new.yaml
deleted file mode 100644
index a400bec03..000000000
--- a/tests/unit/benchmark/contexts/nodes_sample_new.yaml
+++ /dev/null
@@ -1,96 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-nodes:
--
- name: trafficgen_1
- role: TrafficGen
- ip: 10.123.123.123
- user: root
- auth_type: password
- password: password
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:03:00.0"
- driver: ixgbe
- dpdk_port_num: 0
- local_ip: "152.16.100.20"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:00"
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:03:00.1"
- driver: ixgbe
- dpdk_port_num: 1
- local_ip: "152.16.100.21"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:00"
--
- name: sriov
- role: Sriov
- ip: 10.123.123.122
- user: root
- auth_type: password
- password: password
- vf_macs:
- - "00:00:00:00:00:00"
- - "00:00:00:00:00:00"
- phy_ports: # Physical ports to configure sriov
- - "0000:06:00.0"
- - "0000:06:00.1"
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu1.img"
-
--
- name: vnf
- role: vnf
- ip: 10.123.123.121
- user: root
- auth_type: password
- password: password
- host: 10.123.123.121 #BM host == ip, SRIOV & ovs-dpdk host == compute node.
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:06:00.0"
- driver: i40e
- dpdk_port_num: 0
- local_ip: "152.16.100.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:00"
-
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:06:00.1"
- driver: i40e
- dpdk_port_num: 1
- local_ip: "152.16.40.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:00"
- routing_table:
- - network: "152.16.100.20"
- netmask: "255.255.255.0"
- gateway: "152.16.100.20"
- if: "xe0"
- - network: "152.16.40.20"
- netmask: "255.255.255.0"
- gateway: "152.16.40.20"
- if: "xe1"
- nd_route_tbl:
- - network: "0064:ff9b:0:0:0:0:9810:6414"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:6414"
- if: "xe0"
- - network: "0064:ff9b:0:0:0:0:9810:2814"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:2814"
- if: "xe1"
-
diff --git a/tests/unit/benchmark/contexts/nodes_sample_new_sriov.yaml b/tests/unit/benchmark/contexts/nodes_sample_new_sriov.yaml
deleted file mode 100644
index 55ff2e778..000000000
--- a/tests/unit/benchmark/contexts/nodes_sample_new_sriov.yaml
+++ /dev/null
@@ -1,82 +0,0 @@
-nodes:
--
- name: trafficgen_1
- role: TrafficGen
- ip: 10.123.123.123
- user: root
- auth_type: password
- password: password
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:03:00.0"
- driver: ixgbe
- dpdk_port_num: 0
- local_ip: "152.16.100.20"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:00"
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:03:00.1"
- driver: ixgbe
- dpdk_port_num: 1
- local_ip: "152.16.100.21"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:00"
--
- name: sriov
- role: Sriov1
- ip: 10.123.123.122
- user: root
- auth_type: password
- password: password
- vf_macs:
- - "00:00:00:00:00:00"
- - "00:00:00:00:00:00"
- phy_ports: # Physical ports to configure sriov
- - "0000:06:00.0"
- - "0000:06:00.1"
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu1.img"
-
--
- name: vnf
- role: vnf
- ip: 10.123.123.121
- user: root
- auth_type: password
- password: password
- host: 10.123.123.121 #BM host == ip, SRIOV & ovs-dpdk host == compute node.
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:06:00.0"
- driver: i40e
- dpdk_port_num: 0
- local_ip: "152.16.100.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:00"
-
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:06:00.1"
- driver: i40e
- dpdk_port_num: 1
- local_ip: "152.16.40.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:00"
- routing_table:
- - network: "152.16.100.20"
- netmask: "255.255.255.0"
- gateway: "152.16.100.20"
- if: "xe0"
- - network: "152.16.40.20"
- netmask: "255.255.255.0"
- gateway: "152.16.40.20"
- if: "xe1"
- nd_route_tbl:
- - network: "0064:ff9b:0:0:0:0:9810:6414"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:6414"
- if: "xe0"
- - network: "0064:ff9b:0:0:0:0:9810:2814"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:2814"
- if: "xe1"
-
diff --git a/tests/unit/benchmark/contexts/nodes_sample_ovs.yaml b/tests/unit/benchmark/contexts/nodes_sample_ovs.yaml
deleted file mode 100644
index b1da1ea9f..000000000
--- a/tests/unit/benchmark/contexts/nodes_sample_ovs.yaml
+++ /dev/null
@@ -1,104 +0,0 @@
-# Copyright (c) 2016 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-nodes:
--
- name: trafficgen_1
- role: TrafficGen
- ip: 10.223.197.182
- user: root
- auth_type: password
- password: intel123
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:03:00.0"
- driver: ixgbe
- dpdk_port_num: 0
- local_ip: "152.16.100.20"
- netmask: "255.255.255.0"
- local_mac: "90:e2:ba:77:ce:68"
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:03:00.1"
- driver: ixgbe
- dpdk_port_num: 1
- local_ip: "152.16.100.21"
- netmask: "255.255.255.0"
- local_mac: "90:e2:ba:77:ce:69"
--
- name: ovs
- role: Ovsdpdk
- ip: 10.223.197.222
- user: root
- auth_type: password
- password: intel123
- vpath: "/usr/local/"
- vports:
- - dpdkvhostuser0
- - dpdkvhostuser1
- vports_mac:
- - "00:00:00:00:00:03"
- - "00:00:00:00:00:04"
- phy_ports: # Physical ports to configure ovs
- - "0000:06:00.0"
- - "0000:06:00.1"
- flow:
- - ovs-ofctl add-flow br0 in_port=1,action=output:3
- - ovs-ofctl add-flow br0 in_port=3,action=output:1
- - ovs-ofctl add-flow br0 in_port=4,action=output:2
- - ovs-ofctl add-flow br0 in_port=2,action=output:4
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu1.img"
-
--
- name: vnf
- role: vnf
- ip: 10.223.197.155
- user: root
- auth_type: password
- password: intel123
- host: 10.223.197.140
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:00:04.0"
- driver: virtio-pci
- dpdk_port_num: 0
- local_ip: "152.16.100.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:03"
-
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:00:05.0"
- driver: virtio-pci
- dpdk_port_num: 1
- local_ip: "152.16.40.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:04"
- routing_table:
- - network: "152.16.100.20"
- netmask: "255.255.255.0"
- gateway: "152.16.100.20"
- if: "xe0"
- - network: "152.16.40.20"
- netmask: "255.255.255.0"
- gateway: "152.16.40.20"
- if: "xe1"
- nd_route_tbl:
- - network: "0064:ff9b:0:0:0:0:9810:6414"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:6414"
- if: "xe0"
- - network: "0064:ff9b:0:0:0:0:9810:2814"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:2814"
- if: "xe1"
diff --git a/tests/unit/benchmark/contexts/nodes_sample_ovsdpdk.yaml b/tests/unit/benchmark/contexts/nodes_sample_ovsdpdk.yaml
deleted file mode 100644
index c02849a05..000000000
--- a/tests/unit/benchmark/contexts/nodes_sample_ovsdpdk.yaml
+++ /dev/null
@@ -1,104 +0,0 @@
-# Copyright (c) 2016 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-nodes:
--
- name: trafficgen_1
- role: TrafficGen
- ip: 10.223.197.182
- user: root
- auth_type: password
- password: intel123
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:03:00.0"
- driver: ixgbe
- dpdk_port_num: 0
- local_ip: "152.16.100.20"
- netmask: "255.255.255.0"
- local_mac: "90:e2:ba:77:ce:68"
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:03:00.1"
- driver: ixgbe
- dpdk_port_num: 1
- local_ip: "152.16.100.21"
- netmask: "255.255.255.0"
- local_mac: "90:e2:ba:77:ce:69"
--
- name: ovs
- role: Ovsdpdk1
- ip: 10.223.197.222
- user: root
- auth_type: password
- password: intel123
- vpath: "/usr/local/"
- vports:
- - dpdkvhostuser0
- - dpdkvhostuser1
- vports_mac:
- - "00:00:00:00:00:03"
- - "00:00:00:00:00:04"
- phy_ports: # Physical ports to configure ovs
- - "0000:06:00.0"
- - "0000:06:00.1"
- flow:
- - ovs-ofctl add-flow br0 in_port=1,action=output:3
- - ovs-ofctl add-flow br0 in_port=3,action=output:1
- - ovs-ofctl add-flow br0 in_port=4,action=output:2
- - ovs-ofctl add-flow br0 in_port=2,action=output:4
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu1.img"
-
--
- name: vnf
- role: vnf
- ip: 10.223.197.155
- user: root
- auth_type: password
- password: intel123
- host: 10.223.197.140
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:00:04.0"
- driver: virtio-pci
- dpdk_port_num: 0
- local_ip: "152.16.100.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:03"
-
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:00:05.0"
- driver: virtio-pci
- dpdk_port_num: 1
- local_ip: "152.16.40.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:04"
- routing_table:
- - network: "152.16.100.20"
- netmask: "255.255.255.0"
- gateway: "152.16.100.20"
- if: "xe0"
- - network: "152.16.40.20"
- netmask: "255.255.255.0"
- gateway: "152.16.40.20"
- if: "xe1"
- nd_route_tbl:
- - network: "0064:ff9b:0:0:0:0:9810:6414"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:6414"
- if: "xe0"
- - network: "0064:ff9b:0:0:0:0:9810:2814"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:2814"
- if: "xe1"
diff --git a/tests/unit/benchmark/contexts/standalone/__init__.py b/tests/unit/benchmark/contexts/standalone/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/contexts/standalone/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml b/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml
deleted file mode 100644
index 2e501a6af..000000000
--- a/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml
+++ /dev/null
@@ -1,37 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-nodes:
--
- name: node1
- role: Controller
- ip: 10.229.47.137
- user: root
- key_filename: /root/.yardstick_key
--
- name: node1
- role: Controller
- ip: 10.229.47.138
- user: root
- key_filename: /root/.yardstick_key
-
--
- name: node5
- role: Sriov
- ip: 10.229.47.140
- user: root
- password: password
- key_filename: /root/.yardstick_key
-
--
- name: node5
- role: OvsDpdk
- ip: 10.229.47.140
- user: root
- password: password
- key_filename: /root/.yardstick_key
diff --git a/tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml b/tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml
deleted file mode 100644
index 0f51dbe63..000000000
--- a/tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml
+++ /dev/null
@@ -1,40 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-nodes:
--
- name: node1
- role: Controller
- ip: 10.229.47.137
- user: root
- key_filename: /root/.yardstick_key
--
- name: node2
- role: Controller
- ip: 10.229.47.138
- user: root
- key_filename: /root/.yardstick_key
--
- name: node3
- role: Compute
- ip: 10.229.47.139
- user: root
- key_filename: /root/.yardstick_key
--
- name: node4
- role: Baremetal
- ip: 10.229.47.140
- user: root
- key_filename: /root/.yardstick_key
--
- name: node5
- role: OvsDpdk
- ip: 10.229.47.140
- user: root
- password: password
- key_filename: /root/.yardstick_key
diff --git a/tests/unit/benchmark/contexts/standalone/nodes_sample.yaml b/tests/unit/benchmark/contexts/standalone/nodes_sample.yaml
deleted file mode 100644
index 8d50c3aea..000000000
--- a/tests/unit/benchmark/contexts/standalone/nodes_sample.yaml
+++ /dev/null
@@ -1,33 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-nodes:
--
- name: node1
- role: Controller
- ip: 10.229.47.137
- user: root
- key_filename: /root/.yardstick_key
--
- name: node2
- role: Controller
- ip: 10.229.47.138
- user: root
- key_filename: /root/.yardstick_key
--
- name: node3
- role: Compute
- ip: 10.229.47.139
- user: root
- key_filename: /root/.yardstick_key
--
- name: node4
- role: Baremetal
- ip: 10.229.47.140
- user: root
- key_filename: /root/.yardstick_key
diff --git a/tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml b/tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml
deleted file mode 100644
index 1c43b8725..000000000
--- a/tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml
+++ /dev/null
@@ -1,40 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-nodes:
--
- name: node1
- role: Controller
- ip: 10.229.47.137
- user: root
- key_filename: /root/.yardstick_key
--
- name: node2
- role: Controller
- ip: 10.229.47.138
- user: root
- key_filename: /root/.yardstick_key
--
- name: node3
- role: Compute
- ip: 10.229.47.139
- user: root
- key_filename: /root/.yardstick_key
--
- name: node4
- role: Baremetal
- ip: 10.229.47.140
- user: root
- key_filename: /root/.yardstick_key
--
- name: node5
- role: Sriov
- ip: 10.229.47.140
- user: root
- password: password
- key_filename: /root/.yardstick_key
diff --git a/tests/unit/benchmark/contexts/standalone/test_model.py b/tests/unit/benchmark/contexts/standalone/test_model.py
deleted file mode 100644
index 6090356b6..000000000
--- a/tests/unit/benchmark/contexts/standalone/test_model.py
+++ /dev/null
@@ -1,435 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import copy
-import os
-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
-
-
-XML_SAMPLE = """<?xml version="1.0"?>
-<domain type="kvm">
- <devices>
- </devices>
-</domain>
-"""
-
-XML_SAMPLE_INTERFACE = """<?xml version="1.0"?>
-<domain type="kvm">
- <devices>
- <interface>
- </interface>
- </devices>
-</domain>
-"""
-
-class ModelLibvirtTestCase(unittest.TestCase):
-
- def setUp(self):
- self.xml = ElementTree.ElementTree(
- element=ElementTree.fromstring(XML_SAMPLE))
- self.pci_address_str = '0001:04:03.2'
- self.pci_address = utils.PciAddress(self.pci_address_str)
- self.mac = '00:00:00:00:00:01'
- self._mock_write_xml = mock.patch.object(ElementTree.ElementTree,
- 'write')
- self.mock_write_xml = self._mock_write_xml.start()
-
- self.addCleanup(self._cleanup)
-
- def _cleanup(self):
- self._mock_write_xml.stop()
-
- def test_check_if_vm_exists_and_delete(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
- # NOTE(ralonsoh): this test doesn't cover function execution.
- model.Libvirt.check_if_vm_exists_and_delete("vm_0", ssh_mock)
-
- def test_virsh_create_vm(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
- # NOTE(ralonsoh): this test doesn't cover function execution.
- model.Libvirt.virsh_create_vm(ssh_mock, "vm_0")
-
- def test_virsh_destroy_vm(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
- # NOTE(ralonsoh): this test doesn't cover function execution.
- model.Libvirt.virsh_destroy_vm("vm_0", ssh_mock)
-
- def test_add_interface_address(self):
- xml = ElementTree.ElementTree(
- element=ElementTree.fromstring(XML_SAMPLE_INTERFACE))
- interface = xml.find('devices').find('interface')
- result = model.Libvirt._add_interface_address(interface, self.pci_address)
- self.assertEqual('pci', result.get('type'))
- self.assertEqual('0x{}'.format(self.pci_address.domain),
- result.get('domain'))
- self.assertEqual('0x{}'.format(self.pci_address.bus),
- result.get('bus'))
- self.assertEqual('0x{}'.format(self.pci_address.slot),
- result.get('slot'))
- self.assertEqual('0x{}'.format(self.pci_address.function),
- result.get('function'))
-
- def test_add_ovs_interfaces(self):
- xml_input = mock.Mock()
- with mock.patch.object(ElementTree, 'parse', return_value=self.xml) \
- as mock_parse:
- xml = copy.deepcopy(self.xml)
- mock_parse.return_value = xml
- model.Libvirt.add_ovs_interface(
- '/usr/local', 0, self.pci_address_str, self.mac, xml_input)
- mock_parse.assert_called_once_with(xml_input)
- self.mock_write_xml.assert_called_once_with(xml_input)
- interface = xml.find('devices').find('interface')
- self.assertEqual('vhostuser', interface.get('type'))
- mac = interface.find('mac')
- self.assertEqual(self.mac, mac.get('address'))
- source = interface.find('source')
- self.assertEqual('unix', source.get('type'))
- self.assertEqual('/usr/local/var/run/openvswitch/dpdkvhostuser0',
- source.get('path'))
- self.assertEqual('client', source.get('mode'))
- _model = interface.find('model')
- self.assertEqual('virtio', _model.get('type'))
- driver = interface.find('driver')
- self.assertEqual('4', driver.get('queues'))
- host = driver.find('host')
- self.assertEqual('off', host.get('mrg_rxbuf'))
- self.assertIsNotNone(interface.find('address'))
-
- def test_add_sriov_interfaces(self):
- xml_input = mock.Mock()
- with mock.patch.object(ElementTree, 'parse', return_value=self.xml) \
- as mock_parse:
- xml = copy.deepcopy(self.xml)
- mock_parse.return_value = xml
- vm_pci = '0001:05:04.2'
- model.Libvirt.add_sriov_interfaces(
- vm_pci, self.pci_address_str, self.mac, xml_input)
- mock_parse.assert_called_once_with(xml_input)
- self.mock_write_xml.assert_called_once_with(xml_input)
- interface = xml.find('devices').find('interface')
- self.assertEqual('yes', interface.get('managed'))
- self.assertEqual('hostdev', interface.get('type'))
- mac = interface.find('mac')
- self.assertEqual(self.mac, mac.get('address'))
- source = interface.find('source')
- source_address = source.find('address')
- self.assertIsNotNone(source.find('address'))
-
- self.assertEqual('pci', source_address.get('type'))
- self.assertEqual('0x' + self.pci_address_str.split(':')[0],
- source_address.get('domain'))
- self.assertEqual('0x' + self.pci_address_str.split(':')[1],
- source_address.get('bus'))
- self.assertEqual('0x' + self.pci_address_str.split(':')[2].split('.')[0],
- source_address.get('slot'))
- self.assertEqual('0x' + self.pci_address_str.split(':')[2].split('.')[1],
- source_address.get('function'))
-
- interface_address = interface.find('address')
- self.assertEqual('pci', interface_address.get('type'))
- self.assertEqual('0x' + vm_pci.split(':')[0],
- interface_address.get('domain'))
- self.assertEqual('0x' + vm_pci.split(':')[1],
- interface_address.get('bus'))
- self.assertEqual('0x' + vm_pci.split(':')[2].split('.')[0],
- interface_address.get('slot'))
- self.assertEqual('0x' + vm_pci.split(':')[2].split('.')[1],
- interface_address.get('function'))
-
- def test_create_snapshot_qemu(self):
- result = "/var/lib/libvirt/images/0.qcow2"
- 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
- image = model.Libvirt.create_snapshot_qemu(ssh_mock, "0", "ubuntu.img")
- self.assertEqual(image, result)
-
- @mock.patch.object(model.Libvirt, 'pin_vcpu_for_perf')
- @mock.patch.object(model.Libvirt, 'create_snapshot_qemu')
- def test_build_vm_xml(self, mock_create_snapshot_qemu,
- *args):
- # NOTE(ralonsoh): this test doesn't cover function execution. This test
- # should also check mocked function calls.
- cfg_file = 'test_config_file.cfg'
- self.addCleanup(os.remove, cfg_file)
- result = [4]
- 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
- mock_create_snapshot_qemu.return_value = "0.img"
-
- status = model.Libvirt.build_vm_xml(ssh_mock, {}, cfg_file, 'vm_0', 0)
- self.assertEqual(status[0], result[0])
-
- def test_update_interrupts_hugepages_perf(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
- # NOTE(ralonsoh): 'update_interrupts_hugepages_perf' always return
- # None, this check is trivial.
- #status = Libvirt.update_interrupts_hugepages_perf(ssh_mock)
- #self.assertIsNone(status)
- Libvirt.update_interrupts_hugepages_perf(ssh_mock)
-
- @mock.patch("yardstick.benchmark.contexts.standalone.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.
- 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
- status = Libvirt.pin_vcpu_for_perf(ssh_mock, 4)
- self.assertIsNotNone(status)
-
-class StandaloneContextHelperTestCase(unittest.TestCase):
-
- NODE_SAMPLE = "nodes_sample.yaml"
- NODE_SRIOV_SAMPLE = "nodes_sriov_sample.yaml"
-
- 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'},
- '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'}
- }
-
- def setUp(self):
- self.helper = model.StandaloneContextHelper()
-
- def test___init__(self):
- self.assertIsNone(self.helper.file_path)
-
- def test_install_req_libs(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(1, "a", ""))
- ssh.return_value = ssh_mock
- # NOTE(ralonsoh): this test doesn't cover function execution. This test
- # should also check mocked function calls.
- model.StandaloneContextHelper.install_req_libs(ssh_mock)
-
- def test_get_kernel_module(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(1, "i40e", ""))
- ssh.return_value = ssh_mock
- # NOTE(ralonsoh): this test doesn't cover function execution. This test
- # should also check mocked function calls.
- model.StandaloneContextHelper.get_kernel_module(
- ssh_mock, "05:00.0", None)
-
- @mock.patch.object(model.StandaloneContextHelper, 'get_kernel_module')
- def test_get_nic_details(self, mock_get_kernel_module):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = mock.Mock(return_value=(1, "i40e ixgbe", ""))
- ssh.return_value = ssh_mock
- mock_get_kernel_module.return_value = "i40e"
- # NOTE(ralonsoh): this test doesn't cover function execution. This test
- # should also check mocked function calls.
- model.StandaloneContextHelper.get_nic_details(
- ssh_mock, self.NETWORKS, 'dpdk-devbind.py')
-
- def test_get_virtual_devices(self):
- pattern = "PCI_SLOT_NAME=0000:05:00.0"
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- 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.
- model.StandaloneContextHelper.get_virtual_devices(
- ssh_mock, '0000:00:05.0')
-
- def _get_file_abspath(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- file_path = os.path.join(curr_path, filename)
- return file_path
-
- def test_read_config_file(self):
- self.helper.file_path = self._get_file_abspath(self.NODE_SAMPLE)
- status = self.helper.read_config_file()
- self.assertIsNotNone(status)
-
- def test_parse_pod_file(self):
- self.helper.file_path = self._get_file_abspath("dummy")
- self.assertRaises(IOError, self.helper.parse_pod_file,
- self.helper.file_path)
-
- self.helper.file_path = self._get_file_abspath(self.NODE_SAMPLE)
- self.assertRaises(TypeError, self.helper.parse_pod_file,
- self.helper.file_path)
-
- self.helper.file_path = self._get_file_abspath(self.NODE_SRIOV_SAMPLE)
- self.assertIsNotNone(self.helper.parse_pod_file(self.helper.file_path))
-
- def test_get_mac_address(self):
- status = model.StandaloneContextHelper.get_mac_address()
- self.assertIsNotNone(status)
-
- @mock.patch('yardstick.ssh.SSH')
- def test_get_mgmt_ip(self, *args):
- # NOTE(ralonsoh): test mocked methods/variables.
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = mock.Mock(
- return_value=(1, "1.2.3.4 00:00:00:00:00:01", ""))
- ssh.return_value = ssh_mock
- # NOTE(ralonsoh): this test doesn't cover function execution. This test
- # should also check mocked function calls.
- status = model.StandaloneContextHelper.get_mgmt_ip(
- ssh_mock, "00:00:00:00:00:01", "1.1.1.1/24", {})
- self.assertIsNotNone(status)
-
- @mock.patch('yardstick.ssh.SSH')
- def test_get_mgmt_ip_no(self, *args):
- # NOTE(ralonsoh): test mocked methods/variables.
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- 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.
- model.WAIT_FOR_BOOT = 0
- status = model.StandaloneContextHelper.get_mgmt_ip(
- ssh_mock, "99", "1.1.1.1/24", {})
- self.assertIsNone(status)
-
-
-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'},
- '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'}
- }
-
- def setUp(self):
- self.server = model.Server()
-
- def test___init__(self):
- self.assertIsNotNone(self.server)
-
- def test_build_vnf_interfaces(self):
- vnf = {
- "network_ports": {
- 'mgmt': {'cidr': '152.16.100.10/24'},
- 'xe0': ['private_0'],
- 'xe1': ['public_0'],
- }
- }
- status = model.Server.build_vnf_interfaces(vnf, self.NETWORKS)
- self.assertIsNotNone(status)
-
- def test_generate_vnf_instance(self):
- vnf = {
- "network_ports": {
- 'mgmt': {'cidr': '152.16.100.10/24'},
- 'xe0': ['private_0'],
- 'xe1': ['public_0'],
- }
- }
- status = self.server.generate_vnf_instance(
- {}, 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'},
- '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'}
- }
- @mock.patch('yardstick.ssh.SSH')
- def setUp(self, mock_ssh):
- self.ovs_deploy = model.OvsDeploy(mock_ssh, '/tmp/dpdk-devbind.py', {})
-
- def test___init__(self):
- self.assertIsNotNone(self.ovs_deploy.connection)
-
- @mock.patch('yardstick.benchmark.contexts.standalone.model.os')
- def test_prerequisite(self, *args):
- # NOTE(ralonsoh): this test should check mocked function calls.
- self.ovs_deploy.helper = mock.Mock()
- self.assertIsNone(self.ovs_deploy.prerequisite())
-
- @mock.patch('yardstick.benchmark.contexts.standalone.model.os')
- def test_prerequisite_2(self, *args):
- # NOTE(ralonsoh): this test should check mocked function calls. Rename
- # this test properly.
- self.ovs_deploy.helper = mock.Mock()
- self.ovs_deploy.connection.execute = mock.Mock(
- return_value=(1, '1.2.3.4 00:00:00:00:00:01', ''))
- self.ovs_deploy.prerequisite = mock.Mock()
- self.assertIsNone(self.ovs_deploy.ovs_deploy())
diff --git a/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py b/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
deleted file mode 100644
index e39ecf4f2..000000000
--- a/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
+++ /dev/null
@@ -1,370 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Unittest for yardstick.benchmark.contexts.standalone.standaloneovs
-
-from __future__ import absolute_import
-import os
-import unittest
-import mock
-
-from yardstick.benchmark.contexts.standalone import ovs_dpdk
-
-
-class OvsDpdkContextTestCase(unittest.TestCase):
-
- NODES_SAMPLE = "nodes_sample.yaml"
- NODES_ovs_dpdk_SAMPLE = "nodes_ovs_dpdk_sample.yaml"
- NODES_DUPLICATE_SAMPLE = "nodes_duplicate_sample.yaml"
-
- ATTRS = {
- 'name': 'StandaloneOvsDpdk',
- 'file': 'pod',
- 'flavor': {},
- 'servers': {},
- 'networks': {},
- }
-
- 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'},
- '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'},
- }
-
- 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')
- def test___init__(self, mock_helper, mock_server):
- self.ovs_dpdk.helper = mock_helper
- self.ovs_dpdk.vnf_node = mock_server
- self.assertIsNone(self.ovs_dpdk.file_path)
- self.assertTrue(self.ovs_dpdk.first_run)
-
- def test_init(self):
- self.ovs_dpdk.helper.parse_pod_file = mock.Mock(return_value=[{}, {}, {}])
- self.assertIsNone(self.ovs_dpdk.init(self.ATTRS))
-
- def test_setup_ovs(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 = {}
- self.assertIsNone(self.ovs_dpdk.setup_ovs())
-
- def test_start_ovs_serverswitch(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 = {}
- self.ovs_dpdk.wait_for_vswitchd = 0
- self.assertIsNone(self.ovs_dpdk.start_ovs_serverswitch())
-
- def test_setup_ovs_bridge_add_flows(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.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.benchmark.contexts.standalone.model.OvsDeploy')
- def test_check_ovs_dpdk_env(self, mock_ovs):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(1, "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', 'dpdk': '16.11.1'}
- }
- self.ovs_dpdk.wait_for_vswitchd = 0
- self.ovs_dpdk.cleanup_ovs_dpdk_env = mock.Mock()
- self.assertIsNone(self.ovs_dpdk.check_ovs_dpdk_env())
- self.ovs_dpdk.ovs_properties = {
- 'version': {'ovs': '2.0.0'}
- }
- self.ovs_dpdk.wait_for_vswitchd = 0
- self.cleanup_ovs_dpdk_env = mock.Mock()
- mock_ovs.deploy = mock.Mock()
- 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", "")
-
- self.ovs_dpdk.vm_deploy = False
- self.assertIsNone(self.ovs_dpdk.deploy())
-
- self.ovs_dpdk.vm_deploy = True
- self.ovs_dpdk.host_mgmt = {}
- self.ovs_dpdk.install_req_libs = mock.Mock()
- self.ovs_dpdk.helper.get_nic_details = mock.Mock(return_value={})
- self.ovs_dpdk.check_ovs_dpdk_env = mock.Mock(return_value={})
- self.ovs_dpdk.setup_ovs = mock.Mock(return_value={})
- self.ovs_dpdk.start_ovs_serverswitch = mock.Mock(return_value={})
- self.ovs_dpdk.setup_ovs_bridge_add_flows = mock.Mock(return_value={})
- self.ovs_dpdk.setup_ovs_dpdk_context = mock.Mock(return_value={})
- self.ovs_dpdk.wait_for_vnfs_to_start = mock.Mock(return_value={})
- # TODO(elfoley): This test should check states/sideeffects instead of
- # output.
- self.assertIsNone(self.ovs_dpdk.deploy())
-
- @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", "")
-
- self.ovs_dpdk.vm_deploy = False
- self.assertIsNone(self.ovs_dpdk.undeploy())
-
- self.ovs_dpdk.vm_deploy = True
- 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
- self.assertIsNone(self.ovs_dpdk.undeploy())
-
- def _get_file_abspath(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- file_path = os.path.join(curr_path, filename)
- return file_path
-
- def test__get_server_with_dic_attr_name(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_ovs_dpdk_SAMPLE)
- }
-
- self.ovs_dpdk.init(attrs)
-
- attr_name = {'name': 'foo.bar'}
- result = self.ovs_dpdk._get_server(attr_name)
-
- self.assertEqual(result, None)
-
- def test__get_server_not_found(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_ovs_dpdk_SAMPLE)
- }
-
- self.ovs_dpdk.helper.parse_pod_file = mock.Mock(return_value=[{}, {}, {}])
- self.ovs_dpdk.init(attrs)
-
- attr_name = 'bar.foo'
- result = self.ovs_dpdk._get_server(attr_name)
-
- self.assertEqual(result, None)
-
- def test__get_server_mismatch(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_ovs_dpdk_SAMPLE)
- }
-
- self.ovs_dpdk.init(attrs)
-
- attr_name = 'bar.foo1'
- result = self.ovs_dpdk._get_server(attr_name)
-
- self.assertEqual(result, None)
-
- def test__get_server_duplicate(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_DUPLICATE_SAMPLE)
- }
-
- self.ovs_dpdk.init(attrs)
-
- attr_name = 'node1.foo'
- with self.assertRaises(ValueError):
- self.ovs_dpdk._get_server(attr_name)
-
- def test__get_server_found(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_ovs_dpdk_SAMPLE)
- }
-
- self.ovs_dpdk.init(attrs)
-
- attr_name = 'node1.foo'
- result = self.ovs_dpdk._get_server(attr_name)
-
- self.assertEqual(result['ip'], '10.229.47.137')
- self.assertEqual(result['name'], 'node1.foo')
- self.assertEqual(result['user'], 'root')
- self.assertEqual(result['key_filename'], '/root/.yardstick_key')
-
- def test__get_network(self):
- network1 = {
- 'name': 'net_1',
- 'vld_id': 'vld111',
- 'segmentation_id': 'seg54',
- 'network_type': 'type_a',
- 'physical_network': 'phys',
- }
- network2 = {
- 'name': 'net_2',
- 'vld_id': 'vld999',
- }
- self.ovs_dpdk.networks = {
- 'a': network1,
- 'b': network2,
- }
-
- attr_name = {}
- self.assertIsNone(self.ovs_dpdk._get_network(attr_name))
-
- attr_name = {'vld_id': 'vld777'}
- self.assertIsNone(self.ovs_dpdk._get_network(attr_name))
-
- self.assertIsNone(self.ovs_dpdk._get_network(None))
-
- attr_name = 'vld777'
- self.assertIsNone(self.ovs_dpdk._get_network(attr_name))
-
- attr_name = {'vld_id': 'vld999'}
- expected = {
- "name": 'net_2',
- "vld_id": 'vld999',
- "segmentation_id": None,
- "network_type": None,
- "physical_network": None,
- }
- result = self.ovs_dpdk._get_network(attr_name)
- self.assertDictEqual(result, expected)
-
- attr_name = 'a'
- expected = network1
- result = self.ovs_dpdk._get_network(attr_name)
- self.assertDictEqual(result, expected)
-
- def test_configure_nics_for_ovs_dpdk(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.vm_deploy = True
- self.ovs_dpdk.connection = ssh_mock
- self.ovs_dpdk.vm_names = ['vm_0', 'vm_1']
- self.ovs_dpdk.drivers = []
- self.ovs_dpdk.networks = self.NETWORKS
- self.ovs_dpdk.helper.get_mac_address = mock.Mock(return_value="")
- 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, _):
- 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.vm_deploy = True
- self.ovs_dpdk.connection = ssh_mock
- self.ovs_dpdk.vm_names = ['vm_0', 'vm_1']
- 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'))
-
- @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):
- 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_mock.put = \
- mock.Mock(return_value=(0, "a", ""))
- ssh.return_value = ssh_mock
- self.ovs_dpdk.vm_deploy = True
- self.ovs_dpdk.connection = ssh_mock
- self.ovs_dpdk.vm_names = ['vm_0', 'vm_1']
- self.ovs_dpdk.drivers = []
- self.ovs_dpdk.servers = {
- 'vnf_0': {
- 'network_ports': {
- 'mgmt': {'cidr': '152.16.100.10/24'},
- 'xe0': ['private_0'],
- 'xe1': ['public_0']
- }
- }
- }
- self.ovs_dpdk.networks = self.NETWORKS
- 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"])
- 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={})
- self.assertIsNotNone(self.ovs_dpdk.setup_ovs_dpdk_context())
diff --git a/tests/unit/benchmark/contexts/standalone/test_sriov.py b/tests/unit/benchmark/contexts/standalone/test_sriov.py
deleted file mode 100644
index 7f11a7d59..000000000
--- a/tests/unit/benchmark/contexts/standalone/test_sriov.py
+++ /dev/null
@@ -1,318 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Unittest for yardstick.benchmark.contexts.standalone.standalonesriov
-
-from __future__ import absolute_import
-import os
-import unittest
-import mock
-
-from yardstick import ssh
-from yardstick.benchmark.contexts.standalone import sriov
-
-
-class SriovContextTestCase(unittest.TestCase):
-
- NODES_SAMPLE = "nodes_sample.yaml"
- NODES_SRIOV_SAMPLE = "nodes_sriov_sample.yaml"
- NODES_DUPLICATE_SAMPLE = "nodes_duplicate_sample.yaml"
-
- ATTRS = {
- 'name': 'StandaloneSriov',
- 'file': 'pod',
- 'flavor': {},
- 'servers': {},
- 'networks': {},
- }
-
- 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'},
- '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'},
- }
-
- 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.Server')
- def test___init__(self, mock_helper, mock_libvirt, mock_server):
- # pylint: disable=unused-argument
- # 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)
- self.assertTrue(self.sriov.first_run)
-
- def test_init(self):
- self.sriov.helper.parse_pod_file = mock.Mock(return_value=[{}, {}, {}])
- 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
- # 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())
-
- self.sriov.vm_deploy = True
- self.sriov.host_mgmt = {}
- self.sriov.install_req_libs = mock.Mock()
- self.sriov.get_nic_details = mock.Mock(return_value={})
- self.sriov.setup_sriov_context = mock.Mock(return_value={})
- 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.
- self.sriov.vm_deploy = False
- self.assertIsNone(self.sriov.undeploy())
-
- self.sriov.vm_deploy = True
- self.sriov.connection = mock_ssh
- self.sriov.vm_names = ['vm_0', 'vm_1']
- self.sriov.drivers = ['vm_0', 'vm_1']
- self.assertIsNone(self.sriov.undeploy())
-
- def _get_file_abspath(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- file_path = os.path.join(curr_path, filename)
- return file_path
-
- def test__get_server_with_dic_attr_name(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SRIOV_SAMPLE)
- }
-
- self.sriov.init(attrs)
-
- attr_name = {'name': 'foo.bar'}
- result = self.sriov._get_server(attr_name)
-
- self.assertEqual(result, None)
-
- def test__get_server_not_found(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SRIOV_SAMPLE)
- }
-
- self.sriov.helper.parse_pod_file = mock.Mock(return_value=[{}, {}, {}])
- self.sriov.init(attrs)
-
- attr_name = 'bar.foo'
- result = self.sriov._get_server(attr_name)
-
- self.assertEqual(result, None)
-
- def test__get_server_mismatch(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SRIOV_SAMPLE)
- }
-
- self.sriov.init(attrs)
-
- attr_name = 'bar.foo1'
- result = self.sriov._get_server(attr_name)
-
- self.assertEqual(result, None)
-
- def test__get_server_duplicate(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_DUPLICATE_SAMPLE)
- }
-
- self.sriov.init(attrs)
-
- attr_name = 'node1.foo'
- with self.assertRaises(ValueError):
- self.sriov._get_server(attr_name)
-
- def test__get_server_found(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SRIOV_SAMPLE)
- }
-
- self.sriov.init(attrs)
-
- attr_name = 'node1.foo'
- result = self.sriov._get_server(attr_name)
-
- self.assertEqual(result['ip'], '10.229.47.137')
- self.assertEqual(result['name'], 'node1.foo')
- self.assertEqual(result['user'], 'root')
- self.assertEqual(result['key_filename'], '/root/.yardstick_key')
-
- def test__get_network(self):
- network1 = {
- 'name': 'net_1',
- 'vld_id': 'vld111',
- 'segmentation_id': 'seg54',
- 'network_type': 'type_a',
- 'physical_network': 'phys',
- }
- network2 = {
- 'name': 'net_2',
- 'vld_id': 'vld999',
- }
- self.sriov.networks = {
- 'a': network1,
- 'b': network2,
- }
-
- attr_name = {}
- self.assertIsNone(self.sriov._get_network(attr_name))
-
- attr_name = {'vld_id': 'vld777'}
- self.assertIsNone(self.sriov._get_network(attr_name))
-
- self.assertIsNone(self.sriov._get_network(None))
-
- attr_name = 'vld777'
- self.assertIsNone(self.sriov._get_network(attr_name))
-
- attr_name = {'vld_id': 'vld999'}
- expected = {
- "name": 'net_2',
- "vld_id": 'vld999',
- "segmentation_id": None,
- "network_type": None,
- "physical_network": None,
- }
- result = self.sriov._get_network(attr_name)
- self.assertDictEqual(result, expected)
-
- attr_name = 'a'
- expected = network1
- result = self.sriov._get_network(attr_name)
- self.assertDictEqual(result, expected)
-
- def test_configure_nics_for_sriov(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.sriov.vm_deploy = True
- self.sriov.connection = ssh_mock
- self.sriov.vm_names = ['vm_0', 'vm_1']
- self.sriov.drivers = []
- self.sriov.networks = self.NETWORKS
- self.sriov.helper.get_mac_address = mock.Mock(return_value="")
- 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.
- 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'))
-
- @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.
- 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_mock.put = \
- mock.Mock(return_value=(0, "a", ""))
- ssh.return_value = ssh_mock
- self.sriov.vm_deploy = True
- self.sriov.connection = ssh_mock
- self.sriov.vm_names = ['vm_0', 'vm_1']
- self.sriov.drivers = []
- self.sriov.servers = {
- 'vnf_0': {
- 'network_ports': {
- 'mgmt': {'cidr': '152.16.100.10/24'},
- 'xe0': ['private_0'],
- 'xe1': ['public_0']
- }
- }
- }
- self.sriov.networks = self.NETWORKS
- 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"])
- 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())
-
- def test__get_vf_data(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_mock.put = \
- mock.Mock(return_value=(0, "a", ""))
- ssh.return_value = ssh_mock
- self.sriov.vm_deploy = True
- self.sriov.connection = ssh_mock
- self.sriov.vm_names = ['vm_0', 'vm_1']
- self.sriov.drivers = []
- self.sriov.servers = {
- 'vnf_0': {
- 'network_ports': {
- 'mgmt': {'cidr': '152.16.100.10/24'},
- 'xe0': ['private_0'],
- 'xe1': ['public_0']
- }
- }
- }
- self.sriov.networks = self.NETWORKS
- self.sriov.helper.get_virtual_devices = mock.Mock(
- return_value={'0000:00:01.0': ''})
- self.assertIsNotNone(self.sriov._get_vf_data(
- '0000:00:01.0', '00:00:00:00:00:01', 'if0'))
diff --git a/tests/unit/benchmark/contexts/standalone_duplicate_sample.yaml b/tests/unit/benchmark/contexts/standalone_duplicate_sample.yaml
deleted file mode 100644
index e468d0465..000000000
--- a/tests/unit/benchmark/contexts/standalone_duplicate_sample.yaml
+++ /dev/null
@@ -1,135 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
----
-# Sample config file about the POD information, including the
-# name/IP/user/ssh key of Bare Metal and Controllers/Computes
-#
-# The options of this config file include:
-# name: the name of this node
-# role: node's role, support role: Master/Controller/Comupte/BareMetal
-# ip: the node's IP address
-# user: the username for login
-# key_filename:the path of the private key file for login
-
-nodes:
--
- name: node1
- role: TrafficGen
- ip: 1.1.1.1
- user: root
- password: r00t
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:05:00.0"
- driver: i40e
- dpdk_port_num: 0
- local_ip: "152.16.100.20"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:01"
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:05:00.1"
- driver: i40e
- dpdk_port_num: 1
- local_ip: "152.16.100.21"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:02"
--
- name: node2
- role: nfvi_node
- class: OvsDpdk
- ip: 1.1.1.2
- user: root
- password: r00t
- vports:
- - dpdkvhostuser0
- - dpdkvhostuser1
- vports_mac:
- - "00:00:00:00:00:03"
- - "00:00:00:00:00:04"
- phy_ports: # Physical ports to configure sriov
- - "0000:05:00.0"
- - "0000:05:00.1"
- flow:
- - ovs-ofctl add-flow br0 in_port=1,action=output:3
- - ovs-ofctl add-flow br0 in_port=3,action=output:1
- - ovs-ofctl add-flow br0 in_port=4,action=output:2
- - ovs-ofctl add-flow br0 in_port=2,action=output:4
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu.qcow2"
--
- name: node2
- role: nfvi_node
- class: OvsDpdk
- ip: 1.1.1.5
- user: root
- password: r00t
- vports:
- - dpdkvhostuser0
- - dpdkvhostuser1
- vports_mac:
- - "00:00:00:00:00:03"
- - "00:00:00:00:00:04"
- phy_ports: # Physical ports to configure sriov
- - "0000:05:00.0"
- - "0000:05:00.1"
- flow:
- - ovs-ofctl add-flow br0 in_port=1,action=output:3
- - ovs-ofctl add-flow br0 in_port=3,action=output:1
- - ovs-ofctl add-flow br0 in_port=4,action=output:2
- - ovs-ofctl add-flow br0 in_port=2,action=output:4
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu.qcow2"
-
--
- name: node3
- role: vnf
- ip: 1.1.1.3
- user: root
- password: r00t
- host: 1.1.1.1
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:00:04.0"
- driver: virtio-pci
- dpdk_port_num: 0
- local_ip: "152.16.100.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:05"
-
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:00:05.0"
- driver: virtio-pci
- dpdk_port_num: 1
- local_ip: "152.16.40.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:06"
- routing_table:
- - network: "152.16.100.20"
- netmask: "255.255.255.0"
- gateway: "152.16.100.20"
- if: "xe0"
- - network: "152.16.40.20"
- netmask: "255.255.255.0"
- gateway: "152.16.40.20"
- if: "xe1"
- nd_route_tbl:
- - network: "0064:ff9b:0:0:0:0:9810:6414"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:6414"
- if: "xe0"
- - network: "0064:ff9b:0:0:0:0:9810:2814"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:2814"
- if: "xe1"
diff --git a/tests/unit/benchmark/contexts/standalone_sample.yaml b/tests/unit/benchmark/contexts/standalone_sample.yaml
deleted file mode 100644
index 95e12d62f..000000000
--- a/tests/unit/benchmark/contexts/standalone_sample.yaml
+++ /dev/null
@@ -1,112 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
----
-# Sample config file about the POD information, including the
-# name/IP/user/ssh key of Bare Metal and Controllers/Computes
-#
-# The options of this config file include:
-# name: the name of this node
-# role: node's role, support role: Master/Controller/Comupte/BareMetal
-# ip: the node's IP address
-# user: the username for login
-# key_filename:the path of the private key file for login
-
-nodes:
--
- name: node1
- role: TrafficGen
- ip: 1.1.1.1
- user: root
- password: r00t
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:05:00.0"
- driver: i40e
- dpdk_port_num: 0
- local_ip: "152.16.100.20"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:01"
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:05:00.1"
- driver: i40e
- dpdk_port_num: 1
- local_ip: "152.16.100.21"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:02"
--
- name: node2
- role: nfvi_node
- class: OvsDpdk
- ip: 1.1.1.2
- user: root
- password: r00t
- vports:
- - dpdkvhostuser0
- - dpdkvhostuser1
- vports_mac:
- - "00:00:00:00:00:03"
- - "00:00:00:00:00:04"
- phy_ports: # Physical ports to configure sriov
- - "0000:05:00.0"
- - "0000:05:00.1"
- flow:
- - ovs-ofctl add-flow br0 in_port=1,action=output:3
- - ovs-ofctl add-flow br0 in_port=3,action=output:1
- - ovs-ofctl add-flow br0 in_port=4,action=output:2
- - ovs-ofctl add-flow br0 in_port=2,action=output:4
- phy_driver: i40e # kernel driver
- images: "/var/lib/libvirt/images/ubuntu.qcow2"
-
--
- name: node3
- role: vnf
- ip: 1.1.1.3
- user: root
- password: r00t
- host: 1.1.1.1
- interfaces:
- xe0: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:00:04.0"
- driver: virtio-pci
- dpdk_port_num: 0
- local_ip: "152.16.100.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:05"
-
- xe1: # logical name from topology.yaml and vnfd.yaml
- vpci: "0000:00:05.0"
- driver: virtio-pci
- dpdk_port_num: 1
- local_ip: "152.16.40.19"
- netmask: "255.255.255.0"
- local_mac: "00:00:00:00:00:06"
- routing_table:
- - network: "152.16.100.20"
- netmask: "255.255.255.0"
- gateway: "152.16.100.20"
- if: "xe0"
- - network: "152.16.40.20"
- netmask: "255.255.255.0"
- gateway: "152.16.40.20"
- if: "xe1"
- nd_route_tbl:
- - network: "0064:ff9b:0:0:0:0:9810:6414"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:6414"
- if: "xe0"
- - network: "0064:ff9b:0:0:0:0:9810:2814"
- netmask: "112"
- gateway: "0064:ff9b:0:0:0:0:9810:2814"
- if: "xe1"
diff --git a/tests/unit/benchmark/contexts/test_dummy.py b/tests/unit/benchmark/contexts/test_dummy.py
deleted file mode 100644
index 1a54035df..000000000
--- a/tests/unit/benchmark/contexts/test_dummy.py
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.contexts.dummy
-
-from __future__ import absolute_import
-import unittest
-
-from yardstick.benchmark.contexts import dummy
-
-
-class DummyContextTestCase(unittest.TestCase):
-
- def setUp(self):
- self.test_context = dummy.DummyContext()
-
- def test__get_server(self):
- self.test_context.init(None)
- self.test_context.deploy()
-
- result = self.test_context._get_server(None)
- self.assertEqual(result, None)
-
- self.test_context.undeploy()
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py
deleted file mode 100644
index f2e725df2..000000000
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ /dev/null
@@ -1,503 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.contexts.heat
-
-from __future__ import absolute_import
-
-import logging
-import os
-import unittest
-import uuid
-from collections import OrderedDict
-
-import mock
-
-from itertools import count
-from yardstick.benchmark.contexts import heat
-from yardstick.benchmark.contexts import model
-
-LOG = logging.getLogger(__name__)
-
-
-class HeatContextTestCase(unittest.TestCase):
-
- def __init__(self, *args, **kwargs):
- super(HeatContextTestCase, self).__init__(*args, **kwargs)
- self.name_iter = ('vnf{:03}'.format(x) for x in count(0, step=3))
-
- def setUp(self):
- self.test_context = heat.HeatContext()
- self.mock_context = mock.Mock(spec=heat.HeatContext())
-
- def test___init__(self):
- self.assertIsNone(self.test_context.name)
- self.assertIsNone(self.test_context.stack)
- self.assertEqual(self.test_context.networks, OrderedDict())
- self.assertEqual(self.test_context.servers, [])
- self.assertEqual(self.test_context.placement_groups, [])
- self.assertEqual(self.test_context.server_groups, [])
- self.assertIsNone(self.test_context.keypair_name)
- self.assertIsNone(self.test_context.secgroup_name)
- self.assertEqual(self.test_context._server_map, {})
- self.assertIsNone(self.test_context._image)
- self.assertIsNone(self.test_context._flavor)
- self.assertIsNone(self.test_context._user)
- self.assertIsNone(self.test_context.template_file)
- self.assertIsNone(self.test_context.heat_parameters)
- self.assertIsNotNone(self.test_context.key_uuid)
- self.assertIsNotNone(self.test_context.key_filename)
-
- @mock.patch('yardstick.benchmark.contexts.heat.PlacementGroup')
- @mock.patch('yardstick.benchmark.contexts.heat.ServerGroup')
- @mock.patch('yardstick.benchmark.contexts.heat.Network')
- @mock.patch('yardstick.benchmark.contexts.heat.Server')
- def test_init(self, mock_server, mock_network, mock_sg, mock_pg):
-
- pgs = {'pgrp1': {'policy': 'availability'}}
- sgs = {'servergroup1': {'policy': 'affinity'}}
- networks = {'bar': {'cidr': '10.0.1.0/24'}}
- servers = {'baz': {'floating_ip': True, 'placement': 'pgrp1'}}
- attrs = {'name': 'foo',
- 'placement_groups': pgs,
- 'server_groups': sgs,
- 'networks': networks,
- 'servers': servers}
-
- self.test_context.init(attrs)
-
- self.assertEqual(self.test_context.name, "foo")
- self.assertEqual(self.test_context.keypair_name, "foo-key")
- self.assertEqual(self.test_context.secgroup_name, "foo-secgroup")
-
- mock_pg.assert_called_with('pgrp1', self.test_context,
- 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)
-
- mock_network.assert_called_with(
- 'bar', self.test_context, networks['bar'])
- self.assertTrue(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)
-
- if os.path.exists(self.test_context.key_filename):
- try:
- os.remove(self.test_context.key_filename)
- os.remove(self.test_context.key_filename + ".pub")
- except OSError:
- LOG.exception("key_filename: %s",
- self.test_context.key_filename)
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test__add_resources_to_template_no_servers(self, mock_template):
-
- self.test_context.keypair_name = "foo-key"
- self.test_context.secgroup_name = "foo-secgroup"
- self.test_context.key_uuid = "2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b"
- netattrs = {'cidr': '10.0.0.0/24', 'provider': None, 'external_network': 'ext_net'}
- self.mock_context.name = 'bar'
- self.test_context.networks = OrderedDict(
- {"fool-network": model.Network("fool-network", self.mock_context,
- netattrs)})
-
- self.test_context._add_resources_to_template(mock_template)
- mock_template.add_keypair.assert_called_with(
- "foo-key",
- "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.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test_attrs_get(self, mock_template):
- image, flavor, user = expected_tuple = 'foo1', 'foo2', 'foo3'
- self.assertNotEqual(self.test_context.image, image)
- self.assertNotEqual(self.test_context.flavor, flavor)
- self.assertNotEqual(self.test_context.user, user)
- self.test_context._image = image
- self.test_context._flavor = flavor
- self.test_context._user = user
- attr_tuple = self.test_context.image, self.test_context.flavor, self.test_context.user
- self.assertEqual(attr_tuple, expected_tuple)
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test_attrs_set_negative(self, mock_template):
- with self.assertRaises(AttributeError):
- self.test_context.image = 'foo'
-
- with self.assertRaises(AttributeError):
- self.test_context.flavor = 'foo'
-
- with self.assertRaises(AttributeError):
- self.test_context.user = 'foo'
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test_deploy(self, mock_template):
- self.test_context.name = 'foo'
- self.test_context.template_file = '/bar/baz/some-heat-file'
- self.test_context.heat_parameters = {'image': 'cirros'}
- self.test_context.get_neutron_info = mock.MagicMock()
- self.test_context.deploy()
-
- mock_template.assert_called_with('foo',
- '/bar/baz/some-heat-file',
- {'image': 'cirros'})
- self.assertIsNotNone(self.test_context.stack)
-
- def test_add_server_port(self):
- network1 = mock.MagicMock()
- network2 = mock.MagicMock()
- self.test_context.name = 'foo'
- self.test_context.stack = mock.MagicMock()
- self.test_context.networks = {
- 'a': network1,
- 'c': network2,
- }
- self.test_context.stack.outputs = {
- u'b': u'10.20.30.45',
- u'b-subnet_id': 1,
- u'foo-a-subnet-cidr': u'10.20.0.0/15',
- u'foo-a-subnet-gateway_ip': u'10.20.30.1',
- u'b-mac_address': u'00:01',
- u'b-device_id': u'dev21',
- u'b-network_id': u'net789',
- u'd': u'40.30.20.15',
- u'd-subnet_id': 2,
- u'foo-c-subnet-cidr': u'40.30.0.0/18',
- u'foo-c-subnet-gateway_ip': u'40.30.20.254',
- u'd-mac_address': u'00:10',
- u'd-device_id': u'dev43',
- u'd-network_id': u'net987',
- u'e': u'40.30.20.15',
- u'e-subnet_id': 2,
- u'e-mac_address': u'00:10',
- u'e-device_id': u'dev43',
- u'e-network_id': u'net987',
- }
- server = mock.MagicMock()
- server.ports = OrderedDict([
- ('a', [{'stack_name': 'b', 'port': 'port_a'}]),
- ('c', [{'stack_name': 'd', 'port': 'port_c'},
- {'stack_name': 'e', 'port': 'port_f'}]),
- ])
-
- expected = {
- "private_ip": '10.20.30.45',
- "subnet_id": 1,
- "subnet_cidr": '10.20.0.0/15',
- "network": '10.20.0.0',
- "netmask": '255.254.0.0',
- "name": "port_a",
- "gateway_ip": '10.20.30.1',
- "mac_address": '00:01',
- "device_id": 'dev21',
- "network_id": 'net789',
- "network_name": 'a',
- "local_mac": '00:01',
- "local_ip": '10.20.30.45',
- }
- self.test_context.add_server_port(server)
- self.assertEqual(server.private_ip, '10.20.30.45')
- self.assertEqual(len(server.interfaces), 3)
- self.assertDictEqual(server.interfaces['port_a'], expected)
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test_undeploy(self, mock_template):
- self.test_context.stack = mock_template
- self.test_context.undeploy()
- self.assertTrue(mock_template.delete.called)
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- @mock.patch('yardstick.benchmark.contexts.heat.os')
- def test_undeploy_key_filename(self, mock_template, mock_os):
- 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):
- """
- Use HeatContext._get_server to get a server that matches
- based on a dictionary input.
- """
- foo2_server = mock.Mock()
- foo2_server.key_filename = None
- foo2_server.private_ip = '10.0.0.2'
- foo2_server.public_ip = '127.0.0.2'
- foo2_server.context.user = 'oof'
-
- baz3_server = mock.Mock()
- baz3_server.key_filename = None
- baz3_server.private_ip = '10.0.0.3'
- baz3_server.public_ip = '127.0.0.3'
- baz3_server.context.user = 'zab'
-
- self.test_context.name = 'bar'
- self.test_context._user = 'bot'
- self.test_context.stack = mock.Mock()
- self.test_context.stack.outputs = {
- 'private_ip': '10.0.0.1',
- 'public_ip': '127.0.0.1',
- }
- self.test_context.key_uuid = uuid.uuid4()
- self.test_context._server_map = {
- 'baz3': baz3_server,
- 'foo2': foo2_server,
- }
-
- attr_name = {
- 'name': 'foo.bar',
- 'private_ip_attr': 'private_ip',
- 'public_ip_attr': 'public_ip',
- }
- result = self.test_context._get_server(attr_name)
- self.assertEqual(result['user'], 'bot')
- self.assertEqual(result['ip'], '127.0.0.1')
- 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):
- """
- Use HeatContext._get_server to get a server that matches
- based on a dictionary input.
- """
- foo2_server = mock.Mock()
- foo2_server.private_ip = '10.0.0.2'
- foo2_server.public_ip = '127.0.0.2'
- foo2_server.context.user = 'oof'
-
- baz3_server = mock.Mock()
- baz3_server.private_ip = '10.0.0.3'
- baz3_server.public_ip = '127.0.0.3'
- baz3_server.context.user = 'zab'
-
- self.test_context.name = 'bar'
- self.test_context._user = 'bot'
- self.test_context.stack = mock.Mock()
- self.test_context.stack.outputs = {
- 'private_ip': '10.0.0.1',
- 'public_ip': '127.0.0.1',
- }
- self.test_context.key_uuid = uuid.uuid4()
- self.test_context._server_map = {
- 'baz3': baz3_server,
- 'foo2': foo2_server,
- }
-
- attr_name = {
- 'name': 'foo.bar',
- }
- result = self.test_context._get_server(attr_name)
- self.assertEqual(result['user'], 'bot')
- # no private ip attr mapping in the map results in None value in the result
- self.assertIsNone(result['private_ip'])
- # no public ip attr mapping in the map results in no value in the result
- self.assertNotIn('ip', result)
-
- @mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
- def test__get_server_found_not_dict(self, mock_pkg_resources):
- """
- Use HeatContext._get_server to get a server that matches
- based on a non-dictionary input
- """
- foo2_server = mock.Mock()
- foo2_server.private_ip = '10.0.0.2'
- foo2_server.public_ip = '127.0.0.2'
- foo2_server.context.user = 'oof'
-
- baz3_server = mock.Mock()
- baz3_server.private_ip = '10.0.0.3'
- baz3_server.public_ip = None
- baz3_server.context.user = 'zab'
-
- self.test_context.name = 'bar1'
- self.test_context.stack = mock.Mock()
- self.test_context.stack.outputs = {
- 'private_ip': '10.0.0.1',
- 'public_ip': '127.0.0.1',
- }
- self.test_context.key_uuid = uuid.uuid4()
- self.test_context.generate_routing_table = mock.MagicMock(return_value=[])
-
- self.test_context._server_map = {
- 'baz3': baz3_server,
- 'foo2': foo2_server,
- }
-
- attr_name = 'baz3'
- result = self.test_context._get_server(attr_name)
- self.assertEqual(result['user'], 'zab')
- self.assertEqual(result['private_ip'], '10.0.0.3')
- # no public_ip on the server results in no value in the result
- 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):
- """
- Use HeatContext._get_server to not get a server due to
- None value associated with the match to a non-dictionary
- input
- """
- foo2_server = mock.Mock()
- foo2_server.private_ip = '10.0.0.2'
- foo2_server.public_ip = '127.0.0.2'
- foo2_server.context.user = 'oof'
-
- baz3_server = mock.Mock()
- baz3_server.private_ip = '10.0.0.3'
- baz3_server.public_ip = None
- baz3_server.context.user = 'zab'
-
- self.test_context.name = 'bar1'
- self.test_context.stack = mock.Mock()
- self.test_context.stack.outputs = {
- 'private_ip': '10.0.0.1',
- 'public_ip': '127.0.0.1',
- }
- self.test_context.key_uuid = uuid.uuid4()
- self.test_context._server_map = {
- 'baz3': baz3_server,
- 'foo2': foo2_server,
- 'wow4': None,
- }
-
- attr_name = 'wow4'
- result = self.test_context._get_server(attr_name)
- self.assertIsNone(result)
-
- @mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
- def test__get_server_not_found_dict(self, mock_pkg_resources):
- """
- Use HeatContext._get_server to not get a server for lack
- of a match to a dictionary input
- """
- foo2_server = mock.Mock()
- foo2_server.private_ip = '10.0.0.2'
- foo2_server.public_ip = '127.0.0.2'
- foo2_server.context.user = 'oof'
-
- baz3_server = mock.Mock()
- baz3_server.private_ip = '10.0.0.3'
- baz3_server.public_ip = None
- baz3_server.context.user = 'zab'
-
- self.test_context.name = 'bar1'
- self.test_context.stack = mock.Mock()
- self.test_context.stack.outputs = {
- 'private_ip': '10.0.0.1',
- 'public_ip': '127.0.0.1',
- }
- self.test_context.key_uuid = uuid.uuid4()
- self.test_context._server_map = {
- 'baz3': baz3_server,
- 'foo2': foo2_server,
- }
-
- attr_name = {
- 'name': 'foo.wow4',
- 'private_ip_attr': 'private_ip',
- 'public_ip_attr': 'public_ip',
- }
- result = self.test_context._get_server(attr_name)
- self.assertIsNone(result)
-
- @mock.patch("yardstick.benchmark.contexts.heat.pkg_resources")
- def test__get_server_not_found_not_dict(self, mock_pkg_resources):
- """
- Use HeatContext._get_server to not get a server for lack
- of a match to a non-dictionary input
- """
- foo2_server = mock.Mock()
- foo2_server.private_ip = '10.0.0.2'
- foo2_server.public_ip = '127.0.0.2'
- foo2_server.context.user = 'oof'
-
- baz3_server = mock.Mock()
- baz3_server.private_ip = '10.0.0.3'
- baz3_server.public_ip = None
- baz3_server.context.user = 'zab'
-
- self.mock_context.name = 'bar1'
- self.test_context.stack = mock.Mock()
- self.mock_context.stack.outputs = {
- 'private_ip': '10.0.0.1',
- 'public_ip': '127.0.0.1',
- }
- self.mock_context.key_uuid = uuid.uuid4()
- self.mock_context._server_map = {
- 'baz3': baz3_server,
- 'foo2': foo2_server,
- }
-
- attr_name = 'foo.wow4'
- result = self.test_context._get_server(attr_name)
- self.assertIsNone(result)
-
- def test__get_network(self):
- network1 = mock.MagicMock()
- network1.name = 'net_1'
- network1.vld_id = 'vld111'
- network1.segmentation_id = 'seg54'
- network1.network_type = 'type_a'
- network1.physical_network = 'phys'
-
- network2 = mock.MagicMock()
- network2.name = 'net_2'
- network2.segmentation_id = 'seg45'
- network2.network_type = 'type_b'
- network2.physical_network = 'virt'
-
- self.test_context.networks = {
- 'a': network1,
- 'b': network2,
- }
-
- attr_name = None
- self.assertIsNone(self.test_context._get_network(attr_name))
-
- attr_name = {}
- self.assertIsNone(self.test_context._get_network(attr_name))
-
- attr_name = {'network_type': 'nosuch'}
- self.assertIsNone(self.test_context._get_network(attr_name))
-
- attr_name = 'vld777'
- self.assertIsNone(self.test_context._get_network(attr_name))
-
- attr_name = {'segmentation_id': 'seg45'}
- expected = {
- "name": 'net_2',
- "segmentation_id": 'seg45',
- "network_type": 'type_b',
- "physical_network": 'virt',
- }
- result = self.test_context._get_network(attr_name)
- self.assertDictEqual(result, expected)
-
- attr_name = 'a'
- expected = {
- "name": 'net_1',
- "segmentation_id": 'seg54',
- "network_type": 'type_a',
- "physical_network": 'phys',
- }
- result = self.test_context._get_network(attr_name)
- self.assertDictEqual(result, expected)
diff --git a/tests/unit/benchmark/contexts/test_kubernetes.py b/tests/unit/benchmark/contexts/test_kubernetes.py
deleted file mode 100644
index 3a926f85c..000000000
--- a/tests/unit/benchmark/contexts/test_kubernetes.py
+++ /dev/null
@@ -1,205 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.contexts.kubernetes
-
-from __future__ import absolute_import
-import unittest
-import mock
-
-from yardstick.benchmark.contexts.base import Context
-from yardstick.benchmark.contexts.kubernetes import KubernetesContext
-
-
-context_cfg = {
- 'type': 'Kubernetes',
- 'name': 'k8s',
- 'servers': {
- 'host': {
- 'image': 'openretriever/yardstick',
- 'command': '/bin/bash',
- 'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
-service ssh restart;while true ; do sleep 10000; done']
- },
- 'target': {
- 'image': 'openretriever/yardstick',
- 'command': '/bin/bash',
- 'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
-service ssh restart;while true ; do sleep 10000; done']
- }
- }
-}
-
-prefix = 'yardstick.benchmark.contexts.kubernetes'
-
-
-class KubernetesTestCase(unittest.TestCase):
-
- 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))
- 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.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))
- def test_deploy(self,
- mock_set_ssh_key,
- mock_create_rcs,
- mock_get_rc_pods,
- 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.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()
- self.assertTrue(mock_create.called)
- self.assertTrue(mock_delete.called)
-
- @mock.patch('{}.k8s_utils.read_pod_status'.format(prefix))
- def test_wait_until_running(self, mock_read_pod_status):
-
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context.template.pods = ['server']
- mock_read_pod_status.return_value = 'Running'
- 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))
- def test_get_server(self,
- mock_get_service_by_name,
- mock_get_node_ip,
- mock_get_pod_by_name):
- class Service(object):
- def __init__(self):
- self.name = 'yardstick'
- self.node_port = 30000
-
- class Services(object):
- def __init__(self):
- self.ports = [Service()]
-
- class Status(object):
- def __init__(self):
- self.pod_ip = '172.16.10.131'
-
- class Pod(object):
- 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)
-
- @mock.patch('{}.KubernetesContext._create_rc'.format(prefix))
- def test_create_rcs(self, mock_create_rc):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._create_rcs()
- self.assertTrue(mock_create_rc.called)
-
- @mock.patch('{}.k8s_utils.create_replication_controller'.format(prefix))
- def test_create_rc(self, mock_create_replication_controller):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._create_rc({})
- self.assertTrue(mock_create_replication_controller.called)
-
- @mock.patch('{}.KubernetesContext._delete_rc'.format(prefix))
- def test_delete_rcs(self, mock_delete_rc):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._delete_rcs()
- self.assertTrue(mock_delete_rc.called)
-
- @mock.patch('{}.k8s_utils.delete_replication_controller'.format(prefix))
- def test_delete_rc(self, mock_delete_replication_controller):
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- k8s_context._delete_rc({})
- self.assertTrue(mock_delete_replication_controller.called)
-
- @mock.patch('{}.k8s_utils.get_node_list'.format(prefix))
- def test_get_node_ip(self, mock_get_node_list):
-
- k8s_context = KubernetesContext()
- k8s_context.init(context_cfg)
- 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.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.assertTrue(mock_delete.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/contexts/test_model.py b/tests/unit/benchmark/contexts/test_model.py
deleted file mode 100644
index 53b035b82..000000000
--- a/tests/unit/benchmark/contexts/test_model.py
+++ /dev/null
@@ -1,589 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.contexts.model
-
-from __future__ import absolute_import
-import unittest
-import mock
-
-from yardstick.benchmark.contexts import model
-
-
-class ObjectTestCase(unittest.TestCase):
-
- def setUp(self):
- self.mock_context = mock.Mock()
-
- def test_construct(self):
-
- test_object = model.Object('foo', self.mock_context)
-
- self.assertEqual(test_object.name, 'foo')
- self.assertEqual(test_object._context, self.mock_context)
- self.assertIsNone(test_object.stack_name)
- self.assertIsNone(test_object.stack_id)
-
- def test_dn(self):
-
- self.mock_context.name = 'bar'
- test_object = model.Object('foo', self.mock_context)
-
- self.assertEqual('foo.bar', test_object.dn)
-
-
-class PlacementGroupTestCase(unittest.TestCase):
-
- def setUp(self):
- self.mock_context = mock.Mock()
- self.mock_context.name = 'bar'
-
- def tearDown(self):
- model.PlacementGroup.map = {}
-
- def test_sucessful_construct(self):
-
- test_pg = model.PlacementGroup('foo', self.mock_context, 'affinity')
-
- self.assertEqual(test_pg.name, 'foo')
- self.assertEqual(test_pg.members, set())
- self.assertEqual(test_pg.stack_name, 'bar-foo')
- self.assertEqual(test_pg.policy, 'affinity')
-
- test_map = {'foo': test_pg}
- self.assertEqual(model.PlacementGroup.map, test_map)
-
- def test_wrong_policy_in_construct(self):
-
- self.assertRaises(ValueError, model.PlacementGroup, 'foo',
- self.mock_context, 'baz')
-
- def test_add_member(self):
-
- test_pg = model.PlacementGroup('foo', self.mock_context, 'affinity')
- test_pg.add_member('foo')
-
- self.assertEqual(test_pg.members, set(['foo']))
-
- def test_get_name_successful(self):
-
- model.PlacementGroup.map = {'foo': True}
- self.assertTrue(model.PlacementGroup.get('foo'))
-
- def test_get_name_unsuccessful(self):
-
- self.assertIsNone(model.PlacementGroup.get('foo'))
-
-
-class RouterTestCase(unittest.TestCase):
-
- def test_construct(self):
-
- mock_context = mock.Mock()
- mock_context.name = 'baz'
- test_router = model.Router('foo', 'bar', mock_context, 'qux')
-
- self.assertEqual(test_router.stack_name, 'baz-bar-foo')
- self.assertEqual(test_router.stack_if_name, 'baz-bar-foo-if0')
- self.assertEqual(test_router.external_gateway_info, 'qux')
-
-
-class NetworkTestCase(unittest.TestCase):
-
- def setUp(self):
- self.mock_context = mock.Mock()
- self.mock_context.name = 'bar'
-
- def tearDown(self):
- model.Network.list = []
-
- def test_construct_no_external_network(self):
-
- attrs = {'cidr': '10.0.0.0/24'}
- test_network = model.Network('foo', self.mock_context, attrs)
-
- self.assertEqual(test_network.stack_name, 'bar-foo')
- self.assertEqual(test_network.subnet_stack_name, 'bar-foo-subnet')
- self.assertEqual(test_network.subnet_cidr, attrs['cidr'])
- self.assertIsNone(test_network.router)
- self.assertIn(test_network, model.Network.list)
-
- def test_construct_has_external_network(self):
-
- attrs = {'external_network': 'ext_net'}
- test_network = model.Network('foo', self.mock_context, attrs)
- exp_router = model.Router('router', 'foo', self.mock_context,
- 'ext_net')
-
- self.assertEqual(test_network.router.stack_name, exp_router.stack_name)
- self.assertEqual(test_network.router.stack_if_name,
- exp_router.stack_if_name)
- self.assertEqual(test_network.router.external_gateway_info,
- exp_router.external_gateway_info)
-
- def test_has_route_to(self):
-
- attrs = {'external_network': 'ext_net'}
- test_network = model.Network('foo', self.mock_context, attrs)
-
- self.assertTrue(test_network.has_route_to('ext_net'))
-
- def test_has_no_route_to(self):
-
- attrs = {}
- test_network = model.Network('foo', self.mock_context, attrs)
-
- self.assertFalse(test_network.has_route_to('ext_net'))
-
- @mock.patch('yardstick.benchmark.contexts.model.Network.has_route_to')
- def test_find_by_route_to(self, mock_has_route_to):
-
- mock_network = mock.Mock()
- model.Network.list = [mock_network]
- mock_has_route_to.return_value = True
-
- self.assertIs(mock_network, model.Network.find_by_route_to('foo'))
-
- def test_find_external_network(self):
-
- mock_network = mock.Mock()
- mock_network.router = mock.Mock()
- mock_network.router.external_gateway_info = 'ext_net'
- model.Network.list = [mock_network]
-
- self.assertEqual(model.Network.find_external_network(), 'ext_net')
-
- def test_construct_gateway_ip_is_null(self):
-
- attrs = {'gateway_ip': 'null'}
- test_network = model.Network('foo', self.mock_context, attrs)
- self.assertEqual(test_network.gateway_ip, 'null')
-
- def test_construct_gateway_ip_is_none(self):
-
- attrs = {'gateway_ip': None}
- test_network = model.Network('foo', self.mock_context, attrs)
- self.assertEqual(test_network.gateway_ip, 'null')
-
- def test_construct_gateway_ip_is_absent(self):
-
- attrs = {}
- test_network = model.Network('foo', self.mock_context, attrs)
- self.assertIsNone(test_network.gateway_ip)
-
-
-class ServerTestCase(unittest.TestCase):
-
- def setUp(self):
- self.mock_context = mock.Mock()
- self.mock_context.name = 'bar'
- self.mock_context.keypair_name = 'some-keys'
- self.mock_context.secgroup_name = 'some-secgroup'
- self.mock_context.user = "some-user"
- netattrs = {'cidr': '10.0.0.0/24', 'provider': None, 'external_network': 'ext_net'}
- self.mock_context.networks = [model.Network("some-network", self.mock_context, netattrs)]
-
- def test_construct_defaults(self):
-
- attrs = None
- test_server = model.Server('foo', self.mock_context, attrs)
-
- self.assertEqual(test_server.stack_name, 'foo.bar')
- self.assertEqual(test_server.keypair_name, 'some-keys')
- self.assertEqual(test_server.secgroup_name, 'some-secgroup')
- self.assertEqual(test_server.placement_groups, [])
- self.assertIsNone(test_server.server_group)
- self.assertEqual(test_server.instances, 1)
- self.assertIsNone(test_server.floating_ip)
- self.assertIsNone(test_server._image)
- self.assertIsNone(test_server._flavor)
- self.assertIn(test_server, model.Server.list)
-
- @mock.patch('yardstick.benchmark.contexts.model.PlacementGroup')
- def test_construct_get_wrong_placement_group(self, mock_pg):
-
- attrs = {'placement': 'baz'}
- mock_pg.get.return_value = None
-
- self.assertRaises(ValueError, model.Server, 'foo',
- self.mock_context, attrs)
-
- @mock.patch('yardstick.benchmark.contexts.model.PlacementGroup')
- def test_construct_get_wrong_server_group(self, mock_sg):
-
- attrs = {'server_group': 'baz'}
- mock_sg.get.return_value = None
-
- self.assertRaises(ValueError, model.Server, 'foo',
- self.mock_context, attrs)
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test__add_instance(self, mock_template):
- attrs = {'image': 'some-image', 'flavor': 'some-flavor', 'floating_ip': '192.168.1.10',
- 'floating_ip_assoc': 'some-vm',
- 'availability_zone': 'zone'}
- test_server = model.Server('foo', self.mock_context, attrs)
-
- self.mock_context.flavors = ['flavor1', 'flavor2', 'some-flavor']
-
- mock_network = mock.Mock()
- mock_network.name = 'some-network'
- mock_network.stack_name = 'some-network-stack'
- mock_network.allowed_address_pairs = ["1", "2"]
- mock_network.vnic_type = 'normal'
- mock_network.subnet_stack_name = 'some-network-stack-subnet'
- mock_network.provider = 'sriov'
- mock_network.external_network = 'ext_net'
- mock_network.router = model.Router('some-router', 'some-network', self.mock_context,
- 'ext_net')
-
- test_server._add_instance(mock_template, 'some-server',
- [mock_network], 'hints')
-
- mock_template.add_port.assert_called_with(
- 'some-server-some-network-port',
- mock_network.stack_name,
- mock_network.subnet_stack_name,
- mock_network.vnic_type,
- sec_group_id=self.mock_context.secgroup_name,
- provider=mock_network.provider,
- allowed_address_pairs=mock_network.allowed_address_pairs)
-
- mock_template.add_floating_ip.assert_called_with(
- 'some-server-fip',
- mock_network.external_network,
- 'some-server-some-network-port',
- 'bar-some-network-some-router-if0',
- 'some-secgroup'
- )
-
- mock_template.add_floating_ip_association.assert_called_with(
- 'some-server-fip-assoc',
- 'some-server-fip',
- 'some-server-some-network-port'
- )
-
- mock_template.add_server.assert_called_with(
- 'some-server', 'some-image',
- flavor='some-flavor',
- flavors=['flavor1', 'flavor2', 'some-flavor'],
- ports=['some-server-some-network-port'],
- user=self.mock_context.user,
- key_name=self.mock_context.keypair_name,
- user_data='',
- scheduler_hints='hints',
- availability_zone='zone')
-
- def test_override_ip(self):
- network_ports = {
- 'mgmt': ['mgmt'],
- 'uplink_0': [
- {'xe0': {'local_ip': '10.44.0.20', 'netmask': '255.255.255.0'}},
- ],
- 'downlink_0': [
- {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
- ],
- }
- attrs = {
- 'image': 'some-image', 'flavor': 'some-flavor',
- }
- test_server = model.Server('foo', self.mock_context, attrs)
- test_server.interfaces = {
- "xe0": {
- "local_ip": "1.2.3.4",
- "netmask": "255.255.255.0",
- },
- "xe1": {
- "local_ip": "1.2.3.5",
- "netmask": "255.255.255.0"
- }
- }
- test_server.network_ports = network_ports
-
- test_server.override_ip("uplink_0", {"port": "xe0"})
- self.assertEqual(test_server.interfaces["xe0"], network_ports["uplink_0"][0]["xe0"])
-
- def test_override_ip_multiple(self):
- network_ports = {
- 'mgmt': ['mgmt'],
- 'uplink_0': [
- {'xe0': {'local_ip': '10.44.0.20', 'netmask': '255.255.255.0'}},
- {'xe0': {'local_ip': '10.44.0.21', 'netmask': '255.255.255.0'}},
- ],
- 'downlink_0': [
- {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
- ],
- }
- attrs = {
- 'image': 'some-image', 'flavor': 'some-flavor',
- }
- test_server = model.Server('foo', self.mock_context, attrs)
- test_server.interfaces = {
- "xe0": {
- "local_ip": "1.2.3.4",
- "netmask": "255.255.255.0",
- },
- "xe1": {
- "local_ip": "1.2.3.5",
- "netmask": "255.255.255.0"
- }
- }
- test_server.network_ports = network_ports
- test_server.override_ip("uplink_0", {"port": "xe0"})
- self.assertEqual(test_server.interfaces["xe0"], network_ports["uplink_0"][0]["xe0"])
-
- def test_override_ip_mixed(self):
- network_ports = {
- 'mgmt': ['mgmt'],
- 'uplink_0': [
- 'xe0',
- {'xe0': {'local_ip': '10.44.0.21', 'netmask': '255.255.255.0'}},
- ],
- 'downlink_0': [
- {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
- ],
- }
- attrs = {
- 'image': 'some-image', 'flavor': 'some-flavor',
- }
- test_server = model.Server('foo', self.mock_context, attrs)
- test_server.interfaces = {
- "xe0": {
- "local_ip": "1.2.3.4",
- "netmask": "255.255.255.0",
- },
- "xe1": {
- "local_ip": "1.2.3.5",
- "netmask": "255.255.255.0"
- }
- }
- test_server.network_ports = network_ports
- test_server.override_ip("uplink_0", {"port": "xe0"})
- self.assertEqual(test_server.interfaces["xe0"], network_ports["uplink_0"][1]["xe0"])
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test__add_instance_with_ip_override_invalid_syntax(self, mock_template):
- network_ports = {
- 'mgmt': ['mgmt'],
- 'uplink_0': 'xe0',
- 'downlink_0': [
- {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
- ],
- }
- attrs = {
- 'image': 'some-image', 'flavor': 'some-flavor',
- }
- test_server = model.Server('foo', self.mock_context, attrs)
- test_server.network_ports = network_ports
- context = type("Context", (object,), {})
- # can't use Mock because Mock.name is reserved
- context.name = "context"
- networks = [model.Network(n, context, {}) for n in network_ports]
-
- with self.assertRaises(SyntaxError):
- test_server._add_instance(mock_template, 'some-server',
- networks, 'hints')
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test__add_instance_with_ip_override(self, mock_template):
- network_ports = {
- 'mgmt': ['mgmt'],
- 'uplink_0': [
- {'xe0': {'local_ip': '10.44.0.20', 'netmask': '255.255.255.0'}},
- ],
- 'downlink_0': [
- {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
- ],
- }
- attrs = {
- 'image': 'some-image', 'flavor': 'some-flavor',
- }
- test_server = model.Server('foo', self.mock_context, attrs)
- test_server.network_ports = network_ports
- context = type("Context", (object,), {})
- # can't use Mock because Mock.name is reserved
- context.name = "context"
- networks = [model.Network(n, context, {}) for n in network_ports]
-
- test_server._add_instance(mock_template, 'some-server',
- networks, 'hints')
- self.assertEqual(test_server.ports, {
- 'downlink_0': [{'port': 'xe1', 'stack_name': 'some-server-xe1-port'}],
- 'mgmt': [{'port': 'mgmt', 'stack_name': 'some-server-mgmt-port'}],
- 'uplink_0': [{'port': 'xe0', 'stack_name': 'some-server-xe0-port'}]
- })
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test__add_instance_with_multiple_ip_override(self, mock_template):
- network_ports = {
- 'mgmt': ['mgmt'],
- 'uplink_0': [
- {'xe0': {'local_ip': '10.44.0.20', 'netmask': '255.255.255.0'}},
- {'xe0': {'local_ip': '10.44.0.21', 'netmask': '255.255.255.0'}},
- ],
- 'downlink_0': [
- {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
- ],
- }
- attrs = {
- 'image': 'some-image', 'flavor': 'some-flavor',
- }
- test_server = model.Server('foo', self.mock_context, attrs)
- test_server.network_ports = network_ports
- context = type("Context", (object,), {})
- # can't use Mock because Mock.name is reserved
- context.name = "context"
- networks = [model.Network(n, context, {}) for n in network_ports]
-
- test_server._add_instance(mock_template, 'some-server',
- networks, 'hints')
- self.assertEqual(test_server.ports, {
- 'downlink_0': [{'port': 'xe1', 'stack_name': 'some-server-xe1-port'}],
- 'mgmt': [{'port': 'mgmt', 'stack_name': 'some-server-mgmt-port'}],
- 'uplink_0': [{'port': 'xe0', 'stack_name': 'some-server-xe0-port'},
- # this is not an error, we can produce this, it is left to Heat
- # to detect duplicate ports and error
- {'port': 'xe0', 'stack_name': 'some-server-xe0-port'}]
- })
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test__add_instance_with_user_data(self, mock_template):
- user_data = "USER_DATA"
- attrs = {
- 'image': 'some-image', 'flavor': 'some-flavor',
- 'user_data': user_data,
- }
- test_server = model.Server('foo', self.mock_context, attrs)
-
- test_server._add_instance(mock_template, 'some-server',
- [], 'hints')
-
- mock_template.add_server.assert_called_with(
- 'some-server', 'some-image',
- flavor='some-flavor',
- flavors=self.mock_context.flavors,
- ports=[],
- user=self.mock_context.user,
- key_name=self.mock_context.keypair_name,
- user_data=user_data,
- scheduler_hints='hints',
- availability_zone=None)
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test__add_instance_with_availablity_zone(self, mock_template):
- attrs = {
- 'image': 'some-image', 'flavor': 'some-flavor',
- 'availability_zone': 'zone',
- }
- test_server = model.Server('foo', self.mock_context, attrs)
-
- test_server._add_instance(mock_template, 'some-server',
- [], 'hints')
-
- mock_template.add_server.assert_called_with(
- 'some-server', 'some-image',
- flavor='some-flavor',
- flavors=self.mock_context.flavors,
- ports=[],
- user=self.mock_context.user,
- key_name=self.mock_context.keypair_name,
- user_data='',
- scheduler_hints='hints',
- availability_zone='zone')
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test__add_instance_plus_flavor(self, mock_template):
-
- user_data = ''
- attrs = {
- 'image': 'some-image', 'flavor': 'flavor1',
- 'flavors': ['flavor2'], 'user_data': user_data
- }
- test_server = model.Server('ServerFlavor-2', self.mock_context, attrs)
-
- self.mock_context.flavors = ['flavor2']
- mock_network = mock.Mock()
- mock_network.allowed_address_pairs = ["1", "2"]
- mock_network.vnic_type = 'normal'
- mock_network.configure_mock(name='some-network', stack_name='some-network-stack',
- subnet_stack_name='some-network-stack-subnet',
- provider='some-provider')
-
- test_server._add_instance(mock_template, 'ServerFlavor-2',
- [mock_network], 'hints')
-
- mock_template.add_port.assert_called_with(
- 'ServerFlavor-2-some-network-port',
- mock_network.stack_name,
- mock_network.subnet_stack_name,
- mock_network.vnic_type,
- provider=mock_network.provider,
- sec_group_id=self.mock_context.secgroup_name,
- allowed_address_pairs=mock_network.allowed_address_pairs)
-
- mock_template.add_server.assert_called_with(
- 'ServerFlavor-2', 'some-image',
- flavor='flavor1',
- flavors=['flavor2'],
- ports=['ServerFlavor-2-some-network-port'],
- user=self.mock_context.user,
- key_name=self.mock_context.keypair_name,
- user_data=user_data,
- scheduler_hints='hints',
- availability_zone=None)
-
- @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
- def test__add_instance_misc(self, mock_template):
-
- user_data = ''
- attrs = {
- 'image': 'some-image', 'flavor': 'flavor1',
- 'flavors': ['flavor2'], 'user_data': user_data
- }
- test_server = model.Server('ServerFlavor-3', self.mock_context, attrs)
-
- self.mock_context.flavors = ['flavor2']
- self.mock_context.flavor = {'vcpus': 4}
- mock_network = mock.Mock()
- mock_network.name = 'some-network'
- mock_network.stack_name = 'some-network-stack'
- mock_network.subnet_stack_name = 'some-network-stack-subnet'
-
- test_server._add_instance(mock_template, 'ServerFlavor-3',
- [mock_network], 'hints')
-
- mock_template.add_port(
- 'ServerFlavor-3-some-network-port',
- mock_network.stack_name,
- mock_network.subnet_stack_name,
- sec_group_id=self.mock_context.secgroup_name)
-
- mock_template.add_flavor(
- vcpus=4,
- ram=2048,
- disk=1)
-
- mock_template.add_flavor(
- vcpus=4,
- ram=2048,
- disk=1,
- extra_specs={'cat': 1, 'dog': 2, 'dragon': 1000})
-
- mock_template.add_server.assert_called_with(
- 'ServerFlavor-3', 'some-image',
- flavor='flavor1',
- flavors=['flavor2'],
- ports=['ServerFlavor-3-some-network-port'],
- user=self.mock_context.user,
- key_name=self.mock_context.keypair_name,
- user_data=user_data,
- scheduler_hints='hints',
- availability_zone=None)
diff --git a/tests/unit/benchmark/contexts/test_node.py b/tests/unit/benchmark/contexts/test_node.py
deleted file mode 100644
index a2e2f7b9a..000000000
--- a/tests/unit/benchmark/contexts/test_node.py
+++ /dev/null
@@ -1,398 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015-2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.contexts.node
-
-from __future__ import absolute_import
-import os
-import unittest
-import errno
-import mock
-
-from yardstick.common import constants as consts
-from yardstick.benchmark.contexts import node
-
-
-class NodeContextTestCase(unittest.TestCase):
-
- PREFIX = 'yardstick.benchmark.contexts.node'
-
- NODES_SAMPLE = "nodes_sample.yaml"
- NODES_DUPLICATE_SAMPLE = "nodes_duplicate_sample.yaml"
-
- def setUp(self):
- self.test_context = node.NodeContext()
- self.os_path_join = os.path.join
-
- def _get_file_abspath(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- file_path = self.os_path_join(curr_path, filename)
- return file_path
-
- def test___init__(self):
- self.assertIsNone(self.test_context.name)
- self.assertIsNone(self.test_context.file_path)
- self.assertEqual(self.test_context.nodes, [])
- self.assertEqual(self.test_context.controllers, [])
- self.assertEqual(self.test_context.computes, [])
- self.assertEqual(self.test_context.baremetals, [])
- self.assertEqual(self.test_context.env, {})
- self.assertEqual(self.test_context.attrs, {})
-
- @mock.patch('{}.os.path.join'.format(PREFIX))
- def test_init_negative(self, mock_path_join):
- special_path = '/foo/bar/error_file'
- error_path = self._get_file_abspath("error_file")
-
- def path_join(*args):
- if args == (consts.YARDSTICK_ROOT_PATH, error_path):
- return special_path
- return self.os_path_join(*args)
-
- # we can't count mock_path_join calls because
- # it can catch join calls for .pyc files.
- mock_path_join.side_effect = path_join
- self.test_context.read_config_file = read_mock = mock.Mock()
- read_calls = 0
-
- with self.assertRaises(KeyError):
- self.test_context.init({})
-
- self.assertEqual(read_mock.call_count, read_calls)
-
- attrs = {
- 'name': 'foo',
- 'file': error_path,
- }
- read_mock.side_effect = IOError(errno.EBUSY, 'busy')
- with self.assertRaises(IOError) as raised:
- self.test_context.init(attrs)
-
- read_calls += 1
- self.assertEqual(read_mock.called, read_calls)
- self.assertIn(attrs['file'], self.test_context.file_path)
- self.assertEqual(raised.exception.errno, errno.EBUSY)
- self.assertEqual(str(raised.exception), str(read_mock.side_effect))
-
- read_mock.side_effect = IOError(errno.ENOENT, 'not found')
- with self.assertRaises(IOError) as raised:
- self.test_context.init(attrs)
-
- read_calls += 2
- self.assertEqual(read_mock.call_count, read_calls)
- self.assertEqual(self.test_context.file_path, special_path)
- self.assertEqual(raised.exception.errno, errno.ENOENT)
- self.assertEqual(str(raised.exception), str(read_mock.side_effect))
-
- def test_read_config_file(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
-
- self.test_context.init(attrs)
-
- self.assertIsNotNone(self.test_context.read_config_file())
-
- def test__dispatch_script(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
-
- self.test_context.init(attrs)
-
- self.test_context.env = {'bash': [{'script': 'dummy'}]}
- self.test_context._execute_script = mock.Mock()
- self.assertEqual(self.test_context._dispatch_script('bash'), None)
-
- def test__dispatch_ansible(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
-
- self.test_context.init(attrs)
-
- self.test_context.env = {'ansible': [{'script': 'dummy'}]}
- self.test_context._do_ansible_job = mock.Mock()
- self.assertEqual(self.test_context._dispatch_ansible('ansible'), None)
- self.test_context.env = {}
- self.assertEqual(self.test_context._dispatch_ansible('ansible'), None)
-
- @mock.patch("{}.AnsibleCommon".format(PREFIX))
- def test__do_ansible_job(self, mock_ansible):
- self.assertEqual(None, self.test_context._do_ansible_job('dummy'))
-
- def test_successful_init(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
-
- self.test_context.init(attrs)
-
- self.assertEqual(self.test_context.name, "foo")
- self.assertEqual(len(self.test_context.nodes), 4)
- self.assertEqual(len(self.test_context.controllers), 2)
- self.assertEqual(len(self.test_context.computes), 1)
- self.assertEqual(self.test_context.computes[0]["name"], "node3")
- self.assertEqual(len(self.test_context.baremetals), 1)
- self.assertEqual(self.test_context.baremetals[0]["name"], "node4")
-
- def test__get_server_with_dic_attr_name(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
-
- self.test_context.init(attrs)
-
- attr_name = {'name': 'foo.bar'}
- result = self.test_context._get_server(attr_name)
-
- self.assertEqual(result, None)
-
- def test__get_server_not_found(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
-
- self.test_context.init(attrs)
-
- attr_name = 'bar.foo'
- result = self.test_context._get_server(attr_name)
-
- self.assertEqual(result, None)
-
- def test__get_server_mismatch(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
-
- self.test_context.init(attrs)
-
- attr_name = 'bar.foo1'
- result = self.test_context._get_server(attr_name)
-
- self.assertEqual(result, None)
-
- def test__get_server_duplicate(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_DUPLICATE_SAMPLE)
- }
-
- self.test_context.init(attrs)
-
- attr_name = 'node1.foo'
- with self.assertRaises(ValueError):
- self.test_context._get_server(attr_name)
-
- def test__get_server_found(self):
-
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
-
- self.test_context.init(attrs)
-
- attr_name = 'node1.foo'
- result = self.test_context._get_server(attr_name)
-
- self.assertEqual(result['ip'], '10.229.47.137')
- self.assertEqual(result['name'], 'node1.foo')
- self.assertEqual(result['user'], 'root')
- self.assertEqual(result['key_filename'], '/root/.yardstick_key')
-
- @mock.patch('{}.NodeContext._dispatch_script'.format(PREFIX))
- def test_deploy(self, dispatch_script_mock):
- obj = node.NodeContext()
- obj.env = {
- 'type': 'script'
- }
- obj.deploy()
- self.assertTrue(dispatch_script_mock.called)
-
- @mock.patch('{}.NodeContext._dispatch_ansible'.format(PREFIX))
- def test_deploy_anisible(self, dispatch_ansible_mock):
- obj = node.NodeContext()
- obj.env = {
- 'type': 'ansible'
- }
- obj.deploy()
- self.assertTrue(dispatch_ansible_mock.called)
-
- @mock.patch('{}.NodeContext._dispatch_script'.format(PREFIX))
- def test_undeploy(self, dispatch_script_mock):
- obj = node.NodeContext()
- obj.env = {
- 'type': 'script'
- }
- obj.undeploy()
- self.assertTrue(dispatch_script_mock.called)
-
- @mock.patch('{}.NodeContext._dispatch_ansible'.format(PREFIX))
- def test_undeploy_anisble(self, dispatch_ansible_mock):
- obj = node.NodeContext()
- obj.env = {
- 'type': 'ansible'
- }
- obj.undeploy()
- self.assertTrue(dispatch_ansible_mock.called)
-
- @mock.patch('{}.ssh.SSH._put_file_shell'.format(PREFIX))
- @mock.patch('{}.ssh.SSH.execute'.format(PREFIX))
- def test_execute_remote_script(self, execute_mock, put_file_mock):
- obj = node.NodeContext()
- obj.env = {'prefix': 'yardstick.benchmark.scenarios.compute'}
- node_name_args = 'node5'
- obj.nodes = [{
- 'name': node_name_args,
- 'user': 'ubuntu',
- 'ip': '10.10.10.10',
- 'pwd': 'ubuntu',
- }]
-
- info = {'script': 'computecapacity.bash'}
- execute_mock.return_value = (0, '', '')
- obj._execute_remote_script('node5', info)
-
- self.assertTrue(put_file_mock.called)
- self.assertTrue(execute_mock.called)
-
- @mock.patch('{}.NodeContext._execute_local_script'.format(PREFIX))
- def test_execute_script_local(self, local_execute_mock):
- node_name = 'local'
- info = {}
- node.NodeContext()._execute_script(node_name, info)
- self.assertTrue(local_execute_mock.called)
-
- @mock.patch('{}.NodeContext._execute_remote_script'.format(PREFIX))
- def test_execute_script_remote(self, remote_execute_mock):
- node_name = 'node5'
- info = {}
- node.NodeContext()._execute_script(node_name, info)
- self.assertTrue(remote_execute_mock.called)
-
- def test_get_script(self):
- script_args = 'hello.bash'
- info_args = {
- 'script': script_args
- }
- script, options = node.NodeContext()._get_script(info_args)
- self.assertEqual(script_args, script)
- self.assertEqual('', options)
-
- def test_node_info(self):
- node_name_args = 'node5'
- obj = node.NodeContext()
- obj.nodes = [{'name': node_name_args, 'check': node_name_args}]
- node_info = obj._get_node_info(node_name_args)
- self.assertEqual(node_info.get('check'), node_name_args)
-
- @mock.patch('{}.ssh.SSH.wait'.format(PREFIX))
- def test_get_client(self, wait_mock):
- node_name_args = 'node5'
- obj = node.NodeContext()
- obj.nodes = [{
- 'name': node_name_args,
- 'user': 'ubuntu',
- 'ip': '10.10.10.10',
- 'pwd': 'ubuntu',
- }]
- obj._get_client(node_name_args)
- self.assertTrue(wait_mock.called)
-
- def test_get_server(self):
- self.test_context.name = 'vnf1'
- self.test_context.nodes = [{'name': 'my', 'value': 100}]
-
- with self.assertRaises(ValueError):
- self.test_context.get_server('my.vnf2')
-
- expected = {'name': 'my.vnf1', 'value': 100, 'interfaces': {}}
- result = self.test_context.get_server('my.vnf1')
- self.assertDictEqual(result, expected)
-
- def test_get_context_from_server(self):
- self.test_context.name = 'vnf1'
- self.test_context.nodes = [{'name': 'my', 'value': 100}]
- self.test_context.attrs = {'attr1': 200}
-
- with self.assertRaises(ValueError):
- self.test_context.get_context_from_server('my.vnf2')
-
- result = self.test_context.get_context_from_server('my.vnf1')
- self.assertIs(result, self.test_context)
-
- def test__get_network(self):
- network1 = {
- 'name': 'net_1',
- 'vld_id': 'vld111',
- 'segmentation_id': 'seg54',
- 'network_type': 'type_a',
- 'physical_network': 'phys',
- }
- network2 = {
- 'name': 'net_2',
- 'vld_id': 'vld999',
- }
- self.test_context.networks = {
- 'a': network1,
- 'b': network2,
- }
-
- attr_name = {}
- self.assertIsNone(self.test_context._get_network(attr_name))
-
- attr_name = {'vld_id': 'vld777'}
- self.assertIsNone(self.test_context._get_network(attr_name))
-
- self.assertIsNone(self.test_context._get_network(None))
-
- attr_name = 'vld777'
- self.assertIsNone(self.test_context._get_network(attr_name))
-
- attr_name = {'vld_id': 'vld999'}
- expected = {
- "name": 'net_2',
- "vld_id": 'vld999',
- "segmentation_id": None,
- "network_type": None,
- "physical_network": None,
- }
- result = self.test_context._get_network(attr_name)
- self.assertDictEqual(result, expected)
-
- attr_name = 'a'
- expected = network1
- result = self.test_context._get_network(attr_name)
- self.assertDictEqual(result, expected)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/core/__init__.py b/tests/unit/benchmark/core/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/core/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml b/tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml
deleted file mode 100644
index 44c4a31ff..000000000
--- a/tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
----
-# Huawei US bare daily task suite
-
-schema: "yardstick:suite:0.1"
-
-name: "os-nosdn-nofeature-ha"
-test_cases_dir: "tests/opnfv/test_cases/"
-test_cases:
--
- file_name: opnfv_yardstick_tc037.yaml
--
- file_name: opnfv_yardstick_tc043.yaml
-
diff --git a/tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml b/tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml
deleted file mode 100644
index ced13f19e..000000000
--- a/tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml
+++ /dev/null
@@ -1,23 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
----
-# Huawei US bare daily task suite
-
-schema: "yardstick:suite:0.1"
-
-name: "os-nosdn-nofeature-ha"
-test_cases_dir: "tests/opnfv/test_cases/"
-test_cases:
--
- file_name: opnfv_yardstick_tc037.yaml
--
- file_name: opnfv_yardstick_tc043.yaml
- task_args:
- huawei-pod1: '{"host": "node1.LF","target": "node2.LF"}'
-
diff --git a/tests/unit/benchmark/core/test_plugin.py b/tests/unit/benchmark/core/test_plugin.py
deleted file mode 100644
index f9c076159..000000000
--- a/tests/unit/benchmark/core/test_plugin.py
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.core.plugin
-from __future__ import absolute_import
-import os
-from os.path import dirname as dirname
-
-try:
- from unittest import mock
-except ImportError:
- import mock
-import unittest
-
-from yardstick.benchmark.core import plugin
-
-
-class Arg(object):
-
- def __init__(self):
- # self.input_file = ('plugin/sample_config.yaml',)
- self.input_file = [
- os.path.join(os.path.abspath(
- dirname(dirname(dirname(dirname(dirname(__file__)))))),
- 'plugin/sample_config.yaml')]
-
-
-@mock.patch('yardstick.benchmark.core.plugin.ssh')
-class pluginTestCase(unittest.TestCase):
-
- def setUp(self):
- self.result = {}
-
- def test_install(self, mock_ssh):
- p = plugin.Plugin()
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- input_file = Arg()
- p.install(input_file)
- expected_result = {}
- self.assertEqual(self.result, expected_result)
-
- def test_remove(self, mock_ssh):
- p = plugin.Plugin()
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- input_file = Arg()
- p.remove(input_file)
- expected_result = {}
- self.assertEqual(self.result, expected_result)
-
- def test_install_setup_run(self, mock_ssh):
- p = plugin.Plugin()
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- plugins = {
- "name": "sample"
- }
- deployment = {
- "ip": "10.1.0.50",
- "user": "root",
- "password": "root"
- }
- plugin_name = plugins.get("name")
- p._install_setup(plugin_name, deployment)
- self.assertIsNotNone(p.client)
-
- p._run(plugin_name)
- expected_result = {}
- self.assertEqual(self.result, expected_result)
-
- def test_remove_setup_run(self, mock_ssh):
- p = plugin.Plugin()
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- plugins = {
- "name": "sample"
- }
- deployment = {
- "ip": "10.1.0.50",
- "user": "root",
- "password": "root"
- }
- plugin_name = plugins.get("name")
- p._remove_setup(plugin_name, deployment)
- self.assertIsNotNone(p.client)
-
- p._run(plugin_name)
- expected_result = {}
- self.assertEqual(self.result, expected_result)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/core/test_report.py b/tests/unit/benchmark/core/test_report.py
deleted file mode 100644
index 69546928c..000000000
--- a/tests/unit/benchmark/core/test_report.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2017 Rajesh Kudaka.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.core.report
-
-from __future__ import print_function
-
-from __future__ import absolute_import
-
-import unittest
-import uuid
-
-try:
- from unittest import mock
-except ImportError:
- import mock
-
-from yardstick.benchmark.core import report
-from yardstick.cmd.commands import change_osloobj_to_paras
-
-FAKE_YAML_NAME = 'fake_name'
-FAKE_TASK_ID = str(uuid.uuid4())
-FAKE_DB_FIELDKEYS = [{'fieldKey': 'fake_key'}]
-FAKE_TIME = '0000-00-00T00:00:00.000000Z'
-FAKE_DB_TASK = [{'fake_key': 0.000, 'time': FAKE_TIME}]
-FAKE_TIMESTAMP = ['fake_time']
-DUMMY_TASK_ID = 'aaaaaa-aaaaaaaa-aaaaaaaaaa-aaaaaa'
-
-
-class ReportTestCase(unittest.TestCase):
-
- def setUp(self):
- super(ReportTestCase, self).setUp()
- self.param = change_osloobj_to_paras({})
- self.param.yaml_name = [FAKE_YAML_NAME]
- self.param.task_id = [FAKE_TASK_ID]
- self.rep = report.Report()
-
- @mock.patch('yardstick.benchmark.core.report.Report._get_tasks')
- @mock.patch('yardstick.benchmark.core.report.Report._get_fieldkeys')
- @mock.patch('yardstick.benchmark.core.report.Report._validate')
- def test_generate_success(self, mock_valid, mock_keys, mock_tasks):
- mock_tasks.return_value = FAKE_DB_TASK
- mock_keys.return_value = FAKE_DB_FIELDKEYS
- self.rep.generate(self.param)
- mock_valid.assert_called_once_with(FAKE_YAML_NAME, FAKE_TASK_ID)
- self.assertEqual(1, mock_tasks.call_count)
- self.assertEqual(1, mock_keys.call_count)
-
- def test_invalid_yaml_name(self):
- self.assertRaisesRegexp(ValueError, "yaml*", self.rep._validate,
- 'F@KE_NAME', FAKE_TASK_ID)
-
- def test_invalid_task_id(self):
- self.assertRaisesRegexp(ValueError, "task*", self.rep._validate,
- FAKE_YAML_NAME, DUMMY_TASK_ID)
-
- @mock.patch('api.utils.influx.query')
- def test_task_not_found(self, mock_query):
- mock_query.return_value = []
- self.rep.yaml_name = FAKE_YAML_NAME
- self.rep.task_id = FAKE_TASK_ID
- self.assertRaisesRegexp(KeyError, "Task ID", self.rep._get_fieldkeys)
- self.assertRaisesRegexp(KeyError, "Task ID", self.rep._get_tasks)
diff --git a/tests/unit/benchmark/core/test_task.py b/tests/unit/benchmark/core/test_task.py
deleted file mode 100644
index bed0bb6d8..000000000
--- a/tests/unit/benchmark/core/test_task.py
+++ /dev/null
@@ -1,314 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.core.task
-
-from __future__ import print_function
-
-from __future__ import absolute_import
-import os
-import unittest
-
-try:
- from unittest import mock
-except ImportError:
- import mock
-
-
-from yardstick.benchmark.core import task
-from yardstick.common import constants as consts
-
-
-class TaskTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.benchmark.core.task.Context')
- def test_parse_nodes_host_target_same_context(self, mock_context):
- nodes = {
- "host": "node1.LF",
- "target": "node2.LF"
- }
- scenario_cfg = {"nodes": nodes}
- server_info = {
- "ip": "10.20.0.3",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- mock_context.get_server.return_value = server_info
- context_cfg = task.parse_nodes_with_context(scenario_cfg)
-
- self.assertEqual(context_cfg["host"], server_info)
- self.assertEqual(context_cfg["target"], server_info)
-
- def test_set_dispatchers(self):
- t = task.Task()
- output_config = {"DEFAULT": {"dispatcher": "file, http"}}
- t._set_dispatchers(output_config)
- self.assertEqual(output_config, output_config)
-
- @mock.patch('yardstick.benchmark.core.task.DispatcherBase')
- def test__do_output(self, mock_dispatcher):
- t = task.Task()
- output_config = {"DEFAULT": {"dispatcher": "file, http"}}
- mock_dispatcher.get = mock.MagicMock(return_value=[mock.MagicMock(),
- mock.MagicMock()])
- self.assertEqual(None, t._do_output(output_config, {}))
-
- @mock.patch('yardstick.benchmark.core.task.Context')
- def test_parse_networks_from_nodes(self, mock_context):
- nodes = {
- 'node1': {
- 'interfaces': {
- 'mgmt': {
- 'network_name': 'mgmt',
- },
- 'xe0': {
- 'network_name': 'uplink_0',
- },
- 'xe1': {
- 'network_name': 'downlink_0',
- },
- },
- },
- 'node2': {
- 'interfaces': {
- 'mgmt': {
- 'network_name': 'mgmt',
- },
- 'uplink_0': {
- 'network_name': 'uplink_0',
- },
- 'downlink_0': {
- 'network_name': 'downlink_0',
- },
- },
- },
- }
-
- mock_context.get_network.side_effect = iter([
- None,
- {
- 'name': 'mgmt',
- 'network_type': 'flat',
- },
- {},
- {
- 'name': 'uplink_0',
- 'subnet_cidr': '10.20.0.0/16',
- },
- {
- 'name': 'downlink_0',
- 'segmentation_id': '1001',
- },
- {
- 'name': 'uplink_1',
- },
- ])
-
- # one for each interface
- expected_get_network_calls = 6
- expected = {
- 'mgmt': {'name': 'mgmt', 'network_type': 'flat'},
- 'uplink_0': {'name': 'uplink_0', 'subnet_cidr': '10.20.0.0/16'},
- 'uplink_1': {'name': 'uplink_1'},
- 'downlink_0': {'name': 'downlink_0', 'segmentation_id': '1001'},
- }
-
- networks = task.get_networks_from_nodes(nodes)
- self.assertEqual(mock_context.get_network.call_count, expected_get_network_calls)
- self.assertDictEqual(networks, expected)
-
- @mock.patch('yardstick.benchmark.core.task.Context')
- @mock.patch('yardstick.benchmark.core.task.base_runner')
- def test_run(self, mock_base_runner, mock_ctx):
- scenario = {
- 'host': 'athena.demo',
- 'target': 'ares.demo',
- 'runner': {
- 'duration': 60,
- 'interval': 1,
- 'type': 'Duration'
- },
- 'type': 'Ping'
- }
-
- t = task.Task()
- runner = mock.Mock()
- runner.join.return_value = 0
- runner.get_output.return_value = {}
- runner.get_result.return_value = []
- mock_base_runner.Runner.get.return_value = runner
- t._run([scenario], False, "yardstick.out")
- self.assertTrue(runner.run.called)
-
- @mock.patch('yardstick.benchmark.core.task.os')
- def test_check_precondition(self, mock_os):
- cfg = {
- 'precondition': {
- 'installer_type': 'compass',
- 'deploy_scenarios': 'os-nosdn',
- 'pod_name': 'huawei-pod1'
- }
- }
-
- t = task.TaskParser('/opt')
- mock_os.environ.get.side_effect = ['compass',
- 'os-nosdn',
- 'huawei-pod1']
- result = t._check_precondition(cfg)
- self.assertTrue(result)
-
- def test_parse_suite_no_constraint_no_args(self):
- SAMPLE_SCENARIO_PATH = "no_constraint_no_args_scenario_sample.yaml"
- t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
- with mock.patch('yardstick.benchmark.core.task.os.environ',
- new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}):
- task_files, task_args, task_args_fnames = t.parse_suite()
- print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
- task_args_fnames))
- self.assertEqual(task_files[0], self.change_to_abspath(
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
- self.assertEqual(task_files[1], self.change_to_abspath(
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
- self.assertEqual(task_args[0], None)
- self.assertEqual(task_args[1], None)
- self.assertEqual(task_args_fnames[0], None)
- self.assertEqual(task_args_fnames[1], None)
-
- @mock.patch('yardstick.benchmark.core.task.os.environ')
- def test_parse_suite_no_constraint_with_args(self, mock_environ):
- SAMPLE_SCENARIO_PATH = "no_constraint_with_args_scenario_sample.yaml"
- t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
- with mock.patch('yardstick.benchmark.core.task.os.environ',
- new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}):
- task_files, task_args, task_args_fnames = t.parse_suite()
- print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
- task_args_fnames))
- self.assertEqual(task_files[0], self.change_to_abspath(
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
- self.assertEqual(task_files[1], self.change_to_abspath(
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
- self.assertEqual(task_args[0], None)
- self.assertEqual(task_args[1],
- '{"host": "node1.LF","target": "node2.LF"}')
- self.assertEqual(task_args_fnames[0], None)
- self.assertEqual(task_args_fnames[1], None)
-
- @mock.patch('yardstick.benchmark.core.task.os.environ')
- def test_parse_suite_with_constraint_no_args(self, mock_environ):
- SAMPLE_SCENARIO_PATH = "with_constraint_no_args_scenario_sample.yaml"
- t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
- with mock.patch('yardstick.benchmark.core.task.os.environ',
- new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}):
- task_files, task_args, task_args_fnames = t.parse_suite()
- print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
- task_args_fnames))
- self.assertEqual(task_files[0], self.change_to_abspath(
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
- self.assertEqual(task_files[1], self.change_to_abspath(
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
- self.assertEqual(task_args[0], None)
- self.assertEqual(task_args[1], None)
- self.assertEqual(task_args_fnames[0], None)
- self.assertEqual(task_args_fnames[1], None)
-
- @mock.patch('yardstick.benchmark.core.task.os.environ')
- def test_parse_suite_with_constraint_with_args(self, mock_environ):
- SAMPLE_SCENARIO_PATH = "with_constraint_with_args_scenario_sample.yaml"
- t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
- with mock.patch('yardstick.benchmark.core.task.os.environ',
- new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}):
- task_files, task_args, task_args_fnames = t.parse_suite()
- print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
- task_args_fnames))
- self.assertEqual(task_files[0], self.change_to_abspath(
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
- self.assertEqual(task_files[1], self.change_to_abspath(
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
- self.assertEqual(task_args[0], None)
- self.assertEqual(task_args[1],
- '{"host": "node1.LF","target": "node2.LF"}')
- self.assertEqual(task_args_fnames[0], None)
- self.assertEqual(task_args_fnames[1], None)
-
- def test_parse_options(self):
- options = {
- 'openstack': {
- 'EXTERNAL_NETWORK': '$network'
- },
- 'ndoes': ['node1', '$node'],
- 'host': '$host'
- }
-
- t = task.Task()
- t.outputs = {
- 'network': 'ext-net',
- 'node': 'node2',
- 'host': 'server.yardstick'
- }
-
- idle_result = {
- 'openstack': {
- 'EXTERNAL_NETWORK': 'ext-net'
- },
- 'ndoes': ['node1', 'node2'],
- 'host': 'server.yardstick'
- }
-
- actual_result = t._parse_options(options)
- self.assertEqual(idle_result, actual_result)
-
- def test_change_server_name_host_str(self):
- scenario = {'host': 'demo'}
- suffix = '-8'
- task.change_server_name(scenario, suffix)
- self.assertTrue(scenario['host'], 'demo-8')
-
- def test_change_server_name_host_dict(self):
- scenario = {'host': {'name': 'demo'}}
- suffix = '-8'
- task.change_server_name(scenario, suffix)
- self.assertTrue(scenario['host']['name'], 'demo-8')
-
- def test_change_server_name_target_str(self):
- scenario = {'target': 'demo'}
- suffix = '-8'
- task.change_server_name(scenario, suffix)
- self.assertTrue(scenario['target'], 'demo-8')
-
- def test_change_server_name_target_dict(self):
- scenario = {'target': {'name': 'demo'}}
- suffix = '-8'
- task.change_server_name(scenario, suffix)
- self.assertTrue(scenario['target']['name'], 'demo-8')
-
- @mock.patch('yardstick.benchmark.core.task.utils')
- @mock.patch('yardstick.benchmark.core.task.logging')
- def test_set_log(self, mock_logging, mock_utils):
- task_obj = task.Task()
- task_obj.task_id = 'task_id'
- task_obj._set_log()
- self.assertTrue(mock_logging.root.addHandler.called)
-
- def _get_file_abspath(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- file_path = os.path.join(curr_path, filename)
- return file_path
-
- def change_to_abspath(self, filepath):
- return os.path.join(consts.YARDSTICK_ROOT_PATH, filepath)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/core/test_testcase.py b/tests/unit/benchmark/core/test_testcase.py
deleted file mode 100644
index 1f5aad75e..000000000
--- a/tests/unit/benchmark/core/test_testcase.py
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.cmd.commands.testcase
-
-from __future__ import absolute_import
-import unittest
-
-from yardstick.benchmark.core import testcase
-
-
-class Arg(object):
-
- def __init__(self):
- self.casename = ('opnfv_yardstick_tc001',)
-
-
-class TestcaseUT(unittest.TestCase):
-
- def test_list_all(self):
- t = testcase.Testcase()
- result = t.list_all("")
- self.assertIsInstance(result, list)
-
- def test_show(self):
- t = testcase.Testcase()
- casename = Arg()
- result = t.show(casename)
- self.assertTrue(result)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml b/tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml
deleted file mode 100644
index 168d4b01a..000000000
--- a/tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
----
-# Huawei US bare daily task suite
-
-schema: "yardstick:suite:0.1"
-
-name: "os-nosdn-nofeature-ha"
-test_cases_dir: "tests/opnfv/test_cases/"
-test_cases:
--
- file_name: opnfv_yardstick_tc037.yaml
--
- file_name: opnfv_yardstick_tc043.yaml
- constraint:
- installer: compass
- pod: huawei-pod1
-
diff --git a/tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml b/tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml
deleted file mode 100644
index 299e5de56..000000000
--- a/tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
----
-# Huawei US bare daily task suite
-
-schema: "yardstick:suite:0.1"
-
-name: "os-nosdn-nofeature-ha"
-test_cases_dir: "tests/opnfv/test_cases/"
-test_cases:
--
- file_name: opnfv_yardstick_tc037.yaml
--
- file_name: opnfv_yardstick_tc043.yaml
- constraint:
- installer: compass
- pod: huawei-pod1
- task_args:
- huawei-pod1: '{"host": "node1.LF","target": "node2.LF"}'
-
diff --git a/tests/unit/benchmark/runner/__init__.py b/tests/unit/benchmark/runner/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/runner/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/runner/test_base.py b/tests/unit/benchmark/runner/test_base.py
deleted file mode 100644
index f47b88e95..000000000
--- a/tests/unit/benchmark/runner/test_base.py
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# 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
-
-from yardstick.benchmark.runners import base
-from yardstick.benchmark.runners.iteration import IterationRunner
-
-
-class ActionTestCase(unittest.TestCase):
-
- @mock.patch("yardstick.benchmark.runners.base.subprocess")
- def test__execute_shell_command(self, mock_subprocess):
- mock_subprocess.check_output.side_effect = Exception()
-
- self.assertEqual(base._execute_shell_command("")[0], -1)
-
- @mock.patch("yardstick.benchmark.runners.base.subprocess")
- def test__single_action(self, mock_subprocess):
- mock_subprocess.check_output.side_effect = Exception()
-
- base._single_action(0, "echo", mock.MagicMock())
-
- @mock.patch("yardstick.benchmark.runners.base.subprocess")
- def test__periodic_action(self, mock_subprocess):
- mock_subprocess.check_output.side_effect = Exception()
-
- base._periodic_action(0, "echo", mock.MagicMock())
-
-
-class RunnerTestCase(unittest.TestCase):
-
- @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'})
-
- idle_result = {
- 'case': 'opnfv_yardstick_tc002',
- 'criteria': 'PASS'
- }
-
- for retries in range(1000):
- time.sleep(0.01)
- if not runner.output_queue.empty():
- break
- actual_result = 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'})
-
- idle_result = [
- {'case': 'opnfv_yardstick_tc002'},
- {'criteria': 'PASS'}
- ]
-
- for retries in range(1000):
- time.sleep(0.01)
- if not runner.result_queue.empty():
- break
- actual_result = runner.get_result()
- self.assertEqual(idle_result, actual_result)
-
- def test__run_benchmark(self):
- runner = base.Runner(mock.Mock())
-
- with self.assertRaises(NotImplementedError):
- runner._run_benchmark(mock.Mock(), mock.Mock(), mock.Mock(), mock.Mock())
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/runner/test_search.py b/tests/unit/benchmark/runner/test_search.py
deleted file mode 100644
index 8fab5a71f..000000000
--- a/tests/unit/benchmark/runner/test_search.py
+++ /dev/null
@@ -1,204 +0,0 @@
-# Copyright (c) 2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import absolute_import
-
-import unittest
-import mock
-
-from tests.unit import STL_MOCKS
-
-STLClient = mock.MagicMock()
-stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
-stl_patch.start()
-
-if stl_patch:
- from yardstick.benchmark.runners.search import SearchRunner
- from yardstick.benchmark.runners.search import SearchRunnerHelper
-
-
-class TestSearchRunnerHelper(unittest.TestCase):
-
- def test___call__(self):
- cls = mock.MagicMock()
- aborted = mock.MagicMock()
- scenario_cfg = {
- 'runner': {},
- }
-
- benchmark = cls()
- method = getattr(benchmark, 'my_method')
- helper = SearchRunnerHelper(cls, 'my_method', scenario_cfg, {}, aborted)
-
- with helper.get_benchmark_instance():
- helper()
-
- self.assertEqual(method.call_count, 1)
-
- def test___call___error(self):
- cls = mock.MagicMock()
- aborted = mock.MagicMock()
- scenario_cfg = {
- 'runner': {},
- }
-
- 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):
- cls = mock.MagicMock()
- aborted = mock.MagicMock()
- scenario_cfg = {
- 'runner': {},
- }
-
- mock_time.time.side_effect = range(1000)
-
- helper = SearchRunnerHelper(cls, 'my_method', scenario_cfg, {}, aborted)
-
- index = -1
- for index in helper.is_not_done():
- if index >= 10:
- break
-
- self.assertGreaterEqual(index, 10)
-
- @mock.patch('yardstick.benchmark.runners.search.time')
- def test_is_not_done_immediate_stop(self, mock_time):
- cls = mock.MagicMock()
- aborted = mock.MagicMock()
- scenario_cfg = {
- 'runner': {
- 'run_step': '',
- },
- }
-
- helper = SearchRunnerHelper(cls, 'my_method', scenario_cfg, {}, aborted)
-
- index = -1
- for index in helper.is_not_done():
- if index >= 10:
- break
-
- self.assertEqual(index, -1)
-
-class TestSearchRunner(unittest.TestCase):
-
- def test__worker_run_once(self):
- def update(*args):
- args[-1].update(data)
-
- data = {
- 'key1': {
- 'inner1': 'value1',
- 'done': 0,
- },
- 'key2': {
- 'done': None,
- },
- }
-
- runner = SearchRunner({})
- runner.worker_helper = mock.MagicMock(side_effect=update)
-
- self.assertFalse(runner._worker_run_once('sequence 1'))
-
- def test__worker_run_once_done(self):
- def update(*args):
- args[-1].update(data)
-
- data = {
- 'key1': {
- 'inner1': 'value1',
- 'done': 0,
- },
- 'key2': {
- 'done': None,
- },
- 'key3': {
- 'done': True,
- },
- 'key4': [],
- 'key5': 'value5',
- }
-
- runner = SearchRunner({})
- runner.worker_helper = mock.MagicMock(side_effect=update)
-
- self.assertTrue(runner._worker_run_once('sequence 1'))
-
- def test__worker_run_once_assertion_error_assert(self):
- runner = SearchRunner({})
- runner.sla_action = 'assert'
- runner.worker_helper = mock.MagicMock(side_effect=AssertionError)
-
- with self.assertRaises(AssertionError):
- runner._worker_run_once('sequence 1')
-
- def test__worker_run_once_assertion_error_monitor(self):
- runner = SearchRunner({})
- runner.sla_action = 'monitor'
- runner.worker_helper = mock.MagicMock(side_effect=AssertionError)
-
- self.assertFalse(runner._worker_run_once('sequence 1'))
-
- def test__worker_run_once_non_assertion_error_none(self):
- runner = SearchRunner({})
- runner.worker_helper = mock.MagicMock(side_effect=RuntimeError)
-
- self.assertTrue(runner._worker_run_once('sequence 1'))
-
- def test__worker_run_once_non_assertion_error(self):
- runner = SearchRunner({})
- runner.sla_action = 'monitor'
- runner.worker_helper = mock.MagicMock(side_effect=RuntimeError)
-
- self.assertFalse(runner._worker_run_once('sequence 1'))
-
- def test__worker_run(self):
- cls = mock.MagicMock()
- scenario_cfg = {
- 'runner': {'interval': 0, 'timeout': 1},
- }
-
- runner = SearchRunner({})
- runner._worker_run_once = mock.MagicMock(side_effect=[0, 0, 1])
-
- runner._worker_run(cls, 'my_method', scenario_cfg, {})
-
- def test__worker_run_immediate_stop(self):
- cls = mock.MagicMock()
- scenario_cfg = {
- 'runner': {
- 'run_step': '',
- },
- }
-
- runner = SearchRunner({})
- runner._worker_run(cls, 'my_method', scenario_cfg, {})
-
- @mock.patch('yardstick.benchmark.runners.search.multiprocessing')
- def test__run_benchmark(self, mock_multi_process):
- cls = mock.MagicMock()
- scenario_cfg = {
- 'runner': {},
- }
-
- runner = SearchRunner({})
- runner._run_benchmark(cls, 'my_method', scenario_cfg, {})
- self.assertEqual(mock_multi_process.Process.call_count, 1)
diff --git a/tests/unit/benchmark/scenarios/__init__.py b/tests/unit/benchmark/scenarios/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/scenarios/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/scenarios/availability/__init__.py b/tests/unit/benchmark/scenarios/availability/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/scenarios/availability/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py b/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py
deleted file mode 100644
index cc179602e..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for
-# yardstick.benchmark.scenarios.availability.attacker.attacker_baremetal
-
-from __future__ import absolute_import
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.availability.attacker import \
- attacker_baremetal
-
-
-@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)
- 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)
- self.assertEqual(exitcode, -1)
- mock_log.error.assert_called_once()
-
-
-@mock.patch('yardstick.benchmark.scenarios.availability.attacker.attacker_baremetal.subprocess')
-@mock.patch('yardstick.benchmark.scenarios.availability.attacker.attacker_baremetal.ssh')
-class AttackerBaremetalTestCase(unittest.TestCase):
-
- def setUp(self):
- host = {
- "ipmi_ip": "10.20.0.5",
- "ipmi_user": "root",
- "ipmi_pwd": "123456",
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.context = {"node1": host}
- self.attacker_cfg = {
- 'fault_type': 'bear-metal-down',
- 'host': 'node1',
- }
-
- def test__attacker_baremetal_all_successful(self, mock_ssh, mock_subprocess):
- mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
- ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
- self.context)
-
- ins.setup()
- ins.inject_fault()
- ins.recover()
-
- def test__attacker_baremetal_check_failuer(self, mock_ssh, mock_subprocess):
- mock_ssh.SSH.from_node().execute.return_value = (0, "error check", '')
- ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
- self.context)
- ins.setup()
-
- def test__attacker_baremetal_recover_successful(self, mock_ssh, mock_subprocess):
-
- self.attacker_cfg["jump_host"] = 'node1'
- self.context["node1"]["pwd"] = "123456"
- mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
- ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
- self.context)
-
- ins.setup()
- ins.recover()
diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_general.py b/tests/unit/benchmark/scenarios/availability/test_attacker_general.py
deleted file mode 100644
index 612b5a662..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_attacker_general.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Juan Qiu and others
-# juan_ qiu@tongji.edu.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.availability.attacker
-# .attacker_general
-
-from __future__ import absolute_import
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.availability.attacker import baseattacker
-
-
-@mock.patch('yardstick.benchmark.scenarios.availability.attacker.'
- 'attacker_general.ssh')
-class GeneralAttackerServiceTestCase(unittest.TestCase):
-
- def setUp(self):
- host = {
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.context = {"node1": host}
- self.attacker_cfg = {
- 'fault_type': 'general-attacker',
- 'action_parameter': {'process_name': 'nova_api'},
- 'rollback_parameter': {'process_name': 'nova_api'},
- 'key': 'stop-service',
- 'attack_key': 'stop-service',
- 'host': 'node1',
- }
-
- def test__attacker_service_all_successful(self, mock_ssh):
-
- cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
- ins = cls(self.attacker_cfg, self.context)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
- ins.setup()
- ins.inject_fault()
- ins.recover()
-
- def test__attacker_service_check_failuer(self, mock_ssh):
-
- cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
- ins = cls(self.attacker_cfg, self.context)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, "error check", '')
- ins.setup()
diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_process.py b/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
deleted file mode 100644
index 0a8e8322a..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for
-# yardstick.benchmark.scenarios.availability.attacker.attacker_process
-
-from __future__ import absolute_import
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.availability.attacker import baseattacker
-
-
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.attacker.attacker_process.ssh')
-class AttackerServiceTestCase(unittest.TestCase):
-
- def setUp(self):
- host = {
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.context = {"node1": host}
- self.attacker_cfg = {
- 'fault_type': 'kill-process',
- 'process_name': 'nova-api',
- 'host': 'node1',
- }
-
- def test__attacker_service_all_successful(self, mock_ssh):
-
- cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
- ins = cls(self.attacker_cfg, self.context)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, "10", '')
- ins.setup()
- ins.inject_fault()
- ins.recover()
-
- def test__attacker_service_check_failuer(self, mock_ssh):
-
- cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
- ins = cls(self.attacker_cfg, self.context)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, None, '')
- ins.setup()
diff --git a/tests/unit/benchmark/scenarios/availability/test_basemonitor.py b/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
deleted file mode 100644
index 92ae8aa88..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# 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):
- self.monitor_configs = [
- {
- "monitor_type": "openstack-cmd",
- "command_name": "openstack router list",
- "monitor_time": 10,
- "monitor_number": 3,
- "sla": {
- "max_outage_time": 5
- }
- },
- {
- "monitor_type": "process",
- "process_name": "neutron-server",
- "host": "node1",
- "monitor_time": 20,
- "monitor_number": 3,
- "sla": {
- "max_recover_time": 20
- }
- }
- ]
- self.MonitorMgr = basemonitor.MonitorMgr([])
- self.MonitorMgr.init_monitors(self.monitor_configs, None)
- self.monitor_list = self.MonitorMgr._monitor_list
- for mo in self.monitor_list:
- mo._result = {"outage_time": 10}
-
- def test__MonitorMgr_setup_successful(self, mock_monitor):
- instance = basemonitor.MonitorMgr({"nova-api": 10})
- instance.init_monitors(self.monitor_configs, None)
- instance.start_monitors()
- instance.wait_monitors()
-
- ret = instance.verify_SLA()
-
- def test_MonitorMgr_getitem(self, mock_monitor):
- monitorMgr = basemonitor.MonitorMgr({"nova-api": 10})
- monitorMgr.init_monitors(self.monitor_configs, None)
-
- def test_store_result(self, mock_monitor):
- expect = {'process_neutron-server_outage_time': 10,
- 'openstack-router-list_outage_time': 10}
- result = {}
- self.MonitorMgr.store_result(result)
- self.assertDictEqual(result, expect)
-
-
-class BaseMonitorTestCase(unittest.TestCase):
-
- class MonitorSimple(basemonitor.BaseMonitor):
- __monitor_type__ = "MonitorForTest"
-
- def setup(self):
- self.monitor_result = False
-
- def monitor_func(self):
- return self.monitor_result
-
- def setUp(self):
- self.monitor_cfg = {
- 'monitor_type': 'MonitorForTest',
- 'command_name': 'nova image-list',
- 'monitor_time': 0.01,
- 'sla': {'max_outage_time': 5}
- }
-
- def test__basemonitor_start_wait_successful(self):
- ins = basemonitor.BaseMonitor(self.monitor_cfg, None, {"nova-api": 10})
- ins.start_monitor()
- ins.wait_monitor()
-
- def test__basemonitor_all_successful(self):
- ins = self.MonitorSimple(self.monitor_cfg, None, {"nova-api": 10})
- ins.setup()
- ins.run()
- ins.verify_SLA()
-
- @mock.patch(
- 'yardstick.benchmark.scenarios.availability.monitor.basemonitor'
- '.multiprocessing')
- def test__basemonitor_func_false(self, mock_multiprocess):
- ins = self.MonitorSimple(self.monitor_cfg, None, {"nova-api": 10})
- ins.setup()
- mock_multiprocess.Event().is_set.return_value = False
- ins.run()
- ins.verify_SLA()
-
- def test__basemonitor_getmonitorcls_successfule(self):
- cls = None
- try:
- cls = basemonitor.BaseMonitor.get_monitor_cls(self.monitor_cfg)
- except Exception:
- pass
- self.assertIsNone(cls)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/unit/benchmark/scenarios/availability/test_baseoperation.py b/tests/unit/benchmark/scenarios/availability/test_baseoperation.py
deleted file mode 100644
index 03ec1492b..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_baseoperation.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huan Li and others
-# lihuansse@tongji.edu.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# 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):
- config = {
- 'operation_type': 'general-operation',
- 'key': 'service-status'
- }
-
- self.operation_configs = []
- self.operation_configs.append(config)
-
- def test_all_successful(self, mock_operation):
- mgr_ins = baseoperation.OperationMgr()
- mgr_ins.init_operations(self.operation_configs, None)
- operation_ins = mgr_ins["service-status"]
- mgr_ins.rollback()
-
- def test_getitem_fail(self, mock_operation):
- mgr_ins = baseoperation.OperationMgr()
- mgr_ins.init_operations(self.operation_configs, None)
- with self.assertRaises(KeyError):
- operation_ins = mgr_ins["operation-not-exist"]
-
-
-class TestOperation(baseoperation.BaseOperation):
- __operation__type__ = "test-operation"
-
- def setup(self):
- pass
-
- def run(self):
- pass
-
- def rollback(self):
- pass
-
-
-class BaseOperationTestCase(unittest.TestCase):
-
- def setUp(self):
- self.config = {
- 'operation_type': 'general-operation',
- 'key': 'service-status'
- }
-
- def test_all_successful(self):
- base_ins = baseoperation.BaseOperation(self.config, None)
- base_ins.setup()
- base_ins.run()
- 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")
-
- def test_get_operation_cls_successful(self):
- base_ins = baseoperation.BaseOperation(self.config, None)
- operation_ins = 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")
diff --git a/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py b/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py
deleted file mode 100644
index 36ce900fb..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_baseresultchecker.py
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huan Li and others
-# lihuansse@tongji.edu.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# 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
-
-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):
- config = {
- 'checker_type': 'general-result-checker',
- 'key': 'process-checker'
- }
-
- 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()
-
- 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_fail(self, mock_basechacer):
- mgr_ins = baseresultchecker.ResultCheckerMgr()
- mgr_ins.init_ResultChecker(self.checker_configs, None)
- with self.assertRaises(KeyError):
- checker_ins = mgr_ins["checker-not-exist"]
-
-
-class BaseResultCheckerTestCase(unittest.TestCase):
-
- class ResultCheckeSimple(baseresultchecker.BaseResultChecker):
- __result_checker__type__ = "ResultCheckeForTest"
-
- def setup(self):
- self.success = False
-
- def verify(self):
- return self.success
-
- def setUp(self):
- self.checker_cfg = {
- 'checker_type': 'general-result-checker',
- 'key': 'process-checker'
- }
-
- def test_baseresultchecker_setup_verify_successful(self):
- ins = baseresultchecker.BaseResultChecker(self.checker_cfg, None)
- ins.setup()
- 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()
-
- def test_get_script_fullpath(self):
- ins = baseresultchecker.BaseResultChecker(self.checker_cfg, None)
- path = ins.get_script_fullpath("test.bash")
-
- def test_get_resultchecker_cls_successful(self):
- baseresultchecker.BaseResultChecker.get_resultchecker_cls(
- "ResultCheckeForTest")
-
- def test_get_resultchecker_cls_fail(self):
- with self.assertRaises(RuntimeError):
- baseresultchecker.BaseResultChecker.get_resultchecker_cls(
- "ResultCheckeNotExist")
diff --git a/tests/unit/benchmark/scenarios/availability/test_director.py b/tests/unit/benchmark/scenarios/availability/test_director.py
deleted file mode 100644
index d01a60e2d..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_director.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huan Li and others
-# lihuansse@tongji.edu.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.availability.director
-
-from __future__ import absolute_import
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.availability.director import Director
-
-
-@mock.patch('yardstick.benchmark.scenarios.availability.director.basemonitor')
-@mock.patch('yardstick.benchmark.scenarios.availability.director.baseattacker')
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.director.baseoperation')
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.director.baseresultchecker')
-class DirectorTestCase(unittest.TestCase):
-
- def setUp(self):
- self.scenario_cfg = {
- 'type': "general_scenario",
- 'options': {
- 'attackers': [{
- 'fault_type': "general-attacker",
- 'key': "kill-process"}],
- 'monitors': [{
- 'monitor_type': "general-monitor",
- 'key': "service-status"}],
- 'operations': [{
- 'operation_type': 'general-operation',
- 'key': 'service-status'}],
- 'resultCheckers': [{
- 'checker_type': 'general-result-checker',
- 'key': 'process-checker', }],
- 'steps': [
- {
- 'actionKey': "service-status",
- 'actionType': "operation",
- 'index': 1},
- {
- 'actionKey': "kill-process",
- 'actionType': "attacker",
- 'index': 2},
- {
- 'actionKey': "process-checker",
- 'actionType': "resultchecker",
- 'index': 3},
- {
- 'actionKey': "service-status",
- 'actionType': "monitor",
- 'index': 4},
- ]
- }
- }
- host = {
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.ctx = {"nodes": {"node1": host}}
-
- def test_director_all_successful(self, mock_checer, mock_opertion,
- mock_attacker, mock_monitor):
- ins = Director(self.scenario_cfg, self.ctx)
- opertion_action = ins.createActionPlayer("operation", "service-status")
- attacker_action = ins.createActionPlayer("attacker", "kill-process")
- checker_action = ins.createActionPlayer("resultchecker",
- "process-checker")
- monitor_action = ins.createActionPlayer("monitor", "service-status")
-
- opertion_rollback = ins.createActionRollbacker("operation",
- "service-status")
- attacker_rollback = ins.createActionRollbacker("attacker",
- "kill-process")
- ins.executionSteps.append(opertion_rollback)
- ins.executionSteps.append(attacker_rollback)
-
- opertion_action.action()
- attacker_action.action()
- checker_action.action()
- monitor_action.action()
-
- attacker_rollback.rollback()
- opertion_rollback.rollback()
-
- ins.stopMonitors()
- ins.verify()
- ins.knockoff()
-
- def test_director_get_wrong_item(self, mock_checer, mock_opertion,
- mock_attacker, mock_monitor):
- ins = Director(self.scenario_cfg, self.ctx)
- ins.createActionPlayer("wrong_type", "wrong_key")
- ins.createActionRollbacker("wrong_type", "wrong_key")
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_command.py b/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
deleted file mode 100644
index b84cef23c..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# 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):
- cmd = "env"
- mock_subprocess_check_output.return_value = (0, 'unittest')
- exitcode, _ = 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):
- cmd = "env"
- 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):
- host = {
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.context = {"node1": host}
- self.config = {
- 'monitor_type': 'openstack-api',
- 'command_name': 'nova image-list',
- 'monitor_time': 1,
- 'sla': {'max_outage_time': 5}
- }
-
- def test__monitor_command_monitor_func_successful(self, mock_subprocess_check_output):
-
- instance = monitor_command.MonitorOpenstackCmd(self.config, None, {"nova-api": 10})
- instance.setup()
- 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')
- instance = monitor_command.MonitorOpenstackCmd(self.config, None, {"nova-api": 10})
- instance.setup()
- 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_subprocess_check_output.return_value = (0, 'unittest')
- self.config["host"] = "node1"
- instance = monitor_command.MonitorOpenstackCmd(
- self.config, self.context, {"nova-api": 10})
- instance.setup()
- mock_ssh.SSH.from_node().execute.return_value = (0, "0", '')
- ret = instance.monitor_func()
- self.assertTrue(ret)
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py b/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
deleted file mode 100644
index c14f073ec..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huan Li and others
-# lihuansse@tongji.edu.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.availability.monitor
-# .monitor_general
-
-from __future__ import absolute_import
-import mock
-import unittest
-from yardstick.benchmark.scenarios.availability.monitor import monitor_general
-
-
-@mock.patch('yardstick.benchmark.scenarios.availability.monitor.'
- 'monitor_general.ssh')
-@mock.patch('yardstick.benchmark.scenarios.availability.monitor.'
- 'monitor_general.open')
-class GeneralMonitorServiceTestCase(unittest.TestCase):
-
- def setUp(self):
- host = {
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.context = {"node1": host}
- self.monitor_cfg = {
- 'monitor_type': 'general-monitor',
- 'key': 'service-status',
- 'monitor_key': 'service-status',
- 'host': 'node1',
- 'monitor_time': 3,
- 'parameter': {'serviceName': 'haproxy'},
- 'sla': {'max_outage_time': 1}
- }
- self.monitor_cfg_noparam = {
- 'monitor_type': 'general-monitor',
- 'key': 'service-status',
- 'monitor_key': 'service-status',
- 'host': 'node1',
- 'monitor_time': 3,
- 'sla': {'max_outage_time': 1}
- }
-
- def test__monitor_general_all_successful(self, mock_open, mock_ssh):
- ins = monitor_general.GeneralMonitor(self.monitor_cfg, self.context, {"nova-api": 10})
-
- ins.setup()
- mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
- ins.monitor_func()
- ins._result = {'outage_time': 0}
- ins.verify_SLA()
-
- def test__monitor_general_all_successful_noparam(self, mock_open,
- mock_ssh):
- ins = monitor_general.GeneralMonitor(
- self.monitor_cfg_noparam, self.context, {"nova-api": 10})
-
- ins.setup()
- mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
- ins.monitor_func()
- ins._result = {'outage_time': 0}
- ins.verify_SLA()
-
- def test__monitor_general_failure(self, mock_open, mock_ssh):
- ins = monitor_general.GeneralMonitor(
- self.monitor_cfg_noparam, self.context, {"nova-api": 10})
-
- ins.setup()
- mock_ssh.SSH.from_node().execute.return_value = (1, "error", 'error')
- ins.monitor_func()
- ins._result = {'outage_time': 2}
- ins.verify_SLA()
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py b/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py
deleted file mode 100644
index b59ec6cf1..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huan Li and others
-# lihuansse@tongji.edu.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.availability.monitor
-# .monitor_multi
-
-from __future__ import absolute_import
-import mock
-import unittest
-from yardstick.benchmark.scenarios.availability.monitor import monitor_multi
-
-@mock.patch('yardstick.benchmark.scenarios.availability.monitor.'
- 'monitor_general.ssh')
-@mock.patch('yardstick.benchmark.scenarios.availability.monitor.'
- 'monitor_general.open')
-class MultiMonitorServiceTestCase(unittest.TestCase):
-
- def setUp(self):
- host = {
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.context = {"node1": host}
- self.monitor_cfg = {
- 'monitor_type': 'general-monitor',
- 'monitor_number': 3,
- 'key': 'service-status',
- 'monitor_key': 'service-status',
- 'host': 'node1',
- 'monitor_time': 0.1,
- 'parameter': {'serviceName': 'haproxy'},
- 'sla': {'max_outage_time': 1}
- }
-
- def test__monitor_multi_all_successful(self, mock_open, mock_ssh):
- 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()
-
- def test__monitor_multi_all_fail(self, mock_open, mock_ssh):
- 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/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
deleted file mode 100644
index 41ce5445e..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for
-# yardstick.benchmark.scenarios.availability.monitor.monitor_process
-
-from __future__ import absolute_import
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.availability.monitor import monitor_process
-
-
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.monitor.monitor_process.ssh')
-class MonitorProcessTestCase(unittest.TestCase):
-
- def setUp(self):
- host = {
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.context = {"node1": host}
- self.monitor_cfg = {
- 'monitor_type': 'process',
- 'process_name': 'nova-api',
- 'host': "node1",
- 'monitor_time': 1,
- 'sla': {'max_recover_time': 5}
- }
-
- def test__monitor_process_all_successful(self, mock_ssh):
-
- ins = monitor_process.MonitorProcess(self.monitor_cfg, self.context, {"nova-api": 10})
-
- mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
- ins.setup()
- ins.monitor_func()
- ins._result = {"outage_time": 0}
- ins.verify_SLA()
-
- def test__monitor_process_down_failuer(self, mock_ssh):
-
- ins = monitor_process.MonitorProcess(self.monitor_cfg, self.context, {"nova-api": 10})
-
- mock_ssh.SSH.from_node().execute.return_value = (0, "0", '')
- ins.setup()
- ins.monitor_func()
- ins._result = {"outage_time": 10}
- ins.verify_SLA()
diff --git a/tests/unit/benchmark/scenarios/availability/test_operation_general.py b/tests/unit/benchmark/scenarios/availability/test_operation_general.py
deleted file mode 100644
index fb8ccb122..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_operation_general.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huan Li and others
-# lihuansse@tongji.edu.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.availability.operation
-# .operation_general
-
-from __future__ import absolute_import
-import mock
-import unittest
-from yardstick.benchmark.scenarios.availability.operation import \
- operation_general
-
-
-@mock.patch('yardstick.benchmark.scenarios.availability.operation.'
- 'operation_general.ssh')
-@mock.patch('yardstick.benchmark.scenarios.availability.operation.'
- 'operation_general.open')
-class GeneralOperaionTestCase(unittest.TestCase):
-
- def setUp(self):
- host = {
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.context = {"node1": host}
- self.operation_cfg = {
- 'operation_type': 'general-operation',
- 'action_parameter': {'ins_cup': 2},
- 'rollback_parameter': {'ins_id': 'id123456'},
- 'key': 'nova-create-instance',
- 'operation_key': 'nova-create-instance',
- 'host': 'node1',
- }
- self.operation_cfg_noparam = {
- 'operation_type': 'general-operation',
- 'key': 'nova-create-instance',
- 'operation_key': 'nova-create-instance',
- 'host': 'node1',
- }
-
- def test__operation_successful(self, mock_open, mock_ssh):
- ins = operation_general.GeneralOperaion(self.operation_cfg,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "success", '')
- ins.setup()
- ins.run()
- ins.rollback()
-
- def test__operation_successful_noparam(self, mock_open, mock_ssh):
- ins = operation_general.GeneralOperaion(self.operation_cfg_noparam,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "success", '')
- ins.setup()
- ins.run()
- ins.rollback()
-
- def test__operation_fail(self, mock_open, mock_ssh):
- ins = operation_general.GeneralOperaion(self.operation_cfg,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (1, "failed", '')
- ins.setup()
- ins.run()
- ins.rollback()
diff --git a/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py b/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py
deleted file mode 100644
index d036bb0da..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huan Li and others
-# lihuansse@tongji.edu.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.availability.result_checker
-# .result_checker_general
-
-from __future__ import absolute_import
-import mock
-import unittest
-import copy
-
-from yardstick.benchmark.scenarios.availability.result_checker import \
- result_checker_general
-
-
-@mock.patch('yardstick.benchmark.scenarios.availability.result_checker.'
- 'result_checker_general.ssh')
-@mock.patch('yardstick.benchmark.scenarios.availability.result_checker.'
- 'result_checker_general.open')
-class GeneralResultCheckerTestCase(unittest.TestCase):
-
- def setUp(self):
- host = {
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.context = {"node1": host}
- self.checker_cfg = {
- 'parameter': {'processname': 'process'},
- 'checker_type': 'general-result-checker',
- 'condition': 'eq',
- 'expectedValue': 1,
- 'key': 'process-checker',
- 'checker_key': 'process-checker',
- 'host': 'node1'
- }
-
- def test__result_checker_eq(self, mock_open, mock_ssh):
- ins = result_checker_general.GeneralResultChecker(self.checker_cfg,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
- ins.setup()
- self.assertTrue(ins.verify())
-
- def test__result_checker_gt(self, mock_open, mock_ssh):
- config = copy.deepcopy(self.checker_cfg)
- config['condition'] = 'gt'
- ins = result_checker_general.GeneralResultChecker(config,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "2", '')
- ins.setup()
- self.assertTrue(ins.verify())
-
- def test__result_checker_gt_eq(self, mock_open, mock_ssh):
- config = copy.deepcopy(self.checker_cfg)
- config['condition'] = 'gt_eq'
- ins = result_checker_general.GeneralResultChecker(config,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
- ins.setup()
- self.assertTrue(ins.verify())
-
- def test__result_checker_lt(self, mock_open, mock_ssh):
- config = copy.deepcopy(self.checker_cfg)
- config['condition'] = 'lt'
- ins = result_checker_general.GeneralResultChecker(config,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "0", '')
- ins.setup()
- self.assertTrue(ins.verify())
-
- def test__result_checker_lt_eq(self, mock_open, mock_ssh):
- config = copy.deepcopy(self.checker_cfg)
- config['condition'] = 'lt_eq'
- ins = result_checker_general.GeneralResultChecker(config,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
- ins.setup()
- self.assertTrue(ins.verify())
-
- def test__result_checker_in(self, mock_open, mock_ssh):
- config = copy.deepcopy(self.checker_cfg)
- config['condition'] = 'in'
- config['expectedValue'] = "value"
- ins = result_checker_general.GeneralResultChecker(config,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "value return", '')
- ins.setup()
- self.assertTrue(ins.verify())
-
- def test__result_checker_wrong(self, mock_open, mock_ssh):
- config = copy.deepcopy(self.checker_cfg)
- config['condition'] = 'wrong'
- ins = result_checker_general.GeneralResultChecker(config,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
- ins.setup()
- self.assertFalse(ins.verify())
-
- def test__result_checker_fail(self, mock_open, mock_ssh):
- config = copy.deepcopy(self.checker_cfg)
- config.pop('parameter')
- ins = result_checker_general.GeneralResultChecker(config,
- self.context)
- mock_ssh.SSH.from_node().execute.return_value = (1, "fail", '')
- ins.setup()
- ins.verify()
diff --git a/tests/unit/benchmark/scenarios/availability/test_scenario_general.py b/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
deleted file mode 100644
index 244a5e798..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huan Li and others
-# lihuansse@tongji.edu.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# 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
-
-
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.scenario_general.Director')
-class ScenarioGeneralTestCase(unittest.TestCase):
-
- def setUp(self):
- self.scenario_cfg = {
- 'type': "general_scenario",
- 'options': {
- 'attackers': [{
- 'fault_type': "general-attacker",
- 'key': "kill-process"}],
- 'monitors': [{
- 'monitor_type': "general-monitor",
- 'key': "service-status"}],
- 'steps': [
- {
- 'actionKey': "kill-process",
- 'actionType': "attacker",
- 'index': 1},
- {
- 'actionKey': "service-status",
- 'actionType': "monitor",
- 'index': 2}]
- }
- }
-
- 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_exception(self, mock_director):
- ins = ScenarioGeneral(self.scenario_cfg, None)
- mock_obj = mock.Mock()
- mock_obj.createActionPlayer.side_effect = KeyError('Wrong')
- ins.director = mock_obj
- ins.director.data = {}
- ins.run({})
- ins.teardown()
-
- def test_scenario_general_case_fail(self, mock_director):
- ins = ScenarioGeneral(self.scenario_cfg, None)
- 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()
diff --git a/tests/unit/benchmark/scenarios/availability/test_serviceha.py b/tests/unit/benchmark/scenarios/availability/test_serviceha.py
deleted file mode 100644
index 97d534894..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_serviceha.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.availability.serviceha
-
-from __future__ import absolute_import
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.availability import serviceha
-
-
-class ServicehaTestCase(unittest.TestCase):
-
- def setUp(self):
- host = {
- "ip": "10.20.0.5",
- "user": "root",
- "key_filename": "/root/.ssh/id_rsa"
- }
- self.ctx = {"nodes": {"node1": host}}
- attacker_cfg = {
- "fault_type": "kill-process",
- "process_name": "nova-api",
- "host": "node1"
- }
- attacker_cfgs = []
- attacker_cfgs.append(attacker_cfg)
- monitor_cfg = {
- "monitor_cmd": "nova image-list",
- "monitor_time": 0.1
- }
- monitor_cfgs = []
- monitor_cfgs.append(monitor_cfg)
-
- options = {
- "attackers": attacker_cfgs,
- "monitors": monitor_cfgs
- }
- 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):
- p = serviceha.ServiceHA(self.args, self.ctx)
-
- p.setup()
- self.assertTrue(p.setup_done)
- mock_monitor.MonitorMgr().verify_SLA.return_value = True
- ret = {}
- p.run(ret)
- p.teardown()
-
- 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)
-
-# p.setup()
-# self.assertTrue(p.setup_done)
-#
-# result = {}
-# result["outage_time"] = 10
-# mock_monitor.Monitor().get_result.return_value = result
-
-# ret = {}
-# self.assertRaises(AssertionError, p.run, ret)
diff --git a/tests/unit/benchmark/scenarios/availability/test_util.py b/tests/unit/benchmark/scenarios/availability/test_util.py
deleted file mode 100644
index 548efe91b..000000000
--- a/tests/unit/benchmark/scenarios/availability/test_util.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Kanglin Yin and others
-# 14_ykl@tongji.edu.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.availability.utils
-
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.availability import util
-
-
-class ExecuteShellTestCase(unittest.TestCase):
-
- def setUp(self):
- self.param_config = {'serviceName': '@serviceName', 'value': 1}
- self.intermediate_variables = {'@serviceName': 'nova-api'}
- self.std_output = '| id | 1 |'
- self.cmd_config = {'cmd': 'ls', 'param': '-a'}
-
- self._mock_subprocess = mock.patch.object(util, 'subprocess')
- self.mock_subprocess = self._mock_subprocess.start()
- self.addCleanup(self._stop_mock)
-
- def _stop_mock(self):
- self._mock_subprocess.stop()
-
- def test_util_build_command_shell(self):
- result = util.build_shell_command(self.param_config, True,
- self.intermediate_variables)
- self.assertIn("nova-api", result)
-
- def test_read_stdout_item(self):
- result = util.read_stdout_item(self.std_output, 'id')
- self.assertEqual('1', result)
-
- def test_buildshellparams(self):
- result = util.buildshellparams(self.cmd_config, True)
- self.assertEqual('/bin/bash -s {0} {1}', result)
-
- def test__fun_execute_shell_command_successful(self):
- cmd = "env"
- self.mock_subprocess.check_output.return_value = (0, 'unittest')
- exitcode, _ = util.execute_shell_command(cmd)
- self.assertEqual(exitcode, 0)
-
- def test__fun_execute_shell_command_fail_cmd_exception(self):
- cmd = "env"
- self.mock_subprocess.check_output.side_effect = RuntimeError
- exitcode, _ = util.execute_shell_command(cmd)
- self.assertEqual(exitcode, -1)
diff --git a/tests/unit/benchmark/scenarios/compute/__init__.py b/tests/unit/benchmark/scenarios/compute/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/scenarios/compute/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/scenarios/compute/cachestat_sample_output.txt b/tests/unit/benchmark/scenarios/compute/cachestat_sample_output.txt
deleted file mode 100644
index e2c79a9b1..000000000
--- a/tests/unit/benchmark/scenarios/compute/cachestat_sample_output.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Counting cache functions... Output every 1 seconds.
- HITS MISSES DIRTIES RATIO BUFFERS_MB CACHE_MB
- 6462 0 29 100.0% 1157 66782
-
-Ending tracing...
diff --git a/tests/unit/benchmark/scenarios/compute/cpuload_sample_output1.txt b/tests/unit/benchmark/scenarios/compute/cpuload_sample_output1.txt
deleted file mode 100644
index 723e64bcb..000000000
--- a/tests/unit/benchmark/scenarios/compute/cpuload_sample_output1.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-Linux 3.13.0-68-generic (elxg482ls42) 11/30/2015 _x86_64_ (1 CPU)
-
-04:34:26 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
-04:34:26 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
-04:34:26 PM 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
-
-Average: CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
-Average: all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
-Average: 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
diff --git a/tests/unit/benchmark/scenarios/compute/cpuload_sample_output2.txt b/tests/unit/benchmark/scenarios/compute/cpuload_sample_output2.txt
deleted file mode 100644
index c66520a27..000000000
--- a/tests/unit/benchmark/scenarios/compute/cpuload_sample_output2.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-cpu 245813227 366650 17338727 1195600354 2652765 178 177114 0 80439531 0
-cpu0 32334587 35782 1659040 87008833 401178 60 73571 0 8030817 0
diff --git a/tests/unit/benchmark/scenarios/compute/memload_sample_output.txt b/tests/unit/benchmark/scenarios/compute/memload_sample_output.txt
deleted file mode 100644
index 1793e2f10..000000000
--- a/tests/unit/benchmark/scenarios/compute/memload_sample_output.txt
+++ /dev/null
@@ -1,3 +0,0 @@
- total used free shared buff/cache available
-Mem: 263753976 76737332 187016644 2844 853528 67252400
-Swap: 268029948 0 268029948
diff --git a/tests/unit/benchmark/scenarios/compute/test_cachestat.py b/tests/unit/benchmark/scenarios/compute/test_cachestat.py
deleted file mode 100644
index b0ddfc6b4..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_cachestat.py
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.cachestat.CACHEstat
-
-from __future__ import absolute_import
-import mock
-import unittest
-import os
-
-from yardstick.benchmark.scenarios.compute import cachestat
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.cachestat.ssh')
-class CACHEstatTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': "mykey.key"
- }
- }
-
- self.result = {}
-
- def test_cachestat_successful_setup(self, mock_ssh):
- c = cachestat.CACHEstat({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- c.setup()
- self.assertIsNotNone(c.client)
- self.assertTrue(c.setup_done)
-
- def test_execute_command_success(self, mock_ssh):
- c = cachestat.CACHEstat({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
-
- expected_result = 'abcdefg'
- mock_ssh.SSH.from_node().execute.return_value = (0, expected_result, '')
- result = c._execute_command("foo")
- self.assertEqual(result, expected_result)
-
- def test_execute_command_failed(self, mock_ssh):
- c = cachestat.CACHEstat({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
-
- mock_ssh.SSH.from_node().execute.return_value = (127, '', 'Failed executing \
- command')
- self.assertRaises(RuntimeError, c._execute_command,
- "cat /proc/meminfo")
-
- def test_get_cache_usage_successful(self, mock_ssh):
- options = {
- "interval": 1,
- }
- args = {"options": options}
- c = cachestat.CACHEstat(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
-
- output = self._read_file("cachestat_sample_output.txt")
- mock_ssh.SSH.from_node().execute.return_value = (0, output, '')
- result = c._get_cache_usage()
- expected_result = {"cachestat": {"cache0": {"HITS": "6462",
- "DIRTIES": "29",
- "RATIO": "100.0%",
- "MISSES": "0",
- "BUFFERS_MB": "1157",
- "CACHE_MB": "66782"}},
- "average": {"HITS": 6462, "DIRTIES": 29,
- "RATIO": "100.0%",
- "MISSES": 0, "BUFFERS_MB": 1157,
- "CACHE_MB": 66782},
- "max": {"HITS": 6462,
- "DIRTIES": 29, "RATIO": 100.0, "MISSES": 0,
- "BUFFERS_MB": 1157, "CACHE_MB": 66782}}
-
- self.assertEqual(result, expected_result)
-
- def _read_file(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- output = os.path.join(curr_path, filename)
- with open(output) as f:
- sample_output = f.read()
- return sample_output
diff --git a/tests/unit/benchmark/scenarios/compute/test_computecapacity.py b/tests/unit/benchmark/scenarios/compute/test_computecapacity.py
deleted file mode 100644
index 7b9a5ad4a..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_computecapacity.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for
-# yardstick.benchmark.scenarios.compute.computecapacity.ComputeCapacity
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.compute import computecapacity
-
-SAMPLE_OUTPUT = '{"Cpu_number": "2", "Core_number": "24",\
- "Memory_size": "263753976 kB", "Thread_number": "48",\
- "Cache_size": "30720 KB", "HT_Open": "0"}'
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.computecapacity.ssh')
-class ComputeCapacityTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'nodes': {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': "mykey.key",
- 'password': "root"
- },
- }
- }
-
- self.result = {}
-
- def test_capacity_successful_setup(self, mock_ssh):
- c = computecapacity.ComputeCapacity({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- c.setup()
- self.assertIsNotNone(c.client)
- self.assertTrue(c.setup_done)
-
- def test_capacity_successful(self, mock_ssh):
- c = computecapacity.ComputeCapacity({}, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, SAMPLE_OUTPUT, '')
- c.run(self.result)
- expected_result = jsonutils.loads(SAMPLE_OUTPUT)
- self.assertEqual(self.result, expected_result)
-
- def test_capacity_unsuccessful_script_error(self, mock_ssh):
- c = computecapacity.ComputeCapacity({}, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, c.run, self.result)
diff --git a/tests/unit/benchmark/scenarios/compute/test_cpuload.py b/tests/unit/benchmark/scenarios/compute/test_cpuload.py
deleted file mode 100644
index 840ac7885..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_cpuload.py
+++ /dev/null
@@ -1,264 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.lmbench.Lmbench
-
-from __future__ import absolute_import
-import mock
-import unittest
-import os
-
-from yardstick.benchmark.scenarios.compute import cpuload
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.cpuload.ssh')
-class CPULoadTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': "mykey.key"
- }
- }
-
- self.result = {}
-
- def test_setup_mpstat_installed(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
-
- args = {'options': options}
-
- l = cpuload.CPULoad(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- l.setup()
- self.assertIsNotNone(l.client)
- self.assertTrue(l.setup_done)
- self.assertTrue(l.has_mpstat)
-
- def test_setup_mpstat_not_installed(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
-
- args = {'options': options}
-
- l = cpuload.CPULoad(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (127, '', '')
-
- l.setup()
- self.assertIsNotNone(l.client)
- self.assertTrue(l.setup_done)
- self.assertFalse(l.has_mpstat)
-
- def test_execute_command_success(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
-
- args = {'options': options}
-
- l = cpuload.CPULoad(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- l.setup()
-
- expected_result = 'abcdefg'
- mock_ssh.SSH.from_node().execute.return_value = (0, expected_result, '')
- result = l._execute_command("foo")
- self.assertEqual(result, expected_result)
-
- def test_execute_command_failed(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
-
- args = {'options': options}
-
- l = cpuload.CPULoad(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- l.setup()
-
- mock_ssh.SSH.from_node().execute.return_value = (127, '', 'abcdefg')
- self.assertRaises(RuntimeError, l._execute_command,
- "cat /proc/loadavg")
-
- def test_get_loadavg(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
-
- args = {'options': options}
-
- l = cpuload.CPULoad(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- l.setup()
-
- mock_ssh.SSH.from_node().execute.return_value = \
- (0, '1.50 1.45 1.51 3/813 14322', '')
- result = l._get_loadavg()
- expected_result = \
- {'loadavg': ['1.50', '1.45', '1.51', '3/813', '14322']}
- self.assertEqual(result, expected_result)
-
- def test_get_cpu_usage_mpstat(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
-
- args = {'options': options}
-
- l = cpuload.CPULoad(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- l.setup()
-
- l.interval = 1
- l.count = 1
- mpstat_output = self._read_file("cpuload_sample_output1.txt")
- mock_ssh.SSH.from_node().execute.return_value = (0, mpstat_output, '')
- result = l._get_cpu_usage_mpstat()
-
- expected_result = \
- {"mpstat_minimum":
- {"cpu": {"%steal": "0.00", "%usr": "0.00", "%gnice": "0.00",
- "%idle": "100.00", "%guest": "0.00",
- "%iowait": "0.00", "%sys": "0.00", "%soft": "0.00",
- "%irq": "0.00", "%nice": "0.00"},
- "cpu0": {"%steal": "0.00", "%usr": "0.00", "%gnice": "0.00",
- "%idle": "100.00", "%guest": "0.00",
- "%iowait": "0.00", "%sys": "0.00", "%soft": "0.00",
- "%irq": "0.00", "%nice": "0.00"}},
- "mpstat_average":
- {"cpu": {"%steal": "0.00", "%usr": "0.00", "%gnice": "0.00",
- "%idle": "100.00", "%guest": "0.00",
- "%iowait": "0.00", "%sys": "0.00", "%soft": "0.00",
- "%irq": "0.00", "%nice": "0.00"},
- "cpu0": {"%steal": "0.00", "%usr": "0.00", "%gnice": "0.00",
- "%idle": "100.00", "%guest": "0.00",
- "%iowait": "0.00", "%sys": "0.00", "%soft": "0.00",
- "%irq": "0.00", "%nice": "0.00"}},
- "mpstat_maximun":
- {"cpu": {"%steal": "0.00", "%usr": "0.00", "%gnice": "0.00",
- "%idle": "100.00", "%guest": "0.00",
- "%iowait": "0.00", "%sys": "0.00", "%soft": "0.00",
- "%irq": "0.00", "%nice": "0.00"},
- "cpu0": {"%steal": "0.00", "%usr": "0.00", "%gnice": "0.00",
- "%idle": "100.00", "%guest": "0.00",
- "%iowait": "0.00", "%sys": "0.00", "%soft": "0.00",
- "%irq": "0.00", "%nice": "0.00"}}}
-
- self.assertDictEqual(result, expected_result)
-
- def test_get_cpu_usage(self, mock_ssh):
- options = {
- "interval": 0,
- "count": 1
- }
-
- args = {'options': options}
-
- l = cpuload.CPULoad(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- l.setup()
-
- l.interval = 0
- output = self._read_file("cpuload_sample_output2.txt")
- mock_ssh.SSH.from_node().execute.return_value = (0, output, '')
- result = l._get_cpu_usage()
-
- expected_result = \
- {'mpstat':
- {'cpu':
- {'%steal': '0.00',
- '%usr': '11.31',
- '%gnice': '0.00',
- '%idle': '81.78',
- '%iowait': '0.18',
- '%guest': '5.50',
- '%sys': '1.19',
- '%soft': '0.01',
- '%irq': '0.00',
- '%nice': '0.03'},
- 'cpu0':
- {'%steal': '0.00',
- '%usr': '20.00',
- '%gnice': '0.00',
- '%idle': '71.60',
- '%iowait': '0.33',
- '%guest': '6.61',
- '%sys': '1.37',
- '%soft': '0.06',
- '%irq': '0.00',
- '%nice': '0.03'}}}
-
- self.assertDictEqual(result, expected_result)
-
- def test_run_proc_stat(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
-
- args = {'options': options}
-
- l = cpuload.CPULoad(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
- l.setup()
-
- l.interval = 0
- stat_output = self._read_file("cpuload_sample_output2.txt")
- mock_ssh.SSH.from_node().execute.side_effect = \
- [(0, '1.50 1.45 1.51 3/813 14322', ''), (0, stat_output, '')]
-
- l.run(self.result)
- expected_result = {
- 'loadavg': ['1.50', '1.45', '1.51', '3/813', '14322'],
- 'mpstat':
- {'cpu':
- {'%steal': '0.00',
- '%usr': '11.31',
- '%gnice': '0.00',
- '%idle': '81.78',
- '%iowait': '0.18',
- '%guest': '5.50',
- '%sys': '1.19',
- '%soft': '0.01',
- '%irq': '0.00',
- '%nice': '0.03'},
- 'cpu0':
- {'%steal': '0.00',
- '%usr': '20.00',
- '%gnice': '0.00',
- '%idle': '71.60',
- '%iowait': '0.33',
- '%guest': '6.61',
- '%sys': '1.37',
- '%soft': '0.06',
- '%irq': '0.00',
- '%nice': '0.03'}}}
-
- self.assertDictEqual(self.result, expected_result)
-
- def _read_file(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- output = os.path.join(curr_path, filename)
- with open(output) as f:
- sample_output = f.read()
- return sample_output
diff --git a/tests/unit/benchmark/scenarios/compute/test_cyclictest.py b/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
deleted file mode 100644
index 51ffd2488..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
+++ /dev/null
@@ -1,175 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and other.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.cyclictest.Cyclictest
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.compute import cyclictest
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.cyclictest.ssh')
-class CyclictestTestCase(unittest.TestCase):
-
- def setUp(self):
- self.scenario_cfg = {
- "host": "kvm.LF",
- "setup_options": {
- "rpm_dir": "/opt/rpm",
- "host_setup_seqs": [
- "host-setup0.sh",
- "host-setup1.sh",
- "host-run-qemu.sh"
- ],
- "script_dir": "/opt/scripts",
- "image_dir": "/opt/image",
- "guest_setup_seqs": [
- "guest-setup0.sh",
- "guest-setup1.sh"
- ]
- },
- "sla": {
- "action": "monitor",
- "max_min_latency": 50,
- "max_avg_latency": 100,
- "max_max_latency": 1000
- },
- "options": {
- "priority": 99,
- "threads": 1,
- "loops": 1000,
- "affinity": 1,
- "interval": 1000,
- "histogram": 90
- }
- }
- self.context_cfg = {
- "host": {
- "ip": "10.229.43.154",
- "key_filename": "/yardstick/resources/files/yardstick_key",
- "role": "BareMetal",
- "name": "kvm.LF",
- "user": "root"
- }
- }
-
- def test_cyclictest_successful_setup(self, mock_ssh):
-
- c = cyclictest.Cyclictest(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- c.setup()
- self.assertIsNotNone(c.guest)
- self.assertIsNotNone(c.host)
- self.assertTrue(c.setup_done)
-
- def test_cyclictest_successful_no_sla(self, mock_ssh):
- result = {}
- self.scenario_cfg.pop("sla", None)
- c = cyclictest.Cyclictest(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
-
- c.guest = mock_ssh.SSH.from_node()
- sample_output = '{"min": 100, "avg": 500, "max": 1000}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- c.run(result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(result, expected_result)
-
- def test_cyclictest_successful_sla(self, mock_ssh):
- result = {}
- self.scenario_cfg.update({"sla": {
- "action": "monitor",
- "max_min_latency": 100,
- "max_avg_latency": 500,
- "max_max_latency": 1000
- }
- })
- c = cyclictest.Cyclictest(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
-
- c.guest = mock_ssh.SSH.from_node()
- sample_output = '{"min": 100, "avg": 500, "max": 1000}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- c.run(result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(result, expected_result)
-
- def test_cyclictest_unsuccessful_sla_min_latency(self, mock_ssh):
-
- result = {}
- self.scenario_cfg.update({"sla": {"max_min_latency": 10}})
- c = cyclictest.Cyclictest(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
-
- c.guest = mock_ssh.SSH.from_node()
- sample_output = '{"min": 100, "avg": 500, "max": 1000}'
-
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, c.run, result)
-
- def test_cyclictest_unsuccessful_sla_avg_latency(self, mock_ssh):
-
- result = {}
- self.scenario_cfg.update({"sla": {"max_avg_latency": 10}})
- c = cyclictest.Cyclictest(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
-
- c.guest = mock_ssh.SSH.from_node()
- sample_output = '{"min": 100, "avg": 500, "max": 1000}'
-
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, c.run, result)
-
- def test_cyclictest_unsuccessful_sla_max_latency(self, mock_ssh):
-
- result = {}
- self.scenario_cfg.update({"sla": {"max_max_latency": 10}})
- c = cyclictest.Cyclictest(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
-
- c.guest = mock_ssh.SSH.from_node()
- sample_output = '{"min": 100, "avg": 500, "max": 1000}'
-
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, c.run, result)
-
- def test_cyclictest_unsuccessful_script_error(self, mock_ssh):
-
- result = {}
- self.scenario_cfg.update({"sla": {"max_max_latency": 10}})
- c = cyclictest.Cyclictest(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
-
- c.guest = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, c.run, result)
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/compute/test_lmbench.py b/tests/unit/benchmark/scenarios/compute/test_lmbench.py
deleted file mode 100644
index 65939c6ba..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_lmbench.py
+++ /dev/null
@@ -1,198 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.lmbench.Lmbench
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.compute import lmbench
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.lmbench.ssh')
-class LmbenchTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': "mykey.key"
- }
- }
-
- self.result = {}
-
- def test_successful_setup(self, mock_ssh):
-
- l = lmbench.Lmbench({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- l.setup()
- self.assertIsNotNone(l.client)
- self.assertTrue(l.setup_done)
-
- def test_unsuccessful_unknown_type_run(self, mock_ssh):
-
- options = {
- "test_type": "foo"
- }
- args = {'options': options}
-
- l = lmbench.Lmbench(args, self.ctx)
-
- self.assertRaises(RuntimeError, l.run, self.result)
-
- def test_successful_latency_run_no_sla(self, mock_ssh):
-
- options = {
- "test_type": "latency",
- "stride": 64,
- "stop_size": 16
- }
- args = {'options': options}
- l = lmbench.Lmbench(args, self.ctx)
-
- sample_output = '[{"latency": 4.944, "size": 0.00049}]'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- l.run(self.result)
- expected_result = {"latencies0.latency": 4.944, "latencies0.size": 0.00049}
- self.assertEqual(self.result, expected_result)
-
- def test_successful_bandwidth_run_no_sla(self, mock_ssh):
-
- options = {
- "test_type": "bandwidth",
- "size": 500,
- "benchmark": "rd",
- "warmup": 0
- }
- args = {"options": options}
- l = lmbench.Lmbench(args, self.ctx)
-
- sample_output = '{"size(MB)": 0.262144, "bandwidth(MBps)": 11025.5}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- l.run(self.result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(self.result, expected_result)
-
- def test_successful_latency_run_sla(self, mock_ssh):
-
- options = {
- "test_type": "latency",
- "stride": 64,
- "stop_size": 16
- }
- args = {
- "options": options,
- "sla": {"max_latency": 35}
- }
- l = lmbench.Lmbench(args, self.ctx)
-
- sample_output = '[{"latency": 4.944, "size": 0.00049}]'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- l.run(self.result)
- expected_result = {"latencies0.latency": 4.944, "latencies0.size": 0.00049}
- self.assertEqual(self.result, expected_result)
-
- def test_successful_bandwidth_run_sla(self, mock_ssh):
-
- options = {
- "test_type": "bandwidth",
- "size": 500,
- "benchmark": "rd",
- "warmup": 0
- }
- args = {
- "options": options,
- "sla": {"min_bandwidth": 10000}
- }
- l = lmbench.Lmbench(args, self.ctx)
-
- sample_output = '{"size(MB)": 0.262144, "bandwidth(MBps)": 11025.5}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- l.run(self.result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(self.result, expected_result)
-
- def test_unsuccessful_latency_run_sla(self, mock_ssh):
-
- options = {
- "test_type": "latency",
- "stride": 64,
- "stop_size": 16
- }
- args = {
- "options": options,
- "sla": {"max_latency": 35}
- }
- l = lmbench.Lmbench(args, self.ctx)
-
- sample_output = '[{"latency": 37.5, "size": 0.00049}]'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, l.run, self.result)
-
- def test_unsuccessful_bandwidth_run_sla(self, mock_ssh):
-
- options = {
- "test_type": "bandwidth",
- "size": 500,
- "benchmark": "rd",
- "warmup": 0
- }
- args = {
- "options": options,
- "sla": {"min_bandwidth": 10000}
- }
- l = lmbench.Lmbench(args, self.ctx)
-
- sample_output = '{"size(MB)": 0.262144, "bandwidth(MBps)": 9925.5}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, l.run, self.result)
-
- def test_successful_latency_for_cache_run_sla(self, mock_ssh):
-
- options = {
- "test_type": "latency_for_cache",
- "repetition": 1,
- "warmup": 0
- }
- args = {
- "options": options,
- "sla": {"max_latency": 35}
- }
- l = lmbench.Lmbench(args, self.ctx)
-
- sample_output = "{\"L1cache\": 1.6}"
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- l.run(self.result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(self.result, expected_result)
-
- def test_unsuccessful_script_error(self, mock_ssh):
-
- options = {"test_type": "bandwidth"}
- args = {"options": options}
- l = lmbench.Lmbench(args, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, l.run, self.result)
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/compute/test_memload.py b/tests/unit/benchmark/scenarios/compute/test_memload.py
deleted file mode 100644
index ebae9993d..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_memload.py
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.memload.MEMLoad
-
-from __future__ import absolute_import
-import mock
-import unittest
-import os
-
-from yardstick.benchmark.scenarios.compute import memload
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.memload.ssh')
-class MEMLoadTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': "mykey.key"
- }
- }
-
- self.result = {}
-
- def test_memload_successful_setup(self, mock_ssh):
- m = memload.MEMLoad({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- m.setup()
- self.assertIsNotNone(m.client)
- self.assertTrue(m.setup_done)
-
- def test_execute_command_success(self, mock_ssh):
- m = memload.MEMLoad({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- m.setup()
-
- expected_result = 'abcdefg'
- mock_ssh.SSH.from_node().execute.return_value = (0, expected_result, '')
- result = m._execute_command("foo")
- self.assertEqual(result, expected_result)
-
- def test_execute_command_failed(self, mock_ssh):
- m = memload.MEMLoad({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- m.setup()
-
- mock_ssh.SSH.from_node().execute.return_value = (127, '', 'Failed executing \
- command')
- self.assertRaises(RuntimeError, m._execute_command,
- "cat /proc/meminfo")
-
- def test_get_mem_usage_successful(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
- args = {"options": options}
- m = memload.MEMLoad(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- m.setup()
-
- output = self._read_file("memload_sample_output.txt")
- mock_ssh.SSH.from_node().execute.return_value = (0, output, '')
- result = m._get_mem_usage()
- expected_result = {
- "max": {
- 'shared': 2844,
- 'buff/cache': 853528,
- 'total': 263753976,
- 'free': 187016644,
- 'used': 76737332
- },
- "average": {
- 'shared': 2844,
- 'buff/cache': 853528,
- 'total': 263753976,
- 'free': 187016644,
- 'used': 76737332
- },
- "free": {
- "memory0": {
- "used": "76737332",
- "buff/cache": "853528",
- "free": "187016644",
- "shared": "2844",
- "total": "263753976",
- "available": "67252400"
- }
- }
- }
-
- self.assertEqual(result, expected_result)
-
- def _read_file(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- output = os.path.join(curr_path, filename)
- with open(output) as f:
- sample_output = f.read()
- return sample_output
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/compute/test_plugintest.py b/tests/unit/benchmark/scenarios/compute/test_plugintest.py
deleted file mode 100644
index 680f6ad65..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_plugintest.py
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.plugintest.PluginTest
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.compute import plugintest
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.plugintest.ssh')
-class PluginTestTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'nodes': {
- 'host1': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': "mykey.key",
- 'password': "root"
- },
- }
- }
-
- self.result = {}
-
- def test_sample_successful_setup(self, mock_ssh):
- s = plugintest.PluginTest({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- s.setup()
- self.assertIsNotNone(s.client)
- self.assertTrue(s.setup_done)
-
- def test_sample_successful(self, mock_ssh):
- s = plugintest.PluginTest({}, self.ctx)
-
- sample_output = '{"Test Output": "Hello world!"}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- s.run(self.result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(self.result, expected_result)
-
- def test_sample_unsuccessful_script_error(self, mock_ssh):
- s = plugintest.PluginTest({}, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, s.run, self.result)
diff --git a/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py b/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
deleted file mode 100644
index fb55b809f..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
+++ /dev/null
@@ -1,166 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and other.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.qemu_migrate.QemuMigrate
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.compute import qemu_migrate
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.qemu_migrate.ssh')
-class QemuMigrateTestCase(unittest.TestCase):
-
- def setUp(self):
- self.scenario_cfg = {
- "host": "kvm.LF",
- "setup_options": {
- "rpm_dir": "/opt/rpm",
- "script_dir": "/opt/scripts",
- "image_dir": "/opt/image",
- "host_setup_seqs": [
- "host-setup0.sh",
- "host-setup1.sh",
- "setup-ovsdpdk.sh",
- "host-install-qemu.sh",
- "host-run-qemu4lm.sh"
- ]
- },
- "sla": {
- "action": "monitor",
- "max_totaltime": 10,
- "max_downtime": 0.10,
- "max_setuptime": 0.50
- },
- "options": {
- "smp": 99,
- "migrate_to_port": 4444,
- "incoming_ip": 0,
- "qmp_src_path": "/tmp/qmp-sock-src",
- "qmp_dst_path": "/tmp/qmp-sock-dst",
- "max_down_time": "0.10"
- }
- }
- self.context_cfg = {
- "host": {
- "ip": "10.229.43.154",
- "key_filename": "/yardstick/resources/files/yardstick_key",
- "role": "BareMetal",
- "name": "kvm.LF",
- "user": "root"
- }
- }
-
- def test_qemu_migrate_successful_setup(self, mock_ssh):
-
- q = qemu_migrate.QemuMigrate(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- q.setup()
- self.assertIsNotNone(q.host)
- self.assertTrue(q.setup_done)
-
- def test_qemu_migrate_successful_no_sla(self, mock_ssh):
- result = {}
- self.scenario_cfg.pop("sla", None)
- q = qemu_migrate.QemuMigrate(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- q.setup()
-
- sample_output = '{"totaltime": 15, "downtime": 2, "setuptime": 1}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- q.run(result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(result, expected_result)
-
- def test_qemu_migrate_successful_sla(self, mock_ssh):
- result = {}
- self.scenario_cfg.update({"sla": {
- "action": "monitor",
- "max_totaltime": 15,
- "max_downtime": 2,
- "max_setuptime": 1
- }
- })
- q = qemu_migrate.QemuMigrate(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- q.setup()
-
- sample_output = '{"totaltime": 15, "downtime": 2, "setuptime": 1}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- q.run(result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(result, expected_result)
-
- def test_qemu_migrate_unsuccessful_sla_totaltime(self, mock_ssh):
-
- result = {}
- self.scenario_cfg.update({"sla": {"max_totaltime": 10}})
- q = qemu_migrate.QemuMigrate(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- q.setup()
-
- sample_output = '{"totaltime": 15, "downtime": 2, "setuptime": 1}'
-
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, q.run, result)
-
- def test_qemu_migrate_unsuccessful_sla_downtime(self, mock_ssh):
-
- result = {}
- self.scenario_cfg.update({"sla": {"max_downtime": 0.10}})
- q = qemu_migrate.QemuMigrate(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- q.setup()
-
- sample_output = '{"totaltime": 15, "downtime": 2, "setuptime": 1}'
-
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, q.run, result)
-
- def test_qemu_migrate_unsuccessful_sla_setuptime(self, mock_ssh):
-
- result = {}
- self.scenario_cfg.update({"sla": {"max_setuptime": 0.50}})
- q = qemu_migrate.QemuMigrate(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- q.setup()
-
- sample_output = '{"totaltime": 15, "downtime": 2, "setuptime": 1}'
-
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, q.run, result)
-
- def test_qemu_migrate_unsuccessful_script_error(self, mock_ssh):
-
- result = {}
- self.scenario_cfg.update({"sla": {"max_totaltime": 10}})
- q = qemu_migrate.QemuMigrate(self.scenario_cfg, self.context_cfg)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- q.setup()
-
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, q.run, result)
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/compute/test_ramspeed.py b/tests/unit/benchmark/scenarios/compute/test_ramspeed.py
deleted file mode 100644
index 4f71fbb36..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_ramspeed.py
+++ /dev/null
@@ -1,244 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.ramspeed.Ramspeed
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.common import utils
-from yardstick.benchmark.scenarios.compute import ramspeed
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.ramspeed.ssh')
-class RamspeedTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': "mykey.key"
- }
- }
-
- self.result = {}
-
- def test_ramspeed_successful_setup(self, mock_ssh):
-
- r = ramspeed.Ramspeed({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- r.setup()
- self.assertIsNotNone(r.client)
- self.assertTrue(r.setup_done, True)
-
- def test_ramspeed_successful__run_no_sla(self, mock_ssh):
-
- options = {
- "test_id": 1,
- "load": 16,
- "block_size": 32
- }
- args = {"options": options}
- r = ramspeed.Ramspeed(args, self.ctx)
-
- sample_output = '{"Result": [{"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 1, "Bandwidth(MBps)": 19909.18}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 2, "Bandwidth(MBps)": 19873.89},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 4, "Bandwidth(MBps)":\
- 19907.56}, {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 8,\
- "Bandwidth(MBps)": 19906.94}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 16, "Bandwidth(MBps)": 19881.74}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 32, "Bandwidth(MBps)": 19395.65},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 64, "Bandwidth(MBps)":\
- 17623.14}, {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 128,\
- "Bandwidth(MBps)": 17677.36}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 256, "Bandwidth(MBps)": 16113.49}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 512, "Bandwidth(MBps)": 14659.19},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 1024, "Bandwidth(MBps)":\
- 14680.75}, {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 2048,\
- "Bandwidth(MBps)": 14756.45}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 4096, "Bandwidth(MBps)": 14604.44}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 8192, "Bandwidth(MBps)": 14159.86},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 16384,\
- "Bandwidth(MBps)": 14128.94}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 32768, "Bandwidth(MBps)": 8340.85}]}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- r.run(self.result)
- expected_result = utils.flatten_dict_key(jsonutils.loads(sample_output))
- self.assertEqual(self.result, expected_result)
-
- def test_ramspeed_successful_run_sla(self, mock_ssh):
-
- options = {
- "test_id": 1,
- "load": 16,
- "block_size": 32
- }
- args = {"options": options, "sla": {"min_bandwidth": 6000}}
- r = ramspeed.Ramspeed(args, self.ctx)
-
- sample_output = '{"Result": [{"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 1, "Bandwidth(MBps)": 19909.18}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 2, "Bandwidth(MBps)": 19873.89},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 4, "Bandwidth(MBps)":\
- 19907.56}, {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 8,\
- "Bandwidth(MBps)": 19906.94}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 16, "Bandwidth(MBps)": 19881.74}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 32, "Bandwidth(MBps)": 19395.65},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 64, "Bandwidth(MBps)":\
- 17623.14}, {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 128,\
- "Bandwidth(MBps)": 17677.36}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 256, "Bandwidth(MBps)": 16113.49}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 512, "Bandwidth(MBps)": 14659.19},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 1024, "Bandwidth(MBps)":\
- 14680.75}, {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 2048,\
- "Bandwidth(MBps)": 14756.45}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 4096, "Bandwidth(MBps)": 14604.44}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 8192, "Bandwidth(MBps)": 14159.86},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 16384,\
- "Bandwidth(MBps)": 14128.94}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 32768, "Bandwidth(MBps)": 8340.85}]}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- r.run(self.result)
- expected_result = utils.flatten_dict_key(jsonutils.loads(sample_output))
- self.assertEqual(self.result, expected_result)
-
- def test_ramspeed_unsuccessful_run_sla(self, mock_ssh):
- options = {
- "test_id": 1,
- "load": 8,
- "block_size": 64
- }
- args = {"options": options, "sla": {"min_bandwidth": 100000}}
- r = ramspeed.Ramspeed(args, self.ctx)
-
- sample_output = '{"Result": [{"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 1, "Bandwidth(MBps)": 5000.18}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 2, "Bandwidth(MBps)": 5000.89},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 4,\
- "Bandwidth(MBps)": 5000.56}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 8, "Bandwidth(MBps)": 19906.94}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 16, "Bandwidth(MBps)": 19881.74},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 32,\
- "Bandwidth(MBps)": 19395.65}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 64, "Bandwidth(MBps)": 17623.14}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 128, "Bandwidth(MBps)": 17677.36},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 256, "Bandwidth(MBps)":\
- 16113.49}, {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 512,\
- "Bandwidth(MBps)": 14659.19}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 1024, "Bandwidth(MBps)": 14680.75}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 2048, "Bandwidth(MBps)": 14756.45},\
- {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 4096, "Bandwidth(MBps)":\
- 14604.44}, {"Test_type": "INTEGER & WRITING", "Block_size(kb)": 8192,\
- "Bandwidth(MBps)": 14159.86}, {"Test_type": "INTEGER & WRITING",\
- "Block_size(kb)": 16384, "Bandwidth(MBps)": 14128.94}, {"Test_type":\
- "INTEGER & WRITING", "Block_size(kb)": 32768, "Bandwidth(MBps)": 8340.85}]}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, r.run, self.result)
-
- def test_ramspeed_unsuccessful_script_error(self, mock_ssh):
- options = {
- "test_id": 1,
- "load": 16,
- "block_size": 32
- }
- args = {"options": options}
- r = ramspeed.Ramspeed(args, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, r.run, self.result)
-
- def test_ramspeed_mem_successful_run_no_sla(self, mock_ssh):
- options = {
- "test_id": 3,
- "load": 16,
- "block_size": 32,
- "iteration": 1
- }
- args = {"options": options}
- r = ramspeed.Ramspeed(args, self.ctx)
-
- sample_output = '{"Result": [{"Test_type": "INTEGER Copy:",\
- "Bandwidth(MBps)": 8353.97}, {"Test_type": "INTEGER Scale:",\
- "Bandwidth(MBps)": 9078.59}, {"Test_type": "INTEGER Add:",\
- "Bandwidth(MBps)": 10057.48}, {"Test_type": "INTEGER Triad:",\
- "Bandwidth(MBps)": 10116.27}, {"Test_type": "INTEGER AVERAGE:",\
- "Bandwidth(MBps)": 9401.58}]}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- r.run(self.result)
- expected_result = utils.flatten_dict_key(jsonutils.loads(sample_output))
- self.assertEqual(self.result, expected_result)
-
- def test_ramspeed_mem_successful_run_sla(self, mock_ssh):
- options = {
- "test_id": 3,
- "load": 16,
- "block_size": 32,
- "iteration": 1
- }
- args = {"options": options, "sla": {"min_bandwidth": 6000}}
- r = ramspeed.Ramspeed(args, self.ctx)
-
- sample_output = '{"Result": [{"Test_type": "INTEGER Copy:",\
- "Bandwidth(MBps)": 8353.97}, {"Test_type": "INTEGER Scale:",\
- "Bandwidth(MBps)": 9078.59}, {"Test_type": "INTEGER Add:",\
- "Bandwidth(MBps)": 10057.48}, {"Test_type": "INTEGER Triad:",\
- "Bandwidth(MBps)": 10116.27}, {"Test_type": "INTEGER AVERAGE:",\
- "Bandwidth(MBps)": 9401.58}]}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- r.run(self.result)
- expected_result = utils.flatten_dict_key(jsonutils.loads(sample_output))
- self.assertEqual(self.result, expected_result)
-
- def test_ramspeed_mem_unsuccessful_run_sla(self, mock_ssh):
- options = {
- "test_id": 3,
- "load": 16,
- "block_size": 32,
- "iteration": 1
- }
- args = {"options": options, "sla": {"min_bandwidth": 86000}}
- r = ramspeed.Ramspeed(args, self.ctx)
-
- sample_output = '{"Result": [{"Test_type": "INTEGER Copy:",\
- "Bandwidth(MBps)": 4000.97}, {"Test_type": "INTEGER Scale:",\
- "Bandwidth(MBps)": 4400.59}, {"Test_type": "INTEGER Add:",\
- "Bandwidth(MBps)": 4300.48}, {"Test_type": "INTEGER Triad:",\
- "Bandwidth(MBps)": 1300.27}, {"Test_type": "INTEGER AVERAGE:",\
- "Bandwidth(MBps)": 2401.58}]}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, r.run, self.result)
-
- def test_ramspeed_unsuccessful_unknown_type_run(self, mock_ssh):
- options = {
- "test_id": 30,
- "load": 16,
- "block_size": 32
- }
- args = {'options': options}
- r = ramspeed.Ramspeed(args, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'No such type_id: 30 for \
- Ramspeed scenario')
- self.assertRaises(RuntimeError, r.run, self.result)
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/compute/test_spec_cpu.py b/tests/unit/benchmark/scenarios/compute/test_spec_cpu.py
deleted file mode 100644
index 40423b9da..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_spec_cpu.py
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.spec_cpu.SpecCPU
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-
-from yardstick.common import utils
-from yardstick.benchmark.scenarios.compute import spec_cpu
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.spec_cpu.ssh')
-class SpecCPUTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': "mykey.key"
- }
- }
-
- self.result = {}
-
- def test_spec_cpu_successful_setup(self, mock_ssh):
-
- options = {
- "SPECint_benchmark": "perlbench",
- "runspec_tune": "all",
- "output_format": "all",
- "runspec_iterations": "1",
- "runspec_tune": "base",
- "runspec_size": "test"
- }
- args = {"options": options}
- s = spec_cpu.SpecCPU(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- s.setup()
- self.assertIsNotNone(s.client)
- self.assertTrue(s.setup_done, True)
-
- def test_spec_cpu_successful__run_no_sla(self, mock_ssh):
-
- options = {
- "SPECint_benchmark": "perlbench",
- "runspec_tune": "all",
- "output_format": "all"
- }
- 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 = {}
- self.assertEqual(self.result, expected_result)
-
- def test_ramspeed_unsuccessful_script_error(self, mock_ssh):
- options = {
- "benchmark_subset": "int"
- }
- args = {"options": options}
- s = spec_cpu.SpecCPU(args, self.ctx)
-
- 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/tests/unit/benchmark/scenarios/compute/test_spec_cpu_for_vm.py
deleted file mode 100644
index c428e1fb8..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_spec_cpu_for_vm.py
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.spec_cpu_for_vm.SpecCPUforVM
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-
-from yardstick.benchmark.scenarios.compute import spec_cpu_for_vm
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.spec_cpu_for_vm.ssh')
-class SpecCPUforVMTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': "mykey.key"
- }
- }
-
- self.result = {}
-
- def test_spec_cpu_successful_setup(self, mock_ssh):
-
- options = {
- "SPECint_benchmark": "perlbench",
- "runspec_tune": "all",
- "output_format": "all",
- "runspec_iterations": "1",
- "runspec_size": "test"
- }
- args = {"options": options}
- s = spec_cpu_for_vm.SpecCPUforVM(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- s.setup()
- self.assertIsNotNone(s.client)
- self.assertTrue(s.setup_done, True)
-
- def test_spec_cpu_successful__run_no_sla(self, mock_ssh):
-
- options = {
- "SPECint_benchmark": "perlbench",
- "runspec_tune": "all",
- "output_format": "all"
- }
- args = {"options": options}
- s = spec_cpu_for_vm.SpecCPUforVM(args, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- mock_ssh.SSH.from_node().get.return_value = (0, '', '')
- s.run(self.result)
- expected_result = {'SPEC_CPU_result': ''}
- self.assertEqual(self.result, expected_result)
-
- def test_spec_cpu_unsuccessful_script_error(self, mock_ssh):
- options = {
- "benchmark_subset": "int"
- }
- args = {"options": options}
- s = spec_cpu_for_vm.SpecCPUforVM(args, self.ctx)
-
- 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_unixbench.py b/tests/unit/benchmark/scenarios/compute/test_unixbench.py
deleted file mode 100644
index fec355b45..000000000
--- a/tests/unit/benchmark/scenarios/compute/test_unixbench.py
+++ /dev/null
@@ -1,171 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and other.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.compute.unixbench.Unixbench
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.compute import unixbench
-
-
-@mock.patch('yardstick.benchmark.scenarios.compute.unixbench.ssh')
-class UnixbenchTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- "host": {
- "ip": "192.168.50.28",
- "user": "root",
- "key_filename": "mykey.key"
- }
- }
-
- def test_unixbench_successful_setup(self, mock_ssh):
-
- u = unixbench.Unixbench({}, self.ctx)
- u.setup()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- self.assertIsNotNone(u.client)
- self.assertTrue(u.setup_done)
-
- def test_unixbench_successful_no_sla(self, mock_ssh):
-
- options = {
- "test_type": 'dhry2reg',
- "run_mode": 'verbose'
- }
- args = {
- "options": options,
- }
- u = unixbench.Unixbench(args, self.ctx)
- result = {}
-
- u.server = mock_ssh.SSH.from_node()
-
- sample_output = '{"Score":"4425.4"}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- u.run(result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(result, expected_result)
-
- def test_unixbench_successful_in_quiet_mode(self, mock_ssh):
-
- options = {
- "test_type": 'dhry2reg',
- "run_mode": 'quiet',
- "copies": 1
- }
- args = {
- "options": options,
- }
- u = unixbench.Unixbench(args, self.ctx)
- result = {}
-
- u.server = mock_ssh.SSH.from_node()
-
- sample_output = '{"Score":"4425.4"}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- u.run(result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(result, expected_result)
-
- def test_unixbench_successful_sla(self, mock_ssh):
-
- options = {
- "test_type": 'dhry2reg',
- "run_mode": 'verbose'
- }
- sla = {
- "single_score": '100',
- "parallel_score": '500'
- }
- args = {
- "options": options,
- "sla": sla
- }
- u = unixbench.Unixbench(args, self.ctx)
- result = {}
-
- u.server = mock_ssh.SSH.from_node()
-
- sample_output = '{"signle_score":"2251.7","parallel_score":"4395.9"}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- u.run(result)
- expected_result = jsonutils.loads(sample_output)
- self.assertEqual(result, expected_result)
-
- def test_unixbench_unsuccessful_sla_single_score(self, mock_ssh):
-
- args = {
- "options": {},
- "sla": {"single_score": "500"}
- }
- u = unixbench.Unixbench(args, self.ctx)
- result = {}
-
- u.server = mock_ssh.SSH.from_node()
- sample_output = '{"single_score":"200.7","parallel_score":"4395.9"}'
-
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, u.run, result)
-
- def test_unixbench_unsuccessful_sla_parallel_score(self, mock_ssh):
-
- args = {
- "options": {},
- "sla": {"parallel_score": "4000"}
- }
- u = unixbench.Unixbench(args, self.ctx)
- result = {}
-
- u.server = mock_ssh.SSH.from_node()
- sample_output = '{"signle_score":"2251.7","parallel_score":"3395.9"}'
-
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, u.run, result)
-
- def test_unixbench_unsuccessful_script_error(self, mock_ssh):
-
- options = {
- "test_type": 'dhry2reg',
- "run_mode": 'verbose'
- }
- sla = {
- "single_score": '100',
- "parallel_score": '500'
- }
- args = {
- "options": options,
- "sla": sla
- }
- u = unixbench.Unixbench(args, self.ctx)
- result = {}
-
- u.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, u.run, result)
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/dummy/__init__.py b/tests/unit/benchmark/scenarios/dummy/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/scenarios/dummy/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/scenarios/dummy/test_dummy.py b/tests/unit/benchmark/scenarios/dummy/test_dummy.py
deleted file mode 100644
index bc5131806..000000000
--- a/tests/unit/benchmark/scenarios/dummy/test_dummy.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.dummy.dummy
-
-from __future__ import absolute_import
-import unittest
-
-from yardstick.benchmark.scenarios.dummy import dummy
-
-
-class DummyTestCase(unittest.TestCase):
-
- def setUp(self):
- self.test_context = dummy.Dummy(None, None)
-
- self.assertIsNone(self.test_context.scenario_cfg)
- self.assertIsNone(self.test_context.context_cfg)
- self.assertFalse(self.test_context.setup_done)
-
- def test_run(self):
- result = {}
- self.test_context.run(result)
-
- self.assertEqual(result["hello"], "yardstick")
- self.assertTrue(self.test_context.setup_done)
diff --git a/tests/unit/benchmark/scenarios/lib/__init__.py b/tests/unit/benchmark/scenarios/lib/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/scenarios/lib/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/scenarios/lib/test_add_memory_load.py b/tests/unit/benchmark/scenarios/lib/test_add_memory_load.py
deleted file mode 100644
index bda07f723..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_add_memory_load.py
+++ /dev/null
@@ -1,65 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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.add_memory_load import AddMemoryLoad
-
-
-class AddMemoryLoadTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.ssh.SSH.from_node')
- def test_add_memory_load_with_load(self, mock_from_node):
- scenario_cfg = {
- 'options': {
- 'memory_load': 0.5
- }
- }
- context_cfg = {
- 'host': {}
- }
- mock_from_node().execute.return_value = (0, '0 2048 512', '')
- obj = AddMemoryLoad(scenario_cfg, context_cfg)
- obj.run({})
- self.assertTrue(mock_from_node.called)
-
- @mock.patch('yardstick.ssh.SSH.from_node')
- def test_add_memory_load_without_load(self, mock_from_node):
- scenario_cfg = {
- 'options': {
- 'memory_load': 0
- }
- }
- context_cfg = {
- 'host': {}
- }
- obj = AddMemoryLoad(scenario_cfg, context_cfg)
- obj.run({})
- self.assertTrue(mock_from_node.called)
-
- @mock.patch('yardstick.ssh.SSH.from_node')
- def test_add_memory_load_without_args(self, mock_from_node):
- scenario_cfg = {
- 'options': {
- }
- }
- context_cfg = {
- 'host': {}
- }
- obj = AddMemoryLoad(scenario_cfg, context_cfg)
- obj.run({})
- self.assertTrue(mock_from_node.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_attach_volume.py b/tests/unit/benchmark/scenarios/lib/test_attach_volume.py
deleted file mode 100644
index e69924072..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_attach_volume.py
+++ /dev/null
@@ -1,33 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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.attach_volume import AttachVolume
-
-
-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'
- }
- args = {"options": options}
- obj = AttachVolume(args, {})
- obj.run({})
- self.assertTrue(mock_attach_server_volume.called)
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py b/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py
deleted file mode 100644
index 1fb2f89ca..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py
+++ /dev/null
@@ -1,84 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.lib.check_connectivity.CheckConnectivity
-
-from __future__ import absolute_import
-
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.lib import check_connectivity
-
-
-class CheckConnectivityTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': 'mykey.key',
- 'ssh_port': '22'
- },
- 'target': {
- 'ipaddr': '172.16.0.138'
- }
- }
-
- @mock.patch('yardstick.benchmark.scenarios.lib.check_connectivity.ssh')
- def test_check_connectivity(self, mock_ssh):
-
- args = {
- 'options': {'src_ip_addr': '192.168.23.2',
- 'dest_ip_addr': '192.168.23.10',
- 'ssh_user': 'root',
- 'ssh_passwd': 'root',
- 'ssh_port': '22',
- 'ssh_timeout': 600,
- 'ping_parameter': "-s 2048"
- },
- 'sla': {'status': 'True',
- 'action': 'assert'}
- }
-
- result = {}
-
- 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):
-
- args = {
- 'options': {'ssh_user': 'root',
- 'ssh_key': '/root/.ssh/id_rsa',
- 'ssh_port': '22',
- 'ssh_timeout': 600,
- 'ping_parameter': "-s 2048"
- },
- 'sla': {'status': 'True',
- 'action': 'assert'}
- }
-
- result = {}
-
- obj = check_connectivity.CheckConnectivity(args, self.ctx)
- obj.setup()
-
- mock_ssh.SSH.execute.return_value = (0, '100', '')
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py b/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py
deleted file mode 100644
index 1dd461d41..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py
+++ /dev/null
@@ -1,85 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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.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):
- scenario_cfg = {'info1': {}, 'info2': {}}
- obj = CheckNumaInfo(scenario_cfg, {})
- obj.run({})
- self.assertTrue(mock_check_vm2.called)
-
- def test_check_vm2_status_length_eq_1(self):
- info1 = {
- 'pinning': [0],
- 'vcpupin': [{
- 'cpuset': '1,2'
- }]
- }
- info2 = {
- 'pinning': [0],
- 'vcpupin': [{
- 'cpuset': '1,2'
- }]
- }
- scenario_cfg = {'info1': info1, 'info2': info2}
- obj = CheckNumaInfo(scenario_cfg, {})
- status = obj._check_vm2_status(info1, info2)
- self.assertTrue(status)
-
- def test_check_vm2_status_length_gt_1(self):
- info1 = {
- 'pinning': [0, 1],
- 'vcpupin': [{
- 'cpuset': '1,2'
- }]
- }
- info2 = {
- 'pinning': [0, 1],
- 'vcpupin': [{
- 'cpuset': '1,2'
- }]
- }
- scenario_cfg = {'info1': info1, 'info2': info2}
- obj = CheckNumaInfo(scenario_cfg, {})
- status = obj._check_vm2_status(info1, info2)
- self.assertFalse(status)
-
- def test_check_vm2_status_length_not_in_set(self):
- info1 = {
- 'pinning': [0],
- 'vcpupin': [{
- 'cpuset': '1,7'
- }]
- }
- info2 = {
- 'pinning': [0],
- 'vcpupin': [{
- 'cpuset': '1,7'
- }]
- }
- scenario_cfg = {'info1': info1, 'info2': info2}
- obj = CheckNumaInfo(scenario_cfg, {})
- status = obj._check_vm2_status(info1, info2)
- self.assertFalse(status)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_check_value.py b/tests/unit/benchmark/scenarios/lib/test_check_value.py
deleted file mode 100644
index 21e83f830..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_check_value.py
+++ /dev/null
@@ -1,46 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-
-from yardstick.benchmark.scenarios.lib.check_value import CheckValue
-
-
-class CheckValueTestCase(unittest.TestCase):
-
- 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)
-
- 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)
-
- 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)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_flavor.py b/tests/unit/benchmark/scenarios/lib/test_create_flavor.py
deleted file mode 100644
index 036ae952d..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_flavor.py
+++ /dev/null
@@ -1,37 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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_flavor import CreateFlavor
-
-
-class CreateFlavorTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.create_flavor')
- def test_create_flavor(self, mock_create_flavor):
- options = {
- 'flavor_name': 'yardstick_test_flavor',
- 'vcpus': '2',
- 'ram': '1024',
- 'disk': '100',
- 'is_public': 'True'
- }
- args = {"options": options}
- obj = CreateFlavor(args, {})
- obj.run({})
- self.assertTrue(mock_create_flavor.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_floating_ip.py b/tests/unit/benchmark/scenarios/lib/test_create_floating_ip.py
deleted file mode 100644
index 72dbcd7cd..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_floating_ip.py
+++ /dev/null
@@ -1,34 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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_floating_ip import CreateFloatingIp
-
-
-class CreateFloatingIpTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.create_floating_ip')
- @mock.patch('yardstick.common.openstack_utils.get_network_id')
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- def test_create_floating_ip(self, mock_create_floating_ip, mock_get_network_id, mock_get_neutron_client):
- options = {}
- args = {"options": options}
- obj = CreateFloatingIp(args, {})
- obj.run({})
- self.assertTrue(mock_create_floating_ip.called)
- self.assertTrue(mock_get_network_id.called)
- self.assertTrue(mock_get_neutron_client.called)
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_image.py b/tests/unit/benchmark/scenarios/lib/test_create_image.py
deleted file mode 100644
index c213ceba0..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_image.py
+++ /dev/null
@@ -1,41 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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_image import CreateImage
-
-
-class CreateImageTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.create_image')
- @mock.patch('yardstick.common.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'
- }
- args = {"options": options}
- obj = CreateImage(args, {})
- obj.run({})
- self.assertTrue(mock_create_image.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_keypair.py b/tests/unit/benchmark/scenarios/lib/test_create_keypair.py
deleted file mode 100644
index 4b9b72013..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_keypair.py
+++ /dev/null
@@ -1,36 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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
-
-PREFIX = "yardstick.benchmark.scenarios.lib.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):
- options = {
- 'key_name': 'yardstick_key',
- 'key_path': '/tmp/yardstick_key'
- }
- args = {"options": options}
- obj = CreateKeypair(args, {})
- obj.run({})
- self.assertTrue(mock_op_utils.create_keypair.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_network.py b/tests/unit/benchmark/scenarios/lib/test_create_network.py
deleted file mode 100644
index 8e7d8b5a1..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_network.py
+++ /dev/null
@@ -1,39 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.create_network import CreateNetwork
-
-
-class CreateNetworkTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- @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'
- }
- }
- args = {"options": options}
- obj = CreateNetwork(args, {})
- obj.run({})
- self.assertTrue(mock_get_neutron_client.called)
- self.assertTrue(mock_create_neutron_net.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_port.py b/tests/unit/benchmark/scenarios/lib/test_create_port.py
deleted file mode 100644
index 3b2aa2247..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_port.py
+++ /dev/null
@@ -1,36 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.create_port import CreatePort
-
-
-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'
- }
- }
- args = {"options": options}
- obj = CreatePort(args, {})
- obj.run({})
- self.assertTrue(mock_get_neutron_client.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_router.py b/tests/unit/benchmark/scenarios/lib/test_create_router.py
deleted file mode 100644
index b956a3634..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_router.py
+++ /dev/null
@@ -1,39 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.create_router import CreateRouter
-
-
-class CreateRouterTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- @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'
- }
- }
- args = {"options": options}
- obj = CreateRouter(args, {})
- obj.run({})
- self.assertTrue(mock_get_neutron_client.called)
- self.assertTrue(mock_create_neutron_router.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_sec_group.py b/tests/unit/benchmark/scenarios/lib/test_create_sec_group.py
deleted file mode 100644
index b962f7f0e..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_sec_group.py
+++ /dev/null
@@ -1,39 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.create_sec_group import CreateSecgroup
-
-
-class CreateSecGroupTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- @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'
- }
- }
- args = {"options": options}
- obj = CreateSecgroup(args, {})
- obj.run({})
- self.assertTrue(mock_get_neutron_client.called)
- self.assertTrue(mock_create_security_group_full.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_server.py b/tests/unit/benchmark/scenarios/lib/test_create_server.py
deleted file mode 100644
index 7c4193132..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_server.py
+++ /dev/null
@@ -1,42 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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_server import CreateServer
-
-
-class CreateServerTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.create_instance_and_wait_for_active')
- @mock.patch('yardstick.common.openstack_utils.get_nova_client')
- @mock.patch('yardstick.common.openstack_utils.get_glance_client')
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- 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'
- }
- obj = CreateServer(scenario_cfg, {})
- obj.run({})
- self.assertTrue(mock_get_nova_client.called)
- self.assertTrue(mock_get_glance_client.called)
- self.assertTrue(mock_get_neutron_client.called)
- self.assertTrue(mock_create_instance_and_wait_for_active.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_subnet.py b/tests/unit/benchmark/scenarios/lib/test_create_subnet.py
deleted file mode 100644
index 0154755c4..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_subnet.py
+++ /dev/null
@@ -1,41 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.create_subnet import CreateSubnet
-
-
-class CreateSubnetTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- @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'
- }
- }
- args = {"options": options}
- obj = CreateSubnet(args, {})
- obj.run({})
- self.assertTrue(mock_get_neutron_client.called)
- self.assertTrue(mock_create_neutron_subnet.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_volume.py b/tests/unit/benchmark/scenarios/lib/test_create_volume.py
deleted file mode 100644
index ef2c0ccaf..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_create_volume.py
+++ /dev/null
@@ -1,91 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-
-import yardstick.benchmark.scenarios.lib.create_volume
-
-
-class CreateVolumeTestCase(unittest.TestCase):
-
- def setUp(self):
- self._mock_cinder_client = mock.patch(
- 'yardstick.common.openstack_utils.get_cinder_client')
- self.mock_cinder_client = self._mock_cinder_client.start()
- self._mock_glance_client = mock.patch(
- 'yardstick.common.openstack_utils.get_glance_client')
- self.mock_glance_client = self._mock_glance_client.start()
- self.addCleanup(self._stop_mock)
-
- self.scenario_cfg = {
- "options" :
- {
- 'volume_name': 'yardstick_test_volume_01',
- 'size': '256',
- 'image': 'cirros-0.3.5'
- }
- }
-
- self.scenario = (
- yardstick.benchmark.scenarios.lib.create_volume.CreateVolume(
- scenario_cfg=self.scenario_cfg,
- context_cfg={}))
-
- def _stop_mock(self):
- self._mock_cinder_client.stop()
- self._mock_glance_client.stop()
-
- def test_init(self):
- self.mock_cinder_client.return_value = "All volumes are equal"
- self.mock_glance_client.return_value = "Images are more equal"
-
- expected_vol_name = self.scenario_cfg["options"]["volume_name"]
- expected_vol_size = self.scenario_cfg["options"]["size"]
- 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={}))
-
- self.assertEqual(expected_vol_name, scenario.volume_name)
- self.assertEqual(expected_vol_size, scenario.volume_size)
- self.assertEqual(expected_im_name, scenario.image_name)
- self.assertEqual(expected_im_id, scenario.image_id)
- self.assertEqual("All volumes are equal", scenario.cinder_client)
- self.assertEqual("Images are more equal", scenario.glance_client)
-
- def test_setup(self):
- self.assertFalse(self.scenario.setup_done)
- self.scenario.setup()
- self.assertTrue(self.scenario.setup_done)
-
- @mock.patch('yardstick.common.openstack_utils.create_volume')
- @mock.patch('yardstick.common.openstack_utils.get_image_id')
- def test_run(self, mock_image_id, mock_create_volume):
- self.scenario.run()
-
- mock_image_id.assert_called_once()
- mock_create_volume.assert_called_once()
-
- @mock.patch.object(
- yardstick.benchmark.scenarios.lib.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()
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_flavor.py b/tests/unit/benchmark/scenarios/lib/test_delete_flavor.py
deleted file mode 100644
index 4a91b8939..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_flavor.py
+++ /dev/null
@@ -1,35 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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.delete_flavor import DeleteFlavor
-
-
-class DeleteFlavorTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.delete_flavor')
- @mock.patch('yardstick.common.openstack_utils.get_nova_client')
- def test_delete_flavor(self, mock_get_nova_client, mock_delete_flavor):
- options = {
- 'flavor_name': 'yardstick_test_flavor'
- }
- args = {"options": options}
- obj = DeleteFlavor(args, {})
- obj.run({})
- self.assertTrue(mock_get_nova_client.called)
- self.assertTrue(mock_delete_flavor.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_floating_ip.py b/tests/unit/benchmark/scenarios/lib/test_delete_floating_ip.py
deleted file mode 100644
index 7592c8070..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_floating_ip.py
+++ /dev/null
@@ -1,36 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.delete_floating_ip import DeleteFloatingIp
-
-
-class DeleteFloatingIpTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_nova_client')
- @mock.patch('yardstick.common.openstack_utils.delete_floating_ip')
- def test_delete_floating_ip(self, mock_get_nova_client, mock_delete_floating_ip):
- options = {
- 'floating_ip_id': '123-123-123'
- }
- args = {"options": options}
- obj = DeleteFloatingIp(args, {})
- obj.run({})
- self.assertTrue(mock_get_nova_client.called)
- self.assertTrue(mock_delete_floating_ip.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_image.py b/tests/unit/benchmark/scenarios/lib/test_delete_image.py
deleted file mode 100644
index 2bbf14d16..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_image.py
+++ /dev/null
@@ -1,36 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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.delete_image import DeleteImage
-
-
-class DeleteImageTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.delete_image')
- @mock.patch('yardstick.common.openstack_utils.get_image_id')
- @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'
- }
- args = {"options": options}
- obj = DeleteImage(args, {})
- obj.run({})
- self.assertTrue(mock_delete_image.called)
- self.assertTrue(mock_image_id.called)
- self.assertTrue(mock_get_glance_client.called)
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_keypair.py b/tests/unit/benchmark/scenarios/lib/test_delete_keypair.py
deleted file mode 100644
index 9663fe9fb..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_keypair.py
+++ /dev/null
@@ -1,36 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.delete_keypair import DeleteKeypair
-
-
-class DeleteKeypairTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_nova_client')
- @mock.patch('yardstick.common.openstack_utils.delete_keypair')
- def test_detach_volume(self, mock_get_nova_client, mock_delete_keypair):
- options = {
- 'key_name': 'yardstick_key'
- }
- args = {"options": options}
- obj = DeleteKeypair(args, {})
- obj.run({})
- self.assertTrue(mock_get_nova_client.called)
- self.assertTrue(mock_delete_keypair.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_network.py b/tests/unit/benchmark/scenarios/lib/test_delete_network.py
deleted file mode 100644
index 9ccaa8232..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_network.py
+++ /dev/null
@@ -1,36 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.delete_network import DeleteNetwork
-
-
-class DeleteNetworkTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- @mock.patch('yardstick.common.openstack_utils.delete_neutron_net')
- def test_delete_network(self, mock_get_neutron_client, mock_delete_neutron_net):
- options = {
- 'network_id': '123-123-123'
- }
- args = {"options": options}
- obj = DeleteNetwork(args, {})
- obj.run({})
- self.assertTrue(mock_get_neutron_client.called)
- self.assertTrue(mock_delete_neutron_net.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_port.py b/tests/unit/benchmark/scenarios/lib/test_delete_port.py
deleted file mode 100644
index 77b9c7009..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_port.py
+++ /dev/null
@@ -1,34 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.delete_port import DeletePort
-
-
-class DeletePortTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- def test_delete_port(self, mock_get_neutron_client):
- options = {
- 'port_id': '123-123-123'
- }
- args = {"options": options}
- obj = DeletePort(args, {})
- obj.run({})
- self.assertTrue(mock_get_neutron_client.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_router.py b/tests/unit/benchmark/scenarios/lib/test_delete_router.py
deleted file mode 100644
index ab1ad5d35..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_router.py
+++ /dev/null
@@ -1,36 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.delete_router import DeleteRouter
-
-
-class DeleteRouterTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- @mock.patch('yardstick.common.openstack_utils.delete_neutron_router')
- def test_delete_router(self, mock_get_neutron_client, mock_delete_neutron_router):
- options = {
- 'router_id': '123-123-123'
- }
- args = {"options": options}
- obj = DeleteRouter(args, {})
- obj.run({})
- self.assertTrue(mock_get_neutron_client.called)
- self.assertTrue(mock_delete_neutron_router.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py b/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py
deleted file mode 100644
index 1150dccda..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py
+++ /dev/null
@@ -1,36 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.delete_router_gateway import DeleteRouterGateway
-
-
-class DeleteRouterGatewayTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- @mock.patch('yardstick.common.openstack_utils.remove_gateway_router')
- def test_delete_router_gateway(self, mock_get_neutron_client, mock_remove_gateway_router):
- options = {
- 'router_id': '123-123-123'
- }
- args = {"options": options}
- obj = DeleteRouterGateway(args, {})
- obj.run({})
- self.assertTrue(mock_get_neutron_client.called)
- self.assertTrue(mock_remove_gateway_router.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py b/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py
deleted file mode 100644
index 2cc9c9f37..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py
+++ /dev/null
@@ -1,37 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.delete_router_interface import DeleteRouterInterface
-
-
-class DeleteRouterInterfaceTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
- @mock.patch('yardstick.common.openstack_utils.remove_interface_router')
- def test_delete_router_interface(self, mock_get_neutron_client, mock_remove_interface_router):
- options = {
- 'router_id': '123-123-123',
- 'subnet_id': '321-321-321'
- }
- args = {"options": options}
- obj = DeleteRouterInterface(args, {})
- obj.run({})
- self.assertTrue(mock_get_neutron_client.called)
- self.assertTrue(mock_remove_interface_router.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_server.py b/tests/unit/benchmark/scenarios/lib/test_delete_server.py
deleted file mode 100644
index 622ead5ac..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_server.py
+++ /dev/null
@@ -1,35 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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.delete_server import DeleteServer
-
-
-class DeleteServerTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.delete_instance')
- @mock.patch('yardstick.common.openstack_utils.get_nova_client')
- def test_delete_server(self, mock_get_nova_client, mock_delete_instance):
- options = {
- 'server_id': '1234-4567-0000'
- }
- args = {"options": options}
- obj = DeleteServer(args, {})
- obj.run({})
- self.assertTrue(mock_get_nova_client.called)
- self.assertTrue(mock_delete_instance.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_volume.py b/tests/unit/benchmark/scenarios/lib/test_delete_volume.py
deleted file mode 100644
index a11d0121b..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_delete_volume.py
+++ /dev/null
@@ -1,36 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.delete_volume import DeleteVolume
-
-
-class DeleteVolumeTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_cinder_client')
- @mock.patch('yardstick.common.openstack_utils.delete_volume')
- def test_delete_volume(self, mock_get_cinder_client, mock_delete_volume):
- options = {
- 'volume_id': '123-123-123'
- }
- args = {"options": options}
- obj = DeleteVolume(args, {})
- obj.run({})
- self.assertTrue(mock_get_cinder_client.called)
- self.assertTrue(mock_delete_volume.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_detach_volume.py b/tests/unit/benchmark/scenarios/lib/test_detach_volume.py
deleted file mode 100644
index 0cffcba15..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_detach_volume.py
+++ /dev/null
@@ -1,35 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-import mock
-import paramiko
-
-from yardstick.benchmark.scenarios.lib.detach_volume import DetachVolume
-
-
-class DetachVolumeTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.detach_volume')
- def test_detach_volume(self, mock_detach_volume):
- options = {
- 'server_id': '321-321-321',
- 'volume_id': '123-123-123'
- }
- args = {"options": options}
- obj = DetachVolume(args, {})
- obj.run({})
- self.assertTrue(mock_detach_volume.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_get_flavor.py b/tests/unit/benchmark/scenarios/lib/test_get_flavor.py
deleted file mode 100644
index bf12e0a32..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_get_flavor.py
+++ /dev/null
@@ -1,33 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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.get_flavor import GetFlavor
-
-
-class GetFlavorTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_flavor_by_name')
- def test_get_flavor(self, mock_get_flavor_by_name):
- options = {
- 'flavor_name': 'yardstick_test_flavor'
- }
- args = {"options": options}
- obj = GetFlavor(args, {})
- obj.run({})
- self.assertTrue(mock_get_flavor_by_name.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_get_migrate_target_host.py b/tests/unit/benchmark/scenarios/lib/test_get_migrate_target_host.py
deleted file mode 100644
index f046c92ea..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_get_migrate_target_host.py
+++ /dev/null
@@ -1,51 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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.get_migrate_target_host import GetMigrateTargetHost
-
-BASE = 'yardstick.benchmark.scenarios.lib.get_migrate_target_host'
-
-
-class GetMigrateTargetHostTestCase(unittest.TestCase):
-
- @mock.patch('{}.openstack_utils.get_nova_client'.format(BASE))
- @mock.patch('{}.GetMigrateTargetHost._get_migrate_host'.format(BASE))
- @mock.patch('{}.GetMigrateTargetHost._get_current_host_name'.format(BASE))
- def test_get_migrate_target_host(self,
- mock_get_current_host_name,
- mock_get_migrate_host,
- mock_get_nova_client):
- obj = GetMigrateTargetHost({}, {})
- obj.run({})
- self.assertTrue(mock_get_nova_client.called)
- self.assertTrue(mock_get_current_host_name.called)
- self.assertTrue(mock_get_migrate_host.called)
-
- @mock.patch('{}.openstack_utils.get_nova_client'.format(BASE))
- def test_get_migrate_host(self, mock_get_nova_client):
- class A(object):
- def __init__(self, service):
- self.service = service
- self.host = 'host4'
-
- mock_get_nova_client().hosts.list_all.return_value = [A('compute')]
- obj = GetMigrateTargetHost({}, {})
- host = obj._get_migrate_host('host5')
- self.assertTrue(mock_get_nova_client.called)
- self.assertEqual(host, 'host4')
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_get_numa_info.py b/tests/unit/benchmark/scenarios/lib/test_get_numa_info.py
deleted file mode 100644
index 680692fdc..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_get_numa_info.py
+++ /dev/null
@@ -1,106 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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.get_numa_info import GetNumaInfo
-
-BASE = 'yardstick.benchmark.scenarios.lib.get_numa_info'
-
-
-class GetNumaInfoTestCase(unittest.TestCase):
-
- @mock.patch('{}.GetNumaInfo._check_numa_node'.format(BASE))
- @mock.patch('{}.GetNumaInfo._get_current_host_name'.format(BASE))
- @mock.patch('yardstick.benchmark.scenarios.lib.get_numa_info.yaml_load')
- @mock.patch('yardstick.common.task_template.TaskTemplate.render')
- def test_get_numa_info(self,
- mock_render,
- mock_safe_load,
- mock_get_current_host_name,
- mock_check_numa_node):
- scenario_cfg = {
- 'options': {
- 'server': {
- 'id': '1'
- },
- 'file': 'yardstick/ssh.py'
- },
- 'output': 'numa_info'
- }
- mock_safe_load.return_value = {
- 'nodes': []
- }
- obj = GetNumaInfo(scenario_cfg, {})
- obj.run({})
- self.assertTrue(mock_get_current_host_name.called)
- self.assertTrue(mock_check_numa_node.called)
-
- @mock.patch('yardstick.ssh.SSH.from_node')
- @mock.patch('{}.GetNumaInfo._get_current_host_name'.format(BASE))
- @mock.patch('yardstick.benchmark.scenarios.lib.get_numa_info.yaml_load')
- @mock.patch('yardstick.common.task_template.TaskTemplate.render')
- def test_check_numa_node(self,
- mock_render,
- mock_safe_load,
- mock_get_current_host_name,
- mock_from_node):
- scenario_cfg = {
- 'options': {
- 'server': {
- 'id': '1'
- },
- 'file': 'yardstick/ssh.py'
- },
- 'output': 'numa_info'
- }
- mock_safe_load.return_value = {
- 'nodes': []
- }
- data = """
- <data>
- </data>
- """
- mock_from_node().execute.return_value = (0, data, '')
- obj = GetNumaInfo(scenario_cfg, {})
- result = obj._check_numa_node('1', 'host4')
- self.assertEqual(result, {'pinning': [], 'vcpupin': []})
-
- @mock.patch('{}.change_obj_to_dict'.format(BASE))
- @mock.patch('{}.get_nova_client'.format(BASE))
- @mock.patch('yardstick.benchmark.scenarios.lib.get_numa_info.yaml_load')
- @mock.patch('yardstick.common.task_template.TaskTemplate.render')
- def test_get_current_host_name(self,
- mock_render,
- mock_safe_load,
- mock_get_nova_client,
- mock_change_obj_to_dict):
- scenario_cfg = {
- 'options': {
- 'server': {
- 'id': '1'
- },
- 'file': 'yardstick/ssh.py'
- },
- 'output': 'numa_info'
- }
- mock_get_nova_client().servers.get.return_value = ''
- mock_change_obj_to_dict.return_value = {'OS-EXT-SRV-ATTR:host': 'host5'}
-
- obj = GetNumaInfo(scenario_cfg, {})
- result = obj._get_current_host_name('1')
- self.assertEqual(result, 'host5')
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_get_server.py b/tests/unit/benchmark/scenarios/lib/test_get_server.py
deleted file mode 100644
index aebbf5416..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_get_server.py
+++ /dev/null
@@ -1,50 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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.get_server import GetServer
-
-
-class GetServerTestCase(unittest.TestCase):
-
- @mock.patch('yardstick.common.openstack_utils.get_server_by_name')
- @mock.patch('yardstick.common.openstack_utils.get_nova_client')
- def test_get_server_with_name(self, mock_get_nova_client, mock_get_server_by_name):
- scenario_cfg = {
- 'options': {
- 'server_name': 'yardstick_server'
- },
- 'output': 'status server'
- }
- obj = GetServer(scenario_cfg, {})
- obj.run({})
- self.assertTrue(mock_get_nova_client.called)
- self.assertTrue(mock_get_server_by_name.called)
-
- @mock.patch('yardstick.common.openstack_utils.get_nova_client')
- def test_get_server_with_id(self, mock_get_nova_client):
- scenario_cfg = {
- 'options': {
- 'server_id': '1'
- },
- 'output': 'status server'
- }
- mock_get_nova_client().servers.get.return_value = None
- obj = GetServer(scenario_cfg, {})
- obj.run({})
- self.assertTrue(mock_get_nova_client.called)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_get_server_ip.py b/tests/unit/benchmark/scenarios/lib/test_get_server_ip.py
deleted file mode 100644
index 3d20d5439..000000000
--- a/tests/unit/benchmark/scenarios/lib/test_get_server_ip.py
+++ /dev/null
@@ -1,41 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-
-from yardstick.benchmark.scenarios.lib.get_server_ip import GetServerIp
-
-
-class GetServerIpTestCase(unittest.TestCase):
- def test_get_server_ip(self):
- scenario_cfg = {
- 'options': {
- 'server': {
- 'addresses': {
- 'net1': [
- {
- 'OS-EXT-IPS:type': 'floating',
- 'addr': '127.0.0.1'
- }
- ]
- }
- }
- },
- 'output': 'ip'
- }
- obj = GetServerIp(scenario_cfg, {})
- result = obj.run({})
- self.assertEqual(result, {'ip': '127.0.0.1'})
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/__init__.py b/tests/unit/benchmark/scenarios/networking/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/scenarios/networking/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/scenarios/networking/imix_voice.yaml b/tests/unit/benchmark/scenarios/networking/imix_voice.yaml
deleted file mode 100644
index b8f8e5358..000000000
--- a/tests/unit/benchmark/scenarios/networking/imix_voice.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#imix definition for voice traffic
-#
-# it is a typical case for testing the synthetic VNF performance.
-#
-#percentage of the packets can be less than 100%
-#the traffic in downstream and upstream direction could be different
-
-schema: "nsb:imix:0.1"
-
-imix:
- private:
- imix_small: 100 #ipv4 case - 72B should be 0 ipv6 case - 84B
- imix_128B: 0
- imix_256B: 0
- imix_373B: 0
- imix_570B: 0
- imix_1400B: 0
- imix_1500B: 0
-
- public:
- imix_small: 100 #ipv4 case - 72B ipv6 - 84B
- imix_128B: 0
- imix_256B: 0
- imix_373B: 0
- imix_570B: 0
- imix_1400B: 0
- imix_1500B: 0
diff --git a/tests/unit/benchmark/scenarios/networking/iperf3_sample_output.json b/tests/unit/benchmark/scenarios/networking/iperf3_sample_output.json
deleted file mode 100644
index b56009ba1..000000000
--- a/tests/unit/benchmark/scenarios/networking/iperf3_sample_output.json
+++ /dev/null
@@ -1 +0,0 @@
-{"start": {"connecting_to": {"host": "172.16.0.252", "port": 5201}, "timestamp": {"timesecs": 1436254758, "time": "Tue, 07 Jul 2015 07:39:18 GMT"}, "test_start": {"protocol": "TCP", "num_streams": 1, "omit": 0, "bytes": 0, "blksize": 131072, "duration": 10, "blocks": 0, "reverse": 0}, "system_info": "Linux client 3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:27:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux\n", "version": "iperf 3.0.7", "connected": [{"local_host": "10.0.1.2", "local_port": 37633, "remote_host": "172.16.0.252", "socket": 4, "remote_port": 5201}], "cookie": "client.1436254758.606879.1fb328dc230", "tcp_mss_default": 1448}, "intervals": [{"sum": {"end": 1.00068, "seconds": 1.00068, "bytes": 16996624, "bits_per_second": 135881000.0, "start": 0, "retransmits": 0, "omitted": false}, "streams": [{"end": 1.00068, "socket": 4, "seconds": 1.00068, "bytes": 16996624, "bits_per_second": 135881000.0, "start": 0, "retransmits": 0, "omitted": false, "snd_cwnd": 451776}]}, {"sum": {"end": 2.00048, "seconds": 0.999804, "bytes": 20010192, "bits_per_second": 160113000.0, "start": 1.00068, "retransmits": 0, "omitted": false}, "streams": [{"end": 2.00048, "socket": 4, "seconds": 0.999804, "bytes": 20010192, "bits_per_second": 160113000.0, "start": 1.00068, "retransmits": 0, "omitted": false, "snd_cwnd": 713864}]}, {"sum": {"end": 3.00083, "seconds": 1.00035, "bytes": 18330464, "bits_per_second": 146592000.0, "start": 2.00048, "retransmits": 0, "omitted": false}, "streams": [{"end": 3.00083, "socket": 4, "seconds": 1.00035, "bytes": 18330464, "bits_per_second": 146592000.0, "start": 2.00048, "retransmits": 0, "omitted": false, "snd_cwnd": 768888}]}, {"sum": {"end": 4.00707, "seconds": 1.00624, "bytes": 19658376, "bits_per_second": 156292000.0, "start": 3.00083, "retransmits": 0, "omitted": false}, "streams": [{"end": 4.00707, "socket": 4, "seconds": 1.00624, "bytes": 19658376, "bits_per_second": 156292000.0, "start": 3.00083, "retransmits": 0, "omitted": false, "snd_cwnd": 812328}]}, {"sum": {"end": 5.00104, "seconds": 0.993972, "bytes": 15709072, "bits_per_second": 126435000.0, "start": 4.00707, "retransmits": 0, "omitted": false}, "streams": [{"end": 5.00104, "socket": 4, "seconds": 0.993972, "bytes": 15709072, "bits_per_second": 126435000.0, "start": 4.00707, "retransmits": 0, "omitted": false, "snd_cwnd": 849976}]}, {"sum": {"end": 6.00049, "seconds": 0.999443, "bytes": 19616288, "bits_per_second": 157018000.0, "start": 5.00104, "retransmits": 53, "omitted": false}, "streams": [{"end": 6.00049, "socket": 4, "seconds": 0.999443, "bytes": 19616288, "bits_per_second": 157018000.0, "start": 5.00104, "retransmits": 53, "omitted": false, "snd_cwnd": 641464}]}, {"sum": {"end": 7.00085, "seconds": 1.00036, "bytes": 22250480, "bits_per_second": 177939000.0, "start": 6.00049, "retransmits": 0, "omitted": false}, "streams": [{"end": 7.00085, "socket": 4, "seconds": 1.00036, "bytes": 22250480, "bits_per_second": 177939000.0, "start": 6.00049, "retransmits": 0, "omitted": false, "snd_cwnd": 706624}]}, {"sum": {"end": 8.00476, "seconds": 1.00391, "bytes": 22282240, "bits_per_second": 177564000.0, "start": 7.00085, "retransmits": 0, "omitted": false}, "streams": [{"end": 8.00476, "socket": 4, "seconds": 1.00391, "bytes": 22282240, "bits_per_second": 177564000.0, "start": 7.00085, "retransmits": 0, "omitted": false, "snd_cwnd": 761648}]}, {"sum": {"end": 9.0016, "seconds": 0.996847, "bytes": 19657680, "bits_per_second": 157759000.0, "start": 8.00476, "retransmits": 28, "omitted": false}, "streams": [{"end": 9.0016, "socket": 4, "seconds": 0.996847, "bytes": 19657680, "bits_per_second": 157759000.0, "start": 8.00476, "retransmits": 28, "omitted": false, "snd_cwnd": 570512}]}, {"sum": {"end": 10.0112, "seconds": 1.00955, "bytes": 20932520, "bits_per_second": 165876000.0, "start": 9.0016, "retransmits": 0, "omitted": false}, "streams": [{"end": 10.0112, "socket": 4, "seconds": 1.00955, "bytes": 20932520, "bits_per_second": 165876000.0, "start": 9.0016, "retransmits": 0, "omitted": false, "snd_cwnd": 615400}]}], "end": {"sum_received": {"seconds": 10.0112, "start": 0, "end": 10.0112, "bytes": 193366712, "bits_per_second": 154521000.0}, "streams": [{"sender": {"end": 10.0112, "socket": 4, "seconds": 10.0112, "bytes": 195443936, "bits_per_second": 156181000.0, "start": 0, "retransmits": 81}, "receiver": {"end": 10.0112, "socket": 4, "seconds": 10.0112, "bytes": 193366712, "bits_per_second": 154521000.0, "start": 0}}], "sum_sent": {"end": 10.0112, "seconds": 10.0112, "bytes": 195443936, "bits_per_second": 156181000.0, "start": 0, "retransmits": 81}, "cpu_utilization_percent": {"remote_user": 1.10295, "remote_system": 40.0403, "host_user": 2.41785, "remote_total": 41.1438, "host_system": 5.09548, "host_total": 7.51411}}} \ No newline at end of file
diff --git a/tests/unit/benchmark/scenarios/networking/iperf3_sample_output_udp.json b/tests/unit/benchmark/scenarios/networking/iperf3_sample_output_udp.json
deleted file mode 100644
index 8173c8f64..000000000
--- a/tests/unit/benchmark/scenarios/networking/iperf3_sample_output_udp.json
+++ /dev/null
@@ -1 +0,0 @@
-{"start":{"connected":[{"socket":4, "local_host":"10.0.1.2", "local_port":46384, "remote_host":"172.16.9.195", "remote_port":5201}], "version":"iperf 3.0.7", "system_info":"Linux zeus 3.13.0-61-generic #100-Ubuntu SMP Wed Jul 29 11:21:34 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux\n", "timestamp":{"time":"Tue, 29 Sep 2015 01:48:23 GMT", "timesecs":1443491303}, "connecting_to":{"host":"172.16.9.195", "port":5201}, "cookie":"zeus.1443491303.539703.3479129b58a5b", "test_start":{"protocol":"UDP", "num_streams":1, "blksize":8192, "omit":0, "duration":10, "bytes":0, "blocks":0, "reverse":0}}, "intervals":[{"streams":[{"socket":4, "start":0, "end":1.00022, "seconds":1.00022, "bytes":2252800, "bits_per_second":1.80184e+07, "packets":275, "omitted":false}], "sum":{"start":0, "end":1.00022, "seconds":1.00022, "bytes":2252800, "bits_per_second":1.80184e+07, "packets":275, "omitted":false}}, {"streams":[{"socket":4, "start":1.00022, "end":2.00022, "seconds":0.999993, "bytes":2498560, "bits_per_second":1.99886e+07, "packets":305, "omitted":false}], "sum":{"start":1.00022, "end":2.00022, "seconds":0.999993, "bytes":2498560, "bits_per_second":1.99886e+07, "packets":305, "omitted":false}}, {"streams":[{"socket":4, "start":2.00022, "end":3.00022, "seconds":1, "bytes":2506752, "bits_per_second":2.0054e+07, "packets":306, "omitted":false}], "sum":{"start":2.00022, "end":3.00022, "seconds":1, "bytes":2506752, "bits_per_second":2.0054e+07, "packets":306, "omitted":false}}, {"streams":[{"socket":4, "start":3.00022, "end":4.00022, "seconds":1, "bytes":2498560, "bits_per_second":19988480, "packets":305, "omitted":false}], "sum":{"start":3.00022, "end":4.00022, "seconds":1, "bytes":2498560, "bits_per_second":19988480, "packets":305, "omitted":false}}, {"streams":[{"socket":4, "start":4.00022, "end":5.0002, "seconds":0.999977, "bytes":2498560, "bits_per_second":1.99889e+07, "packets":305, "omitted":false}], "sum":{"start":4.00022, "end":5.0002, "seconds":0.999977, "bytes":2498560, "bits_per_second":1.99889e+07, "packets":305, "omitted":false}}, {"streams":[{"socket":4, "start":5.0002, "end":6.00024, "seconds":1.00004, "bytes":2498560, "bits_per_second":1.99877e+07, "packets":305, "omitted":false}], "sum":{"start":5.0002, "end":6.00024, "seconds":1.00004, "bytes":2498560, "bits_per_second":1.99877e+07, "packets":305, "omitted":false}}, {"streams":[{"socket":4, "start":6.00024, "end":7.00023, "seconds":0.999998, "bytes":2498560, "bits_per_second":1.99885e+07, "packets":305, "omitted":false}], "sum":{"start":6.00024, "end":7.00023, "seconds":0.999998, "bytes":2498560, "bits_per_second":1.99885e+07, "packets":305, "omitted":false}}, {"streams":[{"socket":4, "start":7.00023, "end":8.00023, "seconds":0.999999, "bytes":2506752, "bits_per_second":2.0054e+07, "packets":306, "omitted":false}], "sum":{"start":7.00023, "end":8.00023, "seconds":0.999999, "bytes":2506752, "bits_per_second":2.0054e+07, "packets":306, "omitted":false}}, {"streams":[{"socket":4, "start":8.00023, "end":9.00018, "seconds":0.999945, "bytes":2498560, "bits_per_second":1.99896e+07, "packets":305, "omitted":false}], "sum":{"start":8.00023, "end":9.00018, "seconds":0.999945, "bytes":2498560, "bits_per_second":1.99896e+07, "packets":305, "omitted":false}}, {"streams":[{"socket":4, "start":9.00018, "end":10.0002, "seconds":1.00004, "bytes":2498560, "bits_per_second":1.99876e+07, "packets":305, "omitted":false}], "sum":{"start":9.00018, "end":10.0002, "seconds":1.00004, "bytes":2498560, "bits_per_second":1.99876e+07, "packets":305, "omitted":false}}], "end":{"streams":[{"udp":{"socket":4, "start":0, "end":10.0002, "seconds":10.0002, "bytes":24756224, "bits_per_second":1.98045e+07, "jitter_ms":0.0113579, "lost_packets":0, "packets":3022, "lost_percent":0}}], "sum":{"start":0, "end":10.0002, "seconds":10.0002, "bytes":24756224, "bits_per_second":1.98045e+07, "jitter_ms":0.0113579, "lost_packets":0, "packets":3022, "lost_percent":0}, "cpu_utilization_percent":{"host_total":0.647561, "host_user":0.146468, "host_system":0.501083, "remote_total":0.31751, "remote_user":0, "remote_system":0.31751}}}
diff --git a/tests/unit/benchmark/scenarios/networking/ipv4_1flow_Packets_vpe.yaml b/tests/unit/benchmark/scenarios/networking/ipv4_1flow_Packets_vpe.yaml
deleted file mode 100644
index f3046f463..000000000
--- a/tests/unit/benchmark/scenarios/networking/ipv4_1flow_Packets_vpe.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-flow:
- srcip4_range: '152.16.0.20'
- dstip4_range: '152.40.0.20'
- count: 1
diff --git a/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml b/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml
deleted file mode 100644
index 2123e4705..000000000
--- a/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml
+++ /dev/null
@@ -1,101 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# flow definition for ACL tests - 1K flows - ipv4 only
-#
-# the number of flows defines the widest range of parameters
-# for example if srcip_range=1.0.0.1-1.0.0.255 and dst_ip_range=10.0.0.1-10.0.1.255
-# and it should define only 16 flows
-#
-#there is assumption that packets generated will have a random sequences of following addresses pairs
-# in the packets
-# 1. src=1.x.x.x(x.x.x =random from 1..255) dst=10.x.x.x (random from 1..512)
-# 2. src=1.x.x.x(x.x.x =random from 1..255) dst=10.x.x.x (random from 1..512)
-# ...
-# 512. src=1.x.x.x(x.x.x =random from 1..255) dst=10.x.x.x (random from 1..512)
-#
-# not all combination should be filled
-# Any other field with random range will be added to flow definition
-#
-# the example.yaml provides all possibilities for traffic generation
-#
-# the profile defines a public and private side to make limited traffic correlation
-# between private and public side same way as it is made by IXIA solution.
-#
-schema: "isb:traffic_profile:0.1"
-
-# This file is a template, it will be filled with values from tc.yaml before passing to the traffic generator
-
-name: rfc2544
-description: Traffic profile to run RFC2544 latency
-traffic_profile:
- traffic_type : RFC2544Profile # defines traffic behavior - constant or look for highest possible throughput
- frame_rate : 100 # pc of linerate
- # that specifies a range (e.g. ipv4 address, port)
-
-
-private:
- ipv4:
- outer_l2:
- framesize:
- 64B: "{{ get(imix, 'imix.uplink.imix_small', '0') }}"
- 128B: "{{ get(imix, 'imix.uplink.imix_128B', '0') }}"
- 256B: "{{ get(imix, 'imix.uplink.imix_256B', '0') }}"
- 373b: "{{ get(imix, 'imix.uplink.imix_373B', '0') }}"
- 570B: "{{get(imix, 'imix.uplink.imix_570B', '0') }}"
- 1400B: "{{get(imix, 'imix.uplink.imix_1400B', '0') }}"
- 1518B: "{{get(imix, 'imix.uplink.imix_1500B', '0') }}"
-
- QinQ:
- S-VLAN:
- id: 128
- priority: 0
- cfi: 0
- C-VLAN:
- id: 512
- priority: 0
- cfi: 0
-
- outer_l3v4:
- proto: "tcp"
- srcip4: "{{get(flow, 'flow.srcip4_range', '192.168.0.0-192.168.255.255') }}"
- dstip4: "{{get(flow, 'flow.dstip4_range', '192.16.0.0-192.16.0.31') }}"
- ttl: 32
- dscp: 32
-
- outer_l4:
- srcport: "{{get(flow, 'flow.srcport_range', '0') }}"
- dstport: "{{get(flow, 'flow.dstport_range', '0') }}"
-public:
- ipv4:
- outer_l2:
- framesize:
- 64B: "{{ get(imix, 'imix.uplink.imix_small', '0') }}"
- 128B: "{{ get(imix, 'imix.uplink.imix_128B', '0') }}"
- 256B: "{{ get(imix, 'imix.uplink.imix_256B', '0') }}"
- 373b: "{{ get(imix, 'imix.uplink.imix_373B', '0') }}"
- 570B: "{{get(imix, 'imix.uplink.imix_570B', '0') }}"
- 1400B: "{{get(imix, 'imix.uplink.imix_1400B', '0') }}"
- 1518B: "{{get(imix, 'imix.uplink.imix_1500B', '0') }}"
-
- outer_l3v4:
- proto: "tcp"
- srcip4: "{{get(flow, 'flow.dstip4_range', '192.16.0.0-192.16.0.31') }}"
- dstip4: "{{get(flow, 'flow.srcip4_range', '192.168.0.0-192.168.255.255') }}"
- ttl: 32
- dscp: 32
-
- outer_l4:
- srcport: "{{get(flow, 'flow.dstport_range', '0') }}"
- dstport: "{{get(flow, 'flow.srcport_range', '0') }}"
diff --git a/tests/unit/benchmark/scenarios/networking/netperf_sample_output.json b/tests/unit/benchmark/scenarios/networking/netperf_sample_output.json
deleted file mode 100755
index bba76cfa5..000000000
--- a/tests/unit/benchmark/scenarios/networking/netperf_sample_output.json
+++ /dev/null
@@ -1 +0,0 @@
-{"mean_latency":"9.49","troughput":"823.77","troughput_unit":"10^6bits/s"} \ No newline at end of file
diff --git a/tests/unit/benchmark/scenarios/networking/netutilization_sample_output1.txt b/tests/unit/benchmark/scenarios/networking/netutilization_sample_output1.txt
deleted file mode 100644
index f90457cb3..000000000
--- a/tests/unit/benchmark/scenarios/networking/netutilization_sample_output1.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-Linux 3.19.0-25-generic (huawei-pod4) 07/19/2016 _x86_64_ (1 CPU)
-
-02:01:50 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
-02:01:51 PM eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
-02:01:51 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
-
-Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
-Average: eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
-Average: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
diff --git a/tests/unit/benchmark/scenarios/networking/netutilization_sample_output2.txt b/tests/unit/benchmark/scenarios/networking/netutilization_sample_output2.txt
deleted file mode 100644
index 417613ec1..000000000
--- a/tests/unit/benchmark/scenarios/networking/netutilization_sample_output2.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Linux 3.19.0-25-generic (huawei-pod4) 07/19/2016 _x86_64_ (1 CPU)
-
-02:01:50 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
-02:01:51 PM eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
-02:01:51 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
-
-02:01:52 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
-02:01:53 PM eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
-02:01:53 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
-
-Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
-Average: eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
-Average: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
diff --git a/tests/unit/benchmark/scenarios/networking/test_iperf3.py b/tests/unit/benchmark/scenarios/networking/test_iperf3.py
deleted file mode 100644
index 4d3745230..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_iperf3.py
+++ /dev/null
@@ -1,202 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.networking.iperf3.Iperf
-
-from __future__ import absolute_import
-
-import os
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.common import utils
-from yardstick.benchmark.scenarios.networking import iperf3
-
-
-@mock.patch('yardstick.benchmark.scenarios.networking.iperf3.ssh')
-class IperfTestCase(unittest.TestCase):
- output_name_tcp = 'iperf3_sample_output.json'
- output_name_udp = 'iperf3_sample_output_udp.json'
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': 'mykey.key'
- },
- 'target': {
- 'ip': '172.16.0.138',
- 'user': 'root',
- 'key_filename': 'mykey.key',
- 'ipaddr': '172.16.0.138',
- }
- }
-
- def test_iperf_successful_setup(self, mock_ssh):
-
- p = iperf3.Iperf({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- p.setup()
- self.assertIsNotNone(p.target)
- self.assertIsNotNone(p.host)
- mock_ssh.SSH.from_node().execute.assert_called_with("iperf3 -s -D")
-
- def test_iperf_unsuccessful_setup(self, mock_ssh):
-
- p = iperf3.Iperf({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.setup)
-
- def test_iperf_successful_teardown(self, mock_ssh):
-
- p = iperf3.Iperf({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
- p.target = mock_ssh.SSH.from_node()
-
- p.teardown()
- self.assertTrue(mock_ssh.SSH.from_node().close.called)
- mock_ssh.SSH.from_node().execute.assert_called_with("pkill iperf3")
-
- def test_iperf_successful_no_sla(self, mock_ssh):
-
- options = {}
- args = {'options': options}
- result = {}
-
- p = iperf3.Iperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.output_name_tcp)
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- expected_result = utils.flatten_dict_key(jsonutils.loads(sample_output))
- p.run(result)
- self.assertEqual(result, expected_result)
-
- def test_iperf_successful_sla(self, mock_ssh):
-
- options = {}
- args = {
- 'options': options,
- 'sla': {'bytes_per_second': 15000000}
- }
- result = {}
-
- p = iperf3.Iperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.output_name_tcp)
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- expected_result = utils.flatten_dict_key(jsonutils.loads(sample_output))
- p.run(result)
- self.assertEqual(result, expected_result)
-
- def test_iperf_unsuccessful_sla(self, mock_ssh):
-
- options = {}
- args = {
- 'options': options,
- 'sla': {'bytes_per_second': 25000000}
- }
- result = {}
-
- p = iperf3.Iperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.output_name_tcp)
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, result)
-
- def test_iperf_successful_sla_jitter(self, mock_ssh):
- options = {"protocol": "udp", "bandwidth": "20m"}
- args = {
- 'options': options,
- 'sla': {'jitter': 10}
- }
- result = {}
-
- p = iperf3.Iperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.output_name_udp)
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- expected_result = utils.flatten_dict_key(jsonutils.loads(sample_output))
- p.run(result)
- self.assertEqual(result, expected_result)
-
- def test_iperf_unsuccessful_sla_jitter(self, mock_ssh):
- options = {"protocol": "udp", "bandwidth": "20m"}
- args = {
- 'options': options,
- 'sla': {'jitter': 0.0001}
- }
- result = {}
-
- p = iperf3.Iperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.output_name_udp)
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, result)
-
- def test_iperf_successful_tcp_protocal(self, mock_ssh):
- options = {"protocol": "tcp", "nodelay": "yes"}
- args = {
- 'options': options,
- 'sla': {'bytes_per_second': 15000000}
- }
- result = {}
-
- p = iperf3.Iperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.output_name_tcp)
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- expected_result = utils.flatten_dict_key(jsonutils.loads(sample_output))
- p.run(result)
- self.assertEqual(result, expected_result)
-
- def test_iperf_unsuccessful_script_error(self, mock_ssh):
-
- options = {}
- args = {'options': options}
- result = {}
-
- p = iperf3.Iperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.run, result)
-
- def _read_sample_output(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- output = os.path.join(curr_path, filename)
- with open(output) as f:
- sample_output = f.read()
- return sample_output
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_netperf.py b/tests/unit/benchmark/scenarios/networking/test_netperf.py
deleted file mode 100755
index d82a00931..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_netperf.py
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.networking.netperf.Netperf
-
-from __future__ import absolute_import
-
-import os
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.networking import netperf
-
-
-@mock.patch('yardstick.benchmark.scenarios.networking.netperf.ssh')
-class NetperfTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': 'mykey.key'
- },
- 'target': {
- 'ip': '172.16.0.138',
- 'user': 'cirros',
- 'key_filename': 'mykey.key',
- 'ipaddr': '172.16.0.138'
- }
- }
-
- def test_netperf_successful_setup(self, mock_ssh):
-
- p = netperf.Netperf({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- p.setup()
- self.assertIsNotNone(p.server)
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- def test_netperf_successful_no_sla(self, mock_ssh):
-
- options = {}
- args = {'options': options}
- result = {}
-
- p = netperf.Netperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output()
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- expected_result = jsonutils.loads(sample_output)
- p.run(result)
- self.assertEqual(result, expected_result)
-
- def test_netperf_successful_sla(self, mock_ssh):
-
- options = {}
- args = {
- 'options': options,
- 'sla': {'mean_latency': 100}
- }
- result = {}
-
- p = netperf.Netperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output()
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- expected_result = jsonutils.loads(sample_output)
- p.run(result)
- self.assertEqual(result, expected_result)
-
- def test_netperf_unsuccessful_sla(self, mock_ssh):
-
- options = {}
- args = {
- 'options': options,
- 'sla': {'mean_latency': 5}
- }
- result = {}
-
- p = netperf.Netperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output()
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, result)
-
- def test_netperf_unsuccessful_script_error(self, mock_ssh):
-
- options = {}
- args = {'options': options}
- result = {}
-
- p = netperf.Netperf(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.run, result)
-
- def _read_sample_output(self):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- output = os.path.join(curr_path, 'netperf_sample_output.json')
- with open(output) as f:
- sample_output = f.read()
- return sample_output
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_netperf_node.py b/tests/unit/benchmark/scenarios/networking/test_netperf_node.py
deleted file mode 100755
index 8be9bb94d..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_netperf_node.py
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for
-# yardstick.benchmark.scenarios.networking.netperf_node.NetperfNode
-
-from __future__ import absolute_import
-
-import os
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.networking import netperf_node
-
-
-@mock.patch('yardstick.benchmark.scenarios.networking.netperf_node.ssh')
-class NetperfNodeTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '192.168.10.10',
- 'user': 'root',
- 'password': 'root'
- },
- 'target': {
- 'ip': '192.168.10.11',
- 'user': 'root',
- 'password': 'root'
- }
- }
-
- def test_netperf_node_successful_setup(self, mock_ssh):
-
- p = netperf_node.NetperfNode({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- p.setup()
- self.assertIsNotNone(p.server)
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- def test_netperf_node_successful_no_sla(self, mock_ssh):
-
- options = {}
- args = {'options': options}
- result = {}
-
- p = netperf_node.NetperfNode(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output()
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- expected_result = jsonutils.loads(sample_output)
- p.run(result)
- self.assertEqual(result, expected_result)
-
- def test_netperf_node_successful_sla(self, mock_ssh):
-
- options = {}
- args = {
- 'options': options,
- 'sla': {'mean_latency': 100}
- }
- result = {}
-
- p = netperf_node.NetperfNode(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output()
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- expected_result = jsonutils.loads(sample_output)
- p.run(result)
- self.assertEqual(result, expected_result)
-
- def test_netperf_node_unsuccessful_sla(self, mock_ssh):
-
- options = {}
- args = {
- 'options': options,
- 'sla': {'mean_latency': 5}
- }
- result = {}
-
- p = netperf_node.NetperfNode(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output()
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, result)
-
- def test_netperf_node_unsuccessful_script_error(self, mock_ssh):
-
- options = {}
- args = {'options': options}
- result = {}
-
- p = netperf_node.NetperfNode(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- p.host = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.run, result)
-
- def _read_sample_output(self):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- output = os.path.join(curr_path, 'netperf_sample_output.json')
- with open(output) as f:
- sample_output = f.read()
- return sample_output
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_netutilization.py b/tests/unit/benchmark/scenarios/networking/test_netutilization.py
deleted file mode 100644
index 1227e056e..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_netutilization.py
+++ /dev/null
@@ -1,227 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and other.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for
-# yardstick.benchmark.scenarios.networking.netutilization.NetUtilization
-
-from __future__ import absolute_import
-import mock
-import unittest
-import os
-
-from yardstick.benchmark.scenarios.networking import netutilization
-
-
-@mock.patch('yardstick.benchmark.scenarios.networking.netutilization.ssh')
-class NetUtilizationTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': "mykey.key"
- }
- }
-
- self.result = {}
-
- def test_setup_success(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
- args = {'options': options}
-
- n = netutilization.NetUtilization(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- n.setup()
- self.assertIsNotNone(n.client)
- self.assertTrue(n.setup_done)
-
- def test_execute_command_success(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
- args = {'options': options}
-
- n = netutilization.NetUtilization(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- n.setup()
-
- expected_result = 'abcdefg'
- mock_ssh.SSH.from_node().execute.return_value = (0, expected_result, '')
- result = n._execute_command("foo")
- self.assertEqual(result, expected_result)
-
- def test_execute_command_failed(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
- args = {'options': options}
-
- n = netutilization.NetUtilization(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- n.setup()
-
- mock_ssh.SSH.from_node().execute.return_value = (127, '', 'abcdefg')
- self.assertRaises(RuntimeError, n._execute_command,
- "failed")
-
- def test_get_network_utilization_success(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 1
- }
- args = {'options': options}
-
- n = netutilization.NetUtilization(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- n.setup()
-
- mpstat_output = self._read_file("netutilization_sample_output1.txt")
- mock_ssh.SSH.from_node().execute.return_value = (0, mpstat_output, '')
- result = n._get_network_utilization()
-
- expected_result = \
- {"network_utilization_maximun": {
- "lo": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"},
- "eth0": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"}},
- "network_utilization_average": {
- "lo": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"},
- "eth0": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"}},
- "network_utilization_minimum": {
- "lo": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"},
- "eth0": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"}}}
-
- self.assertDictEqual(result, expected_result)
-
- def test_get_network_utilization_2_success(self, mock_ssh):
- options = {
- "interval": 1,
- "count": 2
- }
- args = {'options': options}
-
- n = netutilization.NetUtilization(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- n.setup()
-
- mpstat_output = self._read_file("netutilization_sample_output2.txt")
- mock_ssh.SSH.from_node().execute.return_value = (0, mpstat_output, '')
- result = n._get_network_utilization()
-
- expected_result = \
- {"network_utilization_maximun": {
- "lo": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"},
- "eth0": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"}},
- "network_utilization_average": {
- "lo": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"},
- "eth0": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"}},
- "network_utilization_minimum": {
- "lo": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"},
- "eth0": {"rxcmp/s": "0.00",
- "%ifutil": "0.00",
- "txcmp/s": "0.00",
- "txkB/s": "0.00",
- "rxkB/s": "0.00",
- "rxpck/s": "0.00",
- "txpck/s": "0.00",
- "rxmcst/s": "0.00"}}}
-
- self.assertDictEqual(result, expected_result)
-
- def _read_file(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- output = os.path.join(curr_path, filename)
- with open(output) as f:
- sample_output = f.read()
- return sample_output
diff --git a/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py b/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py
deleted file mode 100644
index 3e7a3c5ee..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_networkcapacity.py
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for
-# yardstick.benchmark.scenarios.networking.networkcapacity.NetworkCapacity
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.networking import networkcapacity
-
-SAMPLE_OUTPUT = \
- '{"Number of connections":"308","Number of frames received": "166503"}'
-
-
-@mock.patch('yardstick.benchmark.scenarios.networking.networkcapacity.ssh')
-class NetworkCapacityTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'password': "root"
- },
- }
-
- self.result = {}
-
- def test_capacity_successful_setup(self, mock_ssh):
- c = networkcapacity.NetworkCapacity({}, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
- self.assertIsNotNone(c.client)
- self.assertTrue(c.setup_done)
-
- def test_capacity_successful(self, mock_ssh):
- c = networkcapacity.NetworkCapacity({}, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, SAMPLE_OUTPUT, '')
- c.run(self.result)
- expected_result = jsonutils.loads(SAMPLE_OUTPUT)
- self.assertEqual(self.result, expected_result)
-
- def test_capacity_unsuccessful_script_error(self, mock_ssh):
- c = networkcapacity.NetworkCapacity({}, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, c.run, self.result)
diff --git a/tests/unit/benchmark/scenarios/networking/test_nstat.py b/tests/unit/benchmark/scenarios/networking/test_nstat.py
deleted file mode 100644
index 4b58e06c1..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_nstat.py
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# 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
-
-from yardstick.benchmark.scenarios.networking import nstat
-
-
-@mock.patch('yardstick.benchmark.scenarios.networking.nstat.ssh')
-class NstatTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- "host": {
- "ip": "192.168.50.28",
- "user": "root",
- "key_filename": "mykey.key"
- }
- }
-
- def test_nstat_successful_setup(self, mock_ssh):
-
- n = nstat.Nstat({}, self.ctx)
- n.setup()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- self.assertIsNotNone(n.client)
- self.assertTrue(n.setup_done)
-
- def test_nstat_successful_no_sla(self, mock_ssh):
-
- options = {
- "duration": 0
- }
- args = {
- "options": options,
- }
- n = nstat.Nstat(args, self.ctx)
- result = {}
-
- sample_output = '#kernel\nIpInReceives 1837 0.0\nIpInHdrErrors 0 0.0\nIpInAddrErrors 2 0.0\nIcmpInMsgs 319 0.0\nIcmpInErrors 0 0.0\nTcpInSegs 36 0.0\nTcpInErrs 0 0.0\nUdpInDatagrams 1318 0.0\nUdpInErrors 0 0.0\n' # pylint: disable=line-too-long
-
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- n.run(result)
- expected_result = {"TcpInErrs": 0, "UdpInDatagrams": 1318,
- "Tcp_segment_error_rate": 0.0, "IpInAddrErrors": 2,
- "IpInHdrErrors": 0, "IcmpInErrors": 0, "IpErrors": 2,
- "TcpInSegs": 36, "IpInReceives": 1837, "IcmpInMsgs": 319,
- "IP_datagram_error_rate": 0.001, "Udp_datagram_error_rate": 0.0,
- "Icmp_message_error_rate": 0.0, "UdpInErrors": 0}
- self.assertEqual(result, expected_result)
-
- def test_nstat_successful_sla(self, mock_ssh):
-
- options = {
- "duration": 0
- }
- sla = {
- "IP_datagram_error_rate": 0.1
- }
- args = {
- "options": options,
- "sla": sla
- }
- n = nstat.Nstat(args, self.ctx)
- result = {}
-
- sample_output = '#kernel\nIpInReceives 1837 0.0\nIpInHdrErrors 0 0.0\nIpInAddrErrors 2 0.0\nIcmpInMsgs 319 0.0\nIcmpInErrors 0 0.0\nTcpInSegs 36 0.0\nTcpInErrs 0 0.0\nUdpInDatagrams 1318 0.0\nUdpInErrors 0 0.0\n' # pylint: disable=line-too-long
-
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- n.run(result)
- expected_result = {"TcpInErrs": 0, "UdpInDatagrams": 1318,
- "Tcp_segment_error_rate": 0.0, "IpInAddrErrors": 2,
- "IpInHdrErrors": 0, "IcmpInErrors": 0, "IpErrors": 2,
- "TcpInSegs": 36, "IpInReceives": 1837, "IcmpInMsgs": 319,
- "IP_datagram_error_rate": 0.001, "Udp_datagram_error_rate": 0.0,
- "Icmp_message_error_rate": 0.0, "UdpInErrors": 0}
- self.assertEqual(result, expected_result)
-
- def test_nstat_unsuccessful_cmd_error(self, mock_ssh):
-
- options = {
- "duration": 0
- }
- sla = {
- "IP_datagram_error_rate": 0.1
- }
- args = {
- "options": options,
- "sla": sla
- }
- n = nstat.Nstat(args, self.ctx)
- result = {}
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, n.run, result)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_ping.py b/tests/unit/benchmark/scenarios/networking/test_ping.py
deleted file mode 100644
index 06353249a..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_ping.py
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.networking.ping.Ping
-
-from __future__ import absolute_import
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.networking import ping
-
-
-class PingTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': "mykey.key"
- },
- "target": {
- "ipaddr": "10.229.17.105",
- }
- }
-
- @mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh')
- def test_ping_successful_no_sla(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 200},
- 'target': 'ares.demo'
- }
- result = {}
-
- p = ping.Ping(args, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '100', '')
- p.run(result)
- self.assertEqual(result, {'rtt.ares': 100.0})
-
- @mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh')
- def test_ping_successful_sla(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 200},
- 'sla': {'max_rtt': 150},
- 'target': 'ares.demo'
- }
- result = {}
-
- p = ping.Ping(args, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '100', '')
- p.run(result)
- self.assertEqual(result, {'rtt.ares': 100.0})
-
- @mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh')
- def test_ping_unsuccessful_sla(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 200},
- 'sla': {'max_rtt': 50},
- 'target': 'ares.demo'
- }
- result = {}
-
- p = ping.Ping(args, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '100', '')
- self.assertRaises(AssertionError, p.run, result)
-
- @mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh')
- def test_ping_unsuccessful_script_error(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 200},
- 'sla': {'max_rtt': 50},
- 'target': 'ares.demo'
- }
- result = {}
-
- p = ping.Ping(args, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.run, result)
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_ping6.py b/tests/unit/benchmark/scenarios/networking/test_ping6.py
deleted file mode 100644
index d2be6f576..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_ping6.py
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.networking.ping.Ping
-
-from __future__ import absolute_import
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.networking import ping6
-
-
-class PingTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'nodes': {
- 'host1': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'role': "Controller",
- 'key_filename': "mykey.key",
- 'password': "root"
- },
- 'host2': {
- "ip": "172.16.0.138",
- "key_filename": "/root/.ssh/id_rsa",
- "role": "Compute",
- "name": "node3.IPV6",
- "user": "root"
- },
- }
- }
-
- def test_get_controller_node(self):
- args = {
- 'options': {'host': 'host1', 'packetsize': 200, 'ping_count': 5},
- 'sla': {'max_rtt': 50}
- }
- p = ping6.Ping6(args, self.ctx)
- controller_node = p._get_controller_node(['host1', 'host2'])
- self.assertEqual(controller_node, 'host1')
-
- @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh')
- def test_ping_successful_setup(self, mock_ssh):
- args = {
- 'options': {'host': 'host1', 'packetsize': 200, 'ping_count': 5},
- 'sla': {'max_rtt': 50}
- }
- p = ping6.Ping6(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '0', '')
- p.setup()
-
- self.assertTrue(p.setup_done)
-
- @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh')
- def test_ping_successful_no_sla(self, mock_ssh):
- args = {
- 'options': {'host': 'host1', 'packetsize': 200, 'ping_count': 5},
-
- }
- result = {}
-
- p = ping6.Ping6(args, self.ctx)
- p.client = mock_ssh.SSH.from_node()
- mock_ssh.SSH.from_node().execute.side_effect = [(0, 'host1', ''), (0, 100, '')]
- p.run(result)
- self.assertEqual(result, {'rtt': 100.0})
-
- @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh')
- def test_ping_successful_sla(self, mock_ssh):
- args = {
- 'options': {'host': 'host1', 'packetsize': 200, 'ping_count': 5},
- 'sla': {'max_rtt': 150}
- }
- result = {}
-
- p = ping6.Ping6(args, self.ctx)
- p.client = mock_ssh.SSH.from_node()
- mock_ssh.SSH.from_node().execute.side_effect = [(0, 'host1', ''), (0, 100, '')]
- p.run(result)
- self.assertEqual(result, {'rtt': 100.0})
-
- @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh')
- def test_ping_unsuccessful_sla(self, mock_ssh):
- args = {
- 'options': {'host': 'host1', 'packetsize': 200, 'ping_count': 5},
- 'sla': {'max_rtt': 50}
- }
- result = {}
-
- p = ping6.Ping6(args, self.ctx)
- p.client = mock_ssh.SSH.from_node()
- mock_ssh.SSH.from_node().execute.side_effect = [(0, 'host1', ''), (0, 100, '')]
- self.assertRaises(AssertionError, p.run, result)
-
- @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh')
- def test_ping_unsuccessful_script_error(self, mock_ssh):
-
- args = {
- 'options': {'host': 'host1', 'packetsize': 200, 'ping_count': 5},
- 'sla': {'max_rtt': 150}
- }
- result = {}
-
- p = ping6.Ping6(args, self.ctx)
- p.client = mock_ssh.SSH.from_node()
- mock_ssh.SSH.from_node().execute.side_effect = [
- (0, 'host1', ''), (1, '', 'FOOBAR')]
- self.assertRaises(RuntimeError, p.run, result)
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen.py b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
deleted file mode 100644
index 005b53177..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen.py
+++ /dev/null
@@ -1,760 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# 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
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.networking import pktgen
-
-
-@mock.patch('yardstick.benchmark.scenarios.networking.pktgen.ssh')
-class PktgenTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': 'mykey.key'
- },
- 'target': {
- 'ip': '172.16.0.138',
- 'user': 'root',
- 'key_filename': 'mykey.key',
- 'ipaddr': '172.16.0.138'
- }
- }
-
- def test_pktgen_successful_setup(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.setup()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- self.assertIsNotNone(p.server)
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- def test_pktgen_successful_iptables_setup(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.number_of_ports = args['options']['number_of_ports']
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- p._iptables_setup()
-
- mock_ssh.SSH.from_node().execute.assert_called_with(
- "sudo iptables -F; "
- "sudo iptables -A INPUT -p udp --dport 1000:%s -j DROP"
- % 1010, timeout=60)
-
- def test_pktgen_unsuccessful_iptables_setup(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- }
-
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.number_of_ports = args['options']['number_of_ports']
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p._iptables_setup)
-
- def test_pktgen_successful_iptables_get_result(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- }
-
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.number_of_ports = args['options']['number_of_ports']
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '150000', '')
- p._iptables_get_result()
-
- mock_ssh.SSH.from_node().execute.assert_called_with(
- "sudo iptables -L INPUT -vnx |"
- "awk '/dpts:1000:%s/ {{printf \"%%s\", $1}}'"
- % 1010)
-
- def test_pktgen_unsuccessful_iptables_get_result(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- }
-
- p = pktgen.Pktgen(args, self.ctx)
-
- p.server = mock_ssh.SSH.from_node()
- p.number_of_ports = args['options']['number_of_ports']
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p._iptables_get_result)
-
- def test_pktgen_successful_no_sla(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- }
- result = {}
-
- p = pktgen.Pktgen(args, self.ctx)
-
- 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
-
- sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "packetsize": 60, "flows": 110, "ppm": 3179}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
- expected_result = jsonutils.loads(sample_output)
- expected_result["packets_received"] = 149300
- expected_result["packetsize"] = 60
- self.assertEqual(result, expected_result)
-
- def test_pktgen_successful_sla(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- 'sla': {'max_ppm': 10000}
- }
- result = {}
-
- p = pktgen.Pktgen(args, self.ctx)
-
- 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
-
- sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "packetsize": 60, "flows": 110, "ppm": 3179}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
- expected_result = jsonutils.loads(sample_output)
- expected_result["packets_received"] = 149300
- expected_result["packetsize"] = 60
- self.assertEqual(result, expected_result)
-
- def test_pktgen_unsuccessful_sla(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- 'sla': {'max_ppm': 1000}
- }
- result = {}
-
- p = pktgen.Pktgen(args, self.ctx)
-
- 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
-
- sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "packetsize": 60, "flows": 110}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, result)
-
- def test_pktgen_unsuccessful_script_error(self, mock_ssh):
-
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- 'sla': {'max_ppm': 1000}
- }
- result = {}
-
- p = pktgen.Pktgen(args, self.ctx)
-
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.run, result)
-
- def test_pktgen_get_vnic_driver_name(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, 'ixgbevf', '')
-
- vnic_driver_name = p._get_vnic_driver_name()
- self.assertEqual(vnic_driver_name, 'ixgbevf')
-
- def test_pktgen_unsuccessful_get_vnic_driver_name(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- self.assertRaises(RuntimeError, p._get_vnic_driver_name)
-
- def test_pktgen_get_sriov_queue_number(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '2', '')
-
- p.queue_number = p._get_sriov_queue_number()
- self.assertEqual(p.queue_number, 2)
-
- def test_pktgen_unsuccessful_get_sriov_queue_number(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- self.assertRaises(RuntimeError, p._get_sriov_queue_number)
-
- def test_pktgen_get_available_queue_number(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '4', '')
-
- p._get_available_queue_number()
-
- mock_ssh.SSH.from_node().execute.assert_called_with(
- "sudo ethtool -l eth0 | grep Combined | head -1 |"
- "awk '{printf $2}'")
-
- def test_pktgen_unsuccessful_get_available_queue_number(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- self.assertRaises(RuntimeError, p._get_available_queue_number)
-
- def test_pktgen_get_usable_queue_number(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '1', '')
-
- p._get_usable_queue_number()
-
- mock_ssh.SSH.from_node().execute.assert_called_with(
- "sudo ethtool -l eth0 | grep Combined | tail -1 |"
- "awk '{printf $2}'")
-
- def test_pktgen_unsuccessful_get_usable_queue_number(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- self.assertRaises(RuntimeError, p._get_usable_queue_number)
-
- def test_pktgen_enable_ovs_multiqueue(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- 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.queue_number = p._enable_ovs_multiqueue()
- self.assertEqual(p.queue_number, 4)
-
- def test_pktgen_enable_ovs_multiqueue_1q(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- 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.queue_number = p._enable_ovs_multiqueue()
- self.assertEqual(p.queue_number, 1)
-
- def test_pktgen_unsuccessful_enable_ovs_multiqueue(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- 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
-
- self.assertRaises(RuntimeError, p._enable_ovs_multiqueue)
-
- def test_pktgen_setup_irqmapping_ovs(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '10', '')
-
- p._setup_irqmapping_ovs(4)
-
- mock_ssh.SSH.from_node().execute.assert_called_with(
- "echo 8 | sudo tee /proc/irq/10/smp_affinity")
-
- def test_pktgen_setup_irqmapping_ovs_1q(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '10', '')
-
- p._setup_irqmapping_ovs(1)
-
- mock_ssh.SSH.from_node().execute.assert_called_with(
- "echo 1 | sudo tee /proc/irq/10/smp_affinity")
-
- def test_pktgen_unsuccessful_setup_irqmapping_ovs(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- self.assertRaises(RuntimeError, p._setup_irqmapping_ovs, 4)
-
- def test_pktgen_unsuccessful_setup_irqmapping_ovs_1q(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- self.assertRaises(RuntimeError, p._setup_irqmapping_ovs, 1)
-
- def test_pktgen_setup_irqmapping_sriov(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '10', '')
-
- p._setup_irqmapping_sriov(2)
-
- mock_ssh.SSH.from_node().execute.assert_called_with(
- "echo 2 | sudo tee /proc/irq/10/smp_affinity")
-
- def test_pktgen_setup_irqmapping_sriov_1q(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '10', '')
-
- p._setup_irqmapping_sriov(1)
-
- mock_ssh.SSH.from_node().execute.assert_called_with(
- "echo 1 | sudo tee /proc/irq/10/smp_affinity")
-
- def test_pktgen_unsuccessful_setup_irqmapping_sriov(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- self.assertRaises(RuntimeError, p._setup_irqmapping_sriov, 2)
-
- def test_pktgen_unsuccessful_setup_irqmapping_sriov_1q(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- self.assertRaises(RuntimeError, p._setup_irqmapping_sriov, 1)
-
- def test_pktgen_is_irqbalance_disabled(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- p._is_irqbalance_disabled()
-
- mock_ssh.SSH.from_node().execute.assert_called_with(
- "grep ENABLED /etc/default/irqbalance")
-
- def test_pktgen_unsuccessful_is_irqbalance_disabled(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- self.assertRaises(RuntimeError, p._is_irqbalance_disabled)
-
- def test_pktgen_disable_irqbalance(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- p._disable_irqbalance()
-
- mock_ssh.SSH.from_node().execute.assert_called_with(
- "sudo service irqbalance disable")
-
- def test_pktgen_unsuccessful_disable_irqbalance(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- self.assertRaises(RuntimeError, p._disable_irqbalance)
-
- def test_pktgen_multiqueue_setup_ovs(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60, 'multiqueue': True},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- 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.multiqueue_setup()
-
- self.assertEqual(p.queue_number, 4)
-
- def test_pktgen_multiqueue_setup_ovs_1q(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60, 'multiqueue': True},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- 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.multiqueue_setup()
-
- self.assertEqual(p.queue_number, 1)
-
- def test_pktgen_multiqueue_setup_sriov(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60, 'multiqueue': True},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- 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.multiqueue_setup()
-
- self.assertEqual(p.queue_number, 2)
-
- def test_pktgen_multiqueue_setup_sriov_1q(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60, 'multiqueue': True},
- }
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- 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.multiqueue_setup()
-
- self.assertEqual(p.queue_number, 1)
-
- def test_pktgen_run_with_setup_done(self, mock_ssh):
- args = {
- 'options': {
- 'packetsize': 60,
- 'number_of_ports': 10,
- 'duration': 20,
- 'multiqueue': True},
- 'sla': {
- 'max_ppm': 1}}
- result = {}
- p = pktgen.Pktgen(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
-
- p.setup_done = True
- p.multiqueue_setup_done = True
-
- mock_iptables_result = mock.Mock()
- mock_iptables_result.return_value = 149300
- p._iptables_get_result = mock_iptables_result
-
- sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149300, "flows": 110, "ppm": 0}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
- expected_result = jsonutils.loads(sample_output)
- expected_result["packets_received"] = 149300
- expected_result["packetsize"] = 60
- self.assertEqual(result, expected_result)
-
- def test_pktgen_run_with_ovs_multiqueque(self, mock_ssh):
- args = {
- 'options': {
- 'packetsize': 60,
- 'number_of_ports': 10,
- 'duration': 20,
- 'multiqueue': True},
- 'sla': {
- 'max_ppm': 1}}
- result = {}
-
- p = pktgen.Pktgen(args, self.ctx)
-
- 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
-
- sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149300, "flows": 110, "ppm": 0}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
- expected_result = jsonutils.loads(sample_output)
- expected_result["packets_received"] = 149300
- expected_result["packetsize"] = 60
- self.assertEqual(result, expected_result)
-
- def test_pktgen_run_with_sriov_multiqueque(self, mock_ssh):
- args = {
- 'options': {
- 'packetsize': 60,
- 'number_of_ports': 10,
- 'duration': 20,
- 'multiqueue': True},
- 'sla': {
- 'max_ppm': 1}}
- result = {}
-
- p = pktgen.Pktgen(args, self.ctx)
-
- 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
-
- sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149300, "flows": 110, "ppm": 0}'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
- expected_result = jsonutils.loads(sample_output)
- expected_result["packets_received"] = 149300
- expected_result["packetsize"] = 60
- self.assertEqual(result, expected_result)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
deleted file mode 100644
index c9eec4b94..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
+++ /dev/null
@@ -1,192 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 ZTE and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# 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 yardstick.common.utils as utils
-from yardstick.benchmark.scenarios.networking import pktgen_dpdk
-
-
-class PktgenDPDKLatencyTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': 'mykey.key'
- },
- 'target': {
- 'ip': '172.16.0.138',
- 'user': 'root',
- 'key_filename': 'mykey.key',
- 'ipaddr': '172.16.0.138'
- }
- }
-
- self._mock_ssh = mock.patch(
- 'yardstick.benchmark.scenarios.networking.pktgen_dpdk.ssh')
- self.mock_ssh = self._mock_ssh.start()
- self._mock_time = mock.patch(
- 'yardstick.benchmark.scenarios.networking.pktgen_dpdk.time')
- self.mock_time = self._mock_time.start()
-
- self.addCleanup(self._stop_mock)
-
- def _stop_mock(self):
- self._mock_ssh.stop()
- self._mock_time.stop()
-
- def test_pktgen_dpdk_successful_setup(self):
-
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- p.setup()
-
- self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- self.assertIsNotNone(p.server)
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- def test_pktgen_dpdk_successful_get_port_ip(self):
-
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- p.server = self.mock_ssh.SSH.from_node()
-
- self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- utils.get_port_ip(p.server, "eth1")
-
- self.mock_ssh.SSH.from_node().execute.assert_called_with(
- "ifconfig eth1 |grep 'inet addr' |awk '{print $2}' |cut -d ':' -f2 ")
-
- def test_pktgen_dpdk_unsuccessful_get_port_ip(self):
-
- args = {
- 'options': {'packetsize': 60},
- }
-
- p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- p.server = self.mock_ssh.SSH.from_node()
-
- self.mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, utils.get_port_ip, p.server, "eth1")
-
- def test_pktgen_dpdk_successful_get_port_mac(self):
-
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- p.server = self.mock_ssh.SSH.from_node()
-
- self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- utils.get_port_mac(p.server, "eth1")
-
- self.mock_ssh.SSH.from_node().execute.assert_called_with(
- "ifconfig |grep HWaddr |grep eth1 |awk '{print $5}' ")
-
- def test_pktgen_dpdk_unsuccessful_get_port_mac(self):
-
- args = {
- 'options': {'packetsize': 60},
- }
-
- p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- p.server = self.mock_ssh.SSH.from_node()
-
- self.mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, utils.get_port_mac, p.server, "eth1")
-
- def test_pktgen_dpdk_successful_no_sla(self):
-
- args = {
- 'options': {'packetsize': 60},
- }
-
- result = {}
- p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
-
- sample_output = '100\n110\n112\n130\n149\n150\n90\n150\n200\n162\n'
- self.mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
- # with python 3 we get float, might be due python division changes
- # AssertionError: {'avg_latency': 132.33333333333334} != {
- # 'avg_latency': 132}
- delta = result['avg_latency'] - 132
- self.assertLessEqual(delta, 1)
-
- def test_pktgen_dpdk_successful_sla(self):
-
- args = {
- 'options': {'packetsize': 60},
- 'sla': {'max_latency': 100}
- }
- result = {}
-
- p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
-
- sample_output = '100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n'
- self.mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
-
- self.assertEqual(result, {"avg_latency": 100})
-
- def test_pktgen_dpdk_unsuccessful_sla(self):
-
- args = {
- 'options': {'packetsize': 60},
- 'sla': {'max_latency': 100}
- }
- result = {}
-
- p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
-
- p.server = self.mock_ssh.SSH.from_node()
- p.client = self.mock_ssh.SSH.from_node()
-
- sample_output = '100\n110\n112\n130\n149\n150\n90\n150\n200\n162\n'
- self.mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, result)
-
- def test_pktgen_dpdk_unsuccessful_script_error(self):
-
- args = {
- 'options': {'packetsize': 60},
- 'sla': {'max_latency': 100}
- }
- result = {}
-
- p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
-
- self.mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.run, result)
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
deleted file mode 100644
index c2e35af75..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
+++ /dev/null
@@ -1,198 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 Nokia and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# 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
-
-from __future__ import absolute_import
-import unittest
-
-from oslo_serialization import jsonutils
-import mock
-
-from yardstick.benchmark.scenarios.networking import pktgen_dpdk_throughput
-
-
-@mock.patch('yardstick.benchmark.scenarios.networking.pktgen_dpdk_throughput.ssh')
-class PktgenDPDKTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': 'mykey.key'
- },
- 'target': {
- 'ip': '172.16.0.138',
- 'user': 'root',
- 'key_filename': 'mykey.key',
- }
- }
-
- self._mock_time = mock.patch(
- 'yardstick.benchmark.scenarios.networking.pktgen_dpdk_throughput.time')
- self.mock_time = self._mock_time.start()
-
- self.addCleanup(self._cleanup)
-
- def _cleanup(self):
- self._mock_time.stop()
-
- def test_pktgen_dpdk_throughput_successful_setup(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
- p.setup()
-
- mock_ssh.SSH().execute.return_value = (0, '', '')
- self.assertIsNotNone(p.server)
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- def test_pktgen_dpdk_throughput_successful_no_sla(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- }
-
- result = {}
-
- p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
-
- p.server = mock_ssh.SSH()
- p.client = mock_ssh.SSH()
-
- mock_dpdk_result = mock.Mock()
- mock_dpdk_result.return_value = 149300
- p._dpdk_get_result = mock_dpdk_result
-
- sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "flows": 110}'
- mock_ssh.SSH().execute.return_value = (0, sample_output, '')
-
- p.run(result)
- expected_result = jsonutils.loads(sample_output)
- expected_result["packets_received"] = 149300
- expected_result["packetsize"] = 60
- self.assertEqual(result, expected_result)
-
- def test_pktgen_dpdk_throughput_successful_sla(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- 'sla': {'max_ppm': 10000}
- }
- result = {}
-
- p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
-
- p.server = mock_ssh.SSH()
- p.client = mock_ssh.SSH()
-
- mock_dpdk_result = mock.Mock()
- mock_dpdk_result.return_value = 149300
- p._dpdk_get_result = mock_dpdk_result
-
- sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "flows": 110}'
- mock_ssh.SSH().execute.return_value = (0, sample_output, '')
-
- p.run(result)
- expected_result = jsonutils.loads(sample_output)
- expected_result["packets_received"] = 149300
- expected_result["packetsize"] = 60
- self.assertEqual(result, expected_result)
-
- def test_pktgen_dpdk_throughput_unsuccessful_sla(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- 'sla': {'max_ppm': 1000}
- }
- result = {}
-
- p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
-
- p.server = mock_ssh.SSH()
- p.client = mock_ssh.SSH()
-
- mock_dpdk_result = mock.Mock()
- mock_dpdk_result.return_value = 149300
- p._dpdk_get_result = mock_dpdk_result
-
- sample_output = '{"packets_per_second": 9753, "errors": 0, \
- "packets_sent": 149776, "flows": 110}'
- mock_ssh.SSH().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, result)
-
- def test_pktgen_dpdk_throughput_unsuccessful_script_error(
- self, mock_ssh):
- args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10},
- 'sla': {'max_ppm': 1000}
- }
- result = {}
-
- p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
-
- p.server = mock_ssh.SSH()
- p.client = mock_ssh.SSH()
-
- mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.run, result)
-
- def test_pktgen_dpdk_throughput_is_dpdk_setup(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
- p.server = mock_ssh.SSH()
-
- mock_ssh.SSH().execute.return_value = (0, '', '')
-
- p._is_dpdk_setup("server")
-
- mock_ssh.SSH().execute.assert_called_with(
- "ip a | grep eth1 2>/dev/null")
-
- def test_pktgen_dpdk_throughput_dpdk_setup(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
- p.server = mock_ssh.SSH()
- p.client = mock_ssh.SSH()
-
- mock_ssh.SSH().execute.return_value = (0, '', '')
-
- p.dpdk_setup()
-
- self.assertTrue(p.dpdk_setup_done)
-
- def test_pktgen_dpdk_throughput_dpdk_get_result(self, mock_ssh):
- args = {
- 'options': {'packetsize': 60},
- }
- p = pktgen_dpdk_throughput.PktgenDPDK(args, self.ctx)
- p.server = mock_ssh.SSH()
- p.client = mock_ssh.SSH()
-
- mock_ssh.SSH().execute.return_value = (0, '10000', '')
-
- p._dpdk_get_result()
-
- mock_ssh.SSH().execute.assert_called_with(
- "sudo /dpdk/destdir/bin/dpdk-procinfo -- --stats-reset > /dev/null 2>&1")
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_sfc.py b/tests/unit/benchmark/scenarios/networking/test_sfc.py
deleted file mode 100644
index 78c0352dd..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_sfc.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.networking.sfc
-
-from __future__ import absolute_import
-import mock
-import unittest
-
-from yardstick.benchmark.scenarios.networking import sfc
-
-
-class SfcTestCase(unittest.TestCase):
-
- def setUp(self):
- scenario_cfg = {}
- context_cfg = {
- # Used in Sfc.setup()
- 'target': {
- 'user': 'root',
- 'password': 'opnfv',
- 'ip': '127.0.0.1',
- },
-
- # Used in Sfc.run()
- 'host': {
- 'user': 'root',
- 'password': 'opnfv',
- 'ip': None,
- }
- }
-
- self.sfc = sfc.Sfc(scenario_cfg=scenario_cfg, context_cfg=context_cfg)
-
- @mock.patch('yardstick.benchmark.scenarios.networking.sfc.ssh')
- @mock.patch('yardstick.benchmark.scenarios.networking.sfc.sfc_openstack')
- @mock.patch('yardstick.benchmark.scenarios.networking.sfc.subprocess')
- def test_run_for_success(self, mock_subprocess, mock_openstack, mock_ssh):
- # Mock a successfull SSH in Sfc.setup() and Sfc.run()
- mock_ssh.SSH.from_node().execute.return_value = (0, '100', '')
- mock_openstack.get_an_IP.return_value = "127.0.0.1"
- mock_subprocess.call.return_value = 'mocked!'
-
- result = {}
- self.sfc.setup()
- self.sfc.run(result)
- self.sfc.teardown()
-
- @mock.patch('yardstick.benchmark.scenarios.networking.sfc.ssh')
- @mock.patch('yardstick.benchmark.scenarios.networking.sfc.sfc_openstack')
- @mock.patch('yardstick.benchmark.scenarios.networking.sfc.subprocess')
- def test2_run_for_success(self, mock_subprocess, mock_openstack, mock_ssh):
- # Mock a successfull SSH in Sfc.setup() and Sfc.run()
- mock_ssh.SSH.from_node().execute.return_value = (
- 0, 'vxlan_tool.py', 'succeeded timed out')
- mock_openstack.get_an_IP.return_value = "127.0.0.1"
- mock_subprocess.call.return_value = 'mocked!'
-
- result = {}
- self.sfc.setup()
- self.sfc.run(result)
- self.sfc.teardown()
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
deleted file mode 100644
index 016608a21..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
+++ /dev/null
@@ -1,787 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Unittest for yardstick.benchmark.scenarios.networking.test_vnf_generic
-
-from __future__ import absolute_import
-
-import os
-import errno
-import unittest
-import mock
-
-from copy import deepcopy
-
-from tests.unit import STL_MOCKS
-from yardstick.benchmark.scenarios.networking.vnf_generic import \
- SshManager, NetworkServiceTestCase, IncorrectConfig, \
- open_relative_file
-from yardstick.network_services.collector.subscriber import Collector
-from yardstick.network_services.vnf_generic.vnf.base import \
- GenericTrafficGen, GenericVNF
-
-
-COMPLETE_TREX_VNFD = {
- 'vnfd:vnfd-catalog': {
- 'vnfd': [
- {
- 'benchmark': {
- 'kpi': [
- 'rx_throughput_fps',
- 'tx_throughput_fps',
- 'tx_throughput_mbps',
- 'rx_throughput_mbps',
- 'tx_throughput_pc_linerate',
- 'rx_throughput_pc_linerate',
- 'min_latency',
- 'max_latency',
- 'avg_latency',
- ],
- },
- 'connection-point': [
- {
- 'name': 'xe0',
- 'type': 'VPORT',
- },
- {
- 'name': 'xe1',
- 'type': 'VPORT',
- },
- ],
- 'description': 'TRex stateless traffic generator for RFC2544',
- 'id': 'TrexTrafficGen',
- 'mgmt-interface': {
- 'ip': '1.1.1.1',
- 'password': 'berta',
- 'user': 'berta',
- 'vdu-id': 'trexgen-baremetal',
- },
- 'name': 'trexgen',
- 'short-name': 'trexgen',
- 'class-name': 'TrexTrafficGen',
- 'vdu': [
- {
- 'description': 'TRex stateless traffic generator for RFC2544',
- 'external-interface': [
- {
- 'name': 'xe0',
- 'virtual-interface': {
- 'bandwidth': '10 Gbps',
- 'dst_ip': '1.1.1.1',
- 'dst_mac': '00:01:02:03:04:05',
- 'local_ip': '1.1.1.2',
- 'local_mac': '00:01:02:03:05:05',
- 'type': 'PCI-PASSTHROUGH',
- 'netmask': "255.255.255.0",
- 'driver': 'i40',
- 'vpci': '0000:00:10.2',
- },
- 'vnfd-connection-point-ref': 'xe0',
- },
- {
- 'name': 'xe1',
- 'virtual-interface': {
- 'bandwidth': '10 Gbps',
- 'dst_ip': '2.1.1.1',
- 'dst_mac': '00:01:02:03:04:06',
- 'local_ip': '2.1.1.2',
- 'local_mac': '00:01:02:03:05:06',
- 'type': 'PCI-PASSTHROUGH',
- 'netmask': "255.255.255.0",
- 'driver': 'i40',
- 'vpci': '0000:00:10.1',
- },
- 'vnfd-connection-point-ref': 'xe1',
- },
- ],
- 'id': 'trexgen-baremetal',
- 'name': 'trexgen-baremetal',
- },
- ],
- },
- ],
- },
-}
-
-IP_ADDR_SHOW = """
-28: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP \
-group default qlen 1000
- link/ether 90:e2:ba:a7:6a:c8 brd ff:ff:ff:ff:ff:ff
- inet 1.1.1.1/8 brd 1.255.255.255 scope global eth1
- inet6 fe80::92e2:baff:fea7:6ac8/64 scope link
- valid_lft forever preferred_lft forever
-29: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP \
-group default qlen 1000
- link/ether 90:e2:ba:a7:6a:c9 brd ff:ff:ff:ff:ff:ff
- inet 2.1.1.1/8 brd 2.255.255.255 scope global eth5
- inet6 fe80::92e2:baff:fea7:6ac9/64 scope link tentative
- valid_lft forever preferred_lft forever
-"""
-
-SYS_CLASS_NET = """
-lrwxrwxrwx 1 root root 0 sie 10 14:16 eth1 -> \
-../../devices/pci0000:80/0000:80:02.2/0000:84:00.1/net/eth1
-lrwxrwxrwx 1 root root 0 sie 3 10:37 eth2 -> \
-../../devices/pci0000:00/0000:00:01.1/0000:84:00.2/net/eth5
-"""
-
-TRAFFIC_PROFILE = {
- "schema": "isb:traffic_profile:0.1",
- "name": "fixed",
- "description": "Fixed traffic profile to run UDP traffic",
- "traffic_profile": {
- "traffic_type": "FixedTraffic",
- "frame_rate": 100, # pps
- "flow_number": 10,
- "frame_size": 64,
- },
-}
-
-
-class TestNetworkServiceTestCase(unittest.TestCase):
-
- def setUp(self):
- self.tg__1 = {
- 'name': 'trafficgen_1.yardstick',
- 'ip': '10.10.10.11',
- 'role': 'TrafficGen',
- 'user': 'root',
- 'password': 'r00t',
- 'interfaces': {
- 'xe0': {
- 'netmask': '255.255.255.0',
- 'local_ip': '152.16.100.20',
- 'local_mac': '00:00:00:00:00:01',
- 'driver': 'i40e',
- 'vpci': '0000:07:00.0',
- 'dpdk_port_num': 0,
- },
- 'xe1': {
- 'netmask': '255.255.255.0',
- 'local_ip': '152.16.40.20',
- 'local_mac': '00:00:00:00:00:02',
- 'driver': 'i40e',
- 'vpci': '0000:07:00.1',
- 'dpdk_port_num': 1,
- },
- },
- }
-
- self.vnf__1 = {
- 'name': 'vnf.yardstick',
- 'ip': '10.10.10.12',
- 'host': '10.223.197.164',
- 'role': 'vnf',
- 'user': 'root',
- 'password': 'r00t',
- 'interfaces': {
- 'xe0': {
- 'netmask': '255.255.255.0',
- 'local_ip': '152.16.100.19',
- 'local_mac': '00:00:00:00:00:03',
- 'driver': 'i40e',
- 'vpci': '0000:07:00.0',
- 'dpdk_port_num': 0,
- },
- 'xe1': {
- 'netmask': '255.255.255.0',
- 'local_ip': '152.16.40.19',
- 'local_mac': '00:00:00:00:00:04',
- 'driver': 'i40e',
- 'vpci': '0000:07:00.1',
- 'dpdk_port_num': 1,
- },
- },
- 'routing_table': [
- {
- 'netmask': '255.255.255.0',
- 'gateway': '152.16.100.20',
- 'network': '152.16.100.20',
- 'if': 'xe0',
- },
- {
- 'netmask': '255.255.255.0',
- 'gateway': '152.16.40.20',
- 'network': '152.16.40.20',
- 'if': 'xe1',
- },
- ],
- 'nd_route_tbl': [
- {
- 'netmask': '112',
- 'gateway': '0064:ff9b:0:0:0:0:9810:6414',
- 'network': '0064:ff9b:0:0:0:0:9810:6414',
- 'if': 'xe0',
- },
- {
- 'netmask': '112',
- 'gateway': '0064:ff9b:0:0:0:0:9810:2814',
- 'network': '0064:ff9b:0:0:0:0:9810:2814',
- 'if': 'xe1',
- },
- ],
- }
-
- self.context_cfg = {
- 'nodes': {
- 'tg__1': self.tg__1,
- 'vnf__1': self.vnf__1,
- },
- 'networks': {
- GenericVNF.UPLINK: {
- 'vld_id': GenericVNF.UPLINK,
- },
- GenericVNF.DOWNLINK: {
- 'vld_id': GenericVNF.DOWNLINK,
- },
- },
- }
-
- self.vld0 = {
- 'vnfd-connection-point-ref': [
- {
- 'vnfd-connection-point-ref': 'xe0',
- 'member-vnf-index-ref': '1',
- 'vnfd-id-ref': 'trexgen'
- },
- {
- 'vnfd-connection-point-ref': 'xe0',
- 'member-vnf-index-ref': '2',
- 'vnfd-id-ref': 'trexgen'
- }
- ],
- 'type': 'ELAN',
- 'id': GenericVNF.UPLINK,
- 'name': 'tg__1 to vnf__1 link 1'
- }
-
- self.vld1 = {
- 'vnfd-connection-point-ref': [
- {
- 'vnfd-connection-point-ref': 'xe1',
- 'member-vnf-index-ref': '1',
- 'vnfd-id-ref': 'trexgen'
- },
- {
- 'vnfd-connection-point-ref': 'xe1',
- 'member-vnf-index-ref': '2',
- 'vnfd-id-ref': 'trexgen'
- }
- ],
- 'type': 'ELAN',
- 'id': GenericVNF.DOWNLINK,
- 'name': 'vnf__1 to tg__1 link 2'
- }
-
- self.topology = {
- 'id': 'trex-tg-topology',
- 'short-name': 'trex-tg-topology',
- 'name': 'trex-tg-topology',
- 'description': 'trex-tg-topology',
- 'constituent-vnfd': [
- {
- 'member-vnf-index': '1',
- 'VNF model': 'tg_trex_tpl.yaml',
- 'vnfd-id-ref': 'tg__1',
- },
- {
- 'member-vnf-index': '2',
- 'VNF model': 'tg_trex_tpl.yaml',
- 'vnfd-id-ref': 'vnf__1',
- },
- ],
- 'vld': [self.vld0, self.vld1],
- }
-
- self.scenario_cfg = {
- 'task_path': "",
- "topology": self._get_file_abspath("vpe_vnf_topology.yaml"),
- 'task_id': 'a70bdf4a-8e67-47a3-9dc1-273c14506eb7',
- 'tc': 'tc_ipv4_1Mflow_64B_packetsize',
- 'traffic_profile': 'ipv4_throughput_vpe.yaml',
- 'type': 'ISB',
- 'tc_options': {
- 'rfc2544': {
- 'allowed_drop_rate': '0.8 - 1',
- },
- },
- 'options': {
- 'framesize': {'64B': 100}
- },
- 'runner': {
- 'object': 'NetworkServiceTestCase',
- 'interval': 35,
- 'output_filename': 'yardstick.out',
- 'runner_id': 74476,
- 'duration': 400,
- 'type': 'Duration',
- },
- 'traffic_options': {
- 'flow': 'ipv4_1flow_Packets_vpe.yaml',
- 'imix': 'imix_voice.yaml'
- },
- 'nodes': {
- 'tg__2': 'trafficgen_2.yardstick',
- 'tg__1': 'trafficgen_1.yardstick',
- 'vnf__1': 'vnf.yardstick',
- },
- }
-
- self.s = NetworkServiceTestCase(self.scenario_cfg, self.context_cfg)
-
- def _get_file_abspath(self, filename):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- file_path = os.path.join(curr_path, filename)
- return file_path
-
- def test_ssh_manager(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- 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():
- with SshManager(node_dict) as conn:
- self.assertIsNotNone(conn)
-
- def test___init__(self):
- assert self.topology
-
- def test__get_ip_flow_range_string(self):
- 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'))
-
- def test__get_ip_flow_range(self):
- 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({"tg__1": 'xe0'}))
-
- @mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.ipaddress')
- def test__get_ip_flow_range_no_node_data(self, mock_ipaddress):
- scenario_cfg = deepcopy(self.scenario_cfg)
- scenario_cfg["traffic_options"]["flow"] = \
- self._get_file_abspath("ipv4_1flow_Packets_vpe.yaml")
-
- mock_ipaddress.ip_network.return_value = ipaddr = mock.Mock()
- ipaddr.hosts.return_value = []
-
- expected = '0.0.0.0'
- result = self.s._get_ip_flow_range({"tg__2": 'xe0'})
- self.assertEqual(result, expected)
-
- def test__get_ip_flow_range_no_nodes(self):
- expected = '0.0.0.0'
- result = self.s._get_ip_flow_range({})
- self.assertEqual(result, expected)
-
- def test___get_traffic_flow(self):
- self.scenario_cfg["traffic_options"]["flow"] = \
- self._get_file_abspath("ipv4_1flow_Packets_vpe.yaml")
- 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'],
- },
- }
- 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())
-
- def test___get_traffic_flow_error(self):
- self.scenario_cfg["traffic_options"]["flow"] = \
- "ipv4_1flow_Packets_vpe.yaml1"
- self.assertEqual({'flow': {}}, self.s._get_traffic_flow())
-
- def test_get_vnf_imp(self):
- vnfd = COMPLETE_TREX_VNFD['vnfd:vnfd-catalog']['vnfd'][0]['class-name']
- with mock.patch.dict("sys.modules", STL_MOCKS):
- self.assertIsNotNone(self.s.get_vnf_impl(vnfd))
-
- with self.assertRaises(IncorrectConfig) as raised:
- self.s.get_vnf_impl('NonExistentClass')
-
- exc_str = str(raised.exception)
- print(exc_str)
- self.assertIn('No implementation', exc_str)
- self.assertIn('found in', exc_str)
-
- def test_load_vnf_models_invalid(self):
- self.context_cfg["nodes"]['tg__1']['VNF model'] = \
- self._get_file_abspath("tg_trex_tpl.yaml")
- self.context_cfg["nodes"]['vnf__1']['VNF model'] = \
- self._get_file_abspath("tg_trex_tpl.yaml")
-
- vnf = mock.Mock(autospec=GenericVNF)
- self.s.get_vnf_impl = mock.Mock(return_value=vnf)
-
- self.assertIsNotNone(
- self.s.load_vnf_models(self.scenario_cfg, self.context_cfg))
-
- def test_load_vnf_models_no_model(self):
- vnf = mock.Mock(autospec=GenericVNF)
- self.s.get_vnf_impl = mock.Mock(return_value=vnf)
-
- self.assertIsNotNone(
- self.s.load_vnf_models(self.scenario_cfg, self.context_cfg))
-
- def test_map_topology_to_infrastructure(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, SYS_CLASS_NET + IP_ADDR_SHOW, ""))
- ssh.from_node.return_value = ssh_mock
- 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'])
-
- def test_map_topology_to_infrastructure_insufficient_nodes(self):
- del self.context_cfg['nodes']['vnf__1']
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(1, SYS_CLASS_NET + IP_ADDR_SHOW, ""))
- ssh.from_node.return_value = ssh_mock
-
- with self.assertRaises(IncorrectConfig):
- self.s.map_topology_to_infrastructure()
-
- def test_map_topology_to_infrastructure_config_invalid(self):
- cfg = dict(self.context_cfg)
- del cfg['nodes']['vnf__1']['interfaces']['xe0']['local_mac']
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, SYS_CLASS_NET + IP_ADDR_SHOW, ""))
- ssh.from_node.return_value = ssh_mock
-
- with self.assertRaises(IncorrectConfig):
- self.s.map_topology_to_infrastructure()
-
- def test__resolve_topology_invalid_config(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, SYS_CLASS_NET + IP_ADDR_SHOW, ""))
- ssh.from_node.return_value = ssh_mock
-
- # purge an important key from the data structure
- for interface in self.tg__1['interfaces'].values():
- del interface['local_mac']
-
- with mock.patch(
- "yardstick.benchmark.scenarios.networking.vnf_generic.LOG") as mock_log:
- with self.assertRaises(IncorrectConfig) as raised:
- self.s._resolve_topology()
-
- self.assertIn('not found', str(raised.exception))
-
- # restore local_mac
- for index, interface in enumerate(self.tg__1['interfaces'].values()):
- interface['local_mac'] = '00:00:00:00:00:{:2x}'.format(index)
-
- # make a connection point ref with 3 points
- self.s.topology["vld"][0]['vnfd-connection-point-ref'].append(
- self.s.topology["vld"][0]['vnfd-connection-point-ref'][0])
-
- with mock.patch(
- "yardstick.benchmark.scenarios.networking.vnf_generic.LOG") as mock_log:
- with self.assertRaises(IncorrectConfig) as raised:
- self.s._resolve_topology()
-
- self.assertIn('wrong endpoint count', str(raised.exception))
-
- # make a connection point ref with 1 point
- self.s.topology["vld"][0]['vnfd-connection-point-ref'] = \
- self.s.topology["vld"][0]['vnfd-connection-point-ref'][:1]
-
- with mock.patch(
- "yardstick.benchmark.scenarios.networking.vnf_generic.LOG") as mock_log:
- with self.assertRaises(IncorrectConfig) as raised:
- self.s._resolve_topology()
-
- self.assertIn('wrong endpoint count', str(raised.exception))
-
- def test_run(self):
- tgen = mock.Mock(autospec=GenericTrafficGen)
- tgen.traffic_finished = True
- verified_dict = {"verified": True}
- tgen.verify_traffic = lambda x: verified_dict
- tgen.name = "tgen__1"
- vnf = mock.Mock(autospec=GenericVNF)
- vnf.runs_traffic = False
- self.s.vnfs = [tgen, vnf]
- self.s.traffic_profile = mock.Mock()
- self.s.collector = mock.Mock(autospec=Collector)
- self.s.collector.get_kpi = \
- mock.Mock(return_value={tgen.name: verified_dict})
- result = {}
- self.s.run(result)
- self.assertDictEqual(result, {tgen.name: verified_dict})
-
- def test_setup(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, SYS_CLASS_NET + IP_ADDR_SHOW, ""))
- ssh.from_node.return_value = ssh_mock
-
- tgen = mock.Mock(autospec=GenericTrafficGen)
- tgen.traffic_finished = True
- verified_dict = {"verified": True}
- tgen.verify_traffic = lambda x: verified_dict
- tgen.terminate = mock.Mock(return_value=True)
- tgen.name = "tgen__1"
- vnf = mock.Mock(autospec=GenericVNF)
- vnf.runs_traffic = False
- vnf.terminate = mock.Mock(return_value=True)
- self.s.vnfs = [tgen, vnf]
- self.s.traffic_profile = mock.Mock()
- self.s.collector = mock.Mock(autospec=Collector)
- self.s.collector.get_kpi = \
- mock.Mock(return_value={tgen.name: verified_dict})
- self.s.map_topology_to_infrastructure = mock.Mock(return_value=0)
- self.s.load_vnf_models = mock.Mock(return_value=self.s.vnfs)
- self.s._fill_traffic_profile = \
- mock.Mock(return_value=TRAFFIC_PROFILE)
- self.assertEqual(None, self.s.setup())
-
- def test_setup_exception(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, SYS_CLASS_NET + IP_ADDR_SHOW, ""))
- ssh.from_node.return_value = ssh_mock
-
- tgen = mock.Mock(autospec=GenericTrafficGen)
- tgen.traffic_finished = True
- verified_dict = {"verified": True}
- tgen.verify_traffic = lambda x: verified_dict
- tgen.terminate = mock.Mock(return_value=True)
- tgen.name = "tgen__1"
- vnf = mock.Mock(autospec=GenericVNF)
- vnf.runs_traffic = False
- 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()
- self.s.collector = mock.Mock(autospec=Collector)
- self.s.collector.get_kpi = \
- mock.Mock(return_value={tgen.name: verified_dict})
- self.s.map_topology_to_infrastructure = mock.Mock(return_value=0)
- self.s.load_vnf_models = mock.Mock(return_value=self.s.vnfs)
- self.s._fill_traffic_profile = \
- mock.Mock(return_value=TRAFFIC_PROFILE)
- with self.assertRaises(RuntimeError):
- self.s.setup()
-
- def test__get_traffic_profile(self):
- self.scenario_cfg["traffic_profile"] = \
- self._get_file_abspath("ipv4_throughput_vpe.yaml")
- self.assertIsNotNone(self.s._get_traffic_profile())
-
- def test__get_traffic_profile_exception(self):
- with mock.patch.dict(self.scenario_cfg, {'traffic_profile': ''}):
- with self.assertRaises(IOError):
- self.s._get_traffic_profile()
-
- 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())
-
- def test__fill_traffic_profile(self):
- with mock.patch.dict("sys.modules", STL_MOCKS):
- self.scenario_cfg["traffic_profile"] = \
- self._get_file_abspath("ipv4_throughput_vpe.yaml")
- self.scenario_cfg["traffic_options"]["flow"] = \
- self._get_file_abspath("ipv4_1flow_Packets_vpe.yaml")
- self.scenario_cfg["traffic_options"]["imix"] = \
- self._get_file_abspath("imix_voice.yaml")
- self.assertIsNotNone(self.s._fill_traffic_profile())
-
- def test_teardown(self):
- vnf = mock.Mock(autospec=GenericVNF)
- vnf.terminate = mock.Mock(return_value=True)
- vnf.name = str(vnf)
- self.s.vnfs = [vnf]
- self.s.traffic_profile = mock.Mock()
- self.s.collector = mock.Mock(autospec=Collector)
- self.s.collector.stop = \
- mock.Mock(return_value=True)
- self.assertIsNone(self.s.teardown())
-
- def test_teardown_exception(self):
- vnf = mock.Mock(autospec=GenericVNF)
- vnf.terminate = mock.Mock(side_effect=RuntimeError("error duing terminate"))
- vnf.name = str(vnf)
- self.s.vnfs = [vnf]
- self.s.traffic_profile = mock.Mock()
- self.s.collector = mock.Mock(autospec=Collector)
- self.s.collector.stop = \
- mock.Mock(return_value=True)
- with self.assertRaises(RuntimeError):
- self.s.teardown()
-
- SAMPLE_NETDEVS = {
- 'enp11s0': {
- 'address': '0a:de:ad:be:ef:f5',
- 'device': '0x1533',
- 'driver': 'igb',
- 'ifindex': '2',
- 'interface_name': 'enp11s0',
- 'operstate': 'down',
- 'pci_bus_id': '0000:0b:00.0',
- 'subsystem_device': '0x1533',
- 'subsystem_vendor': '0x15d9',
- 'vendor': '0x8086'
- },
- 'lan': {
- 'address': '0a:de:ad:be:ef:f4',
- 'device': '0x153a',
- 'driver': 'e1000e',
- 'ifindex': '3',
- 'interface_name': 'lan',
- 'operstate': 'up',
- 'pci_bus_id': '0000:00:19.0',
- 'subsystem_device': '0x153a',
- 'subsystem_vendor': '0x15d9',
- 'vendor': '0x8086'
- }
- }
-
- SAMPLE_VM_NETDEVS = {
- 'eth1': {
- 'address': 'fa:de:ad:be:ef:5b',
- 'device': '0x0001',
- 'driver': 'virtio_net',
- 'ifindex': '3',
- 'interface_name': 'eth1',
- 'operstate': 'down',
- 'pci_bus_id': '0000:00:04.0',
- 'vendor': '0x1af4'
- }
- }
-
- def test_parse_netdev_info(self):
- output = """\
-/sys/devices/pci0000:00/0000:00:1c.3/0000:0b:00.0/net/enp11s0/ifindex:2
-/sys/devices/pci0000:00/0000:00:1c.3/0000:0b:00.0/net/enp11s0/address:0a:de:ad:be:ef:f5
-/sys/devices/pci0000:00/0000:00:1c.3/0000:0b:00.0/net/enp11s0/operstate:down
-/sys/devices/pci0000:00/0000:00:1c.3/0000:0b:00.0/net/enp11s0/device/vendor:0x8086
-/sys/devices/pci0000:00/0000:00:1c.3/0000:0b:00.0/net/enp11s0/device/device:0x1533
-/sys/devices/pci0000:00/0000:00:1c.3/0000:0b:00.0/net/enp11s0/device/subsystem_vendor:0x15d9
-/sys/devices/pci0000:00/0000:00:1c.3/0000:0b:00.0/net/enp11s0/device/subsystem_device:0x1533
-/sys/devices/pci0000:00/0000:00:1c.3/0000:0b:00.0/net/enp11s0/driver:igb
-/sys/devices/pci0000:00/0000:00:1c.3/0000:0b:00.0/net/enp11s0/pci_bus_id:0000:0b:00.0
-/sys/devices/pci0000:00/0000:00:19.0/net/lan/ifindex:3
-/sys/devices/pci0000:00/0000:00:19.0/net/lan/address:0a:de:ad:be:ef:f4
-/sys/devices/pci0000:00/0000:00:19.0/net/lan/operstate:up
-/sys/devices/pci0000:00/0000:00:19.0/net/lan/device/vendor:0x8086
-/sys/devices/pci0000:00/0000:00:19.0/net/lan/device/device:0x153a
-/sys/devices/pci0000:00/0000:00:19.0/net/lan/device/subsystem_vendor:0x15d9
-/sys/devices/pci0000:00/0000:00:19.0/net/lan/device/subsystem_device:0x153a
-/sys/devices/pci0000:00/0000:00:19.0/net/lan/driver:e1000e
-/sys/devices/pci0000:00/0000:00:19.0/net/lan/pci_bus_id:0000:00:19.0
-"""
- res = NetworkServiceTestCase.parse_netdev_info(output)
- assert res == self.SAMPLE_NETDEVS
-
- def test_parse_netdev_info_virtio(self):
- output = """\
-/sys/devices/pci0000:00/0000:00:04.0/virtio1/net/eth1/ifindex:3
-/sys/devices/pci0000:00/0000:00:04.0/virtio1/net/eth1/address:fa:de:ad:be:ef:5b
-/sys/devices/pci0000:00/0000:00:04.0/virtio1/net/eth1/operstate:down
-/sys/devices/pci0000:00/0000:00:04.0/virtio1/net/eth1/device/vendor:0x1af4
-/sys/devices/pci0000:00/0000:00:04.0/virtio1/net/eth1/device/device:0x0001
-/sys/devices/pci0000:00/0000:00:04.0/virtio1/net/eth1/driver:virtio_net
-"""
- res = NetworkServiceTestCase.parse_netdev_info(output)
- assert res == self.SAMPLE_VM_NETDEVS
-
- def test_probe_missing_values(self):
- netdevs = self.SAMPLE_NETDEVS.copy()
- network = {'local_mac': '0a:de:ad:be:ef:f5'}
- NetworkServiceTestCase._probe_missing_values(netdevs, network)
- assert network['vpci'] == '0000:0b:00.0'
-
- network = {'local_mac': '0a:de:ad:be:ef:f4'}
- NetworkServiceTestCase._probe_missing_values(netdevs, network)
- assert network['vpci'] == '0000:00:19.0'
-
- def test_open_relative_path(self):
- mock_open = mock.mock_open()
- mock_open_result = mock_open()
- mock_open_call_count = 1 # initial call to get result
-
- module_name = \
- 'yardstick.benchmark.scenarios.networking.vnf_generic.open'
-
- # test
- with mock.patch(module_name, mock_open, create=True):
- 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)
- self.assertIn('foo', mock_open.call_args_list[-1][0][0])
- self.assertNotIn('bar', mock_open.call_args_list[-1][0][0])
-
- def open_effect(*args, **kwargs):
- if kwargs.get('name', args[0]) == os.path.join('bar', 'foo'):
- return mock_open_result
- raise IOError(errno.ENOENT, 'not found')
-
- mock_open.side_effect = open_effect
- 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)
- self.assertIn('foo', mock_open.call_args_list[-1][0][0])
- self.assertIn('bar', mock_open.call_args_list[-1][0][0])
-
- # test an IOError of type ENOENT
- mock_open.side_effect = IOError(errno.ENOENT, 'not found')
- with self.assertRaises(IOError):
- # the second call still raises
- open_relative_file('foo', 'bar')
-
- mock_open_call_count += 2 # two more calls expected
- self.assertEqual(mock_open.call_count, mock_open_call_count)
- self.assertIn('foo', mock_open.call_args_list[-1][0][0])
- self.assertIn('bar', mock_open.call_args_list[-1][0][0])
-
- # test an IOError other than ENOENT
- mock_open.side_effect = IOError(errno.EBUSY, 'busy')
- with self.assertRaises(IOError):
- open_relative_file('foo', 'bar')
-
- mock_open_call_count += 1 # one more call expected
- self.assertEqual(mock_open.call_count, mock_open_call_count)
diff --git a/tests/unit/benchmark/scenarios/networking/test_vsperf.py b/tests/unit/benchmark/scenarios/networking/test_vsperf.py
deleted file mode 100644
index be8ac55d0..000000000
--- a/tests/unit/benchmark/scenarios/networking/test_vsperf.py
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2016 Intel Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Unittest for yardstick.benchmark.scenarios.networking.vsperf.Vsperf
-
-from __future__ import absolute_import
-try:
- from unittest import mock
-except ImportError:
- import mock
-import unittest
-
-from yardstick.benchmark.scenarios.networking import vsperf
-
-
-@mock.patch('yardstick.benchmark.scenarios.networking.vsperf.subprocess')
-@mock.patch('yardstick.benchmark.scenarios.networking.vsperf.ssh')
-class VsperfTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- "host": {
- "ip": "10.229.47.137",
- "user": "ubuntu",
- "password": "ubuntu",
- },
- }
- self.args = {
- 'options': {
- 'testname': 'p2p_rfc2544_continuous',
- 'traffic_type': 'continuous',
- 'frame_size': '64',
- 'bidirectional': 'True',
- 'iload': 100,
- 'trafficgen_port1': 'eth1',
- 'trafficgen_port2': 'eth3',
- 'external_bridge': 'br-ex',
- 'conf_file': 'vsperf-yardstick.conf',
- 'setup_script': 'setup_yardstick.sh',
- 'test_params': 'TRAFFICGEN_DURATION=30;',
- },
- 'sla': {
- 'metrics': 'throughput_rx_fps',
- 'throughput_rx_fps': 500000,
- 'action': 'monitor',
- }
- }
-
- def test_vsperf_setup(self, mock_ssh, mock_subprocess):
- p = vsperf.Vsperf(self.args, self.ctx)
- 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)
-
- def test_vsperf_teardown(self, mock_ssh, mock_subprocess):
- p = vsperf.Vsperf(self.args, self.ctx)
-
- # setup() specific mocks
- 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.teardown()
- self.assertFalse(p.setup_done)
-
- def test_vsperf_run_ok(self, mock_ssh, mock_subprocess):
- p = vsperf.Vsperf(self.args, self.ctx)
-
- # setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- mock_subprocess.call().execute.return_value = None
-
- # run() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- 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_run_falied_vsperf_execution(self, mock_ssh,
- mock_subprocess):
- p = vsperf.Vsperf(self.args, self.ctx)
-
- # setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- mock_subprocess.call().execute.return_value = None
-
- # run() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
-
- result = {}
- self.assertRaises(RuntimeError, p.run, result)
-
- def test_vsperf_run_falied_csv_report(self, mock_ssh, mock_subprocess):
- p = vsperf.Vsperf(self.args, self.ctx)
-
- # setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- mock_subprocess.call().execute.return_value = None
-
- # run() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- 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/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/scenarios/networking/tg_trex_tpl.yaml b/tests/unit/benchmark/scenarios/networking/tg_trex_tpl.yaml
deleted file mode 100644
index b1641836b..000000000
--- a/tests/unit/benchmark/scenarios/networking/tg_trex_tpl.yaml
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-vnfd:vnfd-catalog:
- vnfd:
- - id: TrexTrafficGen # NSPerf class mapping
- name: trexgen
- short-name: trexgen
- description: TRex stateless traffic generator for tests
- vm-flavor:
- vcpu-count: '4'
- memory-mb: '4096'
- mgmt-interface:
- vdu-id: trexgen-baremetal
- user: '{{user}}' # Value filled by vnfdgen
- password: '{{password}}' # Value filled by vnfdgen
- ip: '{{ip}}' # Value filled by vnfdgen
- connection-point:
- - name: xe0
- type: VPORT
- - name: xe1
- type: VPORT
- vdu:
- - id: trexgen-baremetal
- name: trexgen-baremetal
- description: TRex stateless traffic generator for tests
- external-interface:
- - name: xe0
- virtual-interface:
- type: PCI-PASSTHROUGH
- # Substitution variables MUST be quoted. Otherwise Python can misinterpet them.
- vpci: '{{ interfaces.xe0.vpci }}' # Value filled by vnfdgen
- local_ip: '{{ interfaces.xe0.local_ip }}' # Value filled by vnfdgen
- driver: '{{ interfaces.xe0.driver}}' # Value filled by vnfdgen
- dst_ip: '{{ interfaces.xe0.dst_ip }}' # Value filled by vnfdgen
- local_mac: '{{ interfaces.xe0.local_mac }}' # Value filled by vnfdgen
- dst_mac: '{{ interfaces.xe0.dst_mac }}' # Value filled by vnfdgen
- vld_id: '{{ interfaces.xe0.vld_id }}' # Value filled by vnfdgen
- bandwidth: 10 Gbps
- vnfd-connection-point-ref: xe0
- - name: xe1
- virtual-interface:
- type: PCI-PASSTHROUGH
- vpci: '{{ interfaces.xe1.vpci }}' # Value filled by vnfdgen
- local_ip: '{{ interfaces.xe1.local_ip }}' # Value filled by vnfdgen
- driver: '{{ interfaces.xe1.driver}}' # Value filled by vnfdgen
- dst_ip: '{{ interfaces.xe1.dst_ip }}' # Value filled by vnfdgen
- local_mac: '{{ interfaces.xe1.local_mac }}' # Value filled by vnfdgen
- dst_mac: '{{ interfaces.xe1.dst_mac }}' # Value filled by vnfdgen
- vld_id: '{{ interfaces.xe1.vld_id }}' # Value filled by vnfdgen
- bandwidth: 10 Gbps
- vnfd-connection-point-ref: xe1
-
- benchmark:
- kpi:
- - rx_throughput_fps
- - tx_throughput_fps
- - tx_throughput_mbps
- - rx_throughput_mbps
- - tx_throughput_pc_linerate
- - rx_throughput_pc_linerate
- - min_latency
- - max_latency
- - avg_latency
diff --git a/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml b/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml
deleted file mode 100644
index 1ac6c1f89..000000000
--- a/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-nsd:nsd-catalog:
- nsd:
- - id: VPE
- name: VPE
- short-name: VPE
- description: scenario with VPE,L3fwd and VNF
- constituent-vnfd:
- - member-vnf-index: '1'
- vnfd-id-ref: tg__1
- VNF model: ../../vnf_descriptors/tg_rfc2544_tpl.yaml #tg_vpe_upstream.yaml #VPE VNF
- - member-vnf-index: '2'
- vnfd-id-ref: vnf__1
- VNF model: ../../vnf_descriptors/vpe_vnf.yaml #tg_l3fwd.yaml #tg_trex_tpl.yaml #TREX
-
- vld:
- - id: uplink
- name: tg__1 to vnf__1 link 1
- type: ELAN
- vnfd-connection-point-ref:
- - member-vnf-index-ref: '1'
- vnfd-connection-point-ref: xe0
- vnfd-id-ref: tg__1 #TREX
- - member-vnf-index-ref: '2'
- vnfd-connection-point-ref: xe0
- vnfd-id-ref: vnf__1 #VNF
-
- - id: downlink
- name: vnf__1 to tg__1 link 2
- type: ELAN
- vnfd-connection-point-ref:
- - member-vnf-index-ref: '2'
- vnfd-connection-point-ref: xe1
- vnfd-id-ref: vnf__1 #L3fwd
- - member-vnf-index-ref: '1'
- vnfd-connection-point-ref: xe1
- vnfd-id-ref: tg__1 #VPE VNF
diff --git a/tests/unit/benchmark/scenarios/parser/__init__.py b/tests/unit/benchmark/scenarios/parser/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/scenarios/parser/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/scenarios/parser/test_parser.py b/tests/unit/benchmark/scenarios/parser/test_parser.py
deleted file mode 100644
index ee2bbc07d..000000000
--- a/tests/unit/benchmark/scenarios/parser/test_parser.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and other.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-import subprocess
-
-import unittest
-import mock
-
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.parser import parser
-
-
-class ParserTestCase(unittest.TestCase):
-
- def setUp(self):
- args = {
- 'options': {'yangfile': '/root/yardstick/samples/yang.yaml',
- 'toscafile': '/root/yardstick/samples/tosca.yaml'},
- }
- self.scenario = parser.Parser(scenario_cfg=args, context_cfg={})
-
- self._mock_popen = mock.patch.object(subprocess, 'Popen')
- self.mock_popen = self._mock_popen.start()
- self._mock_call = mock.patch.object(subprocess, 'call')
- self.mock_call = self._mock_call.start()
-
- self.addCleanup(self._stop_mock)
-
- def _stop_mock(self):
- self._mock_popen.stop()
- self._mock_call.stop()
-
- def test_setup_successful(self):
-
- self.mock_call.return_value = 0
- self.scenario.setup()
- self.assertTrue(self.scenario.setup_done)
-
- def test_run_successful(self):
-
- result = {}
-
- self.mock_popen().returncode = 0
-
- expected_result = jsonutils.loads('{"yangtotosca": "success"}')
-
- self.scenario.run(result)
- self.assertEqual(result, expected_result)
-
- def test_run_fail(self):
- result = {}
-
- self.mock_popen().returncode = 1
- expected_result = jsonutils.loads('{"yangtotosca": "fail"}')
-
- self.scenario.run(result)
- self.assertEqual(result, expected_result)
-
- def test_teardown_successful(self):
-
- self.mock_call.return_value = 0
- self.scenario.teardown()
- self.assertTrue(self.scenario.teardown_done)
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/storage/__init__.py b/tests/unit/benchmark/scenarios/storage/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/unit/benchmark/scenarios/storage/__init__.py
+++ /dev/null
diff --git a/tests/unit/benchmark/scenarios/storage/fio_read_sample_output.json b/tests/unit/benchmark/scenarios/storage/fio_read_sample_output.json
deleted file mode 100644
index e9f642aba..000000000
--- a/tests/unit/benchmark/scenarios/storage/fio_read_sample_output.json
+++ /dev/null
@@ -1 +0,0 @@
-{"fioversion": "fio-2.1.3","jobs": [{"jobname": "yardstick-fio","groupid": 0,"error": 0,"read": {"io_bytes": 2166860,"bw": 36113,"iops": 9028,"runtime": 60001,"slat": {"min": 7,"max": 1807,"mean": 10.49,"stddev": 3.00},"clat": {"min": 1,"max": 16902,"mean": 97.84,"stddev": 78.16,"percentile": {"1.000000": 84,"5.000000": 86,"10.000000": 87,"20.000000": 88,"30.000000": 89,"40.000000": 90,"50.000000": 91,"60.000000": 93,"70.000000": 98,"80.000000": 103,"90.000000": 111,"95.000000": 127,"99.000000": 161,"99.500000": 177,"99.900000": 215,"99.950000": 266,"99.990000": 4128,"0.00": 0,"0.00": 0,"0.00": 0}},"lat": {"min": 86,"max": 16912,"mean": 108.70,"stddev": 78.29},"bw_min": 0,"bw_max": 38128,"bw_agg": 35816.54,"bw_mean": 35816.54,"bw_dev": 3579.16},"write": {"io_bytes": 0,"bw": 0,"iops": 0,"runtime": 0,"slat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00},"clat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00,"percentile": {"1.000000": 0,"5.000000": 0,"10.000000": 0,"20.000000": 0,"30.000000": 0,"40.000000": 0,"50.000000": 0,"60.000000": 0,"70.000000": 0,"80.000000": 0,"90.000000": 0,"95.000000": 0,"99.000000": 0,"99.500000": 0,"99.900000": 0,"99.950000": 0,"99.990000": 0,"0.00": 0,"0.00": 0,"0.00": 0}},"lat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00},"bw_min": 0,"bw_max": 0,"bw_agg": 0.00,"bw_mean": 0.00,"bw_dev": 0.00},"trim": {"io_bytes": 0,"bw": 0,"iops": 0,"runtime": 0,"slat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00},"clat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00,"percentile": {"1.000000": 0,"5.000000": 0,"10.000000": 0,"20.000000": 0,"30.000000": 0,"40.000000": 0,"50.000000": 0,"60.000000": 0,"70.000000": 0,"80.000000": 0,"90.000000": 0,"95.000000": 0,"99.000000": 0,"99.500000": 0,"99.900000": 0,"99.950000": 0,"99.990000": 0,"0.00": 0,"0.00": 0,"0.00": 0}},"lat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00},"bw_min": 0,"bw_max": 0,"bw_agg": 0.00,"bw_mean": 0.00,"bw_dev": 0.00},"usr_cpu": 4.86,"sys_cpu": 19.38,"ctx": 632024,"majf": 0,"minf": 30,"iodepth_level": {"1": 116.58,"2": 0.00,"4": 0.00,"8": 0.00,"16": 0.00,"32": 0.00,">=64": 0.00},"latency_us": {"2": 0.01,"4": 0.01,"10": 0.00,"20": 0.00,"50": 0.01,"100": 72.60,"250": 27.34,"500": 0.04,"750": 0.01,"1000": 0.01},"latency_ms": {"2": 0.01,"4": 0.01,"10": 0.01,"20": 0.01,"50": 0.00,"100": 0.00,"250": 0.00,"500": 0.00,"750": 0.00,"1000": 0.00,"2000": 0.00,">=2000": 0.00}}],"disk_util": [{"name": "vda","read_ios": 631084,"write_ios": 212,"read_merges": 0,"write_merges": 232,"read_ticks": 57300,"write_ticks": 324,"in_queue": 57400,"util": 81.55}]}
diff --git a/tests/unit/benchmark/scenarios/storage/fio_rw_sample_output.json b/tests/unit/benchmark/scenarios/storage/fio_rw_sample_output.json
deleted file mode 100644
index 4c7501818..000000000
--- a/tests/unit/benchmark/scenarios/storage/fio_rw_sample_output.json
+++ /dev/null
@@ -1 +0,0 @@
-{"jobs": [{"trim": {"io_bytes": 0, "slat": {"max": 0, "mean": 0.0, "stddev": 0.0, "min": 0}, "bw_max": 0, "bw_mean": 0.0, "iops": 0, "bw": 0, "lat": {"max": 0, "mean": 0.0, "stddev": 0.0, "min": 0}, "bw_agg": 0.0, "clat": {"max": 0, "mean": 0.0, "percentile": {"70.000000": 0, "5.000000": 0, "50.000000": 0, "99.990000": 0, "30.000000": 0, "10.000000": 0, "99.000000": 0, "0.00": 0, "90.000000": 0, "95.000000": 0, "60.000000": 0, "40.000000": 0, "20.000000": 0, "99.900000": 0, "99.950000": 0, "1.000000": 0, "99.500000": 0, "80.000000": 0}, "stddev": 0.0, "min": 0}, "runtime": 0, "bw_min": 0, "bw_dev": 0.0}, "latency_us": {"10": 0.01, "750": 0.03, "20": 0.0, "50": 0.02, "2": 0.01, "4": 0.01, "100": 0.75, "250": 88.37, "500": 10.72, "1000": 0.01}, "latency_ms": {"10": 0.01, "750": 0.0, "20": 0.01, ">=2000": 0.0, "50": 0.01, "2000": 0.0, "2": 0.07, "4": 0.01, "100": 0.0, "250": 0.01, "500": 0.0, "1000": 0.01}, "read": {"io_bytes": 839056, "slat": {"max": 1990, "mean": 18.14, "stddev": 15.4, "min": 0}, "bw_max": 10328, "bw_mean": 8721.27, "iops": 20972, "bw": 83888, "lat": {"max": 776676, "mean": 236.8, "stddev": 4668.12, "min": 45}, "bw_agg": 8721.27, "clat": {"max": 776663, "mean": 217.79, "percentile": {"70.000000": 199, "5.000000": 119, "50.000000": 175, "99.990000": 15168, "30.000000": 155, "10.000000": 131, "99.000000": 342, "0.00": 0, "90.000000": 247, "95.000000": 278, "60.000000": 185, "40.000000": 165, "20.000000": 145, "99.900000": 820, "99.950000": 1272, "1.000000": 96, "99.500000": 370, "80.000000": 217}, "stddev": 4667.79, "min": 0}, "runtime": 10002, "bw_min": 4, "bw_dev": 2178.08}, "majf": 0, "ctx": 490590, "minf": 87, "jobname": "yardstick-fio", "write": {"io_bytes": 841992, "slat": {"max": 2594, "mean": 19.78, "stddev": 16.25, "min": 0}, "bw_max": 10472, "bw_mean": 8464.0, "iops": 21045, "bw": 84182, "lat": {"max": 776709, "mean": 233.55, "stddev": 3115.46, "min": 64}, "bw_agg": 8464.0, "clat": {"max": 776685, "mean": 212.87, "percentile": {"70.000000": 211, "5.000000": 135, "50.000000": 187, "99.990000": 3536, "30.000000": 169, "10.000000": 145, "99.000000": 358, "0.00": 0, "90.000000": 258, "95.000000": 290, "60.000000": 197, "40.000000": 177, "20.000000": 159, "99.900000": 756, "99.950000": 1288, "1.000000": 114, "99.500000": 382, "80.000000": 229}, "stddev": 3115.23, "min": 0}, "runtime": 10002, "bw_min": 4, "bw_dev": 2584.23}, "iodepth_level": {"16": 0.0, "32": 0.0, "1": 111.92, "2": 0.0, "4": 0.0, ">=64": 0.0, "8": 0.0}, "usr_cp": 2.87, "error": 0, "sys_cp": 12.37, "groupid": 0}], "fio version": "fio-2.1.3", "disk_util": [{"aggr_write_ticks": 42020, "read_merges": 0, "name": "dm-0", "write_ios": 233547, "aggr_write_ios": 235129, "aggr_read_ticks": 42576, "read_ios": 233492, "util": 97.22, "read_ticks": 42096, "aggr_write_merge": 0, "write_merges": 0, "aggr_in_queue": 84524, "aggr_read_ios": 235224, "aggr_util": 96.96, "aggr_read_merges": 0, "in_queue": 83732, "write_ticks": 41468}, {"read_merges": 0, "name": "vda", "write_ios": 235129, "read_ios": 235224, "util": 96.96, "read_ticks": 42576, "write_merges": 0, "in_queue": 84524, "write_ticks": 42020}]}
diff --git a/tests/unit/benchmark/scenarios/storage/fio_write_sample_output.json b/tests/unit/benchmark/scenarios/storage/fio_write_sample_output.json
deleted file mode 100644
index 7c760e8bc..000000000
--- a/tests/unit/benchmark/scenarios/storage/fio_write_sample_output.json
+++ /dev/null
@@ -1 +0,0 @@
-{"fioversion": "fio-2.1.3","jobs": [{"jobname": "yardstick-fio","groupid": 0,"error": 0,"read": {"io_bytes": 0,"bw": 0,"iops": 0,"runtime": 0,"slat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00},"clat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00,"percentile": {"1.000000": 0,"5.000000": 0,"10.000000": 0,"20.000000": 0,"30.000000": 0,"40.000000": 0,"50.000000": 0,"60.000000": 0,"70.000000": 0,"80.000000": 0,"90.000000": 0,"95.000000": 0,"99.000000": 0,"99.500000": 0,"99.900000": 0,"99.950000": 0,"99.990000": 0,"0.00": 0,"0.00": 0,"0.00": 0}},"lat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00},"bw_min": 0,"bw_max": 0,"bw_agg": 0.00,"bw_mean": 0.00,"bw_dev": 0.00},"write": {"io_bytes": 2106508,"bw": 35107,"iops": 8776,"runtime": 60001,"slat": {"min": 8,"max": 5166,"mean": 11.83,"stddev": 7.05},"clat": {"min": 1,"max": 23472,"mean": 99.54,"stddev": 44.23,"percentile": {"1.000000": 85,"5.000000": 87,"10.000000": 88,"20.000000": 89,"30.000000": 90,"40.000000": 91,"50.000000": 93,"60.000000": 99,"70.000000": 104,"80.000000": 107,"90.000000": 113,"95.000000": 127,"99.000000": 161,"99.500000": 179,"99.900000": 231,"99.950000": 286,"99.990000": 628,"0.00": 0,"0.00": 0,"0.00": 0}},"lat": {"min": 87,"max": 23486,"mean": 111.74,"stddev": 45.61},"bw_min": 0,"bw_max": 37288,"bw_agg": 34839.53,"bw_mean": 34839.53,"bw_dev": 3387.37},"trim": {"io_bytes": 0,"bw": 0,"iops": 0,"runtime": 0,"slat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00},"clat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00,"percentile": {"1.000000": 0,"5.000000": 0,"10.000000": 0,"20.000000": 0,"30.000000": 0,"40.000000": 0,"50.000000": 0,"60.000000": 0,"70.000000": 0,"80.000000": 0,"90.000000": 0,"95.000000": 0,"99.000000": 0,"99.500000": 0,"99.900000": 0,"99.950000": 0,"99.990000": 0,"0.00": 0,"0.00": 0,"0.00": 0}},"lat": {"min": 0,"max": 0,"mean": 0.00,"stddev": 0.00},"bw_min": 0,"bw_max": 0,"bw_agg": 0.00,"bw_mean": 0.00,"bw_dev": 0.00},"usr_cpu": 5.25,"sys_cpu": 19.72,"ctx": 616160,"majf": 0,"minf": 27,"iodepth_level": {"1": 116.90,"2": 0.00,"4": 0.00,"8": 0.00,"16": 0.00,"32": 0.00,">=64": 0.00},"latency_us": {"2": 0.01,"4": 0.01,"10": 0.00,"20": 0.00,"50": 0.01,"100": 60.74,"250": 39.18,"500": 0.06,"750": 0.01,"1000": 0.01},"latency_ms": {"2": 0.01,"4": 0.01,"10": 0.01,"20": 0.00,"50": 0.01,"100": 0.00,"250": 0.00,"500": 0.00,"750": 0.00,"1000": 0.00,"2000": 0.00,">=2000": 0.00}}],"disk_util": [{"name": "vda","read_ios": 0,"write_ios": 615418,"read_merges": 0,"write_merges": 231,"read_ticks": 0,"write_ticks": 58284,"in_queue": 58024,"util": 82.45}]}
diff --git a/tests/unit/benchmark/scenarios/storage/test_bonnie.py b/tests/unit/benchmark/scenarios/storage/test_bonnie.py
deleted file mode 100644
index b3524e9a7..000000000
--- a/tests/unit/benchmark/scenarios/storage/test_bonnie.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.storage.bonnie.Bonnie
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-
-from yardstick.common import utils
-from yardstick.benchmark.scenarios.storage import bonnie
-
-
-class BonnieTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'root',
- 'key_filename': "mykey.key"
- }
- }
-
- self.result = {}
-
- @mock.patch('yardstick.benchmark.scenarios.storage.bonnie.ssh')
- def test_bonnie_successful_setup(self, mock_ssh):
-
- options = {
- "file_size": "1024",
- "ram_size": "512",
- "test_dir": "/tmp",
- "concurrency": "1",
- "test_user": "root"
- }
- args = {"options": options}
- b = bonnie.Bonnie(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
- b.setup()
- self.assertIsNotNone(b.client)
- self.assertTrue(b.setup_done, True)
-
- @mock.patch('yardstick.benchmark.scenarios.storage.bonnie.ssh')
- def test_bonnie_unsuccessful_script_error(self, mock_ssh):
- options = {
- "file_size": "1024",
- "ram_size": "512",
- "test_dir": "/tmp",
- "concurrency": "1",
- "test_user": "root"
- }
- args = {"options": options}
- b = bonnie.Bonnie(args, self.ctx)
-
- 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/tests/unit/benchmark/scenarios/storage/test_fio.py
deleted file mode 100644
index 0cffea224..000000000
--- a/tests/unit/benchmark/scenarios/storage/test_fio.py
+++ /dev/null
@@ -1,273 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2015 Ericsson AB and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.storage.fio.Fio
-
-from __future__ import absolute_import
-
-import os
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.storage import fio
-
-
-@mock.patch('yardstick.benchmark.scenarios.storage.fio.ssh')
-class FioTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': 'mykey.key'
- }
- }
- self.sample_output = {
- 'read': 'fio_read_sample_output.json',
- 'write': 'fio_write_sample_output.json',
- 'rw': 'fio_rw_sample_output.json'
- }
-
- def test_fio_successful_setup(self, mock_ssh):
-
- options = {
- 'filename': '/home/ubuntu/data.raw',
- 'bs': '4k',
- 'rw': 'rw',
- 'ramp_time': 10
- }
- args = {'options': options}
- p = fio.Fio(args, self.ctx)
- p.setup()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- def test_fio_job_file_successful_setup(self, mock_ssh):
-
- options = {
- 'job_file': 'job_file.ini',
- 'directory': '/FIO_Test'
- }
- args = {'options': options}
- p = fio.Fio(args, self.ctx)
- p.setup()
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- self.assertIsNotNone(p.client)
- self.assertTrue(p.setup_done)
-
- def test_fio_successful_no_sla(self, mock_ssh):
-
- options = {
- 'filename': '/home/ubuntu/data.raw',
- 'bs': '4k',
- 'rw': 'rw',
- 'ramp_time': 10
- }
- args = {'options': options}
- p = fio.Fio(args, self.ctx)
- result = {}
-
- p.client = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.sample_output['rw'])
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
-
- expected_result = '{"read_bw": 83888, "read_iops": 20972,' \
- '"read_lat": 236.8, "write_bw": 84182, "write_iops": 21045,'\
- '"write_lat": 233.55}'
- expected_result = jsonutils.loads(expected_result)
- self.assertEqual(result, expected_result)
-
- def test_fio_successful_read_no_sla(self, mock_ssh):
-
- options = {
- 'filename': '/home/ubuntu/data.raw',
- 'bs': '4k',
- 'rw': "read",
- 'ramp_time': 10
- }
- args = {'options': options}
- p = fio.Fio(args, self.ctx)
- result = {}
-
- p.client = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.sample_output['read'])
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
-
- expected_result = '{"read_bw": 36113, "read_iops": 9028,' \
- '"read_lat": 108.7}'
- expected_result = jsonutils.loads(expected_result)
- self.assertEqual(result, expected_result)
-
- def test_fio_successful_write_no_sla(self, mock_ssh):
-
- options = {
- 'filename': '/home/ubuntu/data.raw',
- 'bs': '4k',
- 'rw': 'write',
- 'ramp_time': 10
- }
- args = {'options': options}
- p = fio.Fio(args, self.ctx)
- result = {}
-
- p.client = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.sample_output['write'])
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
-
- expected_result = '{"write_bw": 35107, "write_iops": 8776,'\
- '"write_lat": 111.74}'
- expected_result = jsonutils.loads(expected_result)
- self.assertEqual(result, expected_result)
-
- def test_fio_successful_lat_sla(self, mock_ssh):
-
- options = {
- 'filename': '/home/ubuntu/data.raw',
- 'bs': '4k',
- 'rw': 'rw',
- 'ramp_time': 10
- }
- args = {
- 'options': options,
- 'sla': {'write_lat': 300.1}
- }
- p = fio.Fio(args, self.ctx)
- result = {}
-
- p.client = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.sample_output['rw'])
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
-
- expected_result = '{"read_bw": 83888, "read_iops": 20972,' \
- '"read_lat": 236.8, "write_bw": 84182, "write_iops": 21045,'\
- '"write_lat": 233.55}'
- expected_result = jsonutils.loads(expected_result)
- self.assertEqual(result, expected_result)
-
- def test_fio_unsuccessful_lat_sla(self, mock_ssh):
-
- options = {
- 'filename': '/home/ubuntu/data.raw',
- 'bs': '4k',
- 'rw': 'rw',
- 'ramp_time': 10
- }
- args = {
- 'options': options,
- 'sla': {'write_lat': 200.1}
- }
- p = fio.Fio(args, self.ctx)
- result = {}
-
- p.client = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.sample_output['rw'])
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, result)
-
- def test_fio_successful_bw_iops_sla(self, mock_ssh):
-
- options = {
- 'filename': '/home/ubuntu/data.raw',
- 'bs': '4k',
- 'rw': 'rw',
- 'ramp_time': 10
- }
- args = {
- 'options': options,
- 'sla': {'read_iops': 20000}
- }
- p = fio.Fio(args, self.ctx)
- result = {}
-
- p.client = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.sample_output['rw'])
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-
- p.run(result)
-
- expected_result = '{"read_bw": 83888, "read_iops": 20972,' \
- '"read_lat": 236.8, "write_bw": 84182, "write_iops": 21045,'\
- '"write_lat": 233.55}'
- expected_result = jsonutils.loads(expected_result)
- self.assertEqual(result, expected_result)
-
- def test_fio_unsuccessful_bw_iops_sla(self, mock_ssh):
-
- options = {
- 'filename': '/home/ubuntu/data.raw',
- 'bs': '4k',
- 'rw': 'rw',
- 'ramp_time': 10
- }
- args = {
- 'options': options,
- 'sla': {'read_iops': 30000}
- }
- p = fio.Fio(args, self.ctx)
- result = {}
-
- p.client = mock_ssh.SSH.from_node()
-
- sample_output = self._read_sample_output(self.sample_output['rw'])
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- self.assertRaises(AssertionError, p.run, result)
-
- def test_fio_unsuccessful_script_error(self, mock_ssh):
-
- options = {
- 'filename': '/home/ubuntu/data.raw',
- 'bs': '4k',
- 'rw': 'rw',
- 'ramp_time': 10
- }
- args = {'options': options}
- p = fio.Fio(args, self.ctx)
- result = {}
-
- p.client = mock_ssh.SSH.from_node()
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, p.run, result)
-
- def _read_sample_output(self, file_name):
- curr_path = os.path.dirname(os.path.abspath(__file__))
- output = os.path.join(curr_path, file_name)
- with open(output) as f:
- sample_output = f.read()
- return sample_output
-
-
-def main():
- unittest.main()
-
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py b/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py
deleted file mode 100644
index 095674f72..000000000
--- a/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for
-# yardstick.benchmark.scenarios.storage.storagecapacity.StorageCapacity
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.storage import storagecapacity
-
-DISK_SIZE_SAMPLE_OUTPUT = \
- '{"Numberf of devides": "2", "Total disk size in bytes": "1024000000"}'
-BLOCK_SIZE_SAMPLE_OUTPUT = '{"/dev/sda": 1024, "/dev/sdb": 4096}'
-DISK_UTIL_RAW_OUTPUT = "vda 10.00\nvda 0.00"
-DISK_UTIL_SAMPLE_OUTPUT = \
- '{"vda": {"avg_util": 5.0, "max_util": 10.0, "min_util": 0.0}}'
-
-
-@mock.patch('yardstick.benchmark.scenarios.storage.storagecapacity.ssh')
-class StorageCapacityTestCase(unittest.TestCase):
-
- def setUp(self):
- self.scn = {
- "options": {
- 'test_type': 'disk_size'
- }
- }
- self.ctx = {
- "host": {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'password': "root"
- }
- }
- self.result = {}
-
- def test_capacity_successful_setup(self, mock_ssh):
- c = storagecapacity.StorageCapacity(self.scn, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- c.setup()
- self.assertIsNotNone(c.client)
- self.assertTrue(c.setup_done)
-
- def test_capacity_disk_size_successful(self, mock_ssh):
- c = storagecapacity.StorageCapacity(self.scn, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, DISK_SIZE_SAMPLE_OUTPUT, '')
- c.run(self.result)
- expected_result = jsonutils.loads(
- DISK_SIZE_SAMPLE_OUTPUT)
- self.assertEqual(self.result, expected_result)
-
- def test_capacity_block_size_successful(self, mock_ssh):
- args = {
- "options": {
- 'test_type': 'block_size'
- }
- }
- c = storagecapacity.StorageCapacity(args, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, BLOCK_SIZE_SAMPLE_OUTPUT, '')
- c.run(self.result)
- expected_result = jsonutils.loads(
- BLOCK_SIZE_SAMPLE_OUTPUT)
- self.assertEqual(self.result, expected_result)
-
- def test_capacity_disk_utilization_successful(self, mock_ssh):
- args = {
- "options": {
- 'test_type': 'disk_utilization',
- 'interval': 1,
- 'count': 2
- }
- }
- c = storagecapacity.StorageCapacity(args, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (0, DISK_UTIL_RAW_OUTPUT, '')
- c.run(self.result)
- expected_result = jsonutils.loads(
- DISK_UTIL_SAMPLE_OUTPUT)
- self.assertEqual(self.result, expected_result)
-
- def test_capacity_unsuccessful_script_error(self, mock_ssh):
- c = storagecapacity.StorageCapacity(self.scn, self.ctx)
-
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- self.assertRaises(RuntimeError, c.run, self.result)
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/storage/test_storperf.py b/tests/unit/benchmark/scenarios/storage/test_storperf.py
deleted file mode 100644
index 7b16bb37d..000000000
--- a/tests/unit/benchmark/scenarios/storage/test_storperf.py
+++ /dev/null
@@ -1,238 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-# Copyright (c) 2016 Huawei Technologies Co.,Ltd.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-# Unittest for yardstick.benchmark.scenarios.storage.storperf.StorPerf
-
-from __future__ import absolute_import
-
-import unittest
-
-import mock
-from oslo_serialization import jsonutils
-
-from yardstick.benchmark.scenarios.storage import storperf
-
-
-def mocked_requests_config_post(*args, **kwargs):
- class MockResponseConfigPost:
-
- def __init__(self, json_data, status_code):
- self.content = json_data
- self.status_code = status_code
-
- return MockResponseConfigPost(
- '{"stack_id": "dac27db1-3502-4300-b301-91c64e6a1622",'
- '"stack_created": "false"}',
- 200)
-
-
-def mocked_requests_config_get(*args, **kwargs):
- class MockResponseConfigGet:
-
- def __init__(self, json_data, status_code):
- self.content = json_data
- self.status_code = status_code
-
- return MockResponseConfigGet(
- '{"stack_id": "dac27db1-3502-4300-b301-91c64e6a1622",'
- '"stack_created": "true"}',
- 200)
-
-
-def mocked_requests_job_get(*args, **kwargs):
- class MockResponseJobGet:
-
- def __init__(self, json_data, status_code):
- self.content = json_data
- self.status_code = status_code
-
- return MockResponseJobGet(
- '{"Status": "Completed",\
- "_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}',
- 200)
-
-
-def mocked_requests_job_post(*args, **kwargs):
- class MockResponseJobPost:
-
- def __init__(self, json_data, status_code):
- self.content = json_data
- self.status_code = status_code
-
- return MockResponseJobPost('{"job_id": \
- "d46bfb8c-36f4-4a40-813b-c4b4a437f728"}', 200)
-
-
-def mocked_requests_job_delete(*args, **kwargs):
- class MockResponseJobDelete:
-
- def __init__(self, json_data, status_code):
- self.content = json_data
- self.status_code = status_code
-
- return MockResponseJobDelete('{}', 200)
-
-
-def mocked_requests_delete(*args, **kwargs):
- class MockResponseDelete:
-
- def __init__(self, json_data, status_code):
- self.json_data = json_data
- self.status_code = status_code
-
- return MockResponseDelete('{}', 200)
-
-
-def mocked_requests_delete_failed(*args, **kwargs):
- class MockResponseDeleteFailed:
-
- def __init__(self, json_data, status_code):
- self.json_data = json_data
- self.status_code = status_code
-
- if args[0] == "http://172.16.0.137:5000/api/v1.0/configurations":
- return MockResponseDeleteFailed('{"message": "Teardown failed"}', 400)
-
- return MockResponseDeleteFailed('{}', 404)
-
-
-class StorPerfTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ctx = {
- 'host': {
- 'ip': '172.16.0.137',
- 'user': 'cirros',
- 'key_filename': "mykey.key"
- }
- }
-
- self.result = {}
-
- @mock.patch('yardstick.benchmark.scenarios.storage.storperf.requests.post',
- side_effect=mocked_requests_config_post)
- @mock.patch('yardstick.benchmark.scenarios.storage.storperf.requests.get',
- side_effect=mocked_requests_config_get)
- def test_successful_setup(self, mock_post, mock_get):
- options = {
- "agent_count": 8,
- "public_network": 'ext-net',
- "volume_size": 10,
- "block_sizes": 4096,
- "queue_depths": 4,
- "workload": "rs",
- "StorPerf_ip": "192.168.23.2",
- "query_interval": 0,
- "timeout": 60
- }
-
- args = {
- "options": options
- }
-
- s = storperf.StorPerf(args, self.ctx)
-
- s.setup()
-
- self.assertTrue(s.setup_done)
-
- @mock.patch('yardstick.benchmark.scenarios.storage.storperf.requests.post',
- side_effect=mocked_requests_job_post)
- @mock.patch('yardstick.benchmark.scenarios.storage.storperf.requests.get',
- side_effect=mocked_requests_job_get)
- @mock.patch(
- 'yardstick.benchmark.scenarios.storage.storperf.requests.delete',
- side_effect=mocked_requests_job_delete)
- def test_successful_run(self, mock_post, mock_get, mock_delete):
- options = {
- "agent_count": 8,
- "public_network": 'ext-net',
- "volume_size": 10,
- "block_sizes": 4096,
- "queue_depths": 4,
- "workload": "rs",
- "StorPerf_ip": "192.168.23.2",
- "query_interval": 0,
- "timeout": 60
- }
-
- args = {
- "options": options
- }
-
- s = storperf.StorPerf(args, self.ctx)
- s.setup_done = True
-
- sample_output = '{"Status": "Completed",\
- "_ssd_preconditioning.queue-depth.8.block-size.16384.duration": 6}'
-
- expected_result = jsonutils.loads(sample_output)
-
- s.run(self.result)
-
- self.assertEqual(self.result, expected_result)
-
- @mock.patch(
- 'yardstick.benchmark.scenarios.storage.storperf.requests.delete',
- side_effect=mocked_requests_delete)
- def test_successful_teardown(self, mock_delete):
- options = {
- "agent_count": 8,
- "public_network": 'ext-net',
- "volume_size": 10,
- "block_sizes": 4096,
- "queue_depths": 4,
- "workload": "rs",
- "StorPerf_ip": "192.168.23.2",
- "query_interval": 10,
- "timeout": 60
- }
-
- args = {
- "options": options
- }
-
- s = storperf.StorPerf(args, self.ctx)
-
- s.teardown()
-
- self.assertFalse(s.setup_done)
-
- @mock.patch(
- 'yardstick.benchmark.scenarios.storage.storperf.requests.delete',
- side_effect=mocked_requests_delete_failed)
- def test_failed_teardown(self, mock_delete):
- options = {
- "agent_count": 8,
- "public_network": 'ext-net',
- "volume_size": 10,
- "block_sizes": 4096,
- "queue_depths": 4,
- "workload": "rs",
- "StorPerf_ip": "192.168.23.2",
- "query_interval": 10,
- "timeout": 60
- }
-
- args = {
- "options": options
- }
-
- s = storperf.StorPerf(args, self.ctx)
-
- self.assertRaises(AssertionError, s.teardown(), self.result)
-
-
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
diff --git a/tests/unit/benchmark/scenarios/test_base.py b/tests/unit/benchmark/scenarios/test_base.py
deleted file mode 100644
index 78e342978..000000000
--- a/tests/unit/benchmark/scenarios/test_base.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright 2017: Intel Ltd.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import unittest
-
-from yardstick.benchmark.scenarios import base
-
-
-class ScenarioTestCase(unittest.TestCase):
-
- def test_get_scenario_type(self):
- scenario_type = 'dummy scenario'
-
- class DummyScenario(base.Scenario):
- __scenario_type__ = scenario_type
-
- self.assertEqual(scenario_type, DummyScenario.get_scenario_type())
-
- def test_get_scenario_type_not_defined(self):
- class DummyScenario(base.Scenario):
- pass
-
- self.assertEqual(str(None), DummyScenario.get_scenario_type())
-
- def test_get_description(self):
- docstring = """First line
- Second line
- Third line
- """
-
- class DummyScenario(base.Scenario):
- __doc__ = docstring
-
- self.assertEqual(docstring.splitlines()[0],
- DummyScenario.get_description())
-
- def test_get_description_empty(self):
- class DummyScenario(base.Scenario):
- pass
-
- self.assertEqual(str(None), DummyScenario.get_description())
diff --git a/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py b/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
index 9bb5ed3a7..e30aee854 100644
--- a/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
+++ b/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
@@ -117,7 +117,7 @@ Other crypto devices
self.assertEqual(conn, dpdk_bind_helper.ssh_helper)
self.assertEqual(self.CLEAN_STATUS, dpdk_bind_helper.dpdk_status)
self.assertIsNone(dpdk_bind_helper.status_nic_row_re)
- self.assertIsNone(dpdk_bind_helper._dpdk_nic_bind_attr)
+ self.assertIsNone(dpdk_bind_helper._dpdk_devbind)
self.assertIsNone(dpdk_bind_helper._status_cmd_attr)
def test__dpdk_execute(self):
diff --git a/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py b/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
index 616921e33..f13945abf 100644
--- a/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
+++ b/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
@@ -179,9 +179,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
"dst_mac_0": "00:00:00:00:00:03",
"dst_mac_1": "00:00:00:00:00:04",
"dst_mac_2": "00:00:00:00:00:04"}
- result = r_f_c2544_profile._get_ixia_traffic_profile(
- self.PROFILE, mac, xfile="tmp",
- static_traffic=STATIC_TRAFFIC)
+ result = r_f_c2544_profile._get_ixia_traffic_profile(self.PROFILE, mac)
self.assertIsNotNone(result)
def test_get_ixia_traffic_profile(self):
@@ -225,7 +223,6 @@ class TestIXIARFC2544Profile(unittest.TestCase):
"proto": "udp",
"srcip4": "152.16.40.20",
"ttl": 32,
- "count": "1"
},
"outer_l4": {
"dstport": "2001",
@@ -260,7 +257,6 @@ class TestIXIARFC2544Profile(unittest.TestCase):
"proto": "udp",
"srcip4": "152.16.40.20",
"ttl": 32,
- "count": "1"
},
"outer_l3v6": {
"count": 1024,
@@ -269,7 +265,6 @@ class TestIXIARFC2544Profile(unittest.TestCase):
"proto": "udp",
"srcip4": "152.16.40.20",
"ttl": 32,
- "count": "1"
},
"outer_l4": {
"dstport": "1234",
@@ -289,12 +284,11 @@ class TestIXIARFC2544Profile(unittest.TestCase):
"dst_mac_0": "00:00:00:00:00:03",
"dst_mac_1": "00:00:00:00:00:04",
"dst_mac_2": "00:00:00:00:00:04"}
- result = r_f_c2544_profile._get_ixia_traffic_profile(
- self.PROFILE, mac, xfile="tmp", static_traffic=STATIC_TRAFFIC)
+ result = r_f_c2544_profile._get_ixia_traffic_profile(self.PROFILE, mac)
self.assertIsNotNone(result)
@mock.patch("yardstick.network_services.traffic_profile.ixia_rfc2544.open")
- def test_get_ixia_traffic_profile_v6(self, mock_open):
+ def test_get_ixia_traffic_profile_v6(self, *args):
traffic_generator = mock.Mock(autospec=TrexProfile)
traffic_generator.my_ports = [0, 1]
traffic_generator.uplink_ports = [-1]
@@ -435,8 +429,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
'outer_l4': {'dstport': '2001',
'srcport': '1234'}}},
'schema': 'isb:traffic_profile:0.1'}
- result = r_f_c2544_profile._get_ixia_traffic_profile(
- profile_data, mac, static_traffic=STATIC_TRAFFIC)
+ result = r_f_c2544_profile._get_ixia_traffic_profile(profile_data, mac)
self.assertIsNotNone(result)
def test__get_ixia_traffic_profile_default_args(self):
@@ -459,8 +452,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
ixia_obj = mock.MagicMock()
r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.rate = 100
- result = r_f_c2544_profile._ixia_traffic_generate(traffic_generator,
- traffic, ixia_obj)
+ result = r_f_c2544_profile._ixia_traffic_generate(traffic, ixia_obj)
self.assertIsNone(result)
def test_execute(self):
@@ -511,13 +503,6 @@ class TestIXIARFC2544Profile(unittest.TestCase):
self.assertEqual(r_f_c2544_profile.ports, ports_expected)
def test_get_drop_percentage(self):
- traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.networks = {
- "uplink_0": ["xe0"],
- "downlink_0": ["xe1"],
- }
- traffic_generator.client = \
- mock.Mock(return_value=True)
r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.params = self.PROFILE
ixia_obj = mock.MagicMock()
@@ -541,17 +526,11 @@ class TestIXIARFC2544Profile(unittest.TestCase):
"out_packets": 1000}
tol_min = 100.0
tolerance = 0.0
- self.assertIsNotNone(r_f_c2544_profile.get_drop_percentage(
- traffic_generator, samples,
- tol_min, tolerance, ixia_obj))
+ self.assertIsNotNone(
+ r_f_c2544_profile.get_drop_percentage(samples, tol_min, tolerance,
+ ixia_obj))
def test_get_drop_percentage_update(self):
- traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.uplink_ports = [0]
- traffic_generator.downlink_ports = [1]
- traffic_generator.client = \
- mock.Mock(return_value=True)
r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.params = self.PROFILE
ixia_obj = mock.MagicMock()
@@ -575,17 +554,11 @@ class TestIXIARFC2544Profile(unittest.TestCase):
"out_packets": 1002}
tol_min = 0.0
tolerance = 1.0
- self.assertIsNotNone(r_f_c2544_profile.get_drop_percentage(
- traffic_generator, samples,
- tol_min, tolerance, ixia_obj))
+ self.assertIsNotNone(
+ r_f_c2544_profile.get_drop_percentage(samples, tol_min, tolerance,
+ ixia_obj))
def test_get_drop_percentage_div_zero(self):
- traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.uplink_ports = [0]
- traffic_generator.downlink_ports = [1]
- traffic_generator.client = \
- mock.Mock(return_value=True)
r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.params = self.PROFILE
ixia_obj = mock.MagicMock()
@@ -610,9 +583,9 @@ class TestIXIARFC2544Profile(unittest.TestCase):
tol_min = 0.0
tolerance = 0.0
r_f_c2544_profile.tmp_throughput = 0
- self.assertIsNotNone(r_f_c2544_profile.get_drop_percentage(
- traffic_generator, samples,
- tol_min, tolerance, ixia_obj))
+ self.assertIsNotNone(
+ r_f_c2544_profile.get_drop_percentage(samples, tol_min, tolerance,
+ ixia_obj))
def test_get_multiplier(self):
r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
@@ -638,8 +611,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
r_f_c2544_profile._ixia_traffic_generate = mock.Mock()
self.assertEqual(
None,
- r_f_c2544_profile.start_ixia_latency(traffic_generator,
- ixia_obj))
+ r_f_c2544_profile.start_ixia_latency(traffic_generator, ixia_obj))
if __name__ == '__main__':
diff --git a/tests/unit/network_services/traffic_profile/test_prox_binsearch.py b/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
index c1f1c825b..1b4189b48 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
@@ -32,7 +32,7 @@ if stl_patch:
class TestProxBinSearchProfile(unittest.TestCase):
def test_execute_1(self):
- def target(*args, **kwargs):
+ def target(*args, **_):
runs.append(args[2])
if args[2] < 0 or args[2] > 100:
raise RuntimeError(' '.join([str(args), str(runs)]))
@@ -43,6 +43,8 @@ class TestProxBinSearchProfile(unittest.TestCase):
tp_config = {
'traffic_profile': {
'packet_sizes': [200],
+ 'test_precision': 2.0,
+ 'tolerated_loss': 0.001,
},
}
@@ -61,11 +63,47 @@ class TestProxBinSearchProfile(unittest.TestCase):
profile.execute_traffic(traffic_generator)
self.assertEqual(round(profile.current_lower, 2), 74.69)
- self.assertEqual(round(profile.current_upper, 2), 75.39)
- self.assertEqual(len(runs), 8)
+ self.assertEqual(round(profile.current_upper, 2), 76.09)
+ self.assertEqual(len(runs), 7)
+
+ # Result Samples inc theor_max
+ result_tuple = {"Result_Actual_throughput": 7.5e-07,
+ "Result_theor_max_throughput": 0.00012340000000000002,
+ "Result_pktSize": 200}
+ profile.queue.put.assert_called_with(result_tuple)
+
+ success_result_tuple = {"Success_CurrentDropPackets": 0.5,
+ "Success_DropPackets": 0.5,
+ "Success_LatencyAvg": 5.3,
+ "Success_LatencyMax": 5.2,
+ "Success_LatencyMin": 5.1,
+ "Success_PktSize": 200,
+ "Success_RxThroughput": 7.5e-07,
+ "Success_Throughput": 7.5e-07,
+ "Success_TxThroughput": 0.00012340000000000002}
+
+ calls = profile.queue.put(success_result_tuple)
+ profile.queue.put.assert_has_calls(calls)
+
+ success_result_tuple2 = {"Success_CurrentDropPackets": 0.5,
+ "Success_DropPackets": 0.5,
+ "Success_LatencyAvg": 5.3,
+ "Success_LatencyMax": 5.2,
+ "Success_LatencyMin": 5.1,
+ "Success_PktSize": 200,
+ "Success_RxThroughput": 7.5e-07,
+ "Success_Throughput": 7.5e-07,
+ "Success_TxThroughput": 123.4,
+ "Success_can_be_lost": 409600,
+ "Success_drop_total": 20480,
+ "Success_rx_total": 4075520,
+ "Success_tx_total": 4096000}
+
+ calls = profile.queue.put(success_result_tuple2)
+ profile.queue.put.assert_has_calls(calls)
def test_execute_2(self):
- def target(*args, **kwargs):
+ def target(*args, **_):
runs.append(args[2])
if args[2] < 0 or args[2] > 100:
raise RuntimeError(' '.join([str(args), str(runs)]))
@@ -77,6 +115,7 @@ class TestProxBinSearchProfile(unittest.TestCase):
'traffic_profile': {
'packet_sizes': [200],
'test_precision': 2.0,
+ 'tolerated_loss': 0.001,
},
}
@@ -97,3 +136,50 @@ class TestProxBinSearchProfile(unittest.TestCase):
self.assertEqual(round(profile.current_lower, 2), 24.06)
self.assertEqual(round(profile.current_upper, 2), 25.47)
self.assertEqual(len(runs), 7)
+
+ def test_execute_3(self):
+ def target(*args, **_):
+ runs.append(args[2])
+ if args[2] < 0 or args[2] > 100:
+ raise RuntimeError(' '.join([str(args), str(runs)]))
+ if args[2] > 75.0:
+ return fail_tuple, {}
+ return success_tuple, {}
+
+ tp_config = {
+ 'traffic_profile': {
+ 'packet_sizes': [200],
+ 'test_precision': 2.0,
+ 'tolerated_loss': 0.001,
+ },
+ }
+
+ runs = []
+ success_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.1, 5.2, 5.3], 995, 1000, 123.4)
+ fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
+
+ traffic_generator = mock.MagicMock()
+
+ profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
+
+ profile = ProxBinSearchProfile(tp_config)
+ profile.init(mock.MagicMock())
+ profile._profile_helper = profile_helper
+
+ profile.upper_bound = 100.0
+ profile.lower_bound = 99.0
+ profile.execute_traffic(traffic_generator)
+
+
+ # Result Samples
+ result_tuple = {"Result_theor_max_throughput": 0, "Result_pktSize": 200}
+ profile.queue.put.assert_called_with(result_tuple)
+
+ # Check for success_ tuple (None expected)
+ calls = profile.queue.put.mock_calls
+ for call in calls:
+ for call_detail in call[1]:
+ for k in call_detail:
+ if "Success_" in k:
+ self.assertRaises(AttributeError)
diff --git a/tests/unit/network_services/traffic_profile/test_traffic_profile.py b/tests/unit/network_services/traffic_profile/test_traffic_profile.py
index 8355c85b6..37b9a08d0 100644
--- a/tests/unit/network_services/traffic_profile/test_traffic_profile.py
+++ b/tests/unit/network_services/traffic_profile/test_traffic_profile.py
@@ -13,15 +13,15 @@
# 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 ipaddress
-import unittest
import mock
+import six
+import unittest
from tests.unit import STL_MOCKS
-
+from yardstick.common import exceptions as y_exc
STLClient = mock.MagicMock()
stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
@@ -56,79 +56,90 @@ class TestTrexProfile(unittest.TestCase):
EXAMPLE_IP_ADDR = "10.0.0.1"
EXAMPLE_IPv6_ADDR = "0064:ff9b:0:0:0:0:9810:6414"
- PROFILE = {'description': 'Traffic profile to run RFC2544 latency',
- 'name': 'rfc2544',
- 'traffic_profile': {'traffic_type': 'RFC2544Profile',
- 'frame_rate': 100},
- TrafficProfile.DOWNLINK: {'ipv4': {'outer_l2': {'framesize': {'64B': '100',
- '1518B': '0',
- '128B': '0',
- '1400B': '0',
- '256B': '0',
- '373b': '0',
- '570B': '0'},
- "srcmac": "00:00:00:00:00:02",
- "dstmac": "00:00:00:00:00:01"},
- 'outer_l3v4': {'dstip4': '1.1.1.1-1.1.2.2',
- 'proto': 'udp',
- 'srcip4': '9.9.1.1-90.1.2.2',
- 'dscp': 0, 'ttl': 32,
- 'count': 1},
- 'outer_l4': {'srcport': '2001',
- 'dsrport': '1234',
- 'count': 1}}},
- TrafficProfile.UPLINK: {'ipv4':
- {'outer_l2': {'framesize':
- {'64B': '100', '1518B': '0',
- '128B': '0', '1400B': '0',
- '256B': '0', '373b': '0',
- '570B': '0'},
- "srcmac": "00:00:00:00:00:01",
- "dstmac": "00:00:00:00:00:02"},
- 'outer_l3v4': {'dstip4': '9.9.1.1-90.105.255.255',
- 'proto': 'udp',
- 'srcip4': '1.1.1.1-1.15.255.255',
- 'dscp': 0, 'ttl': 32, 'count': 1},
- 'outer_l4': {'dstport': '2001',
- 'srcport': '1234',
- 'count': 1}}},
- 'schema': 'isb:traffic_profile:0.1'}
- PROFILE_v6 = {'description': 'Traffic profile to run RFC2544 latency',
- 'name': 'rfc2544',
- 'traffic_profile': {'traffic_type': 'RFC2544Profile',
- 'frame_rate': 100},
- TrafficProfile.DOWNLINK: {'ipv6': {'outer_l2': {'framesize':
- {'64B': '100', '1518B': '0',
- '128B': '0', '1400B': '0',
- '256B': '0', '373b': '0',
- '570B': '0'},
- "srcmac": "00:00:00:00:00:02",
- "dstmac": "00:00:00:00:00:01"},
- 'outer_l3v4': {'dstip6': '0064:ff9b:0:0:0:0:9810:6414-0064:ff9b:0:0:0:0:9810:6420',
- 'proto': 'udp',
- 'srcip6': '0064:ff9b:0:0:0:0:9810:2814-0064:ff9b:0:0:0:0:9810:2820',
- 'dscp': 0, 'ttl': 32,
- 'count': 1},
- 'outer_l4': {'srcport': '2001',
- 'dsrport': '1234',
- 'count': 1}}},
- TrafficProfile.UPLINK:
- {'ipv6': {'outer_l2': {'framesize':
- {'64B': '100', '1518B': '0',
- '128B': '0', '1400B': '0',
- '256B': '0', '373b': '0',
- '570B': '0'},
- "srcmac": "00:00:00:00:00:01",
- "dstmac": "00:00:00:00:00:02"},
- 'outer_l3v4': {'dstip6': '0064:ff9b:0:0:0:0:9810:2814-0064:ff9b:0:0:0:0:9810:2820',
- 'proto': 'udp',
- 'srcip6': '0064:ff9b:0:0:0:0:9810:6414-0064:ff9b:0:0:0:0:9810:6420',
- 'dscp': 0, 'ttl': 32,
- 'count': 1},
- 'outer_l4': {'dstport': '2001',
- 'srcport': '1234',
- 'count': 1}}},
- 'schema': 'isb:traffic_profile:0.1'}
+ PROFILE = {
+ 'description': 'Traffic profile to run RFC2544 latency',
+ 'name': 'rfc2544',
+ 'traffic_profile': {'traffic_type': 'RFC2544Profile',
+ 'frame_rate': 100},
+ TrafficProfile.DOWNLINK: {
+ 'ipv4': {'outer_l2': {'framesize': {'64B': '100',
+ '1518B': '0',
+ '128B': '0',
+ '1400B': '0',
+ '256B': '0',
+ '373b': '0',
+ '570B': '0'},
+ "srcmac": "00:00:00:00:00:02",
+ "dstmac": "00:00:00:00:00:01"},
+ 'outer_l3v4': {'dstip4': '1.1.1.1-1.1.2.2',
+ 'proto': 'udp',
+ 'srcip4': '9.9.1.1-90.1.2.2',
+ 'dscp': 0, 'ttl': 32,
+ 'count': 1},
+ 'outer_l4': {'srcport': '2001',
+ 'dsrport': '1234',
+ 'count': 1}}},
+ TrafficProfile.UPLINK: {
+ 'ipv4':
+ {'outer_l2': {'framesize':
+ {'64B': '100', '1518B': '0',
+ '128B': '0', '1400B': '0',
+ '256B': '0', '373b': '0',
+ '570B': '0'},
+ "srcmac": "00:00:00:00:00:01",
+ "dstmac": "00:00:00:00:00:02"},
+ 'outer_l3v4': {'dstip4': '9.9.1.1-90.105.255.255',
+ 'proto': 'udp',
+ 'srcip4': '1.1.1.1-1.15.255.255',
+ 'dscp': 0, 'ttl': 32, 'count': 1},
+ 'outer_l4': {'dstport': '2001',
+ 'srcport': '1234',
+ 'count': 1}}},
+ 'schema': 'isb:traffic_profile:0.1'}
+ PROFILE_v6 = {
+ 'description': 'Traffic profile to run RFC2544 latency',
+ 'name': 'rfc2544',
+ 'traffic_profile': {'traffic_type': 'RFC2544Profile',
+ 'frame_rate': 100},
+ TrafficProfile.DOWNLINK: {
+ 'ipv6': {'outer_l2': {'framesize':
+ {'64B': '100', '1518B': '0',
+ '128B': '0', '1400B': '0',
+ '256B': '0', '373b': '0',
+ '570B': '0'},
+ "srcmac": "00:00:00:00:00:02",
+ "dstmac": "00:00:00:00:00:01"},
+ 'outer_l3v4': {
+ 'dstip6':
+ '0064:ff9b:0:0:0:0:9810:6414-0064:ff9b:0:0:0:0:9810:6420',
+ 'proto': 'udp',
+ 'srcip6':
+ '0064:ff9b:0:0:0:0:9810:2814-0064:ff9b:0:0:0:0:9810:2820',
+ 'dscp': 0, 'ttl': 32,
+ 'count': 1},
+ 'outer_l4': {'srcport': '2001',
+ 'dsrport': '1234',
+ 'count': 1}}},
+ TrafficProfile.UPLINK: {
+ 'ipv6': {'outer_l2': {'framesize':
+ {'64B': '100', '1518B': '0',
+ '128B': '0', '1400B': '0',
+ '256B': '0', '373b': '0',
+ '570B': '0'},
+ "srcmac": "00:00:00:00:00:01",
+ "dstmac": "00:00:00:00:00:02"},
+ 'outer_l3v4': {
+ 'dstip6':
+ '0064:ff9b:0:0:0:0:9810:2814-0064:ff9b:0:0:0:0:9810:2820',
+ 'proto': 'udp',
+ 'srcip6':
+ '0064:ff9b:0:0:0:0:9810:6414-0064:ff9b:0:0:0:0:9810:6420',
+ 'dscp': 0, 'ttl': 32,
+ 'count': 1},
+ 'outer_l4': {'dstport': '2001',
+ 'srcport': '1234',
+ 'count': 1}}},
+ 'schema': 'isb:traffic_profile:0.1'}
def test___init__(self):
TrafficProfile.params = self.PROFILE
@@ -205,22 +216,76 @@ class TestTrexProfile(unittest.TestCase):
TrexProfile(TrafficProfile)
self.assertEqual({}, trex_profile.generate_imix_data(False))
- def test__get_start_end_ipv6(self):
- trex_profile = \
- TrexProfile(TrafficProfile)
- self.assertRaises(SystemExit, trex_profile._get_start_end_ipv6,
- "1.1.1.3", "1.1.1.1")
+ def test__count_ip_ipv4(self):
+ start, end, count = TrexProfile._count_ip('1.1.1.1', '1.2.3.4')
+ self.assertEqual('1.1.1.1', str(start))
+ self.assertEqual('1.2.3.4', str(end))
+ diff = (int(ipaddress.IPv4Address(six.u('1.2.3.4'))) -
+ int(ipaddress.IPv4Address(six.u('1.1.1.1'))))
+ self.assertEqual(diff, count)
+
+ def test__count_ip_ipv6(self):
+ start_ip = '0064:ff9b:0:0:0:0:9810:6414'
+ end_ip = '0064:ff9b:0:0:0:0:9810:6420'
+ start, end, count = TrexProfile._count_ip(start_ip, end_ip)
+ self.assertEqual(0x98106414, start)
+ self.assertEqual(0x98106420, end)
+ self.assertEqual(0x98106420 - 0x98106414, count)
+
+ def test__count_ip_ipv6_exception(self):
+ start_ip = '0064:ff9b:0:0:0:0:9810:6420'
+ end_ip = '0064:ff9b:0:0:0:0:9810:6414'
+ with self.assertRaises(y_exc.IPv6RangeError):
+ TrexProfile._count_ip(start_ip, end_ip)
+
+ def test__dscp_range_action_partial_actual_count_zero(self):
+ traffic_profile = TrexProfile(TrafficProfile)
+ dscp_partial = traffic_profile._dscp_range_action_partial()
+
+ flow_vars_initial_length = len(traffic_profile.vm_flow_vars)
+ dscp_partial('1', '1', 'unneeded')
+ self.assertEqual(len(traffic_profile.vm_flow_vars), flow_vars_initial_length + 2)
+
+ def test__dscp_range_action_partial_count_greater_than_actual(self):
+ traffic_profile = TrexProfile(TrafficProfile)
+ dscp_partial = traffic_profile._dscp_range_action_partial()
+
+ flow_vars_initial_length = len(traffic_profile.vm_flow_vars)
+ dscp_partial('1', '10', '100')
+ self.assertEqual(len(traffic_profile.vm_flow_vars), flow_vars_initial_length + 2)
+
+ def test__udp_range_action_partial_actual_count_zero(self):
+ traffic_profile = TrexProfile(TrafficProfile)
+ traffic_profile.udp['field1'] = 'value1'
+ udp_partial = traffic_profile._udp_range_action_partial('field1')
+
+ flow_vars_initial_length = len(traffic_profile.vm_flow_vars)
+ udp_partial('1', '1', 'unneeded')
+ self.assertEqual(len(traffic_profile.vm_flow_vars), flow_vars_initial_length + 2)
+
+ def test__udp_range_action_partial_count_greater_than_actual(self):
+ traffic_profile = TrexProfile(TrafficProfile)
+ traffic_profile.udp['field1'] = 'value1'
+ udp_partial = traffic_profile._udp_range_action_partial('field1', 'not_used_count')
+
+ flow_vars_initial_length = len(traffic_profile.vm_flow_vars)
+ udp_partial('1', '10', '100')
+ self.assertEqual(len(traffic_profile.vm_flow_vars), flow_vars_initial_length + 2)
def test__general_single_action_partial(self):
trex_profile = TrexProfile(TrafficProfile)
- trex_profile._general_single_action_partial(ETHERNET)(SRC)(self.EXAMPLE_ETHERNET_ADDR)
- self.assertEqual(self.EXAMPLE_ETHERNET_ADDR, trex_profile.ether_packet.src)
+ trex_profile._general_single_action_partial(ETHERNET)(SRC)(
+ self.EXAMPLE_ETHERNET_ADDR)
+ self.assertEqual(self.EXAMPLE_ETHERNET_ADDR,
+ trex_profile.ether_packet.src)
- trex_profile._general_single_action_partial(IP)(DST)(self.EXAMPLE_IP_ADDR)
+ trex_profile._general_single_action_partial(IP)(DST)(
+ self.EXAMPLE_IP_ADDR)
self.assertEqual(self.EXAMPLE_IP_ADDR, trex_profile.ip_packet.dst)
- trex_profile._general_single_action_partial(IPv6)(DST)(self.EXAMPLE_IPv6_ADDR)
+ trex_profile._general_single_action_partial(IPv6)(DST)(
+ self.EXAMPLE_IPv6_ADDR)
self.assertEqual(self.EXAMPLE_IPv6_ADDR, trex_profile.ip6_packet.dst)
trex_profile._general_single_action_partial(UDP)(SRC_PORT)(5060)
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py
index 2a2647a91..f9a10149e 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py
@@ -343,6 +343,6 @@ class TestAclApproxVnf(unittest.TestCase):
acl_approx_vnf.used_drivers = {"01:01.0": "i40e",
"01:01.1": "i40e"}
acl_approx_vnf.vnf_execute = mock.MagicMock()
- acl_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
+ acl_approx_vnf.dpdk_devbind = "dpdk-devbind.py"
acl_approx_vnf._resource_collect_stop = mock.Mock()
self.assertEqual(None, acl_approx_vnf.terminate())
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
index f2ce18fb3..62b3c7440 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
@@ -392,22 +392,6 @@ class TestCgnaptApproxVnf(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
@mock.patch(SSH_HELPER)
- def test_terminate(self, ssh, *args):
- mock_ssh(ssh)
-
- vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
- cgnapt_approx_vnf._vnf_process = mock.MagicMock()
- cgnapt_approx_vnf._vnf_process.terminate = mock.Mock()
- cgnapt_approx_vnf.used_drivers = {"01:01.0": "i40e",
- "01:01.1": "i40e"}
- cgnapt_approx_vnf.vnf_execute = mock.MagicMock()
- cgnapt_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
- cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
- self.assertEqual(None, cgnapt_approx_vnf.terminate())
-
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
- @mock.patch(SSH_HELPER)
def test__vnf_up_post(self, ssh, *args):
mock_ssh(ssh)
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
index 0ac46c632..ac67cc52c 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
@@ -1730,7 +1730,7 @@ class TestProxProfileHelper(unittest.TestCase):
}
self.assertIsNone(helper._test_cores)
- expected = [12, 23]
+ expected = [3, 4]
result = helper.test_cores
self.assertEqual(result, expected)
self.assertIs(result, helper._test_cores)
@@ -1787,7 +1787,7 @@ class TestProxProfileHelper(unittest.TestCase):
}
self.assertIsNone(helper._latency_cores)
- expected = [12, 23]
+ expected = [3, 4]
result = helper.latency_cores
self.assertEqual(result, expected)
self.assertIs(result, helper._latency_cores)
@@ -1842,7 +1842,7 @@ class TestProxProfileHelper(unittest.TestCase):
}
}
- expected = [7, 8]
+ expected = [3, 4]
result = helper.get_cores(helper.PROX_CORE_GEN_MODE)
self.assertEqual(result, expected)
@@ -1984,8 +1984,8 @@ class TestProxMplsProfileHelper(unittest.TestCase):
}
}
- expected_tagged = [7]
- expected_plain = [8]
+ expected_tagged = [3]
+ expected_plain = [4]
self.assertIsNone(helper._cores_tuple)
self.assertEqual(helper.tagged_cores, expected_tagged)
self.assertEqual(helper.plain_cores, expected_plain)
@@ -2060,10 +2060,10 @@ class TestProxBngProfileHelper(unittest.TestCase):
}
}
- expected_cpe = [7]
- expected_inet = [8]
- expected_arp = [4, 3]
- expected_arp_task = [0, 4]
+ expected_cpe = [3]
+ expected_inet = [4]
+ expected_arp = [6, 9]
+ expected_arp_task = [0, 6]
expected_combined = (expected_cpe, expected_inet, expected_arp, expected_arp_task)
self.assertIsNone(helper._cores_tuple)
@@ -2131,8 +2131,8 @@ class TestProxVpeProfileHelper(unittest.TestCase):
}
}
- expected_cpe = [7]
- expected_inet = [8]
+ expected_cpe = [3]
+ expected_inet = [4]
expected_combined = (expected_cpe, expected_inet)
self.assertIsNone(helper._cores_tuple)
@@ -2245,8 +2245,8 @@ class TestProxlwAFTRProfileHelper(unittest.TestCase):
}
}
- expected_tun = [7]
- expected_inet = [8]
+ expected_tun = [3]
+ expected_inet = [4]
expected_combined = (expected_tun, expected_inet)
self.assertIsNone(helper._cores_tuple)
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
index 769279066..08be4865b 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
@@ -131,6 +131,8 @@ class TestProxApproxVnf(unittest.TestCase):
'packets_in',
'packets_fwd',
'packets_dropped',
+ 'curr_packets_fwd',
+ 'curr_packets_in'
],
},
'connection-point': [
@@ -329,7 +331,7 @@ class TestProxApproxVnf(unittest.TestCase):
'packets_in': 0,
'packets_dropped': 0,
'packets_fwd': 0,
- 'collect_stats': {'core': {}},
+ 'collect_stats': {'core': {}}
}
result = prox_approx_vnf.collect_kpi()
self.assertEqual(result, expected)
@@ -352,7 +354,11 @@ class TestProxApproxVnf(unittest.TestCase):
'collect_stats': {'core': {'result': 234}},
}
result = prox_approx_vnf.collect_kpi()
- self.assertEqual(result, expected)
+ self.assertEqual(result['packets_in'], expected['packets_in'])
+ self.assertEqual(result['packets_dropped'], expected['packets_dropped'])
+ self.assertEqual(result['packets_fwd'], expected['packets_fwd'])
+ self.assertNotEqual(result['packets_fwd'], 0)
+ self.assertNotEqual(result['packets_fwd'], 0)
@mock.patch(SSH_HELPER)
def test_collect_kpi_error(self, ssh, *args):
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
index 1799353c4..cc4ffa5f7 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
@@ -609,37 +609,34 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
dpdk_vnf_setup_env_helper.setup_vnf_environment(),
ResourceProfile)
- def test__setup_dpdk_early_success(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
+ def test__setup_dpdk(self):
ssh_helper = mock.Mock()
- ssh_helper.execute.return_value = 0, 'output', ''
- ssh_helper.join_bin_path.return_value = 'joined_path'
- ssh_helper.provision_tool.return_value = 'provision string'
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper._setup_hugepages = mock.Mock()
-
- self.assertIsNone(dpdk_setup_helper._setup_dpdk())
- self.assertEqual(dpdk_setup_helper.ssh_helper.execute.call_count, 2)
-
- @mock.patch('yardstick.ssh.SSH')
- def test__setup_dpdk_short(self, _):
- def execute_side(cmd):
- if 'joined_path' in cmd:
- return 0, 'output', ''
- return 1, 'bad output', 'error output'
+ ssh_helper.execute = mock.Mock()
+ ssh_helper.execute.return_value = (0, 0, 0)
+ dpdk_setup_helper = DpdkVnfSetupEnvHelper(mock.ANY, ssh_helper, mock.ANY)
+ with mock.patch.object(dpdk_setup_helper, '_setup_hugepages') as \
+ mock_setup_hp:
+ dpdk_setup_helper._setup_dpdk()
+ mock_setup_hp.assert_called_once()
+ ssh_helper.execute.assert_has_calls([
+ mock.call('sudo modprobe uio && sudo modprobe igb_uio'),
+ mock.call('lsmod | grep -i igb_uio')
+ ])
- vnfd_helper = VnfdHelper(self.VNFD_0)
+ def test__setup_dpdk_igb_uio_not_loaded(self):
ssh_helper = mock.Mock()
- ssh_helper.execute.side_effect = execute_side
- ssh_helper.join_bin_path.return_value = 'joined_path'
- ssh_helper.provision_tool.return_value = 'provision string'
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper._setup_hugepages = mock.Mock()
-
- self.assertIsNone(dpdk_setup_helper._setup_dpdk())
- self.assertEqual(dpdk_setup_helper.ssh_helper.execute.call_count, 3)
+ ssh_helper.execute = mock.Mock()
+ ssh_helper.execute.side_effect = [(0, 0, 0), (1, 0, 0)]
+ dpdk_setup_helper = DpdkVnfSetupEnvHelper(mock.ANY, ssh_helper, mock.ANY)
+ with mock.patch.object(dpdk_setup_helper, '_setup_hugepages') as \
+ mock_setup_hp:
+ with self.assertRaises(y_exceptions.DPDKSetupDriverError):
+ dpdk_setup_helper._setup_dpdk()
+ mock_setup_hp.assert_called_once()
+ ssh_helper.execute.assert_has_calls([
+ mock.call('sudo modprobe uio && sudo modprobe igb_uio'),
+ mock.call('lsmod | grep -i igb_uio')
+ ])
@mock.patch('yardstick.ssh.SSH')
def test__setup_resources(self, _):
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
index e6e4b882e..d77068137 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
@@ -151,6 +151,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.shutil")
def test_instantiate(self, call, shutil, mock_makedirs):
+ # pylint: disable=unused-argument
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
@@ -174,7 +175,8 @@ class TestIxLoadTrafficGen(unittest.TestCase):
'1C/1T',
'worker_threads': 1}}
}})
- with mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open', create=True) as mock_open:
+ with mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open',
+ create=True) as mock_open:
mock_open.return_value = mock.MagicMock()
ixload_traffic_gen.instantiate(scenario_cfg, {})
@@ -185,6 +187,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.max")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.len")
def test_run_traffic(self, call, shutil, main_open, min, max, len):
+ # pylint: disable=unused-argument
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -216,6 +219,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.max")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.len")
def test_run_traffic_csv(self, call, shutil, main_open, min, max, len):
+ # pylint: disable=unused-argument
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -243,7 +247,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
self.assertIsNone(result)
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
- def test_terminate(self, call):
+ def test_terminate(self, *args):
with mock.patch("yardstick.ssh.SSH") as ssh:
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
ssh_mock = mock.Mock(autospec=ssh.SSH)
@@ -256,6 +260,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
@mock.patch("yardstick.ssh.SSH")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
def test_parse_csv_read(self, mock_call, mock_ssh):
+ # pylint: disable=unused-argument
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
kpi_data = {
'HTTP Total Throughput (Kbps)': 1,
@@ -280,6 +285,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
@mock.patch("yardstick.ssh.SSH")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
def test_parse_csv_read_value_error(self, mock_call, mock_ssh):
+ # pylint: disable=unused-argument
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
http_reader = [{
'HTTP Total Throughput (Kbps)': 1,
@@ -302,6 +308,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
@mock.patch("yardstick.ssh.SSH")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
def test_parse_csv_read_error(self, mock_call, mock_ssh):
+ # pylint: disable=unused-argument
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
http_reader = [{
'HTTP Total Throughput (Kbps)': 1,
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
index cda3852fe..472052b0a 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
@@ -462,15 +462,3 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG))
with self.assertRaises(RuntimeError):
udp_replay_approx_vnf.wait_for_instantiate()
-
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
- @mock.patch(SSH_HELPER)
- def test_terminate(self, ssh, *args):
- mock_ssh(ssh)
-
- udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
- udp_replay_approx_vnf._vnf_process = mock.MagicMock()
- udp_replay_approx_vnf._vnf_process.terminate = mock.Mock()
- udp_replay_approx_vnf.used_drivers = {"01:01.0": "i40e", "01:01.1": "i40e"}
- udp_replay_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
- self.assertEqual(None, udp_replay_approx_vnf.terminate())
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py
index d128db0b4..f0a56665c 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py
@@ -348,18 +348,3 @@ pipeline>
'rules': ""}}
self.scenario_cfg.update({"nodes": {"vnf__1": ""}})
self.assertIsNone(vfw_approx_vnf.instantiate(self.scenario_cfg, self.context_cfg))
-
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
- @mock.patch(SSH_HELPER)
- def test_terminate(self, ssh, *args):
- mock_ssh(ssh)
-
- vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- vfw_approx_vnf = FWApproxVnf(name, vnfd)
- vfw_approx_vnf._vnf_process = mock.MagicMock()
- vfw_approx_vnf.used_drivers = {"01:01.0": "i40e",
- "01:01.1": "i40e"}
- vfw_approx_vnf.vnf_execute = mock.Mock()
- vfw_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
- vfw_approx_vnf._resource_collect_stop = mock.Mock()
- self.assertIsNone(vfw_approx_vnf.terminate())
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
index 1abc53688..c074dfb4c 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
@@ -163,6 +163,11 @@ class TestConfigCreate(unittest.TestCase):
self.assertEqual(config_create.downlink_ports, ['xe1'])
self.assertEqual(config_create.socket, 2)
+ def test_dpdk_port_to_link_id(self):
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 2)
+ self.assertEqual(config_create.dpdk_port_to_link_id_map, {'xe0': 0, 'xe1': 1})
+
def test_vpe_initialize(self):
vnfd_helper = VnfdHelper(self.VNFD_0)
config_create = ConfigCreate(vnfd_helper, 2)
@@ -633,7 +638,7 @@ class TestVpeApproxVnf(unittest.TestCase):
def test_build_config(self, ssh, *args):
mock_ssh(ssh)
vpe_approx_vnf = VpeApproxSetupEnvHelper(mock.MagicMock(),
- mock.MagicMock, mock.MagicMock)
+ mock.MagicMock(), mock.MagicMock())
vpe_approx_vnf.tc_file_name = get_file_abspath(TEST_FILE_YAML)
vpe_approx_vnf.generate_port_pairs = mock.Mock()
vpe_approx_vnf.vnf_cfg = {