aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/ci/load_images.sh54
-rwxr-xr-xtests/ci/prepare_env.sh26
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml3
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml65
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc055.yaml1
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml8
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc063.yaml4
-rw-r--r--tests/opnfv/test_suites/opnfv_k8-ovn-lb-noha_daily.yaml18
-rw-r--r--tests/opnfv/test_suites/opnfv_os-nosdn-bar-ha_daily.yaml161
-rw-r--r--tests/opnfv/test_suites/opnfv_os-nosdn-bar-noha_daily.yaml62
-rw-r--r--tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml23
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl-dvr-noha_daily.yaml38
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl-fdio-dvr-ha_daily.yaml38
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl-fdio-ha_daily.yaml38
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl-fdio-noha_daily.yaml38
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl-nofeature-ha_daily.yaml64
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl-ovs-ha_daily.yaml64
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl-sfc-noha_daily.yaml62
-rw-r--r--tests/unit/apiserver/__init__.py6
-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/ovs_sample_password.yaml104
-rw-r--r--tests/unit/benchmark/contexts/standalone/ovs_sample_ssh_key.yaml69
-rw-r--r--tests/unit/benchmark/contexts/standalone/ovs_sample_write_to_file.txt1
-rw-r--r--tests/unit/benchmark/contexts/standalone/sriov_sample_password.yaml52
-rw-r--r--tests/unit/benchmark/contexts/standalone/sriov_sample_ssh_key.yaml54
-rw-r--r--tests/unit/benchmark/contexts/standalone/sriov_sample_write_to_file.txt1
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_model.py331
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py377
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_ovsdpdk.py327
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_sriov.py643
-rw-r--r--tests/unit/benchmark/contexts/test_heat.py38
-rw-r--r--tests/unit/benchmark/contexts/test_kubernetes.py65
-rw-r--r--tests/unit/benchmark/contexts/test_standalone.py682
-rw-r--r--tests/unit/benchmark/core/test_task.py47
-rw-r--r--tests/unit/benchmark/runner/test_base.py43
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_util.py4
-rw-r--r--tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml28
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen.py14
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vnf_generic.py96
-rw-r--r--tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml4
-rw-r--r--tests/unit/common/test_process.py46
-rw-r--r--tests/unit/common/test_utils.py16
-rw-r--r--tests/unit/network_services/collector/test_subscriber.py89
-rw-r--r--tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml4
-rw-r--r--tests/unit/network_services/helpers/test_dpdkbindnic_helper.py260
-rw-r--r--tests/unit/network_services/helpers/test_samplevnf_helper.py480
-rw-r--r--tests/unit/network_services/libs/ixia_libs/test_IxNet.py43
-rw-r--r--tests/unit/network_services/nfvi/test_resource.py201
-rw-r--r--tests/unit/network_services/traffic_profile/test_base.py2
-rw-r--r--tests/unit/network_services/traffic_profile/test_fixed.py4
-rw-r--r--tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py131
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_acl.py52
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_binsearch.py14
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_mpls.py10
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_profile.py20
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_ramp.py21
-rw-r--r--tests/unit/network_services/traffic_profile/test_rfc2544.py47
-rw-r--r--tests/unit/network_services/traffic_profile/test_traffic_profile.py42
-rw-r--r--tests/unit/network_services/vnf_generic/test_vnfdgen.py29
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py12
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_base.py4
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py137
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py1245
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py29
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py414
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py4
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py82
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py41
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py155
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py9
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py158
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py58
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py12
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py216
-rw-r--r--tests/unit/orchestrator/test_kubernetes.py8
80 files changed, 4688 insertions, 3316 deletions
diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh
index c2ae4fe7b..e73d7e800 100755
--- a/tests/ci/load_images.sh
+++ b/tests/ci/load_images.sh
@@ -13,17 +13,21 @@
set -e
YARD_IMG_ARCH=amd64
-export YARD_IMG_ARCH
if ! grep -q "Defaults env_keep += \"YARD_IMG_ARCH\"" "/etc/sudoers"; then
echo "Defaults env_keep += \"YARD_IMG_ARCH YARDSTICK_REPO_DIR\"" | sudo tee -a /etc/sudoers
fi
# Look for a compute node, that is online, and check if it is aarch64
-ARCH_SCRIPT="ssh \$(fuel2 node list | awk -F'|' '\$6 ~ /compute/ && \$11 ~ /rue/ {print \$7; exit;}') uname -m 2>/dev/null | grep -q aarch64"
-if [ "$INSTALLER_TYPE" == "fuel" ]; then
- sshpass -p r00tme ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root "${INSTALLER_IP}" "${ARCH_SCRIPT}" && YARD_IMG_ARCH=arm64
+if [ "${INSTALLER_TYPE}" == 'fuel' ]; then
+ ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
+ COMPUTE_ARCH=$(ssh -l ubuntu ${INSTALLER_IP} -i ${SSH_KEY} ${ssh_options} \
+ "sudo salt 'cmp*' grains.get cpuarch --out yaml | awk '{print \$2; exit}'")
+ if [ "${COMPUTE_ARCH}" == 'aarch64' ]; then
+ YARD_IMG_ARCH=arm64
+ fi
fi
+export YARD_IMG_ARCH
HW_FW_TYPE=""
if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
@@ -78,35 +82,8 @@ load_yardstick_image()
echo
echo "========== Loading yardstick cloud image =========="
EXTRA_PARAMS=""
- if [[ "${YARD_IMG_ARCH}" == "arm64" && "${YARD_IMG_AKI}" == "true" ]]; then
- CLOUD_IMAGE="/tmp/${release}-server-cloudimg-${YARD_IMG_ARCH}.tar.gz"
- CLOUD_KERNEL="/tmp/${release}-server-cloudimg-${YARD_IMG_ARCH}-vmlinuz-generic"
- cd /tmp
- if [ ! -f "${CLOUD_IMAGE}" ]; then
- wget "${CLOUD_IMG_URL}"
- fi
- if [ ! -f "${CLOUD_KERNEL}" ]; then
- tar xf "${CLOUD_IMAGE}" "${CLOUD_KERNEL##**/}"
- fi
- create_kernel=$(openstack ${SECURE} image create \
- --public \
- --disk-format qcow2 \
- --container-format bare \
- --file ${CLOUD_KERNEL} \
- yardstick-${release}-kernel)
-
- GLANCE_KERNEL_ID=$(echo "$create_kernel" | awk '/ id / {print $(NF-1)}')
- if [ -z "$GLANCE_KERNEL_ID" ]; then
- echo 'Failed uploading kernel to cloud'.
- exit 1
- fi
-
- command_line="root=/dev/vdb1 console=tty0 console=ttyS0 console=ttyAMA0 rw"
-
- EXTRA_PARAMS="--property kernel_id=$GLANCE_KERNEL_ID --property os_command_line=\"$command_line\""
-
- rm -f -- "${CLOUD_KERNEL}" "${CLOUD_IMAGE}"
- cd "${YARDSTICK_REPO_DIR}"
+ if [[ "${YARD_IMG_ARCH}" == "arm64" ]]; then
+ EXTRA_PARAMS="--property hw_video_model=vga"
fi
# VPP requires guest memory to be backed by large pages
@@ -150,9 +127,11 @@ load_yardstick_image()
load_cirros_image()
{
+ EXTRA_PARAMS=""
if [[ "${YARD_IMG_ARCH}" == "arm64" ]]; then
CIRROS_IMAGE_VERSION="cirros-d161201"
CIRROS_IMAGE_PATH="/home/opnfv/images/cirros-d161201-aarch64-disk.img"
+ EXTRA_PARAMS="--property hw_video_model=vga --property short_id=ubuntu16.04"
else
CIRROS_IMAGE_VERSION="Cirros-0.3.5"
CIRROS_IMAGE_PATH="/home/opnfv/images/cirros-0.3.5-x86_64-disk.img"
@@ -166,12 +145,15 @@ load_cirros_image()
local image_file="${CIRROS_IMAGE_PATH}"
- EXTRA_PARAMS=""
# VPP requires guest memory to be backed by large pages
if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
fi
+ if [[ -n "${HW_FW_TYPE}" ]]; then
+ EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_firmware_type=${HW_FW_TYPE}"
+ fi
+
output=$(openstack ${SECURE} image create \
--disk-format qcow2 \
--container-format bare \
@@ -267,16 +249,14 @@ main()
build_yardstick_image
load_yardstick_image
if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
- sed -i 's/image: {{image}}/image: TestVM/g' tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml
- sed -i 's/image: cirros-0.3.5/image: TestVM/g' samples/ping.yaml
#We have overlapping IP with the real network
for filename in tests/opnfv/test_cases/*; do
sed -i "s/cidr: '10.0.1.0\/24'/cidr: '10.3.1.0\/24'/g" "${filename}"
done
else
- load_cirros_image
load_ubuntu_image
fi
+ load_cirros_image
create_nova_flavor
}
diff --git a/tests/ci/prepare_env.sh b/tests/ci/prepare_env.sh
index c3ee4c76b..44e2694f7 100755
--- a/tests/ci/prepare_env.sh
+++ b/tests/ci/prepare_env.sh
@@ -85,36 +85,32 @@ ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
if [ "$INSTALLER_TYPE" == "fuel" ]; then
#ip_fuel="10.20.0.2"
verify_connectivity $INSTALLER_IP
- echo "Fetching id_rsa file from jump_server $INSTALLER_IP..."
- sshpass -p r00tme scp 2>/dev/null $ssh_options \
- root@${INSTALLER_IP}:~/.ssh/id_rsa /root/.ssh/id_rsa &> /dev/null
- sshpass -p r00tme ssh 2>/dev/null $ssh_options \
- root@${INSTALLER_IP} fuel node>fuel_node
+ 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 fuel node id and ip info according to the CI env
- controller_IDs=($(cat fuel_node|grep controller|awk '{print $1}'))
- compute_IDs=($(cat fuel_node|grep compute|awk '{print $1}'))
- controller_ips=($(cat fuel_node|grep controller|awk '{print $10}'))
- compute_ips=($(cat fuel_node|grep compute|awk '{print $10}'))
+ # 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;
if [[ ${controller_ips[0]} ]]; then
- sed -i "${node_line_num[0]}s/node1/node${controller_IDs[0]}/;s/ip1/${controller_ips[0]}/" $pod_yaml;
+ sed -i "${node_line_num[0]}s/node1/node$((++node_ID))/;s/ip1/${controller_ips[0]}/" $pod_yaml;
fi
if [[ ${controller_ips[1]} ]]; then
- sed -i "${node_line_num[1]}s/node2/node${controller_IDs[1]}/;s/ip2/${controller_ips[1]}/" $pod_yaml;
+ sed -i "${node_line_num[1]}s/node2/node$((++node_ID))/;s/ip2/${controller_ips[1]}/" $pod_yaml;
fi
if [[ ${controller_ips[2]} ]]; then
- sed -i "${node_line_num[2]}s/node3/node${controller_IDs[2]}/;s/ip3/${controller_ips[2]}/" $pod_yaml;
+ sed -i "${node_line_num[2]}s/node3/node$((++node_ID))/;s/ip3/${controller_ips[2]}/" $pod_yaml;
fi
if [[ ${compute_ips[0]} ]]; then
- sed -i "${node_line_num[3]}s/node4/node${compute_IDs[0]}/;s/ip4/${compute_ips[0]}/" $pod_yaml;
+ sed -i "${node_line_num[3]}s/node4/node$((++node_ID))/;s/ip4/${compute_ips[0]}/" $pod_yaml;
fi
if [[ ${compute_ips[1]} ]]; then
- sed -i "${node_line_num[4]}s/node5/node${compute_IDs[1]}/;s/ip5/${compute_ips[1]}/" $pod_yaml;
+ sed -i "${node_line_num[4]}s/node5/node$((++node_ID))/;s/ip5/${compute_ips[1]}/" $pod_yaml;
fi
fi
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml
index a35629f81..81b42dc4d 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml
@@ -14,6 +14,7 @@ description: >
Measure volume storage IOPS, throughput and latency using fio with job file.
{% set directory = directory or "/FIO_Test" %}
+{% set volume_size = volume_size or 200 %}
{% set provider = provider or none %}
{% set physical_network = physical_network or 'physnet1' %}
{% set segmentation_id = segmentation_id or none %}
@@ -53,7 +54,7 @@ context:
floating_ip: true
volume:
name: test-volume
- size: 200
+ size: {{volume_size}}
volume_mountpoint: /dev/vdb
networks:
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
index a37f83b83..3e630caf2 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
@@ -19,7 +19,7 @@ description: >
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set jump_host = jump_host or 'node0' %}
{% set attack_host = attack_host or 'node1' %}
-{% set monitor_time = monitor_time or 180 %}
+{% set monitor_time = monitor_time or 30 %}
scenarios:
-
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml
index 417327cb6..5eb34e56a 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml
@@ -13,15 +13,12 @@ description: >
Test case for TC054 :OpenStack VIP Master Node abnormally shutdown High Availability;
This test case is written by new scenario-based HA testing framework.
-{% set attack_host = attack_host or 'node1' %}
-{% set check_host = check_host or 'node2' %}
{% set jump_host = jump_host or 'node0' %}
+{% set attack_host = attack_host or 'node1' %}
+{% set check_host = check_host or 'node4' %}
{% set file = file or '/etc/yardstick/pod.yaml' %}
-{% set vip_management = vip_management or '192.168.0.2' %}
-{% set vip_public = vip_public or '172.16.0.3' %}
-{% set vip_router_management = vip_router_management or '192.168.0.1' %}
-{% set vip_router_public = vip_router_public or '172.16.0.2' %}
-{% set monitor_time = monitor_time or 180 %}
+{% set vip_public = vip_public or '10.1.0.222' %}
+{% set monitor_time = monitor_time or 30 %}
scenarios:
-
@@ -47,42 +44,6 @@ scenarios:
-
monitor_type: "general-monitor"
monitor_key: "ip-status"
- key: "vip-mgmt-status"
- host: {{check_host}}
- monitor_time: {{monitor_time}}
- monitor_number: 3
- sla:
- max_outage_time: 5
- parameter:
- ip_address: {{vip_management}}
-
- -
- monitor_type: "general-monitor"
- monitor_key: "ip-status"
- key: "vip-routerp-status"
- host: {{check_host}}
- monitor_time: {{monitor_time}}
- monitor_number: 3
- sla:
- max_outage_time: 5
- parameter:
- ip_address: {{vip_router_public}}
-
- -
- monitor_type: "general-monitor"
- monitor_key: "ip-status"
- key: "vip-router-status"
- host: {{check_host}}
- monitor_time: {{monitor_time}}
- monitor_number: 3
- sla:
- max_outage_time: 5
- parameter:
- ip_address: {{vip_router_management}}
-
- -
- monitor_type: "general-monitor"
- monitor_key: "ip-status"
key: "vip-pub"
host: {{check_host}}
monitor_time: {{monitor_time}}
@@ -102,26 +63,10 @@ scenarios:
actionKey: "list-images"
actionType: "monitor"
index: 2
-
- -
- actionKey: "vip-mgmt-status"
- actionType: "monitor"
- index: 3
-
- -
- actionKey: "vip-routerp-status"
- actionType: "monitor"
- index: 4
-
- -
- actionKey: "vip-router-status"
- actionType: "monitor"
- index: 5
-
-
actionKey: "vip-pub"
actionType: "monitor"
- index: 6
+ index: 3
nodes:
{{jump_host}}: {{jump_host}}.LF
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc055.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc055.yaml
index 7e33741b1..10a7a7108 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc055.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc055.yaml
@@ -24,7 +24,6 @@ description: >
scenarios:
-
type: ComputeCapacity
- options:
nodes:
host: {{host}}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml
index 322e2bd76..28aa0b6bd 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml
@@ -81,7 +81,7 @@ scenarios:
action_parameter:
vip_name: {{vip_mgmt}}
return_parameter:
- all: "$vip_mgmt_host"
+ all: "@vip_mgmt_host"
-
operation_type: "general-operation"
@@ -91,7 +91,7 @@ scenarios:
action_parameter:
vip_name: {{vip_vrouter}}
return_parameter:
- all: "$vip_router_host"
+ all: "@vip_router_host"
resultCheckers:
-
@@ -101,7 +101,7 @@ scenarios:
host: {{check_host}}
parameter:
resource_name: "p_rabbitmq-server"
- resource_host: "$vip_mgmt_host"
+ resource_host: "@vip_mgmt_host"
expectedValue: "Masters"
condition: "in"
@@ -112,7 +112,7 @@ scenarios:
host: {{check_host}}
parameter:
resource_name: "p_conntrackd"
- resource_host: "$vip_router_host"
+ resource_host: "@vip_router_host"
expectedValue: "Masters"
condition: "in"
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml
index dc0675bec..7fb7daf62 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml
@@ -48,7 +48,7 @@ scenarios:
sla:
max_outage_time: 5
parameter:
- ip_address: "$floating_ip"
+ ip_address: "@floating_ip"
operations:
-
@@ -58,7 +58,7 @@ scenarios:
action_parameter:
server_name: "tc058"
return_parameter:
- all: "$floating_ip"
+ all: "@floating_ip"
steps:
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc063.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc063.yaml
index 48288ef62..254c214d2 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc063.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc063.yaml
@@ -13,8 +13,8 @@ description: >
Yardstick TC063 config file;
Measure disk size, block size and disk utilization using fdisk and iostat.
-{% set host = host or "node5.yardstick-TC063" %}
{% set file = file or '/etc/yardstick/pod.yaml' %}
+{% set node = node or "node5" %}
scenarios:
-
@@ -22,7 +22,7 @@ scenarios:
options:
test_type: "disk_size"
- host: {{host}}
+ host: {{node}}.yardstick-TC063
runner:
type: Iteration
diff --git a/tests/opnfv/test_suites/opnfv_k8-ovn-lb-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_k8-ovn-lb-noha_daily.yaml
new file mode 100644
index 000000000..207030073
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_k8-ovn-lb-noha_daily.yaml
@@ -0,0 +1,18 @@
+##############################################################################
+# 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
+##############################################################################
+---
+# k8 ovn lb noha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "k8-ovn-lb-noha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc080.yaml
diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-bar-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-bar-ha_daily.yaml
new file mode 100644
index 000000000..35bc0ebd8
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-nosdn-bar-ha_daily.yaml
@@ -0,0 +1,161 @@
+##############################################################################
+# 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
+##############################################################################
+---
+# os-nosdn-bar-ha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-nosdn-bar-ha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc043.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node4.LF","target": "node5.LF"}'
+-
+ file_name: opnfv_yardstick_tc019.yaml
+ constraint:
+ installer: compass,fuel
+ pod: huawei-pod2,ericsson-pod1
+ task_args:
+ huawei-pod2: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
+ ericsson-pod1: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc045.yaml
+ constraint:
+ installer: compass,fuel
+ pod: huawei-pod2,ericsson-pod1
+ task_args:
+ huawei-pod2: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
+ ericsson-pod1: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc046.yaml
+ constraint:
+ installer: fuel
+ task_args:
+ default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc047.yaml
+ constraint:
+ installer: compass,fuel
+ pod: huawei-pod2,ericsson-pod1
+ task_args:
+ huawei-pod2: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
+ ericsson-pod1: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc048.yaml
+ constraint:
+ installer: compass,fuel
+ pod: huawei-pod2,ericsson-pod1
+ task_args:
+ huawei-pod2: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
+ ericsson-pod1: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc049.yaml
+ constraint:
+ installer: fuel
+ task_args:
+ default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc050.yaml
+ constraint:
+ installer: fuel
+ task_args:
+ default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc051.yaml
+ constraint:
+ installer: compass,fuel
+ pod: huawei-pod2,ericsson-pod1
+ task_args:
+ huawei-pod2: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
+ ericsson-pod1: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc052.yaml
+ constraint:
+ installer: fuel
+ task_args:
+ default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc053.yaml
+ constraint:
+ installer: fuel
+ task_args:
+ default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc055.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC055"}'
+-
+ file_name: opnfv_yardstick_tc063.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC063"}'
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
+-
+ file_name: opnfv_yardstick_tc074.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1, huawei-pod2
+ task_args:
+ huawei-pod1: '{"public_network": "ext-net",
+ "StorPerf_ip": "192.168.10.6"}'
+ huawei-pod2: '{"public_network": "ext-net",
+ "StorPerf_ip": "192.168.11.2"}'
+-
+ file_name: opnfv_yardstick_tc075.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node1.LF"}'
+-
+ file_name: opnfv_yardstick_tc027.yaml
+ constraint:
+ installer: compass,fuel
+ pod: huawei-pod1,lf-pod2,ericsson-pod3,ericsson-pod4
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
+ lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
+ ericsson-pod3: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
+ ericsson-pod4: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
+
diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-bar-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-bar-noha_daily.yaml
new file mode 100644
index 000000000..26e92e704
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-nosdn-bar-noha_daily.yaml
@@ -0,0 +1,62 @@
+##############################################################################
+# 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
+##############################################################################
+---
+# os-nosdn-bar-noha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-nosdn-bar-noha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc055.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC055"}'
+-
+ file_name: opnfv_yardstick_tc063.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC063"}'
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
+-
+ file_name: opnfv_yardstick_tc075.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node1.LF"}'
diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml
index dea44c8b3..222987ec5 100644
--- a/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml
+++ b/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml
@@ -158,4 +158,25 @@ test_cases:
lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
ericsson-pod3: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
ericsson-pod4: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
-
+-
+ file_name: opnfv_yardstick_tc076.yaml
+-
+ file_name: opnfv_yardstick_tc079.yaml
+-
+ file_name: opnfv_yardstick_tc073.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
+-
+ file_name: opnfv_yardstick_tc082.yaml
+-
+ file_name: opnfv_yardstick_tc083.yaml
+-
+ file_name: opnfv_yardstick_tc025.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml", "jump_host": "node0", "attack_host": "node1"}'
diff --git a/tests/opnfv/test_suites/opnfv_os-odl-dvr-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-dvr-noha_daily.yaml
new file mode 100644
index 000000000..1f66f9b3e
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-odl-dvr-noha_daily.yaml
@@ -0,0 +1,38 @@
+##############################################################################
+# 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
+##############################################################################
+---
+# os-odl-dvr-noha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-odl-dvr-noha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
diff --git a/tests/opnfv/test_suites/opnfv_os-odl-fdio-dvr-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-fdio-dvr-ha_daily.yaml
new file mode 100644
index 000000000..825fea7c1
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-odl-fdio-dvr-ha_daily.yaml
@@ -0,0 +1,38 @@
+##############################################################################
+# 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
+##############################################################################
+---
+# os-odl-fdio-dvr-ha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-odl-fdio-dvr-ha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
diff --git a/tests/opnfv/test_suites/opnfv_os-odl-fdio-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-fdio-ha_daily.yaml
new file mode 100644
index 000000000..7716b6ccd
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-odl-fdio-ha_daily.yaml
@@ -0,0 +1,38 @@
+##############################################################################
+# 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
+##############################################################################
+---
+# os-odl-fdio-ha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-odl-fdio-ha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
diff --git a/tests/opnfv/test_suites/opnfv_os-odl-fdio-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-fdio-noha_daily.yaml
new file mode 100644
index 000000000..cc8df99b6
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-odl-fdio-noha_daily.yaml
@@ -0,0 +1,38 @@
+##############################################################################
+# 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
+##############################################################################
+---
+# os-odl-fdio-noha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-odl-fdio-noha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
diff --git a/tests/opnfv/test_suites/opnfv_os-odl-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-nofeature-ha_daily.yaml
new file mode 100644
index 000000000..1ab16e5d1
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-odl-nofeature-ha_daily.yaml
@@ -0,0 +1,64 @@
+##############################################################################
+# 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
+##############################################################################
+---
+# os-odl-nofeature-ha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-odl-nofeature-ha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+ constraint:
+ installer: compass
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc055.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC055"}'
+-
+ file_name: opnfv_yardstick_tc063.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC063"}'
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
+-
+ file_name: opnfv_yardstick_tc075.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node1.LF"}'
diff --git a/tests/opnfv/test_suites/opnfv_os-odl-ovs-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-ovs-ha_daily.yaml
new file mode 100644
index 000000000..b5e53b94c
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-odl-ovs-ha_daily.yaml
@@ -0,0 +1,64 @@
+##############################################################################
+# 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
+##############################################################################
+---
+# os-odl-ovs-ha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-odl-ovs-ha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+ constraint:
+ installer: compass
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc055.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC055"}'
+-
+ file_name: opnfv_yardstick_tc063.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC063"}'
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
+-
+ file_name: opnfv_yardstick_tc075.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node1.LF"}'
diff --git a/tests/opnfv/test_suites/opnfv_os-odl-sfc-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-sfc-noha_daily.yaml
new file mode 100644
index 000000000..ba870417d
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-odl-sfc-noha_daily.yaml
@@ -0,0 +1,62 @@
+##############################################################################
+# 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
+##############################################################################
+---
+# os-odl-sfc-noha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-odl-sfc-noha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc055.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC055"}'
+-
+ file_name: opnfv_yardstick_tc063.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC063"}'
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
+-
+ file_name: opnfv_yardstick_tc075.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node1.LF"}'
diff --git a/tests/unit/apiserver/__init__.py b/tests/unit/apiserver/__init__.py
index 1c9d5a672..5e1ed2ea1 100644
--- a/tests/unit/apiserver/__init__.py
+++ b/tests/unit/apiserver/__init__.py
@@ -1,5 +1,6 @@
from __future__ import absolute_import
+import mock
import os
import socket
import unittest
@@ -16,6 +17,10 @@ class APITestCase(unittest.TestCase):
self.db_fd, self.db_path = tempfile.mkstemp()
consts.SQLITE = 'sqlite:///{}'.format(self.db_path)
+ # server calls gethostbyname which takes 4 seconds, and we should mock it anyway
+ self.socket_mock = mock.patch.dict("sys.modules", {"socket": mock.MagicMock(
+ **{"gethostbyname.return_value": "127.0.0.1", "gethostname.return_value": "localhost"})})
+ self.socket_mock.start()
try:
from api import server
except socket.gaierror:
@@ -30,6 +35,7 @@ class APITestCase(unittest.TestCase):
def tearDown(self):
os.close(self.db_fd)
os.unlink(self.db_path)
+ self.socket_mock.stop()
def _post(self, url, data):
headers = {'Content-Type': 'application/json'}
diff --git a/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml b/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml
new file mode 100644
index 000000000..2e501a6af
--- /dev/null
+++ b/tests/unit/benchmark/contexts/standalone/nodes_duplicate_sample.yaml
@@ -0,0 +1,37 @@
+##############################################################################
+# 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
new file mode 100644
index 000000000..0f51dbe63
--- /dev/null
+++ b/tests/unit/benchmark/contexts/standalone/nodes_ovs_dpdk_sample.yaml
@@ -0,0 +1,40 @@
+##############################################################################
+# 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
new file mode 100644
index 000000000..8d50c3aea
--- /dev/null
+++ b/tests/unit/benchmark/contexts/standalone/nodes_sample.yaml
@@ -0,0 +1,33 @@
+##############################################################################
+# 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
new file mode 100644
index 000000000..1c43b8725
--- /dev/null
+++ b/tests/unit/benchmark/contexts/standalone/nodes_sriov_sample.yaml
@@ -0,0 +1,40 @@
+##############################################################################
+# 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/ovs_sample_password.yaml b/tests/unit/benchmark/contexts/standalone/ovs_sample_password.yaml
deleted file mode 100644
index b1da1ea9f..000000000
--- a/tests/unit/benchmark/contexts/standalone/ovs_sample_password.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/standalone/ovs_sample_ssh_key.yaml b/tests/unit/benchmark/contexts/standalone/ovs_sample_ssh_key.yaml
deleted file mode 100644
index 896ec33bb..000000000
--- a/tests/unit/benchmark/contexts/standalone/ovs_sample_ssh_key.yaml
+++ /dev/null
@@ -1,69 +0,0 @@
-##############################################################################
-# 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
-##############################################################################
----
-# 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: trafficgen_1
- role: TrafficGen
- ip: 10.10.10.10
- auth_type: ssh_key
- user: root
- ssh_port: 22
- key_filename: /root/.ssh/id_rsa
- 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
- auth_type: ssh_key
- user: root
- ssh_port: 22
- key_filename: /root/.ssh/id_rsa
- 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/standalone/ovs_sample_write_to_file.txt b/tests/unit/benchmark/contexts/standalone/ovs_sample_write_to_file.txt
deleted file mode 100644
index f0eec86f6..000000000
--- a/tests/unit/benchmark/contexts/standalone/ovs_sample_write_to_file.txt
+++ /dev/null
@@ -1 +0,0 @@
-some content \ No newline at end of file
diff --git a/tests/unit/benchmark/contexts/standalone/sriov_sample_password.yaml b/tests/unit/benchmark/contexts/standalone/sriov_sample_password.yaml
deleted file mode 100644
index 4f60e46d5..000000000
--- a/tests/unit/benchmark/contexts/standalone/sriov_sample_password.yaml
+++ /dev/null
@@ -1,52 +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.10.10.10
- auth_type: password
- user: root
- 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: "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: sriov
- role: Sriov
- ip: 10.10.10.11
- auth_type: password
- user: root
- password: password
- vf_macs:
- - "00:00:00:71:7d:25"
- - "00:00:00:71:7d:26"
- 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/standalone/sriov_sample_ssh_key.yaml b/tests/unit/benchmark/contexts/standalone/sriov_sample_ssh_key.yaml
deleted file mode 100644
index faa496771..000000000
--- a/tests/unit/benchmark/contexts/standalone/sriov_sample_ssh_key.yaml
+++ /dev/null
@@ -1,54 +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.10.10.10
- auth_type: ssh_key
- user: root
- ssh_port: 22
- key_filename: /root/.ssh/id_rsa
- 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: sriov
- role: Sriov
- ip: 10.10.10.11
- auth_type: ssh_key
- user: root
- ssh_port: 22
- key_filename: /root/.ssh/id_rsa
- vf_macs:
- - "00:00:00:71:7d:25"
- - "00:00:00:71:7d:26"
- 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/standalone/sriov_sample_write_to_file.txt b/tests/unit/benchmark/contexts/standalone/sriov_sample_write_to_file.txt
deleted file mode 100644
index f0eec86f6..000000000
--- a/tests/unit/benchmark/contexts/standalone/sriov_sample_write_to_file.txt
+++ /dev/null
@@ -1 +0,0 @@
-some content \ No newline at end of file
diff --git a/tests/unit/benchmark/contexts/standalone/test_model.py b/tests/unit/benchmark/contexts/standalone/test_model.py
new file mode 100644
index 000000000..ddbc1a4bb
--- /dev/null
+++ b/tests/unit/benchmark/contexts/standalone/test_model.py
@@ -0,0 +1,331 @@
+#!/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.contexts.standalone.model
+
+
+from __future__ import absolute_import
+import os
+import unittest
+import errno
+import mock
+
+from yardstick.common import constants as consts
+from yardstick.benchmark.contexts.standalone.model import Libvirt
+from yardstick.benchmark.contexts.standalone.model import StandaloneContextHelper
+from yardstick.benchmark.contexts.standalone import model
+from yardstick.network_services.utils import PciAddress
+
+
+class ModelLibvirtTestCase(unittest.TestCase):
+
+ 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
+ result = Libvirt.check_if_vm_exists_and_delete("vm_0", ssh_mock)
+ self.assertIsNone(result)
+
+ 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
+ result = Libvirt.virsh_create_vm(ssh_mock, "vm_0")
+ self.assertIsNone(result)
+
+ 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
+ result = Libvirt.virsh_destroy_vm("vm_0", ssh_mock)
+ self.assertIsNone(result)
+
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.ET')
+ def test_add_interface_address(self, mock_et):
+ pci_address = PciAddress.parse_address("0000:00:04.0", multi_line=True)
+ result = Libvirt.add_interface_address("<interface/>", pci_address)
+ self.assertIsNotNone(result)
+
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.Libvirt.add_interface_address')
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.ET')
+ def test_add_ovs_interfaces(self, mock_et, mock_add_interface_address):
+ pci_address = PciAddress.parse_address("0000:00:04.0", multi_line=True)
+ result = Libvirt.add_ovs_interface("/usr/local", 0, "0000:00:04.0",
+ "00:00:00:00:00:01", "xml")
+ self.assertIsNone(result)
+
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.Libvirt.add_interface_address')
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.ET')
+ def test_add_sriov_interfaces(self, mock_et, mock_add_interface_address):
+ pci_address = PciAddress.parse_address("0000:00:04.0", multi_line=True)
+ result = Libvirt.add_sriov_interfaces("0000:00:05.0", "0000:00:04.0",
+ "00:00:00:00:00:01", "xml")
+ self.assertIsNone(result)
+
+ 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 = Libvirt.create_snapshot_qemu(ssh_mock, "0", "ubuntu.img")
+ self.assertEqual(image, result)
+
+ @mock.patch("yardstick.benchmark.contexts.standalone.model.Libvirt.create_snapshot_qemu")
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.open')
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.write_file')
+ def test_build_vm_xml(self, mock_open, mock_write_file, mock_create_snapshot_qemu):
+ 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 = Libvirt.build_vm_xml(ssh_mock, {}, "test", "vm_0", 0)
+ self.assertEqual(status[0], result[0])
+
+ def test_split_cpu_list(self):
+ result = Libvirt.split_cpu_list("1,2,3")
+ self.assertEqual(result, [1, 2, 3])
+
+ def test_get_numa_nodes(self):
+ result = Libvirt.get_numa_nodes()
+ self.assertIsNotNone(result)
+
+ 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
+ status = Libvirt.update_interrupts_hugepages_perf(ssh_mock)
+ self.assertIsNone(status)
+
+ @mock.patch("yardstick.benchmark.contexts.standalone.model.Libvirt.get_numa_nodes")
+ @mock.patch("yardstick.benchmark.contexts.standalone.model.Libvirt.update_interrupts_hugepages_perf")
+ def test_pin_vcpu_for_perf(self, mock_update_interrupts_hugepages_perf, mock_get_numa_nodes):
+ 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_get_numa_nodes.return_value = {'1': [18, 19, 20, 21], '0': [0, 1, 2, 3]}
+ status = Libvirt.pin_vcpu_for_perf(ssh_mock, "vm_0", 4)
+ self.assertIsNone(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 = 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
+ status = StandaloneContextHelper.install_req_libs(ssh_mock)
+ self.assertIsNone(status)
+
+ 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
+ status = StandaloneContextHelper.get_kernel_module(ssh_mock, "05:00.0", None)
+ self.assertEqual(status, "i40e")
+
+ @mock.patch('yardstick.benchmark.contexts.standalone.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"
+ status = StandaloneContextHelper.get_nic_details(ssh_mock, self.NETWORKS, "dpdk-devbind.py")
+ self.assertIsNotNone(status)
+
+ 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
+ status = StandaloneContextHelper.get_virtual_devices(ssh_mock, "0000:00:05.0")
+ self.assertIsNotNone(status)
+
+ 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 = StandaloneContextHelper.get_mac_address()
+ self.assertIsNotNone(status)
+
+ @mock.patch('yardstick.ssh.SSH')
+ def test_get_mgmt_ip(self, mock_ssh):
+ 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
+ status = 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, mock_ssh):
+ 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
+
+ model.WAIT_FOR_BOOT = 0
+ status = 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, mock_ssh):
+ self.ovs_deploy.helper = mock.Mock()
+ self.assertIsNone(self.ovs_deploy.prerequisite())
+
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.os')
+ def test_prerequisite(self, mock_ssh):
+ 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
new file mode 100644
index 000000000..5d1b0421c
--- /dev/null
+++ b/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
@@ -0,0 +1,377 @@
+# 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 errno
+import mock
+
+from yardstick.common import constants as consts
+from yardstick.benchmark.contexts.standalone import ovs_dpdk
+from yardstick.network_services.utils import PciAddress
+
+
+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.assertEqual(self.ovs_dpdk.first_run, True)
+
+ 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, mock_ssh):
+ 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 = 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={})
+ self.assertIsNone(self.ovs_dpdk.deploy())
+
+ @mock.patch('yardstick.benchmark.contexts.standalone.ovs_dpdk.Libvirt')
+ @mock.patch('yardstick.ssh.SSH')
+ def test_undeploy(self, mock_ssh, 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.return_value = ssh_mock
+ self.ovs_dpdk.vm_deploy = False
+ self.assertIsNone(self.ovs_dpdk.undeploy())
+
+ 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 = ['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.ovs_dpdk.Libvirt')
+ def test__enable_interfaces(self, mock_add_ovs_interface):
+ 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_server, 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_ovsdpdk.py b/tests/unit/benchmark/contexts/standalone/test_ovsdpdk.py
deleted file mode 100644
index 1d68384c9..000000000
--- a/tests/unit/benchmark/contexts/standalone/test_ovsdpdk.py
+++ /dev/null
@@ -1,327 +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.
-
-from __future__ import absolute_import
-
-import os
-import unittest
-
-import mock
-
-from yardstick.benchmark.contexts.standalone import ovsdpdk
-
-NIC_INPUT = {
- 'interface': {},
- 'vports_mac': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e'}
-DRIVER = "i40e"
-NIC_DETAILS = {
- 'interface': {0: 'enp6s0f0', 1: 'enp6s0f1'},
- 'vports_mac': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e'}
-
-CORRECT_FILE_PATH = "/etc/yardstick/nodes/pod_ovs.yaml"
-WRONG_FILE_PATH = "/etc/yardstick/wrong.yaml"
-SAMPLE_FILE = "ovs_sample_write_to_file.txt"
-
-OVS = [{
- 'auth_type': 'ssh_key',
- 'name': 'ovs',
- 'ssh_port': 22,
- 'ip': '10.10.10.11',
- 'key_filename': '/root/.ssh/id_rsa',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'vpath': '/usr/local/',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- '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',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
-OVS_PASSWORD = [{
- 'auth_type': 'password',
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.10.10.11',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- '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',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
-#vfnic = "i40evf"
-PCIS = ['0000:06:00.0', '0000:06:00.1']
-
-
-class OvsdpdkTestCase(unittest.TestCase):
-
- NODES_SAMPLE_SSH = "ovs_sample_ssh_key.yaml"
- NODES_SAMPLE_PASSWORD = "ovs_sample_password.yaml"
-
- def setUp(self):
- self.test_context = ovsdpdk.Ovsdpdk()
-
- def test_construct(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.ovs, [])
- self.assertFalse(self.test_context.vm_deploy)
- self.assertTrue(self.test_context.first_run)
- self.assertEqual(self.test_context.user, "")
- self.assertEqual(self.test_context.ssh_ip, "")
- self.assertEqual(self.test_context.passwd, "")
- self.assertEqual(self.test_context.ssh_port, "")
- self.assertEqual(self.test_context.auth_type, "")
-
- def test_init(self):
- self.test_context.parse_pod_and_get_data = mock.Mock()
- self.test_context.file_path = CORRECT_FILE_PATH
- self.test_context.init()
- self.assertIsNone(self.test_context.init())
-
- def test_successful_init_with_ssh(self):
- CORRECT_FILE_PATH = self._get_file_abspath(self.NODES_SAMPLE_SSH)
- self.test_context.parse_pod_and_get_data(CORRECT_FILE_PATH)
-
- def test_successful_init_with_password(self):
- CORRECT_FILE_PATH = self._get_file_abspath(self.NODES_SAMPLE_PASSWORD)
- self.test_context.parse_pod_and_get_data(CORRECT_FILE_PATH)
-
- def test_unsuccessful_init(self):
- self.assertRaises(
- IOError,
- lambda: self.test_context.parse_pod_and_get_data(WRONG_FILE_PATH))
-
- def test_ssh_connection(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
-
- @mock.patch('yardstick.network_services.utils.provision_tool', return_value="b")
- def test_ssh_connection(self, mock_prov):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(1, "b", ""))
- ssh.return_value = ssh_mock
- mock_prov.provision_tool = mock.Mock()
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.connection = ssh_mock
- ovs_obj.ovs = OVS_PASSWORD
- self.assertIsNone(ovs_obj.ssh_remote_machine())
-
- @mock.patch('yardstick.network_services.utils.provision_tool', return_value="b")
- def test_ssh_connection_ssh_key(self, mock_prov):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(1, "b", ""))
- ssh.return_value = ssh_mock
- mock_prov.provision_tool = mock.Mock()
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.connection = ssh_mock
- ovs_obj.ovs = OVS
- ovs_obj.key_filename = '/root/.ssh/id_rsa'
- self.assertIsNone(ovs_obj.ssh_remote_machine())
-
- def test_get_nic_details(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "eth0 eth1", ""))
- ssh.return_value = ssh_mock
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.ovs = OVS
- ovs_obj.connection = ssh_mock
- self.assertIsNotNone(ovs_obj.get_nic_details())
-
- 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=(0, {}, ""))
- ssh.return_value = ssh_mock
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.first_run = True
- ovs_obj.connection = ssh_mock
- self.assertIsNone(ovs_obj.install_req_libs())
-
- 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, {}, ""))
- ssh.return_value = ssh_mock
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.connection = ssh_mock
- ovs_obj.ovs = OVS
- self.assertIsNone(ovs_obj.setup_ovs({"eth0 eth1"}))
-
- 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, {}, ""))
- ssh.return_value = ssh_mock
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.connection = ssh_mock
- ovs_obj.ovs = OVS
- self.assertIsNone(ovs_obj.start_ovs_serverswitch())
-
- def test_setup_ovs_bridge(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.connection = ssh_mock
- ovs_obj.ovs = OVS
- self.assertIsNone(ovs_obj.setup_ovs_bridge())
-
- def test_add_oflows(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.connection = ssh_mock
- ovs_obj.ovs = OVS
- self.assertIsNone(ovs_obj.add_oflows())
-
- def test_setup_ovs_context_vm_already_present(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.connection = ssh_mock
- ovs_obj.ovs = OVS
- mock_ovs = mock.Mock()
- ssh_mock.put = mock.Mock()
- ovs_obj.check_output = mock.Mock(return_value=(0, "vm1"))
- with mock.patch("yardstick.benchmark.contexts.standalone.ovsdpdk.time"):
- self.assertIsNone(ovs_obj.setup_ovs_context(PCIS, NIC_DETAILS, DRIVER))
-
- @mock.patch(
- 'yardstick.benchmark.contexts.standalone.ovsdpdk',
- return_value="Domain vm1 created from /tmp/vm_ovs.xml")
- def test_is_vm_created(self, NIC_INPUT):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh_mock.put = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- mock_ovs = mock.Mock()
- ret_create = mock.Mock()
- pcis = NIC_DETAILS['pci']
- driver = NIC_DETAILS['phy_driver']
- self.assertIsNotNone(
- mock_ovs.ovs_obj.setup_ovs_context(
- pcis,
- NIC_DETAILS,
- driver))
-
- def test_check_output(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- cmd = "command"
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.connection = ssh_mock
- self.assertIsNotNone(ovs_obj.check_output(cmd, None))
-
- def test_split_cpu_list_available(self):
- with mock.patch("itertools.chain") as iter1:
- iter1 = mock.Mock()
- print("{0}".format(iter1))
- ovs_obj = ovsdpdk.Ovsdpdk()
- self.assertIsNotNone(ovs_obj.split_cpu_list('0,5'))
-
- def test_split_cpu_list_null(self):
- with mock.patch("itertools.chain") as iter1:
- iter1 = mock.Mock()
- print("{0}".format(iter1))
- ovs_obj = ovsdpdk.Ovsdpdk()
- self.assertEqual(ovs_obj.split_cpu_list([]), [])
-
- def test_destroy_vm_successful(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.connection = ssh_mock
- ovs_obj.ovs = OVS
- ovs_obj.check_output = mock.Mock(return_value=(0, "vm1"))
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "0 i40e"))
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "0 i40e"))
- self.assertIsNone(ovs_obj.destroy_vm())
-
- def test_destroy_vm_unsuccessful(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- ovs_obj = ovsdpdk.Ovsdpdk()
- ovs_obj.connection = ssh_mock
- ovs_obj.ovs = OVS
- ovs_obj.check_output = mock.Mock(return_value=(1, {}))
- self.assertIsNone(ovs_obj.destroy_vm())
-
- def test_read_from_file(self):
- CORRECT_FILE_PATH = self._get_file_abspath(self.NODES_SAMPLE_PASSWORD)
- ovs_obj = ovsdpdk.Ovsdpdk()
- self.assertIsNotNone(ovs_obj.read_from_file(CORRECT_FILE_PATH))
-
- def test_write_to_file(self):
- ovs_obj = ovsdpdk.Ovsdpdk()
- self.assertIsNone(ovs_obj.write_to_file(SAMPLE_FILE, "some content"))
-
- 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
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/unit/benchmark/contexts/standalone/test_sriov.py b/tests/unit/benchmark/contexts/standalone/test_sriov.py
index ea72e1bab..50ae5fe13 100644
--- a/tests/unit/benchmark/contexts/standalone/test_sriov.py
+++ b/tests/unit/benchmark/contexts/standalone/test_sriov.py
@@ -12,412 +12,311 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import absolute_import
+# Unittest for yardstick.benchmark.contexts.standalone.standalonesriov
+from __future__ import absolute_import
import os
import unittest
-
+import errno
import mock
+from yardstick.common import constants as consts
from yardstick.benchmark.contexts.standalone import sriov
-
-NIC_INPUT = {
- 'interface': {},
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e'}
-DRIVER = "i40e"
-NIC_DETAILS = {
- 'interface': {0: 'enp6s0f0', 1: 'enp6s0f1'},
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e'}
-
-CORRECT_FILE_PATH = "/etc/yardstick/nodes/pod_sriov.yaml"
-WRONG_FILE_PATH = "/etc/yardstick/wrong.yaml"
-SAMPLE_FILE = "sriov_sample_write_to_file.txt"
-
-SRIOV = [{
- 'auth_type': 'ssh_key',
- 'name': 'sriov',
- 'ssh_port': 22,
- 'ip': '10.10.10.11',
- 'key_filename': '/root/.ssh/id_rsa',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
-SRIOV_PASSWORD = [{
- 'auth_type': 'password',
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.10.10.11',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
-vfnic = "i40evf"
-PCIS = ['0000:06:00.0', '0000:06:00.1']
-
-
-class SriovTestCase(unittest.TestCase):
-
- NODES_SAMPLE_SSH = "sriov_sample_ssh_key.yaml"
- NODES_SAMPLE_PASSWORD = "sriov_sample_password.yaml"
+from yardstick.network_services.utils import PciAddress
+
+
+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.test_context = sriov.Sriov()
-
- def test_construct(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.sriov, [])
- self.assertFalse(self.test_context.vm_deploy)
- self.assertTrue(self.test_context.first_run)
- self.assertEqual(self.test_context.user, "")
- self.assertEqual(self.test_context.ssh_ip, "")
- self.assertEqual(self.test_context.passwd, "")
- self.assertEqual(self.test_context.ssh_port, "")
- self.assertEqual(self.test_context.auth_type, "")
+ 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):
+ self.sriov.helper = mock_helper
+ self.sriov.vnf_node = mock_server
+ self.assertIsNone(self.sriov.file_path)
+ self.assertEqual(self.sriov.first_run, True)
def test_init(self):
- self.test_context.parse_pod_and_get_data = mock.Mock()
- self.test_context.file_path = CORRECT_FILE_PATH
- self.test_context.init()
- self.assertIsNone(self.test_context.init())
-
- def test_successful_init_with_ssh(self):
- CORRECT_FILE_PATH = self._get_file_abspath(self.NODES_SAMPLE_SSH)
- self.test_context.parse_pod_and_get_data(CORRECT_FILE_PATH)
-
- def test_successful_init_with_password(self):
- CORRECT_FILE_PATH = self._get_file_abspath(self.NODES_SAMPLE_PASSWORD)
- self.test_context.parse_pod_and_get_data(CORRECT_FILE_PATH)
-
- def test_unsuccessful_init(self):
- self.assertRaises(
- IOError,
- lambda: self.test_context.parse_pod_and_get_data(WRONG_FILE_PATH))
-
- @mock.patch('yardstick.network_services.utils.provision_tool', return_value="a")
- def test_ssh_connection(self, mock_prov):
- 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
- mock_prov.provision_tool = mock.Mock()
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- sriov_obj.sriov = SRIOV_PASSWORD
- self.assertIsNone(sriov_obj.ssh_remote_machine())
-
- @mock.patch('yardstick.network_services.utils.provision_tool', return_value="a")
- def test_ssh_connection_ssh_key(self, mock_prov):
- 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
- mock_prov.provision_tool = mock.Mock()
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- sriov_obj.sriov = SRIOV
- sriov_obj.key_filename = '/root/.ssh/id_rsa'
- self.assertIsNone(sriov_obj.ssh_remote_machine())
-
- def test_get_nic_details(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "eth0 eth1", ""))
- ssh.return_value = ssh_mock
- sriov_obj = sriov.Sriov()
- sriov_obj.sriov = SRIOV
- sriov_obj.connection = ssh_mock
- self.assertIsNotNone(sriov_obj.get_nic_details())
+ self.sriov.helper.parse_pod_file = mock.Mock(return_value=[{}, {}, {}])
+ self.assertIsNone(self.sriov.init(self.ATTRS))
- def test_install_req_libs(self):
+ @mock.patch('yardstick.ssh.SSH')
+ def test_deploy(self, mock_ssh):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
+ mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
- sriov_obj = sriov.Sriov()
- sriov_obj.first_run = True
- sriov_obj.connection = ssh_mock
- self.assertIsNone(sriov_obj.install_req_libs())
- def test_configure_nics_for_sriov(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- nic_details = {
- 'interface': {0: 'enp6s0f0', 1: 'enp6s0f1'},
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e',
- 'vf_pci': [{}, {}]}
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock((DRIVER), return_value=(0, "0 driver", ""))
- ssh.return_value = ssh_mock
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- for i in range(len(NIC_DETAILS['pci'])):
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- ssh_mock.execute = \
- mock.Mock(return_value=(
- 0,
- "{'0':'06:02:00','1':'06:06:00'}",
- ""))
- sriov_obj.get_vf_datas = mock.Mock(return_value={
- '0000:06:00.0': '0000:06:02.0'})
- nic_details['vf_pci'][i] = sriov_obj.get_vf_datas.return_value
- vf_pci = [[], []]
- vf_pci[i] = sriov_obj.get_vf_datas.return_value
- with mock.patch("yardstick.benchmark.contexts.standalone.sriov.time"):
- self.assertIsNotNone(sriov_obj.configure_nics_for_sriov(DRIVER, NIC_DETAILS))
-
- def test_setup_sriov_context(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- nic_details = {
- 'interface': {0: 'enp6s0f0', 1: 'enp6s0f1'},
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e',
- 'vf_pci': [{'vf_pci': '06:02.00'}, {'vf_pci': '06:06.00'}]}
- vf = [{'vf_pci': '06:02.00'}, {'vf_pci': '06:06.00'}]
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- sriov_obj.sriov = SRIOV
- blacklist = "/etc/modprobe.d/blacklist.conf"
- self.assertEqual(vfnic, "i40evf")
- mock_sriov = mock.Mock()
- mock_sriov.sriov_obj.read_from_file(blacklist)
- sriov_obj.read_from_file = mock.Mock(
- return_value="some random text")
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- sriov_obj.configure_nics_for_sriov = mock.Mock(
- return_value=nic_details)
- nic_details = sriov_obj.configure_nics_for_sriov.return_value
- self.assertEqual(vf, nic_details['vf_pci'])
- vf = [
- {'vf_pci': '06:02.00', 'mac': '00:00:00:00:00:0a'},
- {'vf_pci': '06:06.00', 'mac': '00:00:00:00:00:0b'}]
- sriov_obj.add_sriov_interface = mock.Mock()
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh_mock.put = mock.Mock()
- sriov_obj.check_output = mock.Mock(return_value=(1, {}))
- with mock.patch("yardstick.benchmark.contexts.standalone.sriov.time"):
- self.assertIsNone(sriov_obj.setup_sriov_context(PCIS, nic_details, DRIVER))
+ self.sriov.vm_deploy = False
+ self.assertIsNone(self.sriov.deploy())
- def test_setup_sriov_context_vm_already_present(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- nic_details = {
- 'interface': {0: 'enp6s0f0', 1: 'enp6s0f1'},
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e',
- 'vf_pci': [{'vf_pci': '06:02.00'}, {'vf_pci': '06:06.00'}]}
- vf = [{'vf_pci': '06:02.00'}, {'vf_pci': '06:06.00'}]
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- sriov_obj.sriov = SRIOV
- blacklist = "/etc/modprobe.d/blacklist.conf"
- self.assertEqual(vfnic, "i40evf")
- mock_sriov = mock.Mock()
- mock_sriov.sriov_obj.read_from_file(blacklist)
- sriov_obj.read_from_file = mock.Mock(
- return_value="some random text")
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- sriov_obj.configure_nics_for_sriov = mock.Mock(
- return_value=nic_details)
- nic_details = sriov_obj.configure_nics_for_sriov.return_value
- self.assertEqual(vf, nic_details['vf_pci'])
- vf = [
- {'vf_pci': '06:02.00', 'mac': '00:00:00:00:00:0a'},
- {'vf_pci': '06:06.00', 'mac': '00:00:00:00:00:0b'}]
- sriov_obj.add_sriov_interface = mock.Mock()
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh_mock.put = mock.Mock()
- sriov_obj.check_output = mock.Mock(return_value=(0, "vm1"))
- with mock.patch("yardstick.benchmark.contexts.standalone.sriov.time"):
- self.assertIsNone(sriov_obj.setup_sriov_context(PCIS, nic_details, DRIVER))
-
- @mock.patch(
- 'yardstick.benchmark.contexts.standalone.sriov',
- return_value="Domain vm1 created from /tmp/vm_sriov.xml")
- def test_is_vm_created(self, NIC_INPUT):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- mock_sriov = mock.Mock()
- pcis = NIC_DETAILS['pci']
- driver = NIC_DETAILS['phy_driver']
- self.assertIsNotNone(
- mock_sriov.sriov_obj.setup_sriov_context(
- pcis,
- NIC_DETAILS,
- driver))
-
- def test_add_sriov_interface(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh.return_value = ssh_mock
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- with mock.patch("xml.etree.ElementTree.parse") as parse:
- with mock.patch("re.search") as re:
- with mock.patch("xml.etree.ElementTree.SubElement") \
- as elem:
- parse = mock.Mock(return_value="root")
- re = mock.Mock()
- elem = mock.Mock()
- print("{0} {1} {2}".format(parse, re, elem))
- self.assertIsNone(sriov_obj.add_sriov_interface(
- 0,
- "0000:06:02.0",
- "00:00:00:00:00:0a",
- "/tmp/vm_sriov.xml"))
-
- def test_get_virtual_devices(self):
+ 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('yardstick.ssh.SSH')
+ @mock.patch('yardstick.benchmark.contexts.standalone.sriov.Libvirt')
+ def test_undeploy(self, mock_libvirt, mock_ssh):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
+ mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- pci_out = " \
- PCI_CLASS=20000 \
- PCI_ID=8086:154C \
- PCI_SUBSYS_ID=8086:0000 \
- PCI_SLOT_NAME=0000:06:02.0 \
- MODALIAS= \
- pci:v00008086d0000154Csv00008086sd00000000bc02sc00i00"
- pci = "0000:06:00.0"
- sriov_obj.check_output = mock.Mock(return_value=(0, pci_out))
- with mock.patch("re.search") as re:
- re = mock.Mock(return_value="a")
- print("{0}".format(re))
- self.assertIsNotNone(sriov_obj.get_virtual_devices(pci))
-
- def test_get_vf_datas(self):
+
+ self.sriov.vm_deploy = False
+ self.assertIsNone(self.sriov.undeploy())
+
+ self.sriov.vm_deploy = True
+ self.sriov.connection = ssh_mock
+ 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, {}, ""))
+ mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- sriov_obj.get_virtual_devices = mock.Mock(
- return_value={'0000:06:00.0': '0000:06:02.0'})
- with mock.patch("re.search") as re:
- re = mock.Mock()
- print("{0}".format(re))
- self.assertIsNotNone(sriov_obj.get_vf_datas(
- 'vf_pci',
- {'0000:06:00.0': '0000:06:02.0'},
- "00:00:00:00:00:0a"))
-
- def test_check_output(self):
+ 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('yardstick.benchmark.contexts.standalone.sriov.Libvirt')
+ def test__enable_interfaces(self, mock_libvirt):
with mock.patch("yardstick.ssh.SSH") as ssh:
- cmd = "command"
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
+ mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- self.assertIsNotNone(sriov_obj.check_output(cmd, None))
-
- def test_split_cpu_list_available(self):
- with mock.patch("itertools.chain") as iter1:
- iter1 = mock.Mock()
- print("{0}".format(iter1))
- sriov_obj = sriov.Sriov()
- self.assertIsNotNone(sriov_obj.split_cpu_list('0,5'))
-
- def test_split_cpu_list_null(self):
- with mock.patch("itertools.chain") as iter1:
- iter1 = mock.Mock()
- print("{0}".format(iter1))
- sriov_obj = sriov.Sriov()
- self.assertEqual(sriov_obj.split_cpu_list([]), [])
-
- def test_destroy_vm_successful(self):
+ 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.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):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
+ mock.Mock(return_value=(0, "a", ""))
+ ssh_mock.put = \
+ mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- sriov_obj.sriov = SRIOV
- sriov_obj.check_output = mock.Mock(return_value=(0, "vm1"))
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "0 i40e"))
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "0 i40e"))
- self.assertIsNone(sriov_obj.destroy_vm())
-
- def test_destroy_vm_unsuccessful(self):
+ 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, {}, ""))
+ mock.Mock(return_value=(0, "a", ""))
+ ssh_mock.put = \
+ mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
- sriov_obj = sriov.Sriov()
- sriov_obj.connection = ssh_mock
- sriov_obj.sriov = SRIOV
- sriov_obj.check_output = mock.Mock(return_value=(1, {}))
- self.assertIsNone(sriov_obj.destroy_vm())
-
- def test_read_from_file(self):
- CORRECT_FILE_PATH = self._get_file_abspath(self.NODES_SAMPLE_PASSWORD)
- sriov_obj = sriov.Sriov()
- self.assertIsNotNone(sriov_obj.read_from_file(CORRECT_FILE_PATH))
-
- def test_write_to_file(self):
- sriov_obj = sriov.Sriov()
- self.assertIsNone(sriov_obj.write_to_file(SAMPLE_FILE, "some content"))
-
- 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
-
-if __name__ == '__main__':
- unittest.main()
+ 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/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py
index 582d9ab99..223d64060 100644
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ b/tests/unit/benchmark/contexts/test_heat.py
@@ -182,11 +182,17 @@ class HeatContextTestCase(unittest.TestCase):
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'}),
+ ('a', [{'stack_name': 'b', 'port': 'port_a'}]),
+ ('c', [{'stack_name': 'd', 'port': 'port_c'},
+ {'stack_name': 'e', 'port': 'port_f'}]),
])
expected = {
@@ -195,6 +201,7 @@ class HeatContextTestCase(unittest.TestCase):
"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',
@@ -205,7 +212,7 @@ class HeatContextTestCase(unittest.TestCase):
}
self.test_context.add_server_port(server)
self.assertEqual(server.private_ip, '10.20.30.45')
- self.assertEqual(len(server.interfaces), 2)
+ self.assertEqual(len(server.interfaces), 3)
self.assertDictEqual(server.interfaces['port_a'], expected)
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
@@ -221,19 +228,20 @@ class HeatContextTestCase(unittest.TestCase):
mock_os.path.exists.return_value = True
self.assertIsNone(self.test_context.undeploy())
- def test__get_server_found_dict(self):
+ @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 = 'key_file'
+ 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 = 'key_filename'
+ 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'
@@ -258,11 +266,11 @@ class HeatContextTestCase(unittest.TestCase):
}
result = self.test_context._get_server(attr_name)
self.assertEqual(result['user'], 'bot')
- self.assertIsNotNone(result['key_filename'])
self.assertEqual(result['ip'], '127.0.0.1')
self.assertEqual(result['private_ip'], '10.0.0.1')
- def test__get_server_found_dict_no_attrs(self):
+ @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.
@@ -295,13 +303,13 @@ class HeatContextTestCase(unittest.TestCase):
}
result = self.test_context._get_server(attr_name)
self.assertEqual(result['user'], 'bot')
- self.assertIsNotNone(result['key_filename'])
# 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)
- def test__get_server_found_not_dict(self):
+ @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
@@ -333,12 +341,12 @@ class HeatContextTestCase(unittest.TestCase):
attr_name = 'baz3'
result = self.test_context._get_server(attr_name)
self.assertEqual(result['user'], 'zab')
- self.assertIsNotNone(result['key_filename'])
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)
- def test__get_server_none_found_not_dict(self):
+ @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
@@ -371,7 +379,8 @@ class HeatContextTestCase(unittest.TestCase):
result = self.test_context._get_server(attr_name)
self.assertIsNone(result)
- def test__get_server_not_found_dict(self):
+ @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
@@ -406,7 +415,8 @@ class HeatContextTestCase(unittest.TestCase):
result = self.test_context._get_server(attr_name)
self.assertIsNone(result)
- def test__get_server_not_found_not_dict(self):
+ @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
diff --git a/tests/unit/benchmark/contexts/test_kubernetes.py b/tests/unit/benchmark/contexts/test_kubernetes.py
index 4976a9fe0..3a926f85c 100644
--- a/tests/unit/benchmark/contexts/test_kubernetes.py
+++ b/tests/unit/benchmark/contexts/test_kubernetes.py
@@ -47,13 +47,15 @@ class KubernetesTestCase(unittest.TestCase):
# 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_ssh,
+ mock_delete_services):
k8s_context = KubernetesContext()
k8s_context.init(context_cfg)
@@ -61,7 +63,9 @@ class KubernetesTestCase(unittest.TestCase):
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))
@@ -70,7 +74,8 @@ class KubernetesTestCase(unittest.TestCase):
mock_set_ssh_key,
mock_create_rcs,
mock_get_rc_pods,
- mock_wait_until_running):
+ mock_wait_until_running,
+ mock_create_services):
k8s_context = KubernetesContext()
k8s_context.init(context_cfg)
@@ -78,6 +83,7 @@ class KubernetesTestCase(unittest.TestCase):
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)
@@ -106,14 +112,39 @@ class KubernetesTestCase(unittest.TestCase):
mock_read_pod_status.return_value = 'Running'
k8s_context._wait_until_running()
- @mock.patch('{}.k8s_utils.get_pod_list'.format(prefix))
- def test_get_server(self, mock_get_pod_list):
+ @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_pod_list.return_value.items = []
+ 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.assertIsNone(server)
+ self.assertIsNotNone(server)
@mock.patch('{}.KubernetesContext._create_rc'.format(prefix))
def test_create_rcs(self, mock_create_rc):
@@ -143,6 +174,28 @@ class KubernetesTestCase(unittest.TestCase):
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()
diff --git a/tests/unit/benchmark/contexts/test_standalone.py b/tests/unit/benchmark/contexts/test_standalone.py
deleted file mode 100644
index b1402a1c9..000000000
--- a/tests/unit/benchmark/contexts/test_standalone.py
+++ /dev/null
@@ -1,682 +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.contexts.standalone
-
-from __future__ import absolute_import
-
-import os
-import unittest
-
-import mock
-
-from yardstick.benchmark.contexts import standalone
-from yardstick.benchmark.contexts.standalone import ovsdpdk, sriov
-
-MOCKS = {
- 'yardstick.benchmark.contexts': mock.MagicMock(),
- 'yardstick.benchmark.contexts.standalone.sriov': mock.MagicMock(),
- 'yardstick.benchmark.contexts.standalone.ovsdpdk': mock.MagicMock(),
- 'yardstick.benchmark.contexts.standalone': mock.MagicMock(),
-}
-
-
-@mock.patch('yardstick.benchmark.contexts.standalone.ovsdpdk.time')
-@mock.patch('yardstick.benchmark.contexts.standalone.time')
-@mock.patch('yardstick.benchmark.contexts.standalone.sriov.time')
-class StandaloneContextTestCase(unittest.TestCase):
- NODES_SAMPLE = "nodes_sample_new.yaml"
- NODES_SAMPLE_SRIOV = "nodes_sample_new_sriov.yaml"
- NODES_DUPLICATE_SAMPLE = "nodes_duplicate_sample_new.yaml"
-
- NODES_SAMPLE_OVSDPDK = "nodes_sample_ovs.yaml"
- NODES_SAMPLE_OVSDPDK_ROLE = "nodes_sample_ovsdpdk.yaml"
- NODES_DUPLICATE_OVSDPDK = "nodes_duplicate_sample_ovs.yaml"
-
- def setUp(self):
- self.test_context = standalone.StandaloneContext()
-
- def test_construct(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- self.assertIsNone(self.test_context.name)
- self.assertIsNone(self.test_context.file_path)
- self.assertEqual(self.test_context.nodes, [])
- self.assertEqual(self.test_context.nfvi_node, [])
-
- def test_unsuccessful_init(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath("error_file")
- }
- self.assertRaises(IOError, self.test_context.init, attrs)
-
- def test_successful_init_sriov(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs_sriov = {
- 'name': 'sriov',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
- self.test_context.nfvi_node = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- self.test_context.get_nfvi_obj = mock.Mock()
- self.test_context.init(attrs_sriov)
- self.assertEqual(self.test_context.name, "sriov")
- self.assertEqual(len(self.test_context.nodes), 2)
- self.assertEqual(len(self.test_context.nfvi_node), 2)
- self.assertEqual(self.test_context.nfvi_node[0]["name"], "sriov")
-
- def test_successful_init_ovs(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- attrs_ovs = {
- 'name': 'ovs',
- 'file': self._get_file_abspath(self.NODES_SAMPLE_OVSDPDK)
- }
- self.test_context.nfvi_node = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- self.test_context.get_nfvi_obj = mock.Mock()
- self.test_context.init(attrs_ovs)
- self.assertEqual(self.test_context.name, "ovs")
- self.assertEqual(len(self.test_context.nodes), 2)
- self.assertEqual(len(self.test_context.nfvi_node), 2)
- self.assertEqual(self.test_context.nfvi_node[0]["name"], "ovs")
-
- def test__get_server_with_dic_attr_name_sriov(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs_sriov = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
- self.test_context.nfvi_node = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- self.test_context.init(attrs_sriov)
- attr_name = {'name': 'foo.bar'}
- result = self.test_context._get_server(attr_name)
- self.assertEqual(result, None)
-
- def test__get_server_with_dic_attr_name_ovs(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs_ovs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE_OVSDPDK)
- }
- self.test_context.nfvi_node = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- self.test_context.init(attrs_ovs)
- attr_name = {'name': 'foo.bar'}
- result = self.test_context._get_server(attr_name)
- self.assertEqual(result, None)
-
- def test__get_server_not_found_sriov(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
- self.test_context.nfvi_node = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- 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_not_found_ovs(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE_OVSDPDK)
- }
- self.test_context.nfvi_node = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- 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_duplicate_sriov(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_DUPLICATE_SAMPLE)
- }
- self.test_context.nfvi_node = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- self.test_context.get_nfvi_obj = mock.Mock(return_value="sriov")
- self.test_context.init(attrs)
- attr_name = 'sriov.foo'
- # self.test_context.name = "sriov"
- self.assertRaises(ValueError, self.test_context._get_server, attr_name)
-
- def test__get_server_duplicate_ovs(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_DUPLICATE_OVSDPDK)
- }
- self.test_context.nfvi_node = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
- self.test_context.get_nfvi_obj = mock.Mock(return_value="OvsDpdk")
- self.test_context.init(attrs)
-
- attr_name = 'ovs.foo'
- self.assertRaises(
- ValueError,
- self.test_context._get_server,
- attr_name)
-
- def test__get_server_found_sriov(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE_SRIOV)
- }
- self.test_context.nfvi_node = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
- self.test_context.get_nfvi_obj = mock.Mock(return_value="OvsDpdk")
- self.test_context.init(attrs)
- attr_name = 'sriov.foo'
- result = self.test_context._get_server(attr_name)
- self.assertEqual(result['ip'], '10.123.123.122')
- self.assertEqual(result['name'], 'sriov.foo')
- self.assertEqual(result['user'], 'root')
-
- def test__get_server_found_ovs(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE_OVSDPDK_ROLE)
- }
- self.test_context.nfvi_node = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- self.test_context.get_nfvi_obj = mock.Mock(return_value="OvsDpdk")
- self.test_context.init(attrs)
- attr_name = 'ovs.foo'
- result = self.test_context._get_server(attr_name)
- self.assertEqual(result['ip'], '10.223.197.222')
- self.assertEqual(result['name'], 'ovs.foo')
- self.assertEqual(result['user'], 'root')
-
- def test__deploy_unsuccessful(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- self.test_context.vm_deploy = False
-
- def test__deploy_sriov_firsttime(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
- self.test_context.nfvi_node = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
- MYSRIOV = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
- self.test_context.vm_deploy = True
-
- self.test_context.get_nfvi_obj = mock.MagicMock()
- self.test_context.init(attrs)
- self.test_context.nfvi_obj.sriov = MYSRIOV
- self.test_context.nfvi_obj.ssh_remote_machine = mock.Mock()
- self.test_context.nfvi_obj.first_run = True
- self.test_context.nfvi_obj.install_req_libs()
- self.test_context.nfvi_obj.get_nic_details = mock.Mock()
- PORTS = ['0000:06:00.0', '0000:06:00.1']
- NIC_DETAILS = {
- 'interface': {0: 'enp6s0f0', 1: 'enp6s0f1'},
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e'}
- DRIVER = 'i40e'
- result = self.test_context.nfvi_obj.setup_sriov_context(
- PORTS,
- NIC_DETAILS,
- DRIVER)
- print("{0}".format(result))
- self.assertIsNone(self.test_context.deploy())
-
- def test__deploy_sriov_notfirsttime(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
-
- self.test_context.nfvi_node = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- MYSRIOV = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
- self.test_context.vm_deploy = True
- self.test_context.get_nfvi_obj = mock.MagicMock()
- self.test_context.init(attrs)
- self.test_context.nfvi_obj.sriov = MYSRIOV
- self.test_context.nfvi_obj.ssh_remote_machine = mock.Mock()
- self.test_context.nfvi_obj.first_run = False
- self.test_context.nfvi_obj.get_nic_details = mock.Mock()
- PORTS = ['0000:06:00.0', '0000:06:00.1']
- NIC_DETAILS = {
- 'interface': {0: 'enp6s0f0', 1: 'enp6s0f1'},
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e'}
- DRIVER = 'i40e'
- result = self.test_context.nfvi_obj.setup_sriov_context(
- PORTS,
- NIC_DETAILS,
- DRIVER)
- print("{0}".format(result))
- self.assertIsNone(self.test_context.deploy())
-
- def test__deploy_ovs_firsttime(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE_OVSDPDK)
- }
-
- self.test_context.nfvi_node = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
- MYOVS = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- '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_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
- self.test_context.vm_deploy = True
- self.test_context.get_nfvi_obj = mock.MagicMock()
- self.test_context.init(attrs)
- self.test_context.ovs = MYOVS
- self.test_context.nfvi_obj.ssh_remote_machine = mock.Mock()
- self.test_context.nfvi_obj.first_run = True
- self.test_context.nfvi_obj.install_req_libs()
- self.test_context.nfvi_obj.get_nic_details = mock.Mock()
- PORTS = ['0000:06:00.0', '0000:06:00.1']
- NIC_DETAILS = {
- 'interface': {0: 'enp6s0f0', 1: 'enp6s0f1'},
- 'vports_mac': ['00:00:00:00:00:05', '00:00:00:00:00:06'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e'}
- DRIVER = 'i40e'
-
- self.test_context.nfvi_obj.setup_ovs = mock.Mock()
- self.test_context.nfvi_obj.start_ovs_serverswitch = mock.Mock()
- self.test_context.nfvi_obj.setup_ovs_bridge = mock.Mock()
- self.test_context.nfvi_obj.add_oflows = mock.Mock()
-
- result = self.test_context.nfvi_obj.setup_ovs_context(
- PORTS,
- NIC_DETAILS,
- DRIVER)
- print("{0}".format(result))
- self.assertIsNone(self.test_context.deploy())
-
- def test__deploy_ovs_notfirsttime(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE_OVSDPDK)
- }
- self.test_context.nfvi_node = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
- MYOVS = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- '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_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
- self.test_context.vm_deploy = True
- self.test_context.get_nfvi_obj = mock.MagicMock()
- self.test_context.init(attrs)
- self.test_context.ovs = MYOVS
- self.test_context.nfvi_obj.ssh_remote_machine = mock.Mock()
- self.test_context.nfvi_obj.first_run = False
- self.test_context.nfvi_obj.get_nic_details = mock.Mock()
- PORTS = ['0000:06:00.0', '0000:06:00.1']
- NIC_DETAILS = {
- 'interface': {0: 'enp6s0f0', 1: 'enp6s0f1'},
- 'vports_mac': ['00:00:00:00:00:05', '00:00:00:00:00:06'],
- 'pci': ['0000:06:00.0', '0000:06:00.1'],
- 'phy_driver': 'i40e'}
- DRIVER = 'i40e'
-
- self.test_context.nfvi_obj.setup_ovs(PORTS)
- self.test_context.nfvi_obj.start_ovs_serverswitch()
- self.test_context.nfvi_obj.setup_ovs_bridge()
- self.test_context.nfvi_obj.add_oflows()
-
- result = self.test_context.nfvi_obj.setup_ovs_context(
- PORTS,
- NIC_DETAILS,
- DRIVER)
- print("{0}".format(result))
- self.assertIsNone(self.test_context.deploy())
-
- def test_undeploy_sriov(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
- self.test_context.nfvi_node = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- self.test_context.get_nfvi_obj = mock.MagicMock()
- self.test_context.init(attrs)
- self.test_context.nfvi_obj.destroy_vm = mock.Mock()
- self.assertIsNone(self.test_context.undeploy())
-
- def test_undeploy_ovs(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- attrs = {
- 'name': 'foo',
- 'file': self._get_file_abspath(self.NODES_SAMPLE_OVSDPDK)
- }
-
- self.test_context.nfvi_node = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
-
- self.test_context.get_nfvi_obj = mock.MagicMock()
- self.test_context.init(attrs)
- self.test_context.nfvi_obj.destroy_vm = mock.Mock()
- self.assertIsNone(self.test_context.undeploy())
-
- def test_get_nfvi_obj_sriov(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- with mock.patch('yardstick.benchmark.contexts.standalone.sriov'):
- attrs = {
- 'name': 'sriov',
- 'file': self._get_file_abspath(self.NODES_SAMPLE)
- }
- self.test_context.init(attrs)
- self.test_context.nfvi_obj.file_path = self._get_file_abspath(
- self.NODES_SAMPLE)
- self.test_context.nfvi_node = [{
- 'name': 'sriov',
- 'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
- 'ip': '10.223.197.140',
- 'role': 'Sriov',
- 'user': 'root',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'intel123',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- self.test_context.get_nfvi_obj = mock.MagicMock()
- self.test_context.init(attrs)
- self.test_context.get_context_impl = mock.Mock(
- return_value=sriov.Sriov)
- self.assertIsNotNone(self.test_context.get_nfvi_obj())
-
- def test_get_nfvi_obj_ovs(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- with mock.patch('yardstick.benchmark.contexts.standalone.ovsdpdk'):
- attrs = {
- 'name': 'ovs',
- 'file': self._get_file_abspath(self.NODES_SAMPLE_OVSDPDK)
- }
- self.test_context.init(attrs)
- self.test_context.nfvi_obj.file_path = self._get_file_abspath(
- self.NODES_SAMPLE)
- self.test_context.nfvi_node = [{
- 'name': 'ovs',
- 'vports_mac': ['00:00:00:00:00:03', '00:00:00:00:00:04'],
- 'ip': '10.223.197.140',
- 'role': 'Ovsdpdk',
- 'user': 'root',
- 'vpath': '/usr/local/',
- 'images': '/var/lib/libvirt/images/ubuntu1.img',
- 'phy_driver': 'i40e',
- 'password': 'password',
- 'phy_ports': ['0000:06:00.0', '0000:06:00.1']}]
- self.test_context.get_nfvi_obj = mock.MagicMock()
- self.test_context.init(attrs)
- self.test_context.get_context_impl = mock.Mock(
- return_value=ovsdpdk.Ovsdpdk)
- self.assertIsNotNone(self.test_context.get_nfvi_obj())
-
- def test_get_context_impl_correct_obj(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- with mock.patch.dict("sys.modules", MOCKS):
- self.assertIsNotNone(self.test_context.get_context_impl('Sriov'))
-
- def test_get_context_impl_wrong_obj(self, mock_sriov_time, mock_standlalone_time,
- mock_ovsdpdk_time):
- with mock.patch.dict("sys.modules", MOCKS):
- self.assertRaises(
- ValueError,
- lambda: self.test_context.get_context_impl('wrong_object'))
-
- 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_network(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- 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 = None
- self.assertIsNone(self.test_context._get_network(attr_name))
-
- 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))
-
- 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)
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/tests/unit/benchmark/core/test_task.py b/tests/unit/benchmark/core/test_task.py
index e3917b5b2..bed0bb6d8 100644
--- a/tests/unit/benchmark/core/test_task.py
+++ b/tests/unit/benchmark/core/test_task.py
@@ -70,10 +70,10 @@ class TaskTestCase(unittest.TestCase):
'network_name': 'mgmt',
},
'xe0': {
- 'network_name': 'private_0',
+ 'network_name': 'uplink_0',
},
'xe1': {
- 'network_name': 'public_0',
+ 'network_name': 'downlink_0',
},
},
},
@@ -82,11 +82,11 @@ class TaskTestCase(unittest.TestCase):
'mgmt': {
'network_name': 'mgmt',
},
- 'private_0': {
- 'network_name': 'private_0',
+ 'uplink_0': {
+ 'network_name': 'uplink_0',
},
- 'public_0': {
- 'network_name': 'public_0',
+ 'downlink_0': {
+ 'network_name': 'downlink_0',
},
},
},
@@ -100,15 +100,15 @@ class TaskTestCase(unittest.TestCase):
},
{},
{
- 'name': 'private_0',
+ 'name': 'uplink_0',
'subnet_cidr': '10.20.0.0/16',
},
{
- 'name': 'public_0',
+ 'name': 'downlink_0',
'segmentation_id': '1001',
},
{
- 'name': 'private_1',
+ 'name': 'uplink_1',
},
])
@@ -116,9 +116,9 @@ class TaskTestCase(unittest.TestCase):
expected_get_network_calls = 6
expected = {
'mgmt': {'name': 'mgmt', 'network_type': 'flat'},
- 'private_0': {'name': 'private_0', 'subnet_cidr': '10.20.0.0/16'},
- 'private_1': {'name': 'private_1'},
- 'public_0': {'name': 'public_0', 'segmentation_id': '1001'},
+ '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)
@@ -165,12 +165,12 @@ class TaskTestCase(unittest.TestCase):
result = t._check_precondition(cfg)
self.assertTrue(result)
- @mock.patch('yardstick.benchmark.core.task.os.environ')
- def test_parse_suite_no_constraint_no_args(self, mock_environ):
+ 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))
- mock_environ.get.side_effect = ['huawei-pod1', 'compass']
- task_files, task_args, task_args_fnames = t.parse_suite()
+ 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(
@@ -186,8 +186,9 @@ class TaskTestCase(unittest.TestCase):
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))
- mock_environ.get.side_effect = ['huawei-pod1', 'compass']
- task_files, task_args, task_args_fnames = t.parse_suite()
+ 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(
@@ -204,8 +205,9 @@ class TaskTestCase(unittest.TestCase):
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))
- mock_environ.get.side_effect = ['huawei-pod1', 'compass']
- task_files, task_args, task_args_fnames = t.parse_suite()
+ 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(
@@ -221,8 +223,9 @@ class TaskTestCase(unittest.TestCase):
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))
- mock_environ.get.side_effect = ['huawei-pod1', 'compass']
- task_files, task_args, task_args_fnames = t.parse_suite()
+ 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(
diff --git a/tests/unit/benchmark/runner/test_base.py b/tests/unit/benchmark/runner/test_base.py
index 956762c40..f47b88e95 100644
--- a/tests/unit/benchmark/runner/test_base.py
+++ b/tests/unit/benchmark/runner/test_base.py
@@ -17,10 +17,31 @@ import time
from mock import mock
-from yardstick.benchmark.runners.base import Runner
+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")
@@ -41,8 +62,26 @@ class RunnerTestCase(unittest.TestCase):
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 = Runner(mock.Mock())
+ runner = base.Runner(mock.Mock())
with self.assertRaises(NotImplementedError):
runner._run_benchmark(mock.Mock(), mock.Mock(), mock.Mock(), mock.Mock())
diff --git a/tests/unit/benchmark/scenarios/availability/test_util.py b/tests/unit/benchmark/scenarios/availability/test_util.py
index 2e4fff417..0974f385a 100644
--- a/tests/unit/benchmark/scenarios/availability/test_util.py
+++ b/tests/unit/benchmark/scenarios/availability/test_util.py
@@ -20,8 +20,8 @@ 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.param_config = {'serviceName': '@serviceName', 'value': 1}
+ self.intermediate_variables = {'@serviceName': 'nova-api'}
self.std_output = '| id | 1 |'
self.cmd_config = {'cmd':'ls','param':'-a'}
diff --git a/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml b/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml
index cfa166a74..2123e4705 100644
--- a/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml
+++ b/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml
@@ -49,13 +49,13 @@ private:
ipv4:
outer_l2:
framesize:
- 64B: "{{ get(imix, 'imix.private.imix_small', '0') }}"
- 128B: "{{ get(imix, 'imix.private.imix_128B', '0') }}"
- 256B: "{{ get(imix, 'imix.private.imix_256B', '0') }}"
- 373b: "{{ get(imix, 'imix.private.imix_373B', '0') }}"
- 570B: "{{get(imix, 'imix.private.imix_570B', '0') }}"
- 1400B: "{{get(imix, 'imix.private.imix_1400B', '0') }}"
- 1518B: "{{get(imix, 'imix.private.imix_1500B', '0') }}"
+ 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:
@@ -81,13 +81,13 @@ public:
ipv4:
outer_l2:
framesize:
- 64B: "{{ get(imix, 'imix.private.imix_small', '0') }}"
- 128B: "{{ get(imix, 'imix.private.imix_128B', '0') }}"
- 256B: "{{ get(imix, 'imix.private.imix_256B', '0') }}"
- 373b: "{{ get(imix, 'imix.private.imix_373B', '0') }}"
- 570B: "{{get(imix, 'imix.private.imix_570B', '0') }}"
- 1400B: "{{get(imix, 'imix.private.imix_1400B', '0') }}"
- 1518B: "{{get(imix, 'imix.private.imix_1500B', '0') }}"
+ 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"
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen.py b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
index 0ca31d484..3928aacde 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen.py
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
@@ -264,7 +264,7 @@ class PktgenTestCase(unittest.TestCase):
p._get_available_queue_number()
mock_ssh.SSH.from_node().execute.assert_called_with(
- "sudo ethtool -l eth0 | grep Combined | head -1 |" \
+ "sudo ethtool -l eth0 | grep Combined | head -1 |"
"awk '{printf $2}'")
def test_pktgen_unsuccessful_get_available_queue_number(self, mock_ssh):
@@ -290,7 +290,7 @@ class PktgenTestCase(unittest.TestCase):
p._get_usable_queue_number()
mock_ssh.SSH.from_node().execute.assert_called_with(
- "sudo ethtool -l eth0 | grep Combined | tail -1 |" \
+ "sudo ethtool -l eth0 | grep Combined | tail -1 |"
"awk '{printf $2}'")
def test_pktgen_unsuccessful_get_usable_queue_number(self, mock_ssh):
@@ -541,7 +541,7 @@ class PktgenTestCase(unittest.TestCase):
p._is_irqbalance_disabled = mock_result1
mock_result2 = mock.Mock()
- mock_result2.return_value = "virtio_net"
+ mock_result2.return_value = "virtio_net"
p._get_vnic_driver_name = mock_result2
mock_result3 = mock.Mock()
@@ -571,7 +571,7 @@ class PktgenTestCase(unittest.TestCase):
p._is_irqbalance_disabled = mock_result1
mock_result2 = mock.Mock()
- mock_result2.return_value = "virtio_net"
+ mock_result2.return_value = "virtio_net"
p._get_vnic_driver_name = mock_result2
mock_result3 = mock.Mock()
@@ -601,7 +601,7 @@ class PktgenTestCase(unittest.TestCase):
p._is_irqbalance_disabled = mock_result1
mock_result2 = mock.Mock()
- mock_result2.return_value = "ixgbevf"
+ mock_result2.return_value = "ixgbevf"
p._get_vnic_driver_name = mock_result2
p.multiqueue_setup()
@@ -623,7 +623,7 @@ class PktgenTestCase(unittest.TestCase):
p._is_irqbalance_disabled = mock_result1
mock_result2 = mock.Mock()
- mock_result2.return_value = "ixgbevf"
+ mock_result2.return_value = "ixgbevf"
p._get_vnic_driver_name = mock_result2
p.multiqueue_setup()
@@ -670,7 +670,7 @@ class PktgenTestCase(unittest.TestCase):
p.client = mock_ssh.SSH.from_node()
mock_result = mock.Mock()
- mock_result.return_value = "virtio_net"
+ mock_result.return_value = "virtio_net"
p._get_vnic_driver_name = mock_result
mock_result1 = mock.Mock()
diff --git a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
index 58244b8f5..016608a21 100644
--- a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
+++ b/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
@@ -24,6 +24,8 @@ 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, \
@@ -240,11 +242,11 @@ class TestNetworkServiceTestCase(unittest.TestCase):
'vnf__1': self.vnf__1,
},
'networks': {
- 'private': {
- 'vld_id': 'private',
+ GenericVNF.UPLINK: {
+ 'vld_id': GenericVNF.UPLINK,
},
- 'public': {
- 'vld_id': 'public',
+ GenericVNF.DOWNLINK: {
+ 'vld_id': GenericVNF.DOWNLINK,
},
},
}
@@ -263,7 +265,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
}
],
'type': 'ELAN',
- 'id': 'private',
+ 'id': GenericVNF.UPLINK,
'name': 'tg__1 to vnf__1 link 1'
}
@@ -281,7 +283,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
}
],
'type': 'ELAN',
- 'id': 'public',
+ 'id': GenericVNF.DOWNLINK,
'name': 'vnf__1 to tg__1 link 2'
}
@@ -359,12 +361,36 @@ class TestNetworkServiceTestCase(unittest.TestCase):
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")
@@ -419,6 +445,13 @@ class TestNetworkServiceTestCase(unittest.TestCase):
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)
@@ -542,6 +575,35 @@ class TestNetworkServiceTestCase(unittest.TestCase):
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")
@@ -568,8 +630,8 @@ class TestNetworkServiceTestCase(unittest.TestCase):
def test_teardown(self):
vnf = mock.Mock(autospec=GenericVNF)
- vnf.terminate = \
- mock.Mock(return_value=True)
+ 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)
@@ -577,6 +639,18 @@ class TestNetworkServiceTestCase(unittest.TestCase):
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',
@@ -653,12 +727,6 @@ class TestNetworkServiceTestCase(unittest.TestCase):
res = NetworkServiceTestCase.parse_netdev_info(output)
assert res == self.SAMPLE_VM_NETDEVS
- def test_sort_dpdk_port_num(self):
- netdevs = self.SAMPLE_NETDEVS.copy()
- NetworkServiceTestCase._sort_dpdk_port_num(netdevs)
- assert netdevs['lan']['dpdk_port_num'] == 0
- assert netdevs['enp11s0']['dpdk_port_num'] == 1
-
def test_probe_missing_values(self):
netdevs = self.SAMPLE_NETDEVS.copy()
network = {'local_mac': '0a:de:ad:be:ef:f5'}
diff --git a/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml b/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml
index 0de4b6e79..1ac6c1f89 100644
--- a/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml
+++ b/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml
@@ -27,7 +27,7 @@ nsd:nsd-catalog:
VNF model: ../../vnf_descriptors/vpe_vnf.yaml #tg_l3fwd.yaml #tg_trex_tpl.yaml #TREX
vld:
- - id: private
+ - id: uplink
name: tg__1 to vnf__1 link 1
type: ELAN
vnfd-connection-point-ref:
@@ -38,7 +38,7 @@ nsd:nsd-catalog:
vnfd-connection-point-ref: xe0
vnfd-id-ref: vnf__1 #VNF
- - id: public
+ - id: downlink
name: vnf__1 to tg__1 link 2
type: ELAN
vnfd-connection-point-ref:
diff --git a/tests/unit/common/test_process.py b/tests/unit/common/test_process.py
new file mode 100644
index 000000000..5eee55bcc
--- /dev/null
+++ b/tests/unit/common/test_process.py
@@ -0,0 +1,46 @@
+# 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.
+import unittest
+
+import mock
+
+from yardstick.common import process
+
+
+class ProcessTestcase(unittest.TestCase):
+ def test_check_if_procces_failed_None(self):
+ p = mock.MagicMock(**{"exitcode": None, "name": "debug"})
+ process.check_if_process_failed(p)
+
+ def test_check_if_procces_failed_0(self):
+ p = mock.MagicMock(**{"exitcode": 0, "name": "debug"})
+ process.check_if_process_failed(p)
+
+ def test_check_if_procces_failed_1(self):
+ p = mock.MagicMock(**{"exitcode": 1, "name": "debug"})
+ with self.assertRaises(RuntimeError):
+ process.check_if_process_failed(p)
+
+
+@mock.patch("yardstick.common.process.multiprocessing")
+class TerminateChildrenTestcase(unittest.TestCase):
+ def test_some_children(self, mock_multiprocessing):
+ p1 = mock.MagicMock()
+ p2 = mock.MagicMock()
+ mock_multiprocessing.active_children.return_value = [p1, p2]
+ process.terminate_children()
+
+ def test_no_children(self, mock_multiprocessing):
+ mock_multiprocessing.active_children.return_value = []
+ process.terminate_children()
diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py
index 923ec4aaa..42b75d1f0 100644
--- a/tests/unit/common/test_utils.py
+++ b/tests/unit/common/test_utils.py
@@ -17,6 +17,7 @@ import unittest
from copy import deepcopy
from itertools import product, chain
+import errno
import mock
from six.moves import configparser
@@ -780,6 +781,21 @@ class RemoveFileTestCase(unittest.TestCase):
class TestUtils(unittest.TestCase):
+ @mock.patch('yardstick.common.utils.os.makedirs')
+ def test_makedirs(self, *_):
+ self.assertIsNone(utils.makedirs('a/b/c/d'))
+
+ @mock.patch('yardstick.common.utils.os.makedirs')
+ def test_makedirs_exists(self, mock_os_makedirs):
+ mock_os_makedirs.side_effect = OSError(errno.EEXIST, 'exists')
+ self.assertIsNone(utils.makedirs('a/b/c/d'))
+
+ @mock.patch('yardstick.common.utils.os.makedirs')
+ def test_makedirs_busy(self, mock_os_makedirs):
+ mock_os_makedirs.side_effect = OSError(errno.EBUSY, 'busy')
+ with self.assertRaises(OSError):
+ utils.makedirs('a/b/c/d')
+
@mock.patch('yardstick.common.utils.jsonify')
def test_result_handler(self, mock_jsonify):
mock_jsonify.return_value = 432
diff --git a/tests/unit/network_services/collector/test_subscriber.py b/tests/unit/network_services/collector/test_subscriber.py
index 373f5dccf..f324f627d 100644
--- a/tests/unit/network_services/collector/test_subscriber.py
+++ b/tests/unit/network_services/collector/test_subscriber.py
@@ -19,51 +19,80 @@
from __future__ import absolute_import
import unittest
+import mock
from yardstick.network_services.collector import subscriber
-class CollectorTestCase(unittest.TestCase):
-
- TRAFFIC_PROFILE = {}
- VNFS = {}
-
- def setUp(self):
- self.test_subscriber = subscriber.Collector(self.TRAFFIC_PROFILE,
- self.VNFS)
+class MockVnfAprrox(object):
- def test_successful_init(self):
+ def __init__(self):
+ self.result = {}
+ self.name = "vnf__1"
- self.assertEqual(self.test_subscriber.traffic_profile, {})
- self.assertEqual(self.test_subscriber.service, {})
+ def collect_kpi(self):
+ self.result = {
+ 'pkt_in_up_stream': 100,
+ 'pkt_drop_up_stream': 5,
+ 'pkt_in_down_stream': 50,
+ 'pkt_drop_down_stream': 40
+ }
+ return self.result
- def test_unsuccessful_init(self):
- pass
- def test_start(self):
- self.assertIsNone(self.test_subscriber.start())
+class CollectorTestCase(unittest.TestCase):
- def test_stop(self):
- self.assertIsNone(self.test_subscriber.stop())
+ NODES = {
+ 'node1': {},
+ 'node2': {
+ 'ip': '1.2.3.4',
+ 'collectd': {
+ 'plugins': {'abc': 12, 'def': 34},
+ 'interval': 987,
+ },
+ },
+ }
+ TRAFFIC_PROFILE = {
+ 'key1': 'value1',
+ }
- def test_get_kpi(self):
+ def setUp(self):
+ vnf = MockVnfAprrox()
+ self.ssh_patch = mock.patch('yardstick.network_services.nfvi.resource.ssh', autospec=True)
+ mock_ssh = self.ssh_patch.start()
+ mock_instance = mock.Mock()
+ mock_instance.execute.return_value = 0, '', ''
+ mock_ssh.AutoConnectSSH.from_node.return_value = mock_instance
+ self.collector = subscriber.Collector([vnf], self.NODES, self.TRAFFIC_PROFILE, 1800)
+
+ def tearDown(self):
+ self.ssh_patch.stop()
+
+ def test___init__(self, *_):
+ vnf = MockVnfAprrox()
+ collector = subscriber.Collector([vnf], {}, {})
+ self.assertEqual(len(collector.vnfs), 1)
+ self.assertEqual(collector.traffic_profile, {})
+
+ def test___init___with_data(self, *_):
+ self.assertEqual(len(self.collector.vnfs), 1)
+ self.assertDictEqual(self.collector.traffic_profile, self.TRAFFIC_PROFILE)
+ self.assertEqual(len(self.collector.resource_profiles), 1)
+
+ def test___init___negative(self, *_):
+ pass
- class VnfAprrox(object):
- def __init__(self):
- self.result = {}
- self.name = "vnf__1"
+ def test_start(self, *_):
+ self.assertIsNone(self.collector.start())
- def collect_kpi(self):
- self.result = {'pkt_in_up_stream': 100,
- 'pkt_drop_up_stream': 5,
- 'pkt_in_down_stream': 50,
- 'pkt_drop_down_stream': 40}
- return self.result
+ def test_stop(self, *_):
+ self.assertIsNone(self.collector.stop())
- vnf = VnfAprrox()
- result = self.test_subscriber.get_kpi(vnf)
+ def test_get_kpi(self, *_):
+ result = self.collector.get_kpi()
self.assertEqual(result["vnf__1"]["pkt_in_up_stream"], 100)
self.assertEqual(result["vnf__1"]["pkt_drop_up_stream"], 5)
self.assertEqual(result["vnf__1"]["pkt_in_down_stream"], 50)
self.assertEqual(result["vnf__1"]["pkt_drop_down_stream"], 40)
+ self.assertIn('node2', result)
diff --git a/tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml b/tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml
index 606d557e9..f60834fbd 100644
--- a/tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml
+++ b/tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml
@@ -27,7 +27,7 @@ nsd:nsd-catalog:
VNF model: ../../vnf_descriptors/acl_vnf.yaml
vld:
- - id: private_1
+ - id: uplink_1
name: tg__1 to vnf__1 link 1
type: ELAN
vnfd-connection-point-ref:
@@ -38,7 +38,7 @@ nsd:nsd-catalog:
vnfd-connection-point-ref: xe0
vnfd-id-ref: vnf__1 #VNF
- - id: public_1
+ - id: downlink_1
name: vnf__1 to tg__1 link 2
type: ELAN
vnfd-connection-point-ref:
diff --git a/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py b/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
new file mode 100644
index 000000000..0f1cf7d92
--- /dev/null
+++ b/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
@@ -0,0 +1,260 @@
+#!/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.
+
+import mock
+import unittest
+from yardstick.network_services.helpers.dpdkbindnic_helper import DpdkBindHelper
+from yardstick.network_services.helpers.dpdkbindnic_helper import DpdkBindHelperException
+from yardstick.network_services.helpers.dpdkbindnic_helper import NETWORK_KERNEL
+from yardstick.network_services.helpers.dpdkbindnic_helper import NETWORK_DPDK
+from yardstick.network_services.helpers.dpdkbindnic_helper import CRYPTO_KERNEL
+from yardstick.network_services.helpers.dpdkbindnic_helper import CRYPTO_DPDK
+from yardstick.network_services.helpers.dpdkbindnic_helper import NETWORK_OTHER
+from yardstick.network_services.helpers.dpdkbindnic_helper import CRYPTO_OTHER
+
+pass
+
+
+class TestDpdkBindHelper(unittest.TestCase):
+ EXAMPLE_OUTPUT = """
+
+Network devices using DPDK-compatible driver
+============================================
+0000:00:04.0 'Virtio network device' drv=igb_uio unused=
+0000:00:05.0 'Virtio network device' drv=igb_uio unused=
+
+Network devices using kernel driver
+===================================
+0000:00:03.0 'Virtio network device' if=ens3 drv=virtio-pci unused=igb_uio *Active*
+
+Other network devices
+=====================
+<none>
+
+Crypto devices using DPDK-compatible driver
+===========================================
+<none>
+
+Crypto devices using kernel driver
+==================================
+<none>
+
+Other crypto devices
+====================
+<none>
+"""
+
+ PARSED_EXAMPLE = {
+ NETWORK_DPDK: [
+ {'active': False,
+ 'dev_type': 'Virtio network device',
+ 'driver': 'igb_uio',
+ 'iface': None,
+ 'unused': '',
+ 'vpci': '0000:00:04.0',
+ },
+ {'active': False,
+ 'dev_type': 'Virtio network device',
+ 'driver': 'igb_uio',
+ 'iface': None,
+ 'unused': '',
+ 'vpci': '0000:00:05.0',
+ }
+ ],
+ NETWORK_KERNEL: [
+ {'active': True,
+ 'dev_type': 'Virtio network device',
+ 'driver': 'virtio-pci',
+ 'iface': 'ens3',
+ 'unused': 'igb_uio',
+ 'vpci': '0000:00:03.0',
+ }
+ ],
+ CRYPTO_KERNEL: [],
+ CRYPTO_DPDK: [],
+ NETWORK_OTHER: [],
+ CRYPTO_OTHER: [],
+ }
+
+ CLEAN_STATUS = {
+ NETWORK_KERNEL: [],
+ NETWORK_DPDK: [],
+ CRYPTO_KERNEL: [],
+ CRYPTO_DPDK: [],
+ NETWORK_OTHER: [],
+ CRYPTO_OTHER: [],
+ }
+
+ ONE_INPUT_LINE = ("0000:00:03.0 'Virtio network device' if=ens3 "
+ "drv=virtio-pci unused=igb_uio *Active*")
+
+ ONE_INPUT_LINE_PARSED = [{
+ 'vpci': '0000:00:03.0',
+ 'dev_type': 'Virtio network device',
+ 'iface': 'ens3',
+ 'driver': 'virtio-pci',
+ 'unused': 'igb_uio',
+ 'active': True,
+ }]
+
+ def test___init__(self):
+ conn = mock.Mock()
+ conn.provision_tool = mock.Mock(return_value='path_to_tool')
+
+ dpdk_bind_helper = DpdkBindHelper(conn)
+
+ self.assertEquals(conn, dpdk_bind_helper.ssh_helper)
+ self.assertEquals(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._status_cmd_attr)
+
+ def test__dpdk_execute(self):
+ conn = mock.Mock()
+ conn.execute = mock.Mock(return_value=(0, 'output', 'error'))
+ conn.provision_tool = mock.Mock(return_value='tool_path')
+ dpdk_bind_helper = DpdkBindHelper(conn)
+ self.assertEquals((0, 'output', 'error'), dpdk_bind_helper._dpdk_execute('command'))
+
+ def test__dpdk_execute_failure(self):
+ conn = mock.Mock()
+ conn.execute = mock.Mock(return_value=(1, 'output', 'error'))
+ conn.provision_tool = mock.Mock(return_value='tool_path')
+ dpdk_bind_helper = DpdkBindHelper(conn)
+ with self.assertRaises(DpdkBindHelperException):
+ dpdk_bind_helper._dpdk_execute('command')
+
+ def test__addline(self):
+ conn = mock.Mock()
+
+ dpdk_bind_helper = DpdkBindHelper(conn)
+
+ dpdk_bind_helper._addline(NETWORK_KERNEL, self.ONE_INPUT_LINE)
+
+ self.assertIsNotNone(dpdk_bind_helper.dpdk_status)
+ self.assertEquals(self.ONE_INPUT_LINE_PARSED, dpdk_bind_helper.dpdk_status[NETWORK_KERNEL])
+
+ def test__switch_active_dict_by_header(self):
+ line = "Crypto devices using DPDK-compatible driver"
+ olddict = 'olddict'
+ self.assertEqual(CRYPTO_DPDK, DpdkBindHelper._switch_active_dict(line, olddict))
+
+ def test__switch_active_dict_by_header_empty(self):
+ line = "<none>"
+ olddict = 'olddict'
+ self.assertEqual(olddict, DpdkBindHelper._switch_active_dict(line, olddict))
+
+ def test_parse_dpdk_status_output(self):
+ conn = mock.Mock()
+
+ dpdk_bind_helper = DpdkBindHelper(conn)
+
+ dpdk_bind_helper.parse_dpdk_status_output(self.EXAMPLE_OUTPUT)
+
+ self.maxDiff = None
+ self.assertEquals(self.PARSED_EXAMPLE, dpdk_bind_helper.dpdk_status)
+
+ def test_read_status(self):
+ conn = mock.Mock()
+ conn.execute = mock.Mock(return_value=(0, self.EXAMPLE_OUTPUT, ''))
+ conn.provision_tool = mock.Mock(return_value='path_to_tool')
+
+ dpdk_bind_helper = DpdkBindHelper(conn)
+
+ self.assertEquals(self.PARSED_EXAMPLE, dpdk_bind_helper.read_status())
+
+ def test__get_bound_pci_addresses(self):
+ conn = mock.Mock()
+
+ dpdk_bind_helper = DpdkBindHelper(conn)
+
+ dpdk_bind_helper.parse_dpdk_status_output(self.EXAMPLE_OUTPUT)
+
+ self.assertEquals(['0000:00:04.0', '0000:00:05.0'],
+ dpdk_bind_helper._get_bound_pci_addresses(NETWORK_DPDK))
+ self.assertEquals(['0000:00:03.0'],
+ dpdk_bind_helper._get_bound_pci_addresses(NETWORK_KERNEL))
+
+ def test_interface_driver_map(self):
+ conn = mock.Mock()
+
+ dpdk_bind_helper = DpdkBindHelper(conn)
+
+ dpdk_bind_helper.parse_dpdk_status_output(self.EXAMPLE_OUTPUT)
+
+ self.assertEquals({'0000:00:04.0': 'igb_uio',
+ '0000:00:03.0': 'virtio-pci',
+ '0000:00:05.0': 'igb_uio',
+ },
+ dpdk_bind_helper.interface_driver_map)
+
+ def test_bind(self):
+ conn = mock.Mock()
+ conn.execute = mock.Mock(return_value=(0, '', ''))
+ conn.provision_tool = mock.Mock(return_value='/opt/nsb_bin/dpdk-devbind.py')
+
+ dpdk_bind_helper = DpdkBindHelper(conn)
+ dpdk_bind_helper.read_status = mock.Mock()
+
+ dpdk_bind_helper.bind(['0000:00:03.0', '0000:00:04.0'], 'my_driver')
+
+ conn.execute.assert_called_with('sudo /opt/nsb_bin/dpdk-devbind.py --force '
+ '-b my_driver 0000:00:03.0 0000:00:04.0')
+ dpdk_bind_helper.read_status.assert_called_once()
+
+ def test_bind_single_pci(self):
+ conn = mock.Mock()
+ conn.execute = mock.Mock(return_value=(0, '', ''))
+ conn.provision_tool = mock.Mock(return_value='/opt/nsb_bin/dpdk-devbind.py')
+
+ dpdk_bind_helper = DpdkBindHelper(conn)
+ dpdk_bind_helper.read_status = mock.Mock()
+
+ dpdk_bind_helper.bind('0000:00:03.0', 'my_driver')
+
+ conn.execute.assert_called_with('sudo /opt/nsb_bin/dpdk-devbind.py --force '
+ '-b my_driver 0000:00:03.0')
+ dpdk_bind_helper.read_status.assert_called_once()
+
+ def test_rebind_drivers(self):
+ conn = mock.Mock()
+
+ dpdk_bind_helper = DpdkBindHelper(conn)
+
+ dpdk_bind_helper.bind = mock.Mock()
+ dpdk_bind_helper.used_drivers = {
+ 'd1': ['0000:05:00.0'],
+ 'd3': ['0000:05:01.0', '0000:05:02.0'],
+ }
+
+ dpdk_bind_helper.rebind_drivers()
+
+ dpdk_bind_helper.bind.assert_any_call(['0000:05:00.0'], 'd1', True)
+ dpdk_bind_helper.bind.assert_any_call(['0000:05:01.0', '0000:05:02.0'], 'd3', True)
+
+ def test_save_used_drivers(self):
+ conn = mock.Mock()
+ dpdk_bind_helper = DpdkBindHelper(conn)
+ dpdk_bind_helper.dpdk_status = self.PARSED_EXAMPLE
+
+ dpdk_bind_helper.save_used_drivers()
+
+ expected = {
+ 'igb_uio': ['0000:00:04.0', '0000:00:05.0'],
+ 'virtio-pci': ['0000:00:03.0'],
+ }
+
+ self.assertDictEqual(expected, dpdk_bind_helper.used_drivers)
diff --git a/tests/unit/network_services/helpers/test_samplevnf_helper.py b/tests/unit/network_services/helpers/test_samplevnf_helper.py
index 608f31747..0ac363f28 100644
--- a/tests/unit/network_services/helpers/test_samplevnf_helper.py
+++ b/tests/unit/network_services/helpers/test_samplevnf_helper.py
@@ -18,91 +18,152 @@
from __future__ import absolute_import
from __future__ import division
-import os
import unittest
import mock
-from yardstick.network_services.helpers.samplevnf_helper import MultiPortConfig
+from yardstick.network_services.helpers.samplevnf_helper import MultiPortConfig, PortPairs
+from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
+
+
+class TestPortPairs(unittest.TestCase):
+ def test_port_pairs_list(self):
+ vnfd = TestMultiPortConfig.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ interfaces = vnfd['vdu'][0]['external-interface']
+ port_pairs = PortPairs(interfaces)
+ self.assertEqual(port_pairs.port_pair_list, [("xe0", "xe1")])
+
+ def test_valid_networks(self):
+ vnfd = TestMultiPortConfig.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ interfaces = vnfd['vdu'][0]['external-interface']
+ port_pairs = PortPairs(interfaces)
+ self.assertEqual(port_pairs.valid_networks, [("uplink_0", "downlink_0")])
+
+ def test_all_ports(self):
+ vnfd = TestMultiPortConfig.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ interfaces = vnfd['vdu'][0]['external-interface']
+ port_pairs = PortPairs(interfaces)
+ self.assertEqual(set(port_pairs.all_ports), {"xe0", "xe1"})
+
+ def test_uplink_ports(self):
+ vnfd = TestMultiPortConfig.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ interfaces = vnfd['vdu'][0]['external-interface']
+ port_pairs = PortPairs(interfaces)
+ self.assertEqual(port_pairs.uplink_ports, ["xe0"])
+
+ def test_downlink_ports(self):
+ vnfd = TestMultiPortConfig.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ interfaces = vnfd['vdu'][0]['external-interface']
+ port_pairs = PortPairs(interfaces)
+ self.assertEqual(port_pairs.downlink_ports, ["xe1"])
class TestMultiPortConfig(unittest.TestCase):
- VNFD = {'vnfd:vnfd-catalog':
- {'vnfd':
- [{'short-name': 'VpeVnf',
- 'vdu':
- [{'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'}],
- 'description': 'VPE approximation using DPDK',
- 'name': 'vpevnf-baremetal',
- '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'}],
- 'id': 'vpevnf-baremetal',
- 'external-interface':
- [
- {'virtual-interface':
- {
- 'dst_mac': '00:00:00:00:00:04',
- 'vpci': '0000:05:00.0',
- 'local_ip': '152.16.100.19',
- 'type': 'PCI-PASSTHROUGH',
- 'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
- 'bandwidth': '10 Gbps',
- 'driver': "i40e",
- 'dst_ip': '152.16.100.20',
- 'ifname': 'xe0',
- 'local_iface_name': 'eth0',
- 'local_mac': '00:00:00:00:00:02',
- 'vld_id': 'private_1',
- },
- 'vnfd-connection-point-ref': 'xe0',
- 'name': 'xe0'},
- {'virtual-interface':
- {
- 'dst_mac': '00:00:00:00:00:03',
- 'vpci': '0000:05:00.1',
- 'local_ip': '152.16.40.19',
- 'type': 'PCI-PASSTHROUGH',
- 'driver': "i40e",
- 'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
- 'bandwidth': '10 Gbps',
- 'dst_ip': '152.16.40.20',
- 'ifname': 'xe1',
- 'local_iface_name': 'eth1',
- 'local_mac': '00:00:00:00:00:01',
- 'vld_id': 'public_1',
- },
- 'vnfd-connection-point-ref': 'xe1',
- 'name': 'xe1'}
- ]}],
- 'description': 'Vpe approximation using DPDK',
- 'mgmt-interface':
- {'vdu-id': 'vpevnf-baremetal',
- 'host': '1.2.1.1',
- 'password': 'r00t',
- 'user': 'root',
- 'ip': '1.2.1.1'},
- 'benchmark':
- {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
- 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
- {'type': 'VPORT', 'name': 'xe1'}],
- 'id': 'AclApproxVnf', 'name': 'VPEVnfSsh'}]}}
+
+ VNFD_0 = {'short-name': 'VpeVnf',
+ 'vdu':
+ [{'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'}],
+ 'description': 'VPE approximation using DPDK',
+ 'name': 'vpevnf-baremetal',
+ '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'}],
+ 'id': 'vpevnf-baremetal',
+ 'external-interface':
+ [
+ {'virtual-interface':
+ {
+ 'dst_mac': '00:00:00:00:00:04',
+ 'vpci': '0000:05:00.0',
+ 'local_ip': '152.16.100.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 0,
+ 'bandwidth': '10 Gbps',
+ 'driver': "i40e",
+ 'dst_ip': '152.16.100.20',
+ 'ifname': 'xe0',
+ 'local_iface_name': 'eth0',
+ 'local_mac': '00:00:00:00:00:02',
+ 'vld_id': 'uplink_0',
+ },
+ 'vnfd-connection-point-ref': 'xe0',
+ 'name': 'xe0'},
+ {'virtual-interface':
+ {
+ 'dst_mac': '00:00:00:00:00:03',
+ 'vpci': '0000:05:00.1',
+ 'local_ip': '152.16.40.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'driver': "i40e",
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 1,
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.40.20',
+ 'ifname': 'xe1',
+ 'local_iface_name': 'eth1',
+ 'local_mac': '00:00:00:00:00:01',
+ 'vld_id': 'downlink_0',
+ },
+ 'vnfd-connection-point-ref': 'xe1',
+ 'name': 'xe1'}
+ ]}],
+ 'description': 'Vpe approximation using DPDK',
+ 'mgmt-interface':
+ {'vdu-id': 'vpevnf-baremetal',
+ 'host': '1.2.1.1',
+ 'password': 'r00t',
+ 'user': 'root',
+ 'ip': '1.2.1.1'},
+ 'benchmark':
+ {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
+ 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
+ {'type': 'VPORT', 'name': 'xe1'}],
+ 'id': 'AclApproxVnf', 'name': 'VPEVnfSsh'}
+
+ VNFD = {
+ 'vnfd:vnfd-catalog': {
+ 'vnfd': [
+ VNFD_0,
+ ]
+ }
+ }
+
+ def test_validate_ip_and_prefixlen(self):
+ ip_addr, prefix_len = MultiPortConfig.validate_ip_and_prefixlen('10.20.30.40', '16')
+ self.assertEqual(ip_addr, '10.20.30.40')
+ self.assertEqual(prefix_len, 16)
+
+ ip_addr, prefix_len = MultiPortConfig.validate_ip_and_prefixlen('::1', '40')
+ self.assertEqual(ip_addr, '0000:0000:0000:0000:0000:0000:0000:0001')
+ self.assertEqual(prefix_len, 40)
+
+ def test_validate_ip_and_prefixlen_negative(self):
+ with self.assertRaises(AttributeError):
+ MultiPortConfig.validate_ip_and_prefixlen('', '')
+
+ with self.assertRaises(AttributeError):
+ MultiPortConfig.validate_ip_and_prefixlen('10.20.30.400', '16')
+
+ with self.assertRaises(AttributeError):
+ MultiPortConfig.validate_ip_and_prefixlen('10.20.30.40', '33')
+
+ with self.assertRaises(AttributeError):
+ MultiPortConfig.validate_ip_and_prefixlen('::1', '129')
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
@@ -111,11 +172,12 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
self.assertEqual(0, opnfv_vnf.swq)
mock_os.path = mock.MagicMock()
mock_os.path.isfile = mock.Mock(return_value=False)
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
self.assertEqual(0, opnfv_vnf.swq)
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
@@ -125,7 +187,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -139,7 +202,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = VnfdHelper(self.VNFD_0)
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -148,7 +212,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
self.assertIsNotNone(opnfv_vnf.generate_script(self.VNFD))
opnfv_vnf.lb_config = 'HW'
self.assertIsNotNone(opnfv_vnf.generate_script(self.VNFD))
@@ -160,12 +224,13 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.update_write_parser = mock.MagicMock()
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.vnf_type = 'ACL'
opnfv_vnf.generate_link_config = mock.Mock()
opnfv_vnf.generate_arp_config = mock.Mock()
@@ -181,7 +246,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -190,7 +256,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'ACL'
opnfv_vnf.get_ports_gateway = mock.Mock(return_value=u'1.1.1.1')
@@ -212,7 +278,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -221,7 +288,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.get_ports_gateway = mock.Mock(return_value=u'1.1.1.1')
@@ -239,7 +306,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -248,7 +316,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.get_ports_gateway = mock.Mock(return_value=u'1.1.1.1')
@@ -268,7 +336,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -277,7 +346,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.get_ports_gateway = mock.Mock(return_value=u'1.1.1.1')
@@ -297,7 +366,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -306,7 +376,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.txrx_pipeline = ''
@@ -323,7 +393,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -332,7 +403,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.txrx_pipeline = ''
@@ -349,7 +420,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -358,7 +430,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.txrx_pipeline = ''
@@ -375,7 +447,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -384,7 +457,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.txrx_pipeline = ''
@@ -401,7 +474,9 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -410,7 +485,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.txrx_pipeline = ''
@@ -418,7 +493,11 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.get_ports_gateway6 = mock.Mock()
opnfv_vnf.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
opnfv_vnf.interfaces = opnfv_vnf.vnfd['vdu'][0]['external-interface']
- self.assertIsNotNone(opnfv_vnf.generate_link_config())
+ opnfv_vnf.all_ports = ['32', '1', '987']
+ opnfv_vnf.validate_ip_and_prefixlen = mock.Mock(return_value=('10.20.30.40', 16))
+
+ result = opnfv_vnf.generate_link_config()
+ self.assertEqual(len(result.splitlines()), 9)
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
@@ -427,7 +506,8 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -436,7 +516,7 @@ class TestMultiPortConfig(unittest.TestCase):
mock.Mock(return_value={'link_config': 0, 'arp_config': '',
'arp_config6': '', 'actions': '',
'rules': ''})
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.get_ports_gateway6 = mock.Mock()
@@ -459,10 +539,11 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -482,10 +563,11 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -505,10 +587,11 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -533,10 +616,11 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -556,10 +640,11 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -581,10 +666,11 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -614,10 +700,11 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -649,10 +736,10 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = VnfdHelper(self.VNFD_0)
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -666,10 +753,12 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.worker_config = '1t'
opnfv_vnf.start_core = 0
opnfv_vnf.lb_count = 1
+ opnfv_vnf._port_pairs = PortPairs(vnfd_mock.interfaces)
+ opnfv_vnf.port_pair_list = opnfv_vnf._port_pairs.port_pair_list
result = opnfv_vnf.generate_lb_to_port_pair_mapping()
self.assertEqual(None, result)
result = opnfv_vnf.set_priv_to_pub_mapping()
- self.assertEqual('(0, 1)', result)
+ self.assertEqual('(0,1)', result)
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
@@ -680,11 +769,12 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = VnfdHelper(self.VNFD_0)
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
- opnfv_vnf.port_pairs = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
+ opnfv_vnf.port_pairs = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -702,6 +792,43 @@ class TestMultiPortConfig(unittest.TestCase):
self.assertEqual(None, result)
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
+ @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
+ def test_generate_arp_route_tbl(self, *_):
+ topology_file = mock.Mock()
+ config_tpl = mock.Mock()
+ tmp_file = mock.Mock()
+ vnfd_mock = mock.MagicMock()
+ vnfd_mock.port_num.side_effect = ['32', '1', '987']
+ vnfd_mock.find_interface.side_effect = [
+ {
+ 'virtual-interface': {
+ 'dst_ip': '10.20.30.40',
+ 'netmask': '20',
+ },
+ },
+ {
+ 'virtual-interface': {
+ 'dst_ip': '10.200.30.40',
+ 'netmask': '24',
+ },
+ },
+ {
+ 'virtual-interface': {
+ 'dst_ip': '10.20.3.40',
+ 'netmask': '8',
+ },
+ },
+ ]
+
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf.all_ports = [3, 2, 5]
+
+ expected = '(0a141000,fffff000,32,0a141e28) (0ac81e00,ffffff00,1,0ac81e28) ' \
+ '(0a000000,ff000000,987,0a140328)'
+ result = opnfv_vnf.generate_arp_route_tbl()
+ self.assertEqual(result, expected)
+
+ @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
@@ -710,11 +837,12 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
- opnfv_vnf.port_pairs = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
+ opnfv_vnf.port_pairs = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -754,11 +882,12 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
- opnfv_vnf.port_pairs = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
+ opnfv_vnf.port_pairs = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -795,11 +924,12 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
- opnfv_vnf.port_pairs = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
+ opnfv_vnf.port_pairs = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -848,11 +978,12 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
- opnfv_vnf.port_pairs = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
+ opnfv_vnf.port_pairs = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -884,11 +1015,12 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
- opnfv_vnf.port_pairs = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
+ opnfv_vnf.port_pairs = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -932,11 +1064,12 @@ class TestMultiPortConfig(unittest.TestCase):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = VnfdHelper(self.VNFD_0)
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
- opnfv_vnf.port_pairs = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
+ opnfv_vnf.port_pairs = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
@@ -982,7 +1115,7 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.loadb_tpl = mock.MagicMock()
opnfv_vnf.vnf_type = 'CGNAPT'
opnfv_vnf.update_timer = mock.Mock()
- opnfv_vnf.port_pair_list = [[[0], [1], [2]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1"), ("xe0", "xe2")]
opnfv_vnf.lb_to_port_pair_mapping = [0, 1]
opnfv_vnf.generate_arpicmp_data = mock.Mock()
result = opnfv_vnf.generate_config_data()
@@ -992,66 +1125,17 @@ class TestMultiPortConfig(unittest.TestCase):
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
@mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_get_port_pairs(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
- topology_file = mock.Mock()
- config_tpl = mock.Mock()
- tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
- opnfv_vnf.socket = 0
- opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
- opnfv_vnf.port_pairs = [[[0], [1]]]
- opnfv_vnf.txrx_pipeline = ''
- opnfv_vnf.rules = ''
- opnfv_vnf.write_parser = mock.MagicMock()
- opnfv_vnf.read_parser = mock.MagicMock()
- opnfv_vnf.read_parser.sections = mock.Mock(return_value=['MASTER'])
- opnfv_vnf.read_parser.has_option = mock.Mock(return_value=[])
- opnfv_vnf.write_parser.set = mock.Mock()
- opnfv_vnf.write_parser.add_section = mock.Mock()
- opnfv_vnf.read_parser.items = mock.MagicMock()
- opnfv_vnf.pipeline_counter = 0
- opnfv_vnf.worker_config = '1t'
- opnfv_vnf.start_core = 0
- opnfv_vnf.lb_count = 1
- opnfv_vnf.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- opnfv_vnf.interfaces = opnfv_vnf.vnfd['vdu'][0]['external-interface']
- opnfv_vnf.lb_to_port_pair_mapping = [0, 1]
- opnfv_vnf.lb_index = 1
- opnfv_vnf.ports_len = 1
- opnfv_vnf.pktq_out = ['1', '2']
- opnfv_vnf.prv_que_handler = 0
- opnfv_vnf.init_write_parser_template = mock.Mock()
- opnfv_vnf.arpicmp_tpl = mock.MagicMock()
- opnfv_vnf.txrx_tpl = mock.MagicMock()
- opnfv_vnf.loadb_tpl = mock.MagicMock()
- opnfv_vnf.vnf_tpl = {'public_ip_port_range': '98164810 (1,65535)',
- 'vnf_set': '(2,4,5)'}
- opnfv_vnf.generate_vnf_data = mock.Mock(return_value={})
- opnfv_vnf.update_write_parser = mock.Mock()
-
- curr_path = os.path.dirname(os.path.abspath(__file__))
- opnfv_vnf.topology_file = \
- os.path.join(curr_path, 'acl_vnf_topology_ixia.yaml')
- opnfv_vnf.lb_count = 10
- result = opnfv_vnf.get_port_pairs(opnfv_vnf.interfaces)
- self.assertEqual(result[0], [('xe0', 'xe1')])
-
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
def test_init_eal(self, mock_open, mock_os, ConfigParser,
OrderedDict):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file)
+ vnfd_mock = mock.MagicMock()
+ opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
- opnfv_vnf.port_pair_list = [[[0], [1]]]
- opnfv_vnf.port_pairs = [[[0], [1]]]
+ opnfv_vnf.port_pair_list = [("xe0", "xe1")]
+ opnfv_vnf.port_pairs = [("xe0", "xe1")]
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.write_parser = mock.MagicMock()
diff --git a/tests/unit/network_services/libs/ixia_libs/test_IxNet.py b/tests/unit/network_services/libs/ixia_libs/test_IxNet.py
index 7fe83406a..3f374fb50 100644
--- a/tests/unit/network_services/libs/ixia_libs/test_IxNet.py
+++ b/tests/unit/network_services/libs/ixia_libs/test_IxNet.py
@@ -26,6 +26,9 @@ from yardstick.network_services.libs.ixia_libs.IxNet.IxNet import IP_VERSION_4
from yardstick.network_services.libs.ixia_libs.IxNet.IxNet import IP_VERSION_6
+UPLINK = "uplink"
+DOWNLINK = "downlink"
+
class TestIxNextgen(unittest.TestCase):
def test___init__(self):
@@ -79,10 +82,8 @@ class TestIxNextgen(unittest.TestCase):
config = {
'chassis': '1.1.1.1',
- 'card1': '1',
- 'card2': '2',
- 'port1': '2',
- 'port2': '2',
+ 'cards': ['1', '2'],
+ 'ports': ['2', '2'],
}
ixnet_gen = IxNextgen(ixnet)
@@ -97,7 +98,7 @@ class TestIxNextgen(unittest.TestCase):
def test_ix_update_frame(self):
static_traffic_params = {
- "private": {
+ UPLINK: {
"id": 1,
"bidir": "False",
"duration": 60,
@@ -139,7 +140,7 @@ class TestIxNextgen(unittest.TestCase):
},
"traffic_type": "continuous"
},
- "public": {
+ DOWNLINK: {
"id": 2,
"bidir": "False",
"duration": 60,
@@ -268,7 +269,7 @@ class TestIxNextgen(unittest.TestCase):
def test_add_ip_header_v4(self):
static_traffic_params = {
- "private_1": {
+ "uplink_0": {
"id": 1,
"bidir": "False",
"duration": 60,
@@ -308,7 +309,7 @@ class TestIxNextgen(unittest.TestCase):
},
"traffic_type": "continuous"
},
- "public_1": {
+ "downlink_0": {
"id": 2,
"bidir": "False",
"duration": 60,
@@ -366,7 +367,7 @@ class TestIxNextgen(unittest.TestCase):
def test_add_ip_header_v4_nothing_to_do(self):
static_traffic_params = {
- "private_1": {
+ "uplink_0": {
"id": 1,
"bidir": "False",
"duration": 60,
@@ -406,7 +407,7 @@ class TestIxNextgen(unittest.TestCase):
},
"traffic_type": "continuous"
},
- "public_1": {
+ "downlink_0": {
"id": 2,
"bidir": "False",
"duration": 60,
@@ -464,7 +465,7 @@ class TestIxNextgen(unittest.TestCase):
def test_add_ip_header_v6(self):
static_traffic_profile = {
- "private_1": {
+ "uplink_0": {
"id": 1,
"bidir": "False",
"duration": 60,
@@ -497,7 +498,7 @@ class TestIxNextgen(unittest.TestCase):
},
"traffic_type": "continuous"
},
- "public_1": {
+ "downlink_0": {
"id": 2,
"bidir": "False",
"duration": 60,
@@ -547,7 +548,7 @@ class TestIxNextgen(unittest.TestCase):
def test_add_ip_header_v6_nothing_to_do(self):
static_traffic_params = {
- "private_1": {
+ "uplink_0": {
"id": 1,
"bidir": "False",
"duration": 60,
@@ -579,7 +580,7 @@ class TestIxNextgen(unittest.TestCase):
},
"traffic_type": "continuous"
},
- "public_1": {
+ "downlink_0": {
"id": 2,
"bidir": "False",
"duration": 60,
@@ -670,10 +671,8 @@ class TestIxNextgen(unittest.TestCase):
'machine': 'test1',
'port': 'test5',
'chassis': 'test4',
- 'card1': '0000',
- 'port1': '07',
- 'card2': '0001',
- 'port2': '08',
+ 'cards': ['0000', '0001'],
+ 'ports': ['07', '08'],
'output_dir': 'test2',
'version': 'test3',
'bidir': True,
@@ -684,7 +683,7 @@ class TestIxNextgen(unittest.TestCase):
def test_ix_update_ether(self):
static_traffic_params = {
- "private_1": {
+ "uplink_0": {
"id": 1,
"bidir": "False",
"duration": 60,
@@ -723,7 +722,7 @@ class TestIxNextgen(unittest.TestCase):
},
"traffic_type": "continuous"
},
- "public_1": {
+ "downlink_0": {
"id": 2,
"bidir": "False",
"duration": 60,
@@ -787,7 +786,7 @@ class TestIxNextgen(unittest.TestCase):
def test_ix_update_ether_nothing_to_do(self):
static_traffic_params = {
- "private_1": {
+ "uplink_0": {
"id": 1,
"bidir": "False",
"duration": 60,
@@ -820,7 +819,7 @@ class TestIxNextgen(unittest.TestCase):
},
"traffic_type": "continuous"
},
- "public_1": {
+ "downlink_0": {
"id": 2,
"bidir": "False",
"duration": 60,
diff --git a/tests/unit/network_services/nfvi/test_resource.py b/tests/unit/network_services/nfvi/test_resource.py
index 21beba882..799cc202b 100644
--- a/tests/unit/network_services/nfvi/test_resource.py
+++ b/tests/unit/network_services/nfvi/test_resource.py
@@ -14,7 +14,8 @@
from __future__ import absolute_import
import unittest
-import multiprocessing
+
+import errno
import mock
from yardstick.network_services.nfvi.resource import ResourceProfile
@@ -54,7 +55,7 @@ class TestResourceProfile(unittest.TestCase):
'local_ip': '172.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'dst_ip': '172.16.100.20',
'local_mac': '3c:fd:fe:a1:2b:80'},
@@ -66,7 +67,7 @@ class TestResourceProfile(unittest.TestCase):
'local_ip': '172.16.40.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '172.16.40.20',
'local_mac': '3c:fd:fe:a1:2b:81'},
@@ -86,24 +87,32 @@ class TestResourceProfile(unittest.TestCase):
'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
def 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, {}, ""))
- ssh.from_node.return_value = ssh_mock
+ with mock.patch("yardstick.ssh.AutoConnectSSH") as ssh:
+ self.ssh_mock = mock.Mock(autospec=ssh.SSH)
+ self.ssh_mock.execute = \
+ mock.Mock(return_value=(0, "", ""))
+ ssh.from_node.return_value = self.ssh_mock
mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
+ # interfaces = \
+ # self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
+ port_names = \
self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
self.resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
+ ResourceProfile(mgmt, port_names, [1, 2, 3])
+ self.resource_profile.connection = self.ssh_mock
def test___init__(self):
self.assertEqual(True, self.resource_profile.enable)
def test_check_if_sa_running(self):
self.assertEqual(self.resource_profile.check_if_sa_running("collectd"),
- [True, {}])
+ (0, ""))
+
+ def test_check_if_sa_running_excetion(self):
+ with mock.patch.object(self.resource_profile.connection, "execute") as mock_execute:
+ mock_execute.side_effect = OSError(errno.ECONNRESET, "error")
+ self.assertEqual(self.resource_profile.check_if_sa_running("collectd"), (1, None))
def test_get_cpu_data(self):
reskey = ["", "cpufreq", "cpufreq-0"]
@@ -118,133 +127,37 @@ class TestResourceProfile(unittest.TestCase):
self.assertEqual(val, ('error', 'Invalid', '', ''))
def test__start_collectd(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._prepare_collectd_conf = mock.Mock()
- self.assertIsNone(
- resource_profile._start_collectd(ssh_mock, "/opt/nsb_bin"))
-
- def test__prepare_collectd_conf_BM(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._provide_config_file = mock.Mock()
self.assertIsNone(
- resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
+ self.resource_profile._start_collectd(self.ssh_mock, "/opt/nsb_bin"))
- def test__prepare_collectd_conf_managed_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, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._provide_config_file = mock.Mock()
+ def test__prepare_collectd_conf(self):
self.assertIsNone(
- resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
-
- def test__prepare_collectd_conf_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, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._provide_config_file = mock.Mock()
- self.assertIsNone(
- resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
-
- def test__prepare_collectd_conf_managed_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, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._provide_config_file = mock.Mock()
- self.assertIsNone(
- resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
-
- def test__prepare_collectd_conf_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, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._provide_config_file = mock.Mock()
- self.assertIsNone(
- resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
+ self.resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
@mock.patch("yardstick.network_services.nfvi.resource.open")
- @mock.patch("yardstick.network_services.nfvi.resource.tempfile")
@mock.patch("yardstick.network_services.nfvi.resource.os")
- def test__provide_config_file(self, mock_open, mock_tempfile, mock_os):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._prepare_collectd_conf = mock.Mock()
- resource_profile.connection = ssh_mock
- resource_profile.connection.put = \
- mock.Mock(return_value=(0, "", ""))
- mock_tempfile.mkstemp = mock.Mock(return_value=["test", ""])
- self.assertIsNone(
- resource_profile._provide_config_file("/opt/nsb_bin",
- "collectd.cfg", {}))
+ def test__provide_config_file(self, mock_open, mock_os):
+ loadplugin = range(5)
+ port_names = range(5)
+ kwargs = {
+ "interval": '25',
+ "loadplugin": loadplugin,
+ "port_names": port_names,
+ }
+ self.resource_profile._provide_config_file("/opt/nsb_bin", "collectd.conf", kwargs)
+ self.ssh_mock.execute.assert_called_once()
@mock.patch("yardstick.network_services.nfvi.resource.open")
def test_initiate_systemagent(self, mock_open):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._start_collectd = mock.Mock()
- self.assertIsNone(
- resource_profile.initiate_systemagent("/opt/nsb_bin"))
+ self.resource_profile._start_collectd = mock.Mock()
+ self.assertIsNone(
+ self.resource_profile.initiate_systemagent("/opt/nsb_bin"))
+
+ @mock.patch("yardstick.network_services.nfvi.resource.open")
+ def test_initiate_systemagent_raise(self, mock_open):
+ self.resource_profile._start_collectd = mock.Mock(side_effect=RuntimeError)
+ with self.assertRaises(RuntimeError):
+ self.resource_profile.initiate_systemagent("/opt/nsb_bin")
def test__parse_hugepages(self):
reskey = ["cpu", "cpuFreq"]
@@ -271,7 +184,7 @@ class TestResourceProfile(unittest.TestCase):
self.assertEqual({'ovs/stats': '45'}, res)
def test_parse_collectd_result(self):
- res = self.resource_profile.parse_collectd_result({}, [0, 1, 2])
+ res = self.resource_profile.parse_collectd_result({})
expected_result = {'cpu': {}, 'dpdkstat': {}, 'hugepages': {},
'memory': {}, 'ovs_stats': {}, 'timestamp': '',
'intel_pmu': {},
@@ -284,7 +197,7 @@ class TestResourceProfile(unittest.TestCase):
"ipc",
"1234",
""])
- res = self.resource_profile.parse_collectd_result(metric, [0, 1, 2])
+ res = self.resource_profile.parse_collectd_result(metric)
expected_result = {'cpu': {1: {'ipc': '1234'}}, 'dpdkstat': {}, 'hugepages': {},
'memory': {}, 'ovs_stats': {}, 'timestamp': '',
'intel_pmu': {},
@@ -293,7 +206,7 @@ class TestResourceProfile(unittest.TestCase):
def test_parse_collectd_result_memory(self):
metric = {"nsb_stats/memory/bw": "101"}
- res = self.resource_profile.parse_collectd_result(metric, [0, 1, 2])
+ res = self.resource_profile.parse_collectd_result(metric)
expected_result = {'cpu': {}, 'dpdkstat': {}, 'hugepages': {},
'memory': {'bw': '101'}, 'ovs_stats': {}, 'timestamp': '',
'intel_pmu': {},
@@ -301,28 +214,27 @@ class TestResourceProfile(unittest.TestCase):
self.assertDictEqual(res, expected_result)
def test_parse_collectd_result_hugepage(self):
- metric = {"nsb_stats/hugepages/free": "101"}
- self.resource_profile.parse_hugepages = \
- mock.Mock(return_value={"free": "101"})
- res = self.resource_profile.parse_collectd_result(metric, [0, 1, 2])
- expected_result = {'cpu': {}, 'dpdkstat': {}, 'hugepages': {'free':
- '101'},
+ # amqp returns bytes
+ metric = {b"nsb_stats/hugepages/free": b"101"}
+ self.resource_profile.parse_hugepages = mock.Mock(return_value={"free": "101"})
+ res = self.resource_profile.parse_collectd_result(metric)
+ expected_result = {'cpu': {}, 'dpdkstat': {}, 'hugepages': {'free': '101'},
'memory': {}, 'ovs_stats': {}, 'timestamp': '',
'intel_pmu': {},
'virt': {}}
self.assertDictEqual(res, expected_result)
def test_parse_collectd_result_dpdk_virt_ovs(self):
- metric = {"nsb_stats/dpdkstat/tx": "101",
- "nsb_stats/ovs_stats/tx": "101",
- "nsb_stats/virt/virt/memory": "101"}
+ metric = {b"nsb_stats/dpdkstat/tx": b"101",
+ b"nsb_stats/ovs_stats/tx": b"101",
+ b"nsb_stats/virt/virt/memory": b"101"}
self.resource_profile.parse_dpdkstat = \
mock.Mock(return_value={"tx": "101"})
self.resource_profile.parse_virt = \
mock.Mock(return_value={"memory": "101"})
self.resource_profile.parse_ovs_stats = \
mock.Mock(return_value={"tx": "101"})
- res = self.resource_profile.parse_collectd_result(metric, [0, 1, 2])
+ res = self.resource_profile.parse_collectd_result(metric)
expected_result = {'cpu': {}, 'dpdkstat': {'tx': '101'}, 'hugepages': {},
'memory': {}, 'ovs_stats': {'tx': '101'}, 'timestamp': '',
'intel_pmu': {},
@@ -347,7 +259,6 @@ class TestResourceProfile(unittest.TestCase):
self.assertIsNotNone(res)
def test_run_collectd_amqp(self):
- _queue = multiprocessing.Queue()
resource.AmqpConsumer = mock.Mock(autospec=collectd)
self.assertIsNone(self.resource_profile.run_collectd_amqp())
@@ -357,5 +268,9 @@ class TestResourceProfile(unittest.TestCase):
def test_stop(self):
self.assertIsNone(self.resource_profile.stop())
+ def test_stop(self):
+ self.resource_profile.amqp_client = mock.MagicMock()
+ self.assertIsNone(self.resource_profile.stop())
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/unit/network_services/traffic_profile/test_base.py b/tests/unit/network_services/traffic_profile/test_base.py
index 72b097b52..290610361 100644
--- a/tests/unit/network_services/traffic_profile/test_base.py
+++ b/tests/unit/network_services/traffic_profile/test_base.py
@@ -48,7 +48,7 @@ class TestTrafficProfile(unittest.TestCase):
def test_execute(self):
traffic_profile = TrafficProfile(self.TRAFFIC_PROFILE)
- self.assertRaises(NotImplementedError, traffic_profile.execute, {})
+ self.assertRaises(NotImplementedError, traffic_profile.execute_traffic, {})
def test_get(self):
traffic_profile = TrafficProfile(self.TRAFFIC_PROFILE)
diff --git a/tests/unit/network_services/traffic_profile/test_fixed.py b/tests/unit/network_services/traffic_profile/test_fixed.py
index 84843178e..eb182a2fb 100644
--- a/tests/unit/network_services/traffic_profile/test_fixed.py
+++ b/tests/unit/network_services/traffic_profile/test_fixed.py
@@ -74,7 +74,7 @@ class TestFixedProfile(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.100.20',
'local_mac': '00:00:00:00:00:01'},
@@ -86,7 +86,7 @@ class TestFixedProfile(unittest.TestCase):
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_mac': '00:00:00:00:00:02'},
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 846bfa307..616921e33 100644
--- a/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
+++ b/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
@@ -20,6 +20,8 @@ from __future__ import division
import unittest
import mock
+from copy import deepcopy
+
from tests.unit import STL_MOCKS
STLClient = mock.MagicMock()
@@ -35,6 +37,7 @@ if stl_patch:
class TestIXIARFC2544Profile(unittest.TestCase):
+
TRAFFIC_PROFILE = {
"schema": "isb:traffic_profile:0.1",
"name": "fixed",
@@ -43,13 +46,15 @@ class TestIXIARFC2544Profile(unittest.TestCase):
"traffic_type": "FixedTraffic",
"frame_rate": 100, # pps
"flow_number": 10,
- "frame_size": 64}}
+ "frame_size": 64,
+ },
+ }
PROFILE = {'description': 'Traffic profile to run RFC2544 latency',
'name': 'rfc2544',
'traffic_profile': {'traffic_type': 'IXIARFC2544Profile',
'frame_rate': 100},
- 'public': {'ipv4':
+ IXIARFC2544Profile.DOWNLINK: {'ipv4':
{'outer_l2': {'framesize':
{'64B': '100', '1518B': '0',
'128B': '0', '1400B': '0',
@@ -61,7 +66,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
'dscp': 0, 'ttl': 32},
'outer_l4': {'srcport': '2001',
'dsrport': '1234'}}},
- 'private': {'ipv4':
+ IXIARFC2544Profile.UPLINK: {'ipv4':
{'outer_l2': {'framesize':
{'64B': '100', '1518B': '0',
'128B': '0', '1400B': '0',
@@ -78,12 +83,12 @@ class TestIXIARFC2544Profile(unittest.TestCase):
def test_get_ixia_traffic_profile_error(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [-1]
- traffic_generator.pub_ports = [1]
+ traffic_generator.uplink_ports = [-1]
+ traffic_generator.downlink_ports = [1]
traffic_generator.client = \
mock.Mock(return_value=True)
STATIC_TRAFFIC = {
- "private": {
+ IXIARFC2544Profile.UPLINK: {
"id": 1,
"bidir": "False",
"duration": 60,
@@ -122,7 +127,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
},
"traffic_type": "continuous"
},
- "public": {
+ IXIARFC2544Profile.DOWNLINK: {
"id": 2,
"bidir": "False",
"duration": 60,
@@ -174,21 +179,20 @@ 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"}
- self.assertRaises(IOError, 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, xfile="tmp",
+ static_traffic=STATIC_TRAFFIC)
+ self.assertIsNotNone(result)
- @mock.patch("yardstick.network_services.traffic_profile.ixia_rfc2544.open")
- def test_get_ixia_traffic_profile(self, mock_open):
+ def test_get_ixia_traffic_profile(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [-1]
- traffic_generator.pub_ports = [1]
+ traffic_generator.uplink_ports = [-1]
+ traffic_generator.downlink_ports = [1]
traffic_generator.client = \
mock.Mock(return_value=True)
STATIC_TRAFFIC = {
- "private": {
+ IXIARFC2544Profile.UPLINK: {
"id": 1,
"bidir": "False",
"duration": 60,
@@ -230,7 +234,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
},
"traffic_type": "continuous"
},
- "public": {
+ IXIARFC2544Profile.DOWNLINK: {
"id": 2,
"bidir": "False",
"duration": 60,
@@ -293,12 +297,12 @@ class TestIXIARFC2544Profile(unittest.TestCase):
def test_get_ixia_traffic_profile_v6(self, mock_open):
traffic_generator = mock.Mock(autospec=TrexProfile)
traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [-1]
- traffic_generator.pub_ports = [1]
+ traffic_generator.uplink_ports = [-1]
+ traffic_generator.downlink_ports = [1]
traffic_generator.client = \
mock.Mock(return_value=True)
STATIC_TRAFFIC = {
- "private": {
+ IXIARFC2544Profile.UPLINK: {
"id": 1,
"bidir": "False",
"duration": 60,
@@ -337,7 +341,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
},
"traffic_type": "continuous"
},
- "public": {
+ IXIARFC2544Profile.DOWNLINK: {
"id": 2,
"bidir": "False",
"duration": 60,
@@ -394,7 +398,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
'traffic_profile':
{'traffic_type': 'IXIARFC2544Profile',
'frame_rate': 100},
- 'public':
+ IXIARFC2544Profile.DOWNLINK:
{'ipv4':
{'outer_l2': {'framesize':
{'64B': '100', '1518B': '0',
@@ -411,7 +415,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
'dscp': 0, 'ttl': 32},
'outer_l4': {'srcport': '2001',
'dsrport': '1234'}}},
- 'private': {'ipv4':
+ IXIARFC2544Profile.UPLINK: {'ipv4':
{'outer_l2': {'framesize':
{'64B': '100', '1518B': '0',
'128B': '0', '1400B': '0',
@@ -435,15 +439,23 @@ class TestIXIARFC2544Profile(unittest.TestCase):
profile_data, mac, static_traffic=STATIC_TRAFFIC)
self.assertIsNotNone(result)
+ def test__get_ixia_traffic_profile_default_args(self):
+ r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
+
+ expected = {}
+ result = r_f_c2544_profile._get_ixia_traffic_profile({})
+ self.assertDictEqual(result, expected)
+
def test__ixia_traffic_generate(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [-1]
- traffic_generator.pub_ports = [1]
+ traffic_generator.networks = {
+ "uplink_0": ["xe0"],
+ "downlink_0": ["xe1"],
+ }
traffic_generator.client = \
mock.Mock(return_value=True)
- traffic = {"public": {'iload': 10},
- "private": {'iload': 10}}
+ traffic = {IXIARFC2544Profile.DOWNLINK: {'iload': 10},
+ IXIARFC2544Profile.UPLINK: {'iload': 10}}
ixia_obj = mock.MagicMock()
r_f_c2544_profile = IXIARFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.rate = 100
@@ -451,18 +463,18 @@ class TestIXIARFC2544Profile(unittest.TestCase):
traffic, ixia_obj)
self.assertIsNone(result)
-
def test_execute(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [-1]
- traffic_generator.pub_ports = [1]
+ 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.first_run = True
- r_f_c2544_profile.params = {"public": {'iload': 10},
- "private": {'iload': 10}}
+ r_f_c2544_profile.params = {IXIARFC2544Profile.DOWNLINK: {'iload': 10},
+ IXIARFC2544Profile.UPLINK: {'iload': 10}}
r_f_c2544_profile.get_streams = mock.Mock()
r_f_c2544_profile.full_profile = {}
@@ -470,14 +482,40 @@ class TestIXIARFC2544Profile(unittest.TestCase):
r_f_c2544_profile.get_multiplier = mock.Mock()
r_f_c2544_profile._ixia_traffic_generate = mock.Mock()
ixia_obj = mock.MagicMock()
- self.assertEqual(None, r_f_c2544_profile.execute(traffic_generator,
- ixia_obj))
+ self.assertEqual(None, r_f_c2544_profile.execute_traffic(traffic_generator, ixia_obj))
+
+ def test_update_traffic_profile(self):
+ traffic_generator = mock.Mock(autospec=TrexProfile)
+ traffic_generator.networks = {
+ "uplink_0": ["xe0"], # private, one value for intfs
+ "downlink_0": ["xe1", "xe2"], # public, two values for intfs
+ "downlink_1": ["xe3"], # not in TRAFFIC PROFILE
+ "tenant_0": ["xe4"], # not public or private
+ }
+
+ ports_expected = [8, 3, 5]
+ traffic_generator.vnfd_helper.port_num.side_effect = ports_expected
+ traffic_generator.client.return_value = True
+
+ traffic_profile = deepcopy(self.TRAFFIC_PROFILE)
+ traffic_profile.update({
+ "uplink_0": ["xe0"],
+ "downlink_0": ["xe1", "xe2"],
+ })
+
+ r_f_c2544_profile = IXIARFC2544Profile(traffic_profile)
+ r_f_c2544_profile.full_profile = {}
+ r_f_c2544_profile.get_streams = mock.Mock()
+
+ self.assertIsNone(r_f_c2544_profile.update_traffic_profile(traffic_generator))
+ self.assertEqual(r_f_c2544_profile.ports, ports_expected)
def test_get_drop_percentage(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [0]
- traffic_generator.pub_ports = [1]
+ 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)
@@ -510,8 +548,8 @@ class TestIXIARFC2544Profile(unittest.TestCase):
def test_get_drop_percentage_update(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [0]
- traffic_generator.pub_ports = [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)
@@ -544,8 +582,8 @@ class TestIXIARFC2544Profile(unittest.TestCase):
def test_get_drop_percentage_div_zero(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [0]
- traffic_generator.pub_ports = [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)
@@ -584,9 +622,10 @@ class TestIXIARFC2544Profile(unittest.TestCase):
def test_start_ixia_latency(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [0]
- traffic_generator.pub_ports = [1]
+ 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)
diff --git a/tests/unit/network_services/traffic_profile/test_prox_acl.py b/tests/unit/network_services/traffic_profile/test_prox_acl.py
index be172f26b..ef5bac0d5 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_acl.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_acl.py
@@ -29,38 +29,50 @@ if stl_patch:
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxTestDataTuple
-class TestProxRampProfile(unittest.TestCase):
+class TestProxACLProfile(unittest.TestCase):
def test_run_test_with_pkt_size(self):
+ def target(*args, **kwargs):
+ 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, {}
+
+ def get_mock_samples(*args, **kwargs):
+ if args[2] < 0:
+ raise RuntimeError(' '.join([str(args), str(runs)]))
+ return success_tuple
+
tp_config = {
- 'traffic_profile': {
+ 'traffic_profile': {
'upper_bound': 100.0,
+ 'lower_bound': 0.0,
+ 'tolerated_loss': 50.0,
+ 'attempts': 20
},
}
+ 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_gen = mock.MagicMock()
- traffic_gen.resource_helper.run_test.side_effect = [
- success_tuple,
- success_tuple,
- success_tuple,
- fail_tuple,
- success_tuple,
- fail_tuple,
- fail_tuple,
- fail_tuple,
- ]
-
- fill_values = [1, 2, 3, 4, RuntimeError]
+
+ profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
profile = ProxACLProfile(tp_config)
- profile.fill_samples = fill_samples = mock.MagicMock(side_effect=fill_values)
- profile.queue = mock.MagicMock()
+ profile.init(mock.MagicMock())
- with self.assertRaises(RuntimeError):
- profile.run_test_with_pkt_size(traffic_gen, 128, 30)
+ profile.prox_config["attempts"] = 20
+ profile.queue = mock.MagicMock()
+ profile.tolerated_loss = 50.0
+ profile.pkt_size = 128
+ profile.duration = 30
+ profile.test_value = 100.0
+ profile.tolerated_loss = 100.0
+ profile._profile_helper = profile_helper
- self.assertEqual(traffic_gen.resource_helper.run_test.call_count, 5)
- self.assertEqual(fill_samples.call_count, 5)
+ profile.run_test_with_pkt_size(traffic_gen, profile.pkt_size, profile.duration)
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 0edce7a14..c1f1c825b 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
@@ -51,12 +51,15 @@ class TestProxBinSearchProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_generator = mock.MagicMock()
- traffic_generator.run_test = target
+
+ profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
profile = ProxBinSearchProfile(tp_config)
profile.init(mock.MagicMock())
+ profile._profile_helper = profile_helper
- profile.execute(traffic_generator)
+ 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)
@@ -82,12 +85,15 @@ class TestProxBinSearchProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_generator = mock.MagicMock()
- traffic_generator.run_test = target
+
+ profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
profile = ProxBinSearchProfile(tp_config)
profile.init(mock.MagicMock())
+ profile._profile_helper = profile_helper
- profile.execute(traffic_generator)
+ profile.execute_traffic(traffic_generator)
self.assertEqual(round(profile.current_lower, 2), 24.06)
self.assertEqual(round(profile.current_upper, 2), 25.47)
self.assertEqual(len(runs), 7)
diff --git a/tests/unit/network_services/traffic_profile/test_prox_mpls.py b/tests/unit/network_services/traffic_profile/test_prox_mpls.py
index 77bca9cc0..00a690d2a 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_mpls.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_mpls.py
@@ -51,12 +51,13 @@ class TestProxMplsTagUntagProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_generator = mock.MagicMock()
- traffic_generator.run_test = target
profile = ProxMplsTagUntagProfile(tp_config)
profile.init(mock.MagicMock())
+ profile._profile_helper = profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
- profile.execute(traffic_generator)
+ 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)
@@ -82,12 +83,13 @@ class TestProxMplsTagUntagProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_generator = mock.MagicMock()
- traffic_generator.run_test = target
profile = ProxMplsTagUntagProfile(tp_config)
profile.init(mock.MagicMock())
+ profile._profile_helper = profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
- profile.execute(traffic_generator)
+ profile.execute_traffic(traffic_generator)
self.assertEqual(round(profile.current_lower, 2), 24.06)
self.assertEqual(round(profile.current_upper, 2), 25.47)
self.assertEqual(len(runs), 7)
diff --git a/tests/unit/network_services/traffic_profile/test_prox_profile.py b/tests/unit/network_services/traffic_profile/test_prox_profile.py
index 14223da0f..078e72b8e 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_profile.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_profile.py
@@ -26,6 +26,7 @@ stl_patch.start()
if stl_patch:
from yardstick.network_services.traffic_profile.prox_profile import ProxProfile
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxResourceHelper
class TestProxProfile(unittest.TestCase):
@@ -62,10 +63,11 @@ class TestProxProfile(unittest.TestCase):
}
profile = ProxProfile(tp_config)
- profile.init(234)
- self.assertEqual(profile.queue, 234)
+ queue = mock.Mock()
+ profile.init(queue)
+ self.assertIs(profile.queue, queue)
- def test_execute(self):
+ def test_execute_traffic(self):
packet_sizes = [
10,
100,
@@ -78,14 +80,22 @@ class TestProxProfile(unittest.TestCase):
}
traffic_generator = mock.MagicMock()
+
+ setup_helper = traffic_generator.setup_helper
+ setup_helper.find_in_section.return_value = None
+
+ prox_resource_helper = ProxResourceHelper(setup_helper)
+ traffic_generator.resource_helper = prox_resource_helper
+
profile = ProxProfile(tp_config)
self.assertFalse(profile.done)
for _ in packet_sizes:
with self.assertRaises(NotImplementedError):
- profile.execute(traffic_generator)
+ profile.execute_traffic(traffic_generator)
- self.assertIsNone(profile.execute(traffic_generator))
+ self.assertIsNone(profile.execute_traffic(traffic_generator))
+ self.assertTrue(profile.done)
def test_bounds_iterator(self):
tp_config = {
diff --git a/tests/unit/network_services/traffic_profile/test_prox_ramp.py b/tests/unit/network_services/traffic_profile/test_prox_ramp.py
index 357298759..1acec2f68 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_ramp.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_ramp.py
@@ -26,6 +26,7 @@ stl_patch.start()
if stl_patch:
from yardstick.network_services.traffic_profile.prox_ramp import ProxRampProfile
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxProfileHelper
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxTestDataTuple
@@ -43,14 +44,18 @@ class TestProxRampProfile(unittest.TestCase):
success_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.1, 5.2, 5.3], 995, 1000, 123.4)
traffic_gen = mock.MagicMock()
- traffic_gen.resource_helper.run_test.return_value = success_tuple
+ traffic_gen._test_type = 'Generic'
+
+ profile_helper = ProxProfileHelper(traffic_gen.resource_helper)
+ profile_helper.run_test = run_test = mock.MagicMock(return_value=success_tuple)
profile = ProxRampProfile(tp_config)
profile.fill_samples = fill_samples = mock.MagicMock()
profile.queue = mock.MagicMock()
+ profile._profile_helper = profile_helper
profile.run_test_with_pkt_size(traffic_gen, 128, 30)
- self.assertEqual(traffic_gen.resource_helper.run_test.call_count, 10)
+ self.assertEqual(run_test.call_count, 10)
self.assertEqual(fill_samples.call_count, 10)
def test_run_test_with_pkt_size_with_fail(self):
@@ -65,8 +70,7 @@ class TestProxRampProfile(unittest.TestCase):
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_gen = mock.MagicMock()
- traffic_gen.resource_helper.run_test.side_effect = [
+ result_list = [
success_tuple,
success_tuple,
success_tuple,
@@ -77,10 +81,17 @@ class TestProxRampProfile(unittest.TestCase):
fail_tuple,
]
+ traffic_gen = mock.MagicMock()
+ traffic_gen._test_type = 'Generic'
+
+ profile_helper = ProxProfileHelper(traffic_gen.resource_helper)
+ profile_helper.run_test = run_test = mock.MagicMock(side_effect=result_list)
+
profile = ProxRampProfile(tp_config)
profile.fill_samples = fill_samples = mock.MagicMock()
profile.queue = mock.MagicMock()
+ profile._profile_helper = profile_helper
profile.run_test_with_pkt_size(traffic_gen, 128, 30)
- self.assertEqual(traffic_gen.resource_helper.run_test.call_count, 4)
+ self.assertEqual(run_test.call_count, 4)
self.assertEqual(fill_samples.call_count, 3)
diff --git a/tests/unit/network_services/traffic_profile/test_rfc2544.py b/tests/unit/network_services/traffic_profile/test_rfc2544.py
index aef0b93de..221233710 100644
--- a/tests/unit/network_services/traffic_profile/test_rfc2544.py
+++ b/tests/unit/network_services/traffic_profile/test_rfc2544.py
@@ -50,7 +50,7 @@ class TestRFC2544Profile(unittest.TestCase):
'name': 'rfc2544',
'traffic_profile': {'traffic_type': 'RFC2544Profile',
'frame_rate': 100},
- 'public_1': {'ipv4':
+ 'downlink_0': {'ipv4':
{'outer_l2': {'framesize':
{'64B': '100', '1518B': '0',
'128B': '0', '1400B': '0',
@@ -62,7 +62,7 @@ class TestRFC2544Profile(unittest.TestCase):
'dscp': 0, 'ttl': 32, 'count': 1},
'outer_l4': {'srcport': '2001',
'dsrport': '1234', 'count': 1}}},
- 'private_1': {'ipv4':
+ 'uplink_0': {'ipv4':
{'outer_l2': {'framesize':
{'64B': '100', '1518B': '0',
'128B': '0', '1400B': '0',
@@ -82,27 +82,29 @@ class TestRFC2544Profile(unittest.TestCase):
def test_execute(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [-1]
- traffic_generator.pub_ports = [1]
+ traffic_generator.networks = {
+ "uplink_0": ["xe0"],
+ "downlink_0": ["xe1"],
+ }
traffic_generator.client = \
mock.Mock(return_value=True)
r_f_c2544_profile = RFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.params = self.PROFILE
r_f_c2544_profile.first_run = True
- self.assertEqual(None, r_f_c2544_profile.execute(traffic_generator))
+ self.assertEqual(None, r_f_c2544_profile.execute_traffic(traffic_generator))
def test_get_drop_percentage(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [0]
- traffic_generator.pub_ports = [1]
+ traffic_generator.networks = {
+ "uplink_0": ["xe0"],
+ "downlink_0": ["xe1"],
+ }
traffic_generator.client = mock.Mock(return_value=True)
r_f_c2544_profile = RFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.params = self.PROFILE
r_f_c2544_profile.register_generator(traffic_generator)
- self.assertIsNone(r_f_c2544_profile.execute(traffic_generator))
+ self.assertIsNone(r_f_c2544_profile.execute_traffic(traffic_generator))
samples = {}
for ifname in range(1):
@@ -140,15 +142,16 @@ class TestRFC2544Profile(unittest.TestCase):
def test_get_drop_percentage_update(self):
traffic_generator = mock.Mock(autospec=RFC2544Profile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [0]
- traffic_generator.pub_ports = [1]
+ traffic_generator.networks = {
+ "uplink_0": ["xe0"],
+ "downlink_0": ["xe1"],
+ }
traffic_generator.client = mock.Mock(return_value=True)
r_f_c2544_profile = RFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.params = self.PROFILE
r_f_c2544_profile.register_generator(traffic_generator)
- self.assertIsNone(r_f_c2544_profile.execute())
+ self.assertIsNone(r_f_c2544_profile.execute_traffic())
samples = {}
for ifname in range(1):
@@ -187,14 +190,15 @@ class TestRFC2544Profile(unittest.TestCase):
def test_get_drop_percentage_div_zero(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [0]
- traffic_generator.pub_ports = [1]
+ traffic_generator.networks = {
+ "uplink_0": ["xe0"],
+ "downlink_0": ["xe1"],
+ }
traffic_generator.client = \
mock.Mock(return_value=True)
r_f_c2544_profile = RFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.params = self.PROFILE
- self.assertEqual(None, r_f_c2544_profile.execute(traffic_generator))
+ self.assertEqual(None, r_f_c2544_profile.execute_traffic(traffic_generator))
samples = {}
for ifname in range(1):
name = "xe{}".format(ifname)
@@ -254,9 +258,10 @@ class TestRFC2544Profile(unittest.TestCase):
def test_execute_latency(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
- traffic_generator.my_ports = [0, 1]
- traffic_generator.priv_ports = [-1]
- traffic_generator.pub_ports = [1]
+ traffic_generator.networks = {
+ "private_0": ["xe0"],
+ "public_0": ["xe1"],
+ }
traffic_generator.client = \
mock.Mock(return_value=True)
r_f_c2544_profile = RFC2544Profile(self.TRAFFIC_PROFILE)
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 55e7d483a..8355c85b6 100644
--- a/tests/unit/network_services/traffic_profile/test_traffic_profile.py
+++ b/tests/unit/network_services/traffic_profile/test_traffic_profile.py
@@ -60,24 +60,24 @@ class TestTrexProfile(unittest.TestCase):
'name': 'rfc2544',
'traffic_profile': {'traffic_type': 'RFC2544Profile',
'frame_rate': 100},
- 'public': {'ipv4': {'outer_l2': {'framesize': {'64B': '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',
+ "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',
+ 'outer_l4': {'srcport': '2001',
'dsrport': '1234',
'count': 1}}},
- 'private': {'ipv4':
+ TrafficProfile.UPLINK: {'ipv4':
{'outer_l2': {'framesize':
{'64B': '100', '1518B': '0',
'128B': '0', '1400B': '0',
@@ -97,22 +97,22 @@ class TestTrexProfile(unittest.TestCase):
'name': 'rfc2544',
'traffic_profile': {'traffic_type': 'RFC2544Profile',
'frame_rate': 100},
- 'public': {'ipv6': {'outer_l2': {'framesize':
+ 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',
+ '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',
+ 'outer_l4': {'srcport': '2001',
'dsrport': '1234',
'count': 1}}},
- 'private':
+ TrafficProfile.UPLINK:
{'ipv6': {'outer_l2': {'framesize':
{'64B': '100', '1518B': '0',
'128B': '0', '1400B': '0',
@@ -136,11 +136,6 @@ class TestTrexProfile(unittest.TestCase):
TrexProfile(TrafficProfile)
self.assertEqual(trex_profile.pps, 100)
- def test_execute(self):
- trex_profile = \
- TrexProfile(TrafficProfile)
- self.assertEqual(None, trex_profile.execute({}))
-
def test_qinq(self):
qinq = {"S-VLAN": {"id": 128, "priority": 0, "cfi": 0},
"C-VLAN": {"id": 512, "priority": 0, "cfi": 0}}
@@ -158,21 +153,21 @@ class TestTrexProfile(unittest.TestCase):
TrexProfile(TrafficProfile)
qinq = {"S-VLAN": {"id": 128, "priority": 0, "cfi": 0},
"C-VLAN": {"id": 512, "priority": 0, "cfi": 0}}
- outer_l2 = self.PROFILE['private']['ipv4']['outer_l2']
+ outer_l2 = self.PROFILE[TrafficProfile.UPLINK]['ipv4']['outer_l2']
outer_l2['QinQ'] = qinq
self.assertEqual(None, trex_profile._set_outer_l2_fields(outer_l2))
def test__set_outer_l3v4_fields(self):
trex_profile = \
TrexProfile(TrafficProfile)
- outer_l3v4 = self.PROFILE['private']['ipv4']['outer_l3v4']
+ outer_l3v4 = self.PROFILE[TrafficProfile.UPLINK]['ipv4']['outer_l3v4']
outer_l3v4['proto'] = 'tcp'
self.assertEqual(None, trex_profile._set_outer_l3v4_fields(outer_l3v4))
def test__set_outer_l3v6_fields(self):
trex_profile = \
TrexProfile(TrafficProfile)
- outer_l3v6 = self.PROFILE_v6['private']['ipv6']['outer_l3v4']
+ outer_l3v6 = self.PROFILE_v6[TrafficProfile.UPLINK]['ipv6']['outer_l3v4']
outer_l3v6['proto'] = 'tcp'
outer_l3v6['tc'] = 1
outer_l3v6['hlim'] = 10
@@ -181,19 +176,19 @@ class TestTrexProfile(unittest.TestCase):
def test__set_outer_l4_fields(self):
trex_profile = \
TrexProfile(TrafficProfile)
- outer_l4 = self.PROFILE['private']['ipv4']['outer_l4']
+ outer_l4 = self.PROFILE[TrafficProfile.UPLINK]['ipv4']['outer_l4']
self.assertEqual(None, trex_profile._set_outer_l4_fields(outer_l4))
def test_get_streams(self):
trex_profile = \
TrexProfile(TrafficProfile)
trex_profile.params = self.PROFILE
- profile_data = self.PROFILE["private"]
+ profile_data = self.PROFILE[TrafficProfile.UPLINK]
self.assertIsNotNone(trex_profile.get_streams(profile_data))
trex_profile.pg_id = 1
self.assertIsNotNone(trex_profile.get_streams(profile_data))
trex_profile.params = self.PROFILE_v6
- trex_profile.profile_data = self.PROFILE_v6["private"]
+ trex_profile.profile_data = self.PROFILE_v6[TrafficProfile.UPLINK]
self.assertIsNotNone(trex_profile.get_streams(profile_data))
trex_profile.pg_id = 1
self.assertIsNotNone(trex_profile.get_streams(profile_data))
@@ -239,7 +234,7 @@ class TestTrexProfile(unittest.TestCase):
ether_range = "00:00:00:00:00:01-00:00:00:00:00:02"
ip_range = "1.1.1.2-1.1.1.10"
- ipv6_range = '0064:ff9b:0:0:0:0:9810:6414-0064:ff9b:0:0:0:0:9810:6420'
+ ipv6_range = '0064:ff9b:0:0:0:0:9810:6414-0064:ff9b:0:0:0:0:9810:6420'
trex_profile._set_proto_addr(ETHERNET, SRC, ether_range)
trex_profile._set_proto_addr(ETHERNET, DST, ether_range)
@@ -249,6 +244,3 @@ class TestTrexProfile(unittest.TestCase):
trex_profile._set_proto_addr(IPv6, DST, ipv6_range)
trex_profile._set_proto_addr(UDP, SRC_PORT, "5060-5090")
trex_profile._set_proto_addr(UDP, DST_PORT, "5060")
-
-
-
diff --git a/tests/unit/network_services/vnf_generic/test_vnfdgen.py b/tests/unit/network_services/vnf_generic/test_vnfdgen.py
index c2b923568..ee881c963 100644
--- a/tests/unit/network_services/vnf_generic/test_vnfdgen.py
+++ b/tests/unit/network_services/vnf_generic/test_vnfdgen.py
@@ -24,6 +24,10 @@ from six.moves import range
from yardstick.common.yaml_loader import yaml_load
from yardstick.network_services.vnf_generic import vnfdgen
+
+UPLINK = "uplink"
+DOWNLINK = "downlink"
+
TREX_VNFD_TEMPLATE = """
vnfd:vnfd-catalog:
vnfd:
@@ -183,22 +187,23 @@ NODE_CFG = {'ip': '1.1.1.1',
}
+# need to template, but can't use {} so use %s
TRAFFIC_PROFILE_TPL = """
-private:
+%(0)s:
- ipv4:
outer_l2:
framesize:
- 64B: "{{ get(imix, 'private.imix_small', 10) }}"
- 128B: "{{ get(imix, 'private.imix_128B', 10) }}"
- 256B: "{{ get(imix, 'private.imix_256B', 10) }}"
- 373B: "{{ get(imix, 'private.imix_373B', 10) }}"
- 570B: "{{get(imix, 'private.imix_570B', 10) }}"
- 1400B: "{{get(imix, 'private.imix_1400B', 10) }}"
- 1518B: "{{get(imix, 'private.imix_1500B', 40) }}"
-"""
+ 64B: "{{ get(imix, '%(0)s.imix_small', 10) }}"
+ 128B: "{{ get(imix, '%(0)s.imix_128B', 10) }}"
+ 256B: "{{ get(imix, '%(0)s.imix_256B', 10) }}"
+ 373B: "{{ get(imix, '%(0)s.imix_373B', 10) }}"
+ 570B: "{{get(imix, '%(0)s.imix_570B', 10) }}"
+ 1400B: "{{get(imix, '%(0)s.imix_1400B', 10) }}"
+ 1518B: "{{get(imix, '%(0)s.imix_1500B', 40) }}"
+""" % {"0": UPLINK}
TRAFFIC_PROFILE = {
- "private": [{"ipv4": {"outer_l2":
+ UPLINK: [{"ipv4": {"outer_l2":
{"framesize": {"64B": '10', "128B": '10',
"256B": '10', "373B": '10',
"570B": '10', "1400B": '10',
@@ -269,8 +274,8 @@ class TestVnfdGen(unittest.TestCase):
generated_tp = \
vnfdgen.generate_vnfd(TRAFFIC_PROFILE_TPL,
- {"imix": {"private": {"imix_small": '20'}}})
+ {"imix": {UPLINK: {"imix_small": '20'}}})
self.maxDiff = None
tp2 = dict(TRAFFIC_PROFILE)
- tp2["private"][0]["ipv4"]["outer_l2"]["framesize"]["64B"] = '20'
+ tp2[UPLINK][0]["ipv4"]["outer_l2"]["framesize"]["64B"] = '20'
self.assertDictEqual(tp2, generated_tp)
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 2e83353cd..e9444b493 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
@@ -75,7 +75,7 @@ class TestAclApproxVnf(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'driver': "i40e",
'dst_ip': '152.16.100.20',
@@ -90,7 +90,7 @@ class TestAclApproxVnf(unittest.TestCase):
'type': 'PCI-PASSTHROUGH',
'driver': "i40e",
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_iface_name': 'xe1',
@@ -144,7 +144,7 @@ class TestAclApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens513f0',
- 'vld_id': 'public',
+ 'vld_id': AclApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.20',
'dst_mac': '00:00:00:00:00:01',
@@ -172,7 +172,7 @@ class TestAclApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens785f0',
- 'vld_id': 'private',
+ 'vld_id': AclApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.20',
'dst_mac': '00:00:00:00:00:02',
@@ -197,7 +197,7 @@ class TestAclApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens786f0',
- 'vld_id': 'private',
+ 'vld_id': AclApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.19',
'dst_mac': '00:00:00:00:00:04',
@@ -207,7 +207,7 @@ class TestAclApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.0',
'dpdk_port_num': 0},
'xe1': {'local_iface_name': 'ens786f1',
- 'vld_id': 'public',
+ 'vld_id': AclApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.19',
'dst_mac': '00:00:00:00:00:03',
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_base.py b/tests/unit/network_services/vnf_generic/vnf/test_base.py
index e1c69e7b3..478ce186b 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_base.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_base.py
@@ -150,7 +150,7 @@ class TestGenericVNF(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.100.20',
'local_mac': '00:00:00:00:00:01'
@@ -165,7 +165,7 @@ class TestGenericVNF(unittest.TestCase):
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_mac': '00:00:00:00:00:02'
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 e5503697a..b0ef1da91 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
@@ -21,6 +21,8 @@ import os
import unittest
import mock
+from copy import deepcopy
+
from tests.unit import STL_MOCKS
from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
@@ -39,7 +41,7 @@ TEST_FILE_YAML = 'nsb_test_case.yaml'
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
-name = 'vnf__1'
+name = 'vnf__0'
class TestCgnaptApproxSetupEnvHelper(unittest.TestCase):
@@ -66,15 +68,22 @@ link 1 up
"""
header = "This is a header"
- out = CgnaptApproxSetupEnvHelper._update_cgnat_script_file(header, sample.splitlines(), "")
+ out = CgnaptApproxSetupEnvHelper._update_cgnat_script_file(header, sample.splitlines())
self.assertNotIn("This is a header", out)
- def test__get_cgnapt_confgi(self):
+ def test__get_cgnapt_config(self):
+ vnfd_helper = mock.Mock()
+ vnfd_helper.port_pairs.uplink_ports = [{"name": 'a'}, {"name": "b"}, {"name": "c"}]
+
+ helper = CgnaptApproxSetupEnvHelper(vnfd_helper, mock.Mock(), mock.Mock())
+ helper._get_ports_gateway = mock.Mock(side_effect=[3, 5, 2])
+ result = helper._get_cgnapt_config([{"name": 'a'}, {}, {"name": "b"}, {}, {"name": "c"}])
+ self.assertEqual(result, [3, 5, 2])
- c = CgnaptApproxSetupEnvHelper(mock.MagicMock(), mock.MagicMock(), mock.MagicMock())
- c._get_ports_gateway = mock.Mock(return_value=3)
- ret = c._get_cgnapt_config([{"name": 'a'}, {}, {"name": "b"}, {}, {"name": "c"}])
- self.assertEqual(ret, [3, 3, 3])
+ def test_scale(self):
+ helper = CgnaptApproxSetupEnvHelper(mock.Mock(), mock.Mock(), mock.Mock())
+ with self.assertRaises(NotImplementedError):
+ helper.scale()
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Process")
@@ -111,7 +120,7 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'driver': "i40e",
'dst_ip': '152.16.100.20',
@@ -126,7 +135,7 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'type': 'PCI-PASSTHROUGH',
'driver': "i40e",
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_iface_name': 'xe1',
@@ -146,31 +155,48 @@ class TestCgnaptApproxVnf(unittest.TestCase):
{'type': 'VPORT', 'name': 'xe1'}],
'id': 'CgnaptApproxVnf', 'name': 'VPEVnfSsh'}]}}
- scenario_cfg = {'options': {'packetsize': 64, 'traffic_type': 4,
- 'rfc2544': {'allowed_drop_rate': '0.8 - 1'},
- 'vnf__1': {'rules': 'acl_1rule.yaml',
- 'vnf_config': {'lb_config': 'SW',
- 'lb_count': 1,
- 'worker_config':
- '1C/1T',
- 'worker_threads': 1}}
- },
- 'task_id': 'a70bdf4a-8e67-47a3-9dc1-273c14506eb7',
- 'task_path': '/tmp',
- 'tc': 'tc_ipv4_1Mflow_64B_packetsize',
- 'runner': {'object': 'NetworkServiceTestCase',
- 'interval': 35,
- 'output_filename': '/tmp/yardstick.out',
- 'runner_id': 74476, 'duration': 400,
- 'type': 'Duration'},
- 'traffic_profile': 'ipv4_throughput_acl.yaml',
- 'traffic_options': {'flow': 'ipv4_Packets_acl.yaml',
- 'imix': 'imix_voice.yaml'},
- 'type': 'ISB',
- 'nodes': {'tg__2': 'trafficgen_2.yardstick',
- 'tg__1': 'trafficgen_1.yardstick',
- 'vnf__1': 'vnf.yardstick'},
- 'topology': 'vpe-tg-topology-baremetal.yaml'}
+ SCENARIO_CFG = {
+ 'options': {
+ 'packetsize': 64,
+ 'traffic_type': 4,
+ 'rfc2544': {
+ 'allowed_drop_rate': '0.8 - 1',
+ },
+ 'vnf__0': {
+ 'napt': 'dynamic',
+ 'vnf_config': {
+ 'lb_config': 'SW',
+ 'lb_count': 1,
+ 'worker_config':
+ '1C/1T',
+ 'worker_threads': 1,
+ },
+ },
+ 'flow': {'count': 1,
+ 'dst_ip': [{'tg__1': 'xe0'}],
+ 'public_ip': [''],
+ 'src_ip': [{'tg__0': 'xe0'}]},
+ },
+ 'task_id': 'a70bdf4a-8e67-47a3-9dc1-273c14506eb7',
+ 'task_path': '/tmp',
+ 'tc': 'tc_ipv4_1Mflow_64B_packetsize',
+ 'runner': {
+ 'object': 'NetworkServiceTestCase',
+ 'interval': 35,
+ 'output_filename': '/tmp/yardstick.out',
+ 'runner_id': 74476,
+ 'duration': 400,
+ 'type': 'Duration',
+ },
+ 'traffic_profile': 'ipv4_throughput_acl.yaml',
+ 'type': 'NSPerf',
+ 'nodes': {
+ 'tg__1': 'trafficgen_1.yardstick',
+ 'tg__0': 'trafficgen_0.yardstick',
+ 'vnf__0': 'vnf.yardstick',
+ },
+ 'topology': 'vpe-tg-topology-baremetal.yaml',
+ }
context_cfg = {'nodes': {'tg__2':
{'member-vnf-index': '3',
@@ -180,7 +206,7 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens513f0',
- 'vld_id': 'public',
+ 'vld_id': CgnaptApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.20',
'dst_mac': '00:00:00:00:00:01',
@@ -208,7 +234,7 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens785f0',
- 'vld_id': 'private',
+ 'vld_id': CgnaptApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.20',
'dst_mac': '00:00:00:00:00:02',
@@ -227,13 +253,13 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'password': 'r00t',
'VNF model': 'tg_rfc2544_tpl.yaml',
'user': 'root'},
- 'vnf__1':
+ 'vnf__0':
{'name': 'vnf.yardstick',
- 'vnfd-id-ref': 'vnf__1',
+ 'vnfd-id-ref': 'vnf__0',
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens786f0',
- 'vld_id': 'private',
+ 'vld_id': CgnaptApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.19',
'dst_mac': '00:00:00:00:00:04',
@@ -243,7 +269,7 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.0',
'dpdk_port_num': 0},
'xe1': {'local_iface_name': 'ens786f1',
- 'vld_id': 'public',
+ 'vld_id': CgnaptApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.19',
'dst_mac': '00:00:00:00:00:03',
@@ -277,18 +303,23 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'password': 'r00t',
'VNF model': 'cgnapt_vnf.yaml'}}}
+ def setUp(self):
+ self.scenario_cfg = deepcopy(self.SCENARIO_CFG)
+
def test___init__(self, mock_process):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
self.assertIsNone(cgnapt_approx_vnf._vnf_process)
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch(SSH_HELPER)
def test_collect_kpi(self, ssh, mock_time, mock_process):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
+ cgnapt_approx_vnf._vnf_process = mock.MagicMock(
+ **{"is_alive.return_value": True, "exitcode": None})
cgnapt_approx_vnf.q_in = mock.MagicMock()
cgnapt_approx_vnf.q_out = mock.MagicMock()
cgnapt_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
@@ -296,7 +327,7 @@ class TestCgnaptApproxVnf(unittest.TestCase):
result = {'packets_dropped': 0, 'packets_fwd': 0, 'packets_in': 0}
self.assertEqual(result, cgnapt_approx_vnf.collect_kpi())
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch(SSH_HELPER)
def test_vnf_execute_command(self, ssh, mock_time, mock_process):
mock_ssh(ssh)
@@ -359,7 +390,7 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'rules': ""}}
cgnapt_approx_vnf.q_out.put("pipeline>")
cgnapt_vnf.WAIT_TIME = 3
- self.scenario_cfg.update({"nodes": {"vnf__1": ""}})
+ self.scenario_cfg.update({"nodes": {"vnf__0": ""}})
self.assertIsNone(cgnapt_approx_vnf.instantiate(self.scenario_cfg,
self.context_cfg))
@@ -386,9 +417,24 @@ class TestCgnaptApproxVnf(unittest.TestCase):
self.assertEqual(None, cgnapt_approx_vnf.terminate())
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
- @mock.patch("yardstick.network_services.vnf_generic.vnf.cgnapt_vnf.time")
@mock.patch(SSH_HELPER)
- def test__vnf_up_post(self, ssh, mock_time, mock_cgnapt_time, mock_process):
+ def test__vnf_up_post(self, ssh, mock_time, mock_process):
+ mock_ssh(ssh)
+
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ self.scenario_cfg['options'][name]['napt'] = 'static'
+
+ cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
+ cgnapt_approx_vnf._vnf_process = mock.MagicMock()
+ cgnapt_approx_vnf._vnf_process.terminate = mock.Mock()
+ cgnapt_approx_vnf.vnf_execute = mock.MagicMock()
+ cgnapt_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg
+ cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
+ cgnapt_approx_vnf._vnf_up_post()
+
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
+ @mock.patch(SSH_HELPER)
+ def test__vnf_up_post_short(self, ssh, mock_time, mock_process):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
@@ -399,7 +445,6 @@ class TestCgnaptApproxVnf(unittest.TestCase):
cgnapt_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg
cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
cgnapt_approx_vnf._vnf_up_post()
- cgnapt_approx_vnf.vnf_execute.assert_called_once()
if __name__ == '__main__':
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 cba3d449f..3c073812c 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
@@ -21,10 +21,10 @@ import os
import socket
import unittest
from itertools import repeat, chain
-from contextlib import contextmanager
import mock
from tests.unit import STL_MOCKS
+from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
STLClient = mock.MagicMock()
stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
@@ -38,7 +38,12 @@ if stl_patch:
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxTestDataTuple
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxDpdkVnfSetupEnvHelper
from yardstick.network_services.vnf_generic.vnf.prox_helpers import TotStatsTuple
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxDataHelper
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxResourceHelper
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxProfileHelper
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxMplsProfileHelper
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxBngProfileHelper
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxVpeProfileHelper
class TestCoreTuple(unittest.TestCase):
@@ -634,6 +639,211 @@ class TestProxSocketHelper(unittest.TestCase):
class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
+
+ VNFD0 = {
+ 'short-name': 'ProxVnf',
+ 'vdu': [
+ {
+ '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',
+ },
+ ],
+ 'description': 'PROX approximation using DPDK',
+ 'name': 'proxvnf-baremetal',
+ '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',
+ },
+ ],
+ 'id': 'proxvnf-baremetal',
+ 'external-interface': [
+ {
+ 'virtual-interface': {
+ 'dst_mac': '00:00:00:00:00:04',
+ 'vpci': '0000:05:00.0',
+ 'local_ip': '152.16.100.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'vld_id': 'uplink_0',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 0,
+ 'bandwidth': '10 Gbps',
+ 'driver': "i40e",
+ 'dst_ip': '152.16.100.19',
+ 'local_iface_name': 'xe0',
+ 'local_mac': '00:00:00:00:00:02',
+ 'ifname': 'xe0',
+ },
+ 'vnfd-connection-point-ref': 'xe0',
+ 'name': 'xe0',
+ },
+ {
+ 'virtual-interface': {
+ 'dst_mac': '00:00:00:00:00:03',
+ 'vpci': '0000:05:00.1',
+ 'local_ip': '152.16.40.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'vld_id': 'downlink_0',
+ 'driver': "i40e",
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 1,
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.40.20',
+ 'local_iface_name': 'xe1',
+ 'local_mac': '00:00:00:00:00:01',
+ 'ifname': 'xe1',
+ },
+ 'vnfd-connection-point-ref': 'xe1',
+ 'name': 'xe1',
+ },
+ ],
+ },
+ ],
+ 'description': 'PROX approximation using DPDK',
+ 'mgmt-interface': {
+ 'vdu-id': 'proxvnf-baremetal',
+ 'host': '1.2.1.1',
+ 'password': 'r00t',
+ 'user': 'root',
+ 'ip': '1.2.1.1',
+ },
+ 'benchmark': {
+ 'kpi': [
+ 'packets_in',
+ 'packets_fwd',
+ 'packets_dropped',
+ ],
+ },
+ 'id': 'ProxApproxVnf',
+ 'name': 'ProxVnf',
+ }
+
+ VNFD = {
+ 'vnfd:vnfd-catalog': {
+ 'vnfd': [
+ VNFD0,
+ ],
+ },
+ }
+
+ def test_global_section(self):
+ setup_helper = ProxDpdkVnfSetupEnvHelper(mock.MagicMock(), mock.MagicMock(),
+ mock.MagicMock())
+
+ setup_helper._prox_config_data = [('a', [])]
+
+ with self.assertRaises(KeyError):
+ _ = setup_helper.global_section
+
+ global_section = (
+ 'global', [
+ ('not_name', 'other data'),
+ ('name_not', 'more data'),
+ ('name', 'prox type'),
+ ],
+ )
+
+ setup_helper._prox_config_data = [
+ ('section1', []),
+ ('section2', [
+ ('a', 'b'),
+ ('c', 'd'),
+ ]),
+ ('core 1', []),
+ ('core 2', [
+ ('index', 8),
+ ('mode', ''),
+ ]),
+ global_section,
+ ('core 3', [
+ ('index', 5),
+ ('mode', 'gen'),
+ ('name', 'tagged'),
+ ]),
+ ('section3', [
+ ('key1', 'value1'),
+ ('key2', 'value2'),
+ ('key3', 'value3'),
+ ]),
+ ('core 4', [
+ ('index', 7),
+ ('mode', 'gen'),
+ ('name', 'udp'),
+ ]),
+ ]
+
+ result = setup_helper.global_section
+ self.assertEqual(result, global_section[1])
+
+ def test_find_in_section(self):
+ setup_helper = ProxDpdkVnfSetupEnvHelper(mock.MagicMock(), mock.MagicMock(),
+ mock.MagicMock())
+
+ setup_helper._prox_config_data = [
+ ('global', [
+ ('not_name', 'other data'),
+ ('name_not', 'more data'),
+ ('name', 'prox type'),
+ ]),
+ ('section1', []),
+ ('section2', [
+ ('a', 'b'),
+ ('c', 'd'),
+ ]),
+ ('core 1', []),
+ ('core 2', [
+ ('index', 8),
+ ('mode', ''),
+ ]),
+ ('core 3', [
+ ('index', 5),
+ ('mode', 'gen'),
+ ('name', 'tagged'),
+ ]),
+ ('section3', [
+ ('key1', 'value1'),
+ ('key2', 'value2'),
+ ('key3', 'value3'),
+ ]),
+ ('core 4', [
+ ('index', 7),
+ ('mode', 'gen'),
+ ('name', 'udp'),
+ ]),
+ ]
+
+ expected = 'value3'
+ result = setup_helper.find_in_section('section3', 'key3')
+ self.assertEqual(result, expected)
+
+ expected = 'default value'
+ result = setup_helper.find_in_section('section3', 'key4', 'default value')
+ self.assertEqual(result, expected)
+
+ with self.assertRaises(KeyError):
+ setup_helper.find_in_section('section4', 'key1')
+
+ with self.assertRaises(KeyError):
+ setup_helper.find_in_section('section1', 'key1')
+
def test__replace_quoted_with_value(self):
# empty string
input_str = ''
@@ -751,32 +961,15 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
result = ProxDpdkVnfSetupEnvHelper.write_prox_config(input_data)
self.assertEqual(result, expected)
- def test_rebind_drivers(self):
- def find_drivers(*args, **kwargs):
- setup_helper.used_drivers = used_drivers
+ def test_prox_config_data(self):
+ setup_helper = ProxDpdkVnfSetupEnvHelper(mock.MagicMock(), mock.MagicMock(),
+ mock.MagicMock())
- used_drivers = {
- 'a': (1, 'b'),
- 'c': (2, 'd'),
- }
+ setup_helper.config_queue = config_queue = mock.MagicMock()
+ config_queue.get.return_value = expected = [('s', [('a', 3), ('b', 45)])]
- vnfd_helper = mock.MagicMock()
- ssh_helper = mock.MagicMock()
- scenario_helper = mock.MagicMock()
- setup_helper = ProxDpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- setup_helper._find_used_drivers = mock_find = mock.MagicMock(side_effect=find_drivers)
-
- setup_helper.rebind_drivers()
- self.assertEqual(mock_find.call_count, 1)
- self.assertEqual(ssh_helper.execute.call_count, 2)
- self.assertIn('--force', ssh_helper.execute.call_args[0][0])
-
- mock_find.reset_mock()
- ssh_helper.execute.reset_mock()
- setup_helper.rebind_drivers(False)
- self.assertEqual(mock_find.call_count, 0)
- self.assertEqual(ssh_helper.execute.call_count, 2)
- self.assertNotIn('--force', ssh_helper.execute.call_args[0][0])
+ result = setup_helper.prox_config_data
+ self.assertEqual(result, expected)
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.find_relative_file')
def test_build_config_file_no_additional_file(self, mock_find_path):
@@ -784,6 +977,7 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
'prox_args': {'-c': ""},
'prox_path': 'd',
'prox_config': 'e/f',
+ 'prox_generate_parameter': False,
}
mock_find_path.side_effect = ['1', '2']
@@ -804,11 +998,11 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
helper.upload_prox_config = mock.MagicMock(return_value='5')
self.assertEqual(helper.additional_files, {})
- self.assertNotEqual(helper.prox_config_dict, '4')
+ self.assertNotEqual(helper._prox_config_data, '4')
self.assertNotEqual(helper.remote_path, '5')
helper.build_config_file()
self.assertEqual(helper.additional_files, {})
- self.assertEqual(helper.prox_config_dict, '4')
+ self.assertEqual(helper._prox_config_data, '4')
self.assertEqual(helper.remote_path, '5')
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.find_relative_file')
@@ -818,6 +1012,7 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
'prox_path': 'd',
'prox_config': 'e/f',
'prox_files': 'g/h.i',
+ 'prox_generate_parameter': True,
}
mock_find_path.side_effect = ['1', '2']
@@ -831,6 +1026,7 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
},
}
+ vnfd_helper.port_pairs.all_ports = ['xe0', 'xe1', 'xe2', 'xe3']
helper = ProxDpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
helper.copy_to_target = mock.MagicMock(side_effect=['33', '34', '35'])
helper.generate_prox_config_file = mock.MagicMock(return_value='44')
@@ -854,7 +1050,7 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
],
}
- mock_find_path.side_effect = ['1', '2']
+ mock_find_path.side_effect = ['1', '2'] + [str(i) for i in range(len(vnf1['prox_files']))]
vnfd_helper = mock.MagicMock()
ssh_helper = mock.MagicMock()
scenario_helper = ScenarioHelper('vnf1')
@@ -871,12 +1067,12 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
helper.upload_prox_config = mock.MagicMock(return_value='55')
self.assertEqual(helper.additional_files, {})
- self.assertNotEqual(helper.prox_config_dict, '44')
+ self.assertNotEqual(helper._prox_config_data, '44')
self.assertNotEqual(helper.remote_path, '55')
expected = {'h.i': '33', 'l': '34', 'm_n': '35'}
helper.build_config_file()
self.assertDictEqual(helper.additional_files, expected)
- self.assertEqual(helper.prox_config_dict, '44')
+ self.assertEqual(helper._prox_config_data, '44')
self.assertEqual(helper.remote_path, '55')
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.find_relative_file')
@@ -906,9 +1102,10 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
helper = ProxDpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
helper.remote_path = "/tmp/prox.cfg"
- prox_cmd = helper.build_config()
expected = "sudo bash -c 'cd /opt/nsb_bin; /opt/nsb_bin/prox -o cli -f -f /tmp/prox.cfg '"
- self.assertEqual(prox_cmd, expected)
+ with mock.patch.object(helper, "build_config_file") as mock_build_config:
+ prox_cmd = helper.build_config()
+ self.assertEqual(prox_cmd, expected)
def test__insert_additional_file(self):
vnfd_helper = mock.MagicMock()
@@ -931,8 +1128,7 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
mock_parser_type.side_effect = init
- vnfd_helper = mock.MagicMock()
- vnfd_helper.interfaces = []
+ vnfd_helper = VnfdHelper(self.VNFD0)
ssh_helper = mock.MagicMock()
scenario_helper = mock.MagicMock()
@@ -946,23 +1142,6 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
helper.additional_files = {"ipv4.lua": "/tmp/ipv4.lua"}
helper.remote_prox_file_name = 'remote'
- vnfd_helper.interfaces = [
- {
- 'virtual-interface': {
- 'dst_mac': '00:00:00:de:ad:88',
- },
- },
- {
- 'virtual-interface': {
- 'dst_mac': '00:00:00:de:ad:ee',
- },
- },
- {
- 'virtual-interface': {
- 'dst_mac': '00:00:00:de:ad:ff',
- },
- },
- ]
sections_data = [
[
'lua',
@@ -975,7 +1154,7 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
[
['ip', ''],
['mac', 'foo'],
- ['dst mac', '@@2'],
+ ['dst mac', '@@1'],
['tx port', '1'],
],
],
@@ -1004,7 +1183,7 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
[
['ip', ''],
['mac', 'hardware'],
- ['dst mac', '00:00:00:de:ad:ff'],
+ ['dst mac', '00:00:00:00:00:03'],
['tx port', '1'],
],
],
@@ -1012,7 +1191,7 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
'port 2',
[
['ip', ''],
- ['$sut_mac0', '00 00 00 de ad 88'],
+ ['$sut_mac0', '00 00 00 00 00 04'],
['tx port', '0'],
['single', '@'],
['user_table', 'dofile("/tmp/ipv4.lua")'],
@@ -1078,79 +1257,6 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
with self.assertRaises(Exception):
helper.generate_prox_config_file('a/b')
- def test_generate_prox_lua_file(self):
- vnfd_helper = mock.MagicMock()
- vnfd_helper.interfaces = []
- ssh_helper = mock.MagicMock()
- scenario_helper = mock.MagicMock()
-
- helper = ProxDpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- helper.LUA_PARAMETER_NAME = 'sut'
-
- expected = ''
- result = helper.generate_prox_lua_file()
- self.assertEqual(result, expected)
-
- vnfd_helper.interfaces = [
- {
- 'local_ip': '10.20.30.40',
- 'dst_ip': '10.11.12.13',
- 'virtual-interface': {
- 'dpdk_port_num': 3,
- },
- },
- {
- 'local_ip': '10.20.30.45',
- 'dst_ip': '10.11.12.19',
- 'virtual-interface': {
- 'dpdk_port_num': 7,
- },
- },
- ]
-
- expected = os.linesep.join([
- 'sut_hex_ip_port_3:"0a 14 1e 28"',
- 'sut_ip_port_3:"10.20.30.40"',
- 'gen_hex_ip_port_3:"0a 0b 0c 0d"',
- 'gen_ip_port_3:"10.11.12.13"',
-
- 'sut_hex_ip_port_7:"0a 14 1e 2d"',
- 'sut_ip_port_7:"10.20.30.45"',
- 'gen_hex_ip_port_7:"0a 0b 0c 13"',
- 'gen_ip_port_7:"10.11.12.19"',
- ])
- result = helper.generate_prox_lua_file()
- self.assertEqual(result, expected)
-
- def test_upload_prox_lua(self):
- def identity(*args):
- return args
-
- vnfd_helper = mock.MagicMock()
- vnfd_helper.interfaces = []
- ssh_helper = mock.MagicMock()
- scenario_helper = mock.MagicMock()
-
- helper = ProxDpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- helper.generate_prox_lua_file = mock.MagicMock(return_value=234)
- helper.put_string_to_file = identity
-
- expected = ''
- result = helper.upload_prox_lua('my_dir', {})
- self.assertEqual(result, expected)
-
- input_data = {
- 'lua': {
- 'key1': 'value1 ("inside") tail',
- 'key2': 'value2',
- 'key3 ("key_side") head': 'value3',
- },
- }
-
- expected = 234, 'my_dir/key_side'
- result = helper.upload_prox_lua('my_dir', input_data)
- self.assertEqual(result, expected)
-
def test_put_string_to_file(self):
vnfd_helper = mock.MagicMock()
vnfd_helper.interfaces = []
@@ -1198,10 +1304,110 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
class TestProxResourceHelper(unittest.TestCase):
- def test_line_rate_to_pps(self):
- expected = 0.25 * 1e8
- result = ProxResourceHelper.line_rate_to_pps(180, 4)
- self.assertEqual(result, expected)
+
+ VNFD0 = {
+ 'short-name': 'ProxVnf',
+ 'vdu': [
+ {
+ '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',
+ },
+ ],
+ 'description': 'PROX approximation using DPDK',
+ 'name': 'proxvnf-baremetal',
+ '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',
+ },
+ ],
+ 'id': 'proxvnf-baremetal',
+ 'external-interface': [
+ {
+ 'virtual-interface': {
+ 'dst_mac': '00:00:00:00:00:04',
+ 'vpci': '0000:05:00.0',
+ 'local_ip': '152.16.100.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'vld_id': 'uplink_0',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 0,
+ 'bandwidth': '10 Gbps',
+ 'driver': "i40e",
+ 'dst_ip': '152.16.100.19',
+ 'local_iface_name': 'xe0',
+ 'local_mac': '00:00:00:00:00:02',
+ 'ifname': 'xe0',
+ },
+ 'vnfd-connection-point-ref': 'xe0',
+ 'name': 'xe0',
+ },
+ {
+ 'virtual-interface': {
+ 'dst_mac': '00:00:00:00:00:03',
+ 'vpci': '0000:05:00.1',
+ 'local_ip': '152.16.40.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'vld_id': 'downlink_0',
+ 'driver': "i40e",
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 1,
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.40.20',
+ 'local_iface_name': 'xe1',
+ 'local_mac': '00:00:00:00:00:01',
+ 'ifname': 'xe1',
+ },
+ 'vnfd-connection-point-ref': 'xe1',
+ 'name': 'xe1',
+ },
+ ],
+ },
+ ],
+ 'description': 'PROX approximation using DPDK',
+ 'mgmt-interface': {
+ 'vdu-id': 'proxvnf-baremetal',
+ 'host': '1.2.1.1',
+ 'password': 'r00t',
+ 'user': 'root',
+ 'ip': '1.2.1.1',
+ },
+ 'benchmark': {
+ 'kpi': [
+ 'packets_in',
+ 'packets_fwd',
+ 'packets_dropped',
+ ],
+ },
+ 'id': 'ProxApproxVnf',
+ 'name': 'ProxVnf',
+ }
+
+ VNFD = {
+ 'vnfd:vnfd-catalog': {
+ 'vnfd': [
+ VNFD0,
+ ],
+ },
+ }
def test_find_pci(self):
input_str_list = [
@@ -1231,14 +1437,259 @@ class TestProxResourceHelper(unittest.TestCase):
self.assertIs(result, helper.client)
self.assertIs(result, helper.sut)
+ def test_test_type(self):
+ setup_helper = mock.MagicMock()
+ setup_helper.find_in_section.return_value = expected = 'prox type'
+
+ helper = ProxResourceHelper(setup_helper)
+
+ self.assertIsNone(helper._test_type)
+ self.assertEqual(helper.test_type, expected)
+ self.assertEqual(helper._test_type, expected)
+ self.assertEqual(helper.test_type, expected)
+
+ def test_collect_collectd_kpi(self):
+ helper = ProxResourceHelper(mock.MagicMock())
+ helper.resource = resource = mock.MagicMock()
+
+ resource.check_if_sa_running.return_value = 0, '1234'
+ resource.amqp_collect_nfvi_kpi.return_value = 543
+ resource.check_if_sa_running.return_value = (0, None)
+
+ expected = {'core': 543}
+ result = helper.collect_collectd_kpi()
+ self.assertDictEqual(result, expected)
+
+ def test_collect_kpi(self):
+ helper = ProxResourceHelper(mock.MagicMock())
+ helper._queue = queue = mock.MagicMock()
+ helper._result = {'z': 123}
+ helper.resource = resource = mock.MagicMock()
+
+ resource.check_if_sa_running.return_value = 0, '1234'
+ resource.amqp_collect_nfvi_kpi.return_value = 543
+ resource.check_if_sa_running.return_value = (0, None)
+
+ queue.empty.return_value = False
+ queue.get.return_value = {'a': 789}
+
+ expected = {'z': 123, 'a': 789, 'collect_stats': {'core': 543}}
+ result = helper.collect_kpi()
+ self.assertDictEqual(result, expected)
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.ProxSocketHelper')
+ def test__connect(self, mock_socket_helper_type, mock_time):
+ client = mock_socket_helper_type()
+ client.connect.side_effect = chain(repeat(socket.error, 5), [None])
+
+ setup_helper = mock.MagicMock()
+ setup_helper.vnfd_helper.interfaces = []
+
+ helper = ProxResourceHelper(setup_helper)
+
+ result = helper._connect()
+ self.assertIs(result, client)
+
+ client.connect.side_effect = chain(repeat(socket.error, 65), [None])
+
+ with self.assertRaises(Exception):
+ helper._connect()
+
+ def test_run_traffic(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ traffic_profile = mock.MagicMock(**{"done": True})
+ helper.run_traffic(traffic_profile)
+ self.assertEqual(helper._terminated.value, 1)
+
+ def test__run_traffic_once(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ traffic_profile = mock.MagicMock(**{"done": True})
+ helper._run_traffic_once(traffic_profile)
+ self.assertEqual(helper._terminated.value, 1)
+
+ def test_start_collect(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ helper.resource = resource = mock.MagicMock()
+ self.assertIsNone(helper.start_collect())
+ resource.start.assert_called_once()
+
+ def test_terminate(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ with self.assertRaises(NotImplementedError):
+ helper.terminate()
+
+ def test_up_post(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ helper.client = expected = mock.MagicMock()
+ result = helper.up_post()
+ self.assertEqual(result, expected)
+
+ def test_execute(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ helper.client = mock.MagicMock()
+
+ expected = helper.client.my_command()
+ result = helper.execute('my_command')
+ self.assertEqual(result, expected)
+
+ helper.client = object()
+
+ result = helper.execute('my_command')
+ self.assertIsNone(result)
+
+
+class TestProxDataHelper(unittest.TestCase):
+
+ def test_totals_and_pps(self):
+ pkt_size = 180
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+
+ sut = mock.MagicMock()
+ sut.port_stats.return_value = list(range(10))
+
+ data_helper = ProxDataHelper(vnfd_helper, sut, pkt_size, 25, None)
+
+ self.assertEqual(data_helper.rx_total, 6)
+ self.assertEqual(data_helper.tx_total, 7)
+ self.assertEqual(data_helper.pps, 6.25e6)
+
+ def test_samples(self):
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+ vnfd_helper.ports_iter.return_value = [('xe1', 3), ('xe2', 7)]
+
+ sut = mock.MagicMock()
+ sut.port_stats.return_value = list(range(10))
+
+ data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None)
+
+ expected = {
+ 'xe1': {
+ 'in_packets': 6,
+ 'out_packets': 7,
+ },
+ 'xe2': {
+ 'in_packets': 6,
+ 'out_packets': 7,
+ },
+ }
+ result = data_helper.samples
+ self.assertDictEqual(result, expected)
+
+ def test___enter__(self):
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+ vnfd_helper.ports_iter.return_value = [('xe1', 3), ('xe2', 7)]
+
+ sut = mock.MagicMock()
+ sut.port_stats.return_value = list(range(10))
+
+ data_helper = ProxDataHelper(vnfd_helper, sut, None, None, 5.4)
+ data_helper._totals_and_pps = 12, 32, 4.5
+ data_helper.tsc_hz = 9.8
+ data_helper.measured_stats = {'delta': TotStatsTuple(6.1, 6.2, 6.3, 6.4)}
+ data_helper.latency = 7
+
+ self.assertIsNone(data_helper.result_tuple)
+
+ expected = ProxTestDataTuple(5.4, 9.8, 6.1, 6.2, 6.3, 7, 12, 32, 4.5)
+ with data_helper:
+ pass
+
+ result = data_helper.result_tuple
+ self.assertEqual(result, expected)
+
+ data_helper.make_tuple()
+ self.assertIs(data_helper.result_tuple, result)
+
+ def test___enter___negative(self):
+ vnfd_helper = mock.MagicMock()
+
+ data_helper = ProxDataHelper(vnfd_helper, None, None, None, None)
+
+ vnfd_helper.port_pairs.all_ports = []
+ with self.assertRaises(AssertionError):
+ with data_helper:
+ pass
+
+ vnfd_helper.port_pairs.all_ports = [0, 1, 2]
+ with self.assertRaises(AssertionError):
+ with data_helper:
+ pass
+
+ def test_measure_tot_stats(self):
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+
+ start = (3, 4, 1, 2)
+ end = (9, 7, 6, 8)
+
+ sut = ProxSocketHelper(mock.MagicMock())
+ sut.get_all_tot_stats = mock.MagicMock(side_effect=[start, end])
+
+ data_helper = ProxDataHelper(vnfd_helper, sut, None, None, 5.4)
+
+ self.assertIsNone(data_helper.measured_stats)
+
+ expected = {
+ 'start_tot': start,
+ 'end_tot': end,
+ 'delta': TotStatsTuple(6, 3, 5, 6),
+ }
+ with data_helper.measure_tot_stats():
+ pass
+
+ self.assertEqual(data_helper.measured_stats, expected)
+
+ def test_capture_tsc_hz(self):
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+
+ sut = mock.MagicMock()
+ sut.hz.return_value = '54.6'
+
+ data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None)
+
+ self.assertIsNone(data_helper.tsc_hz)
+
+ expected = 54.6
+ data_helper.capture_tsc_hz()
+ self.assertEqual(data_helper.tsc_hz, expected)
+
+
+class TestProxProfileHelper(unittest.TestCase):
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.utils')
+ def test_get_cls(self, mock_utils):
+ mock_type1 = mock.MagicMock()
+ mock_type1.__prox_profile_type__ = 'another_type'
+ mock_type2 = mock.MagicMock()
+ mock_type2.__prox_profile_type__ = 'my_type'
+ mock_utils.itersubclasses.return_value = [mock_type1, mock_type2]
+
+ self.assertEqual(ProxProfileHelper.get_cls('my_type'), mock_type2)
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.utils')
+ def test_get_cls_default(self, mock_utils):
+ mock_utils.itersubclasses.return_value = []
+ ProxProfileHelper.get_cls('my_type')
+
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.SocketTopology')
def test_cpu_topology(self, mock_socket_topology):
mock_socket_topology.parse_cpuinfo.return_value = 432
- setup_helper = mock.MagicMock()
- setup_helper.ssh_helper.execute.return_value = 0, 'output', ''
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.ssh_helper.execute.return_value = 0, 'output', ''
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(resource_helper)
self.assertIsNone(helper._cpu_topology)
result = helper.cpu_topology
self.assertEqual(result, 432)
@@ -1246,17 +1697,17 @@ class TestProxResourceHelper(unittest.TestCase):
self.assertIs(result, helper.cpu_topology)
def test_test_cores(self):
- setup_helper = mock.MagicMock()
- setup_helper.prox_config_dict = {}
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = []
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(resource_helper)
helper._cpu_topology = []
expected = []
result = helper.test_cores
self.assertEqual(result, expected)
- setup_helper.prox_config_dict = [
+ resource_helper.setup_helper.prox_config_data = [
('section1', []),
('section2', [
('a', 'b'),
@@ -1277,7 +1728,7 @@ class TestProxResourceHelper(unittest.TestCase):
]),
]
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(resource_helper)
helper._cpu_topology = {
1: {
3: {
@@ -1302,59 +1753,74 @@ class TestProxResourceHelper(unittest.TestCase):
self.assertIs(result, helper._test_cores)
self.assertIs(result, helper.test_cores)
- def test_get_test_type(self):
- setup_helper = mock.MagicMock()
- setup_helper.prox_config_dict = {}
+ def test_latency_cores(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = []
- helper = ProxResourceHelper(setup_helper)
- setup_helper.prox_config_dict = [
- ('global', [
- ('name', helper.PROX_CORE_MPLS_TEST)
- ]),
+ helper = ProxProfileHelper(resource_helper)
+ helper._cpu_topology = []
+
+ expected = []
+ result = helper.latency_cores
+ self.assertEqual(result, expected)
+
+ resource_helper.setup_helper.prox_config_data = [
+ ('section1', []),
('section2', [
('a', 'b'),
('c', 'd'),
]),
- ('core 1', []),
- ('core 2', [
+ ('core 1s3', []),
+ ('core 2s5', [
('index', 8),
('mode', ''),
]),
- ('core 3', [
+ ('core 3s1', [
('index', 5),
- ('mode', 'gen'),
+ ('mode', 'lat'),
]),
- ('core 4', [
+ ('core 4s9h', [
('index', 7),
- ('mode', 'gen'),
+ ('mode', 'lat'),
]),
]
- test_type = helper.get_test_type()
- self.assertEqual(test_type, helper.PROX_CORE_MPLS_TEST)
-
- def test_get_cores(self):
- setup_helper = mock.MagicMock()
- setup_helper.prox_config_dict = {}
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(resource_helper)
helper._cpu_topology = {
- 0: {
- 1: {
- 5: (5, 1, 0)
- },
- 2: {
- 6: (6, 2, 0)
- },
+ 1: {
3: {
- 7: (7, 3, 0)
+ 'key1': (23, 32),
+ 'key2': (12, 21),
+ 'key3': (44, 33),
},
+ },
+ 9: {
4: {
- 8: (8, 3, 0)
+ 'key1': (44, 32),
+ 'key2': (23, 21),
+ 'key3': (12, 33),
},
- }
+ },
}
- setup_helper.prox_config_dict = [
+ self.assertIsNone(helper._latency_cores)
+ expected = [12, 23]
+ result = helper.latency_cores
+ self.assertEqual(result, expected)
+ self.assertIs(result, helper._latency_cores)
+ self.assertIs(result, helper.latency_cores)
+
+ def test_all_rx_cores(self):
+ helper = ProxBngProfileHelper(mock.MagicMock())
+ helper._latency_cores = expected = [3, 4, 6]
+ helper._test_cores = [5, 2, 1]
+
+ result = helper.all_rx_cores
+ self.assertEqual(result, expected)
+
+ def test_get_cores(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = [
('section1', []),
('section2', [
('a', 'b'),
@@ -1375,15 +1841,52 @@ class TestProxResourceHelper(unittest.TestCase):
]),
]
+ helper = ProxProfileHelper(resource_helper)
+ helper._cpu_topology = {
+ 0: {
+ 1: {
+ 5: (5, 1, 0)
+ },
+ 2: {
+ 6: (6, 2, 0)
+ },
+ 3: {
+ 7: (7, 3, 0)
+ },
+ 4: {
+ 8: (8, 3, 0)
+ },
+ }
+ }
+
expected = [7, 8]
result = helper.get_cores(helper.PROX_CORE_GEN_MODE)
self.assertEqual(result, expected)
- def test_get_cores_mpls(self):
+ def test_get_latency(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.vnfd_helper.interfaces = []
+
+ helper = ProxProfileHelper(resource_helper)
+ helper._latency_cores = []
+
+ expected = []
+ result = helper.get_latency()
+ self.assertEqual(result, expected)
+
+ helper._latency_cores = [1, 2]
+ helper.client = mock.MagicMock()
+
+ expected = helper.sut.lat_stats()
+ result = helper.get_latency()
+ self.assertIs(result, expected)
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
+ def test_traffic_context(self, mock_time):
setup_helper = mock.MagicMock()
- setup_helper.prox_config_dict = {}
+ setup_helper.vnfd_helper.interfaces = []
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(setup_helper)
helper._cpu_topology = {
0: {
1: {
@@ -1401,7 +1904,12 @@ class TestProxResourceHelper(unittest.TestCase):
}
}
- setup_helper.prox_config_dict = [
+ setup_helper.prox_config_data = [
+ ('global', [
+ ('not_name', 'other data'),
+ ('name_not', 'more data'),
+ ('name', helper.__prox_profile_type__),
+ ]),
('section1', []),
('section2', [
('a', 'b'),
@@ -1424,121 +1932,128 @@ class TestProxResourceHelper(unittest.TestCase):
]),
]
- expected_tagged = [7]
- expected_plain = [8]
- result_tagged, result_plain = helper.get_cores_mpls(helper.PROX_CORE_GEN_MODE)
- self.assertEqual(result_tagged, expected_tagged)
- self.assertEqual(result_plain, expected_plain)
+ client = mock.MagicMock()
+ client.hz.return_value = 2
+ client.port_stats.return_value = tuple(range(12))
- def test_latency_cores(self):
- setup_helper = mock.MagicMock()
- setup_helper.prox_config_dict = {}
+ helper.client = client
+ helper.get_latency = mock.MagicMock(return_value=[3.3, 3.6, 3.8])
- helper = ProxResourceHelper(setup_helper)
- helper._cpu_topology = []
+ helper._test_cores = [3, 4]
- expected = []
- result = helper.latency_cores
- self.assertEqual(result, expected)
+ with helper.traffic_context(64, 1):
+ pass
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
+ def test_run_test(self, _):
+ resource_helper = mock.MagicMock()
+ resource_helper.step_delta = 0.4
+ resource_helper.vnfd_helper.port_pairs.all_ports = list(range(2))
+ resource_helper.sut.port_stats.return_value = list(range(10))
- setup_helper.prox_config_dict = [
+ helper = ProxProfileHelper(resource_helper)
+
+ helper.run_test(120, 5, 6.5)
+
+
+class TestProxMplsProfileHelper(unittest.TestCase):
+
+ def test_mpls_cores(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = [
('section1', []),
('section2', [
('a', 'b'),
('c', 'd'),
]),
- ('core 1s3', []),
- ('core 2s5', [
+ ('core 1', []),
+ ('core 2', [
('index', 8),
('mode', ''),
]),
- ('core 3s1', [
+ ('core 3', [
('index', 5),
- ('mode', 'lat'),
+ ('mode', 'gen'),
+ ('name', 'tagged'),
]),
- ('core 4s9h', [
+ ('core 4', [
('index', 7),
- ('mode', 'lat'),
+ ('mode', 'gen'),
+ ('name', 'udp'),
]),
]
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxMplsProfileHelper(resource_helper)
helper._cpu_topology = {
- 1: {
+ 0: {
+ 1: {
+ 5: (5, 1, 0)
+ },
+ 2: {
+ 6: (6, 2, 0)
+ },
3: {
- 'key1': (23, 32),
- 'key2': (12, 21),
- 'key3': (44, 33),
+ 7: (7, 3, 0)
},
- },
- 9: {
4: {
- 'key1': (44, 32),
- 'key2': (23, 21),
- 'key3': (12, 33),
+ 8: (8, 3, 0)
},
- },
+ }
}
- self.assertIsNone(helper._latency_cores)
- expected = [12, 23]
- result = helper.latency_cores
- self.assertEqual(result, expected)
- self.assertIs(result, helper._latency_cores)
- self.assertIs(result, helper.latency_cores)
-
- def test_run_traffic(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- traffic_proifle = mock.MagicMock(**{"done": True})
- helper.run_traffic(traffic_proifle)
- self.assertEqual(helper._terminated.value, 1)
-
- def test__run_traffic_once(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- traffic_proifle = mock.MagicMock(**{"done": True})
- helper._run_traffic_once(traffic_proifle)
- self.assertEqual(helper._terminated.value, 1)
-
- def test_start_collect(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- self.assertIsNone(helper.start_collect())
-
- def test_terminate(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- with self.assertRaises(NotImplementedError):
- helper.terminate()
-
- def test_up_post(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- helper.client = expected = mock.MagicMock()
- result = helper.up_post()
- self.assertEqual(result, expected)
+ expected_tagged = [7]
+ expected_plain = [8]
+ self.assertIsNone(helper._cores_tuple)
+ self.assertEqual(helper.tagged_cores, expected_tagged)
+ self.assertEqual(helper.plain_cores, expected_plain)
+ self.assertEqual(helper._cores_tuple, (expected_tagged, expected_plain))
- def test_execute(self):
+ def test_traffic_context(self):
setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- helper.client = mock.MagicMock()
+ helper = ProxMplsProfileHelper(setup_helper)
- expected = helper.client.my_command()
- result = helper.execute('my_command')
- self.assertEqual(result, expected)
+ with helper.traffic_context(120, 5.4):
+ pass
- helper.client = object()
- result = helper.execute('my_command')
- self.assertIsNone(result)
+class TestProxBngProfileHelper(unittest.TestCase):
- @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
- def test_traffic_context(self, mock_time):
- setup_helper = mock.MagicMock()
- setup_helper.prox_config_dict = {}
+ def test_bng_cores(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = [
+ ('section1', []),
+ ('section2', [
+ ('a', 'b'),
+ ('c', 'd'),
+ ]),
+ ('core 1', []),
+ ('core 2', [
+ ('index', 8),
+ ('mode', ''),
+ ]),
+ ('core 3', [
+ ('index', 5),
+ ('mode', 'gen'),
+ ('name', 'cpe'),
+ ]),
+ ('core 4', [
+ ('index', 7),
+ ('mode', 'gen'),
+ ('name', 'inet'),
+ ]),
+ ('core 6', [
+ ('index', 3),
+ ('mode', 'gen'),
+ ('name', 'arp_task'),
+ ]),
+ ('core 9', [
+ ('index', 2),
+ ('mode', 'gen'),
+ ('name', 'arp'),
+ ]),
+ ]
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxBngProfileHelper(resource_helper)
helper._cpu_topology = {
0: {
1: {
@@ -1553,13 +2068,46 @@ class TestProxResourceHelper(unittest.TestCase):
4: {
8: (8, 3, 0)
},
+ 6: {
+ 1: (4, 8, 0)
+ },
+ 9: {
+ 2: (3, 7, 0)
+ },
}
}
- setup_helper.prox_config_dict = [
- ('global', [
- ('name', helper.PROX_CORE_MPLS_TEST)
- ]),
+ expected_cpe = [7]
+ expected_inet = [8]
+ expected_arp = [4, 3]
+ expected_arp_task = [0, 4]
+ expected_combined = (expected_cpe, expected_inet, expected_arp, expected_arp_task)
+
+ self.assertIsNone(helper._cores_tuple)
+ self.assertEqual(helper.cpe_cores, expected_cpe)
+ self.assertEqual(helper.inet_cores, expected_inet)
+ self.assertEqual(helper.arp_cores, expected_arp)
+ self.assertEqual(helper.arp_task_cores, expected_arp_task)
+ self.assertEqual(helper._cores_tuple, expected_combined)
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
+ def test_run_test(self, _):
+ resource_helper = mock.MagicMock()
+ resource_helper.step_delta = 0.4
+ resource_helper.vnfd_helper.port_pairs.all_ports = list(range(2))
+ resource_helper.sut.port_stats.return_value = list(range(10))
+
+ helper = ProxBngProfileHelper(resource_helper)
+
+ helper.run_test(120, 5, 6.5)
+ helper.run_test(-1000, 5, 6.5) # negative pkt_size is the only way to make ratio > 1
+
+
+class TestProxVpeProfileHelper(unittest.TestCase):
+
+ def test_vpe_cores(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = [
('section1', []),
('section2', [
('a', 'b'),
@@ -1573,122 +2121,97 @@ class TestProxResourceHelper(unittest.TestCase):
('core 3', [
('index', 5),
('mode', 'gen'),
- ('name', 'tagged'),
+ ('name', 'cpe'),
]),
('core 4', [
('index', 7),
('mode', 'gen'),
- ('name', 'udp'),
+ ('name', 'inet'),
]),
]
- setup_helper = mock.MagicMock()
- setup_helper.vnfd_helper.interfaces = []
-
- client = mock.MagicMock()
- client.hz.return_value = 2
- client.port_stats.return_value = tuple(range(12))
-
- helper.client = client
- helper.get_latency = mock.MagicMock(return_value=[3.3, 3.6, 3.8])
-
- helper._test_cores = [3, 4]
-
- with helper.traffic_context(64, 1):
- pass
-
- @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
- def test_run_test(self, mock_time):
- @contextmanager
- def measure(*args, **kwargs):
- yield stats
-
- setup_helper = mock.MagicMock()
- setup_helper.vnfd_helper.interfaces = []
-
- stats = {
- 'delta': TotStatsTuple(6, 7, 8, 9),
+ helper = ProxVpeProfileHelper(resource_helper)
+ helper._cpu_topology = {
+ 0: {
+ 1: {
+ 5: (5, 1, 0)
+ },
+ 2: {
+ 6: (6, 2, 0)
+ },
+ 3: {
+ 7: (7, 3, 0)
+ },
+ 4: {
+ 8: (8, 3, 0)
+ },
+ }
}
- client = mock.MagicMock()
- client.hz.return_value = 2
- client.measure_tot_stats = measure
- client.port_stats.return_value = tuple(range(12))
+ expected_cpe = [7]
+ expected_inet = [8]
+ expected_combined = (expected_cpe, expected_inet)
- helper = ProxResourceHelper(setup_helper)
- helper.client = client
- helper.get_latency = mock.MagicMock(return_value=[3.3, 3.6, 3.8])
+ self.assertIsNone(helper._cores_tuple)
+ self.assertEqual(helper.cpe_cores, expected_cpe)
+ self.assertEqual(helper.inet_cores, expected_inet)
+ self.assertEqual(helper._cores_tuple, expected_combined)
- with self.assertRaises(AssertionError):
- helper.run_test(980, 15, 45)
-
- setup_helper.vnfd_helper.interfaces = [
- {'name': 'a', 'virtual-interface': {'vpci': 'z'}},
- {'name': 'b', 'virtual-interface': {'vpci': 'y'}},
- {'name': 'c', 'virtual-interface': {'vpci': 'x'}},
- {'name': 'd', 'virtual-interface': {'vpci': 'w'}},
+ def test_vpe_ports(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = [
+ ('section1', []),
+ ('section2', [
+ ('a', 'b'),
+ ('c', 'd'),
+ ]),
+ ('port 3', [
+ ('index', '5'),
+ ('name', 'cpe'),
+ ('mac', 'hardware'),
+ ]),
+ ('port 4', [
+ ('index', '7'),
+ ('name', 'inet'),
+ ('mac', 'hardware'),
+ ]),
]
- helper._test_cores = [3, 4]
- expected_test_data = ProxTestDataTuple(0.0, 2.0, 6, 7, 8, [3.3, 3.6, 3.8], 6, 7, 1.3e7)
- expected_port_samples = {
- 'a': {'in_packets': 6, 'out_packets': 7},
- 'b': {'in_packets': 6, 'out_packets': 7},
- 'c': {'in_packets': 6, 'out_packets': 7},
- 'd': {'in_packets': 6, 'out_packets': 7},
+ helper = ProxVpeProfileHelper(resource_helper)
+ helper._port_list = {
+ 0: {
+ 1: {
+ 5: 'cpe'
+ },
+ 2: {
+ 6: 'inet'
+ },
+ 3: {
+ 7: 'cpe'
+ },
+ 4: {
+ 8: 'inet'
+ },
+ }
}
- test_data, port_samples = helper.run_test(230, 60, 65)
- self.assertEqual(test_data, expected_test_data, '\n'.join(str(x) for x in test_data))
- self.assertEqual(port_samples, expected_port_samples,
- '\n'.join(str(x) for x in port_samples))
- def test_get_latency(self):
- setup_helper = mock.MagicMock()
- setup_helper.vnfd_helper.interfaces = []
-
- helper = ProxResourceHelper(setup_helper)
- helper._latency_cores = []
-
- expected = []
- result = helper.get_latency()
- self.assertEqual(result, expected)
+ expected_cpe = [3]
+ expected_inet = [4]
+ expected_combined = (expected_cpe, expected_inet)
- helper._latency_cores = [1, 2]
- helper.client = mock.MagicMock()
-
- expected = helper.sut.lat_stats()
- result = helper.get_latency()
- self.assertIs(result, expected)
-
- def test__get_logical_if_name(self):
- setup_helper = mock.MagicMock()
- setup_helper.vnfd_helper.interfaces = []
-
- helper = ProxResourceHelper(setup_helper)
- helper._vpci_to_if_name_map = {
- 'key1': 234,
- 'key2': 432,
- }
-
- expected = 234
- result = helper._get_logical_if_name('key1')
- self.assertEqual(result, expected)
+ self.assertIsNone(helper._ports_tuple)
+ self.assertEqual(helper.cpe_ports, expected_cpe)
+ self.assertEqual(helper.inet_ports, expected_inet)
+ self.assertEqual(helper._ports_tuple, expected_combined)
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
- @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.ProxSocketHelper')
- def test__connect(self, mock_socket_helper_type, mock_time):
- client = mock_socket_helper_type()
- client.connect.side_effect = chain(repeat(socket.error, 5), [None])
+ def test_run_test(self, _):
+ resource_helper = mock.MagicMock()
+ resource_helper.step_delta = 0.4
+ resource_helper.vnfd_helper.port_pairs.all_ports = list(range(2))
+ resource_helper.sut.port_stats.return_value = list(range(10))
- setup_helper = mock.MagicMock()
- setup_helper.vnfd_helper.interfaces = []
+ helper = ProxVpeProfileHelper(resource_helper)
- helper = ProxResourceHelper(setup_helper)
-
- result = helper._connect()
- self.assertIs(result, client)
-
- client.connect.side_effect = chain(repeat(socket.error, 65), [None])
-
- with self.assertRaises(Exception):
- helper._connect()
+ helper.run_test(120, 5, 6.5)
+ helper.run_test(-1000, 5, 6.5) # negative pkt_size is the only way to make ratio > 1
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 4b115f2d6..09060ff57 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
@@ -85,9 +85,10 @@ class TestProxApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.0',
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
- 'vld_id': '',
+ 'vld_id': 'downlink_0',
+ 'ifname': 'xe1',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'driver': "i40e",
'dst_ip': '152.16.100.20',
@@ -103,10 +104,11 @@ class TestProxApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.1',
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
- 'vld_id': '',
+ 'vld_id': 'uplink_0',
+ 'ifname': 'xe1',
'driver': "i40e",
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_iface_name': 'xe1',
@@ -187,7 +189,7 @@ class TestProxApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens513f0',
- 'vld_id': 'public',
+ 'vld_id': ProxApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.20',
'dst_mac': '00:00:00:00:00:01',
@@ -221,7 +223,7 @@ class TestProxApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens785f0',
- 'vld_id': 'private',
+ 'vld_id': ProxApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.20',
'dst_mac': '00:00:00:00:00:02',
@@ -252,7 +254,7 @@ class TestProxApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens786f0',
- 'vld_id': 'private',
+ 'vld_id': ProxApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.19',
'dst_mac': '00:00:00:00:00:04',
@@ -264,7 +266,7 @@ class TestProxApproxVnf(unittest.TestCase):
},
'xe1': {
'local_iface_name': 'ens786f1',
- 'vld_id': 'public',
+ 'vld_id': ProxApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.19',
'dst_mac': '00:00:00:00:00:03',
@@ -340,7 +342,7 @@ class TestProxApproxVnf(unittest.TestCase):
resource_helper = mock.MagicMock()
resource_helper.execute.return_value = list(range(12))
- resource_helper.collect_kpi.return_value = {'core': {'result': 234}}
+ resource_helper.collect_collectd_kpi.return_value = {'core': {'result': 234}}
prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
prox_approx_vnf.resource_helper = resource_helper
@@ -363,6 +365,7 @@ class TestProxApproxVnf(unittest.TestCase):
prox_approx_vnf = ProxApproxVnf(NAME, deepcopy(self.VNFD0))
prox_approx_vnf.resource_helper = resource_helper
prox_approx_vnf.vnfd_helper['vdu'][0]['external-interface'] = []
+ prox_approx_vnf.vnfd_helper.port_pairs.interfaces = []
with self.assertRaises(RuntimeError):
prox_approx_vnf.collect_kpi()
@@ -372,8 +375,10 @@ class TestProxApproxVnf(unittest.TestCase):
file_path = os.path.join(curr_path, filename)
return file_path
+ @mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open', create=True)
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.iniparser.open', create=True)
@mock.patch(SSH_HELPER)
- def test_run_prox(self, ssh, mock_time):
+ def test_run_prox(self, ssh, *_):
mock_ssh(ssh)
prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
@@ -382,7 +387,7 @@ class TestProxApproxVnf(unittest.TestCase):
prox_approx_vnf.setup_helper.remote_path = 'configs/file56.cfg'
expected = "sudo bash -c 'cd /tool_path12; " \
- "/tool_path12/tool_file34 -o cli -t -f configs/file56.cfg '"
+ "/tool_path12/tool_file34 -o cli -t -f /tmp/l3-swap-2.cfg '"
prox_approx_vnf._run()
result = prox_approx_vnf.ssh_helper.run.call_args[0][0]
@@ -395,7 +400,7 @@ class TestProxApproxVnf(unittest.TestCase):
prox_approx_vnf.setup_helper = mock.MagicMock()
# we can't mock super
prox_approx_vnf.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG)
- prox_approx_vnf.setup_helper.build_config.assert_called_once
+ prox_approx_vnf.setup_helper.build_config.assert_called_once()
@mock.patch(SSH_HELPER)
def test_wait_for_instantiate_panic(self, ssh, mock_time):
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 983c21e61..1e6bc1a13 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
@@ -98,10 +98,12 @@ class TestVnfSshHelper(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.100.20',
- 'local_mac': '00:00:00:00:00:01'
+ 'local_mac': '00:00:00:00:00:01',
+ 'vld_id': 'uplink_0',
+ 'ifname': 'xe0',
},
'vnfd-connection-point-ref': 'xe0',
'name': 'xe0'
@@ -113,10 +115,12 @@ class TestVnfSshHelper(unittest.TestCase):
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
- 'local_mac': '00:00:00:00:00:02'
+ 'local_mac': '00:00:00:00:00:02',
+ 'vld_id': 'downlink_0',
+ 'ifname': 'xe1',
},
'vnfd-connection-point-ref': 'xe1',
'name': 'xe1'
@@ -292,10 +296,12 @@ class TestSetupEnvHelper(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.100.20',
- 'local_mac': '00:00:00:00:00:01'
+ 'local_mac': '00:00:00:00:00:01',
+ 'vld_id': 'uplink_0',
+ 'ifname': 'xe0',
},
'vnfd-connection-point-ref': 'xe0',
'name': 'xe0'
@@ -307,10 +313,12 @@ class TestSetupEnvHelper(unittest.TestCase):
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
- 'local_mac': '00:00:00:00:00:02'
+ 'local_mac': '00:00:00:00:00:02',
+ 'vld_id': 'downlink_0',
+ 'ifname': 'xe1',
},
'vnfd-connection-point-ref': 'xe1',
'name': 'xe1'
@@ -414,16 +422,15 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
'virtual-interface': {
'dst_mac': '00:00:00:00:00:03',
'vpci': '0000:05:00.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'driver': 'i40e',
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
'bandwidth': '10 Gbps',
'dst_ip': '152.16.100.20',
'local_mac': '00:00:00:00:00:01',
- 'vld_id': 'private_0',
+ 'vld_id': 'uplink_0',
'ifname': 'xe0',
},
'vnfd-connection-point-ref': 'xe0',
@@ -433,16 +440,15 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
'virtual-interface': {
'dst_mac': '00:00:00:00:00:04',
'vpci': '0000:05:00.1',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'driver': 'ixgbe',
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_mac': '00:00:00:00:00:02',
- 'vld_id': 'public_0',
+ 'vld_id': 'downlink_0',
'ifname': 'xe1',
},
'vnfd-connection-point-ref': 'xe1',
@@ -549,7 +555,8 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
call_args_iter = (args[0][0] for args in ssh_helper.execute.call_args_list)
self.assertIsNone(result)
self.assertEqual(ssh_helper.execute.call_count, 3)
- for expect_start, expect_in, arg0 in zip(expect_start_list, expect_in_list, call_args_iter):
+ for expect_start, expect_in, arg0 in zip(expect_start_list, expect_in_list,
+ call_args_iter):
self.assertTrue(arg0.startswith(expect_start))
self.assertIn(expect_in, arg0)
@@ -566,19 +573,11 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
call_args_iter = (args[0][0] for args in ssh_helper.execute.call_args_list)
self.assertIsNone(result)
self.assertEqual(ssh_helper.execute.call_count, 3)
- for expect_start, expect_in, arg0 in zip(expect_start_list, expect_in_list, call_args_iter):
+ for expect_start, expect_in, arg0 in zip(expect_start_list, expect_in_list,
+ call_args_iter):
self.assertTrue(arg0.startswith(expect_start))
self.assertIn(expect_in, arg0)
- def test__get_dpdk_port_num(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- expected = '0'
- result = dpdk_setup_helper._get_dpdk_port_num('xe0')
- self.assertEqual(result, expected)
-
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.open')
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.find_relative_file')
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.MultiPortConfig')
@@ -590,7 +589,6 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
scenario_helper.vnf_cfg = {}
scenario_helper.all_options = {}
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper.all_ports = []
dpdk_setup_helper.PIPELINE_COMMAND = expected = 'pipeline command'
result = dpdk_setup_helper.build_config()
@@ -614,7 +612,7 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
expected = {
'cfg_file': 'config',
'script': 'script',
- 'ports_len_hex': '0xf',
+ 'port_mask_hex': '0x3',
'tool_path': 'tool_path',
}
dpdk_setup_helper._build_pipeline_kwargs()
@@ -725,73 +723,25 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
result = dpdk_setup_helper._validate_cpu_cfg()
self.assertEqual(result, expected)
- def test__find_used_drivers(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- stdout = '''
-00:01.2 foo drv=name1
-00:01.4 drv foo=name2
-00:02.2 drv=name3
-00:02.3 drv=name4
-'''
- ssh_helper.execute.return_value = 0, stdout, ''
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper.used_drivers = None
- dpdk_setup_helper._dpdk_nic_bind = ''
- dpdk_setup_helper.bound_pci = [
- 'pci 00:01.2',
- 'pci 00:02.3',
- ]
-
- expected = {
- '00:01.2': (0, 'name1'),
- '00:02.3': (2, 'name4'),
- }
- dpdk_setup_helper._find_used_drivers()
- self.assertEqual(dpdk_setup_helper.used_drivers, expected)
-
- def test_dpdk_nic_bind(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- ssh_helper.provision_tool.return_value = nic_bind = object()
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
-
- self.assertIsNone(dpdk_setup_helper._dpdk_nic_bind)
- self.assertIs(dpdk_setup_helper.dpdk_nic_bind, nic_bind)
- self.assertIs(dpdk_setup_helper.dpdk_nic_bind, nic_bind)
- self.assertEqual(ssh_helper.provision_tool.call_count, 1)
-
- # ensure provision tool is not called a second time
- self.assertIs(dpdk_setup_helper.dpdk_nic_bind, nic_bind)
- self.assertEqual(ssh_helper.provision_tool.call_count, 1)
-
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch('yardstick.ssh.SSH')
def test_setup_vnf_environment(self, _, mock_time):
- cores = ['3', '4']
+ def execute(cmd, *args, **kwargs):
+ if cmd.startswith('which '):
+ return exec_failure
+ return exec_success
- vnfd_helper = VnfdHelper(deepcopy(self.VNFD_0))
+ exec_success = (0, 'good output', '')
+ exec_failure = (1, 'bad output', 'error output')
+
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
- ssh_helper.execute.return_value = 1, 'bad output', 'error 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()
- dpdk_setup_helper._validate_cpu_cfg = mock.Mock(return_value=cores)
- dpdk_setup_helper._find_used_drivers = mock.Mock()
- dpdk_setup_helper.used_drivers = {
- '0000:05:00.0': (1, ''),
- '0000:05:01.0': (3, ''),
- }
+ ssh_helper.execute = execute
- result = dpdk_setup_helper.setup_vnf_environment()
- self.assertIsInstance(result, ResourceProfile)
- self.assertEqual(result.cores, cores)
- self.assertEqual(vnfd_helper.interfaces[0]['dpdk_port_num'], 1)
- self.assertNotIn('dpdk_port_num', vnfd_helper.interfaces[1])
+ dpdk_vnf_setup_env_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, mock.Mock())
+ dpdk_vnf_setup_env_helper._validate_cpu_cfg = mock.Mock(return_value=[])
+
+ self.assertIsInstance(dpdk_vnf_setup_env_helper.setup_vnf_environment(), ResourceProfile)
def test__setup_dpdk_early_success(self):
vnfd_helper = VnfdHelper(self.VNFD_0)
@@ -833,6 +783,8 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
dpdk_setup_helper._validate_cpu_cfg = mock.Mock()
+ dpdk_setup_helper.bound_pci = [v['virtual-interface']["vpci"] for v in
+ vnfd_helper.interfaces]
result = dpdk_setup_helper._setup_resources()
self.assertIsInstance(result, ResourceProfile)
self.assertEqual(dpdk_setup_helper.socket, 0)
@@ -847,87 +799,153 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
dpdk_setup_helper._validate_cpu_cfg = mock.Mock()
+ dpdk_setup_helper.bound_pci = [v['virtual-interface']["vpci"] for v in
+ vnfd_helper.interfaces]
result = dpdk_setup_helper._setup_resources()
self.assertIsInstance(result, ResourceProfile)
self.assertEqual(dpdk_setup_helper.socket, 1)
- def test__bind_dpdk_unforced(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
-
- dpdk_setup_helper._bind_dpdk('x', 'y', force=False)
- self.assertNotIn('--force', ssh_helper.execute.call_args_list[0][0][0])
-
- def test__detect_and_bind_dpdk_short(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- ssh_helper.execute.return_value = 0, 'output', ''
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
-
- self.assertIsNone(dpdk_setup_helper._detect_and_bind_dpdk('a', 'b'))
- self.assertEqual(ssh_helper.execute.call_count, 1)
-
- def test__detect_and_bind_dpdk_fail_to_bind(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
+ def test__detect_and_bind_drivers(self, mock_time):
+ vnfd_helper = VnfdHelper(deepcopy(self.VNFD_0))
ssh_helper = mock.Mock()
- ssh_helper.execute.return_value = 1, 'bad output', 'error output'
+ # ssh_helper.execute = mock.Mock(return_value = (0, 'text', ''))
+ # ssh_helper.execute.return_value = 0, 'output', ''
scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper._bind_dpdk = mock.Mock()
+ rv = ['0000:05:00.1', '0000:05:00.0']
- self.assertIsNone(dpdk_setup_helper._detect_and_bind_dpdk('a', 'b'))
- self.assertEqual(ssh_helper.execute.call_count, 2)
-
- def test__detect_and_bind_dpdk(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- ssh_helper.execute.side_effect = iter([
- (1, 'bad output', 'error output'),
- (0, 'output', ''),
- ])
- scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper._bind_dpdk = mock.Mock()
+ dpdk_setup_helper.dpdk_bind_helper._get_bound_pci_addresses = mock.Mock(return_value=rv)
+ dpdk_setup_helper.dpdk_bind_helper.bind = mock.Mock()
+ dpdk_setup_helper.dpdk_bind_helper.read_status = mock.Mock()
- self.assertEqual(dpdk_setup_helper._detect_and_bind_dpdk('a', 'b'), 'output')
- self.assertEqual(ssh_helper.execute.call_count, 2)
+ self.assertIsNone(dpdk_setup_helper._detect_and_bind_drivers())
- def test__bind_kernel_devices(self):
- bind_iter = iter([
- None,
- 'output',
- ])
-
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper._detect_and_bind_dpdk = mock.Mock(side_effect=bind_iter)
-
- self.assertIsNone(dpdk_setup_helper._bind_kernel_devices())
+ intf_0 = vnfd_helper.vdu[0]['external-interface'][0]['virtual-interface']
+ intf_1 = vnfd_helper.vdu[0]['external-interface'][1]['virtual-interface']
+ self.assertEquals(0, intf_0['dpdk_port_num'])
+ self.assertEquals(1, intf_1['dpdk_port_num'])
def test_tear_down(self):
vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper._dpdk_nic_bind = 'a'
- dpdk_setup_helper.used_drivers = {
- '0000:05:00.0': (1, 'd1'),
- '0000:05:01.0': (3, 'd3'),
+ dpdk_setup_helper.dpdk_bind_helper.bind = mock.Mock()
+ dpdk_setup_helper.dpdk_bind_helper.used_drivers = {
+ 'd1': ['0000:05:00.0'],
+ 'd3': ['0000:05:01.0'],
}
self.assertIsNone(dpdk_setup_helper.tear_down())
+ dpdk_setup_helper.dpdk_bind_helper.bind.assert_any_call(['0000:05:00.0'], 'd1', True)
+ dpdk_setup_helper.dpdk_bind_helper.bind.assert_any_call(['0000:05:01.0'], 'd3', True)
class TestResourceHelper(unittest.TestCase):
+ VNFD_0 = {
+ 'short-name': 'VpeVnf',
+ 'vdu': [
+ {
+ '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'
+ },
+ ],
+ 'description': 'VPE approximation using DPDK',
+ 'name': 'vpevnf-baremetal',
+ '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'
+ },
+ ],
+ 'id': 'vpevnf-baremetal',
+ 'external-interface': [
+ {
+ 'virtual-interface': {
+ 'dst_mac': '00:00:00:00:00:03',
+ 'vpci': '0000:05:00.0',
+ 'driver': 'i40e',
+ 'local_ip': '152.16.100.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 0,
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.100.20',
+ 'local_mac': '00:00:00:00:00:01'
+ },
+ 'vnfd-connection-point-ref': 'xe0',
+ 'name': 'xe0'
+ },
+ {
+ 'virtual-interface': {
+ 'dst_mac': '00:00:00:00:00:04',
+ 'vpci': '0000:05:00.1',
+ 'driver': 'ixgbe',
+ 'local_ip': '152.16.40.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 1,
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.40.20',
+ 'local_mac': '00:00:00:00:00:02'
+ },
+ 'vnfd-connection-point-ref': 'xe1',
+ 'name': 'xe1'
+ },
+ ],
+ },
+ ],
+ 'description': 'Vpe approximation using DPDK',
+ 'mgmt-interface': {
+ 'vdu-id': 'vpevnf-baremetal',
+ 'host': '1.1.1.1',
+ 'password': 'r00t',
+ 'user': 'root',
+ 'ip': '1.1.1.1'
+ },
+ 'benchmark': {
+ 'kpi': [
+ 'packets_in',
+ 'packets_fwd',
+ 'packets_dropped',
+ ],
+ },
+ 'connection-point': [
+ {
+ 'type': 'VPORT',
+ 'name': 'xe0',
+ },
+ {
+ 'type': 'VPORT',
+ 'name': 'xe1',
+ },
+ ],
+ 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'
+ }
+
def test_setup(self):
resource = object()
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -938,7 +956,7 @@ class TestResourceHelper(unittest.TestCase):
self.assertIs(resource_helper.resource, resource)
def test_generate_cfg(self):
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -947,7 +965,7 @@ class TestResourceHelper(unittest.TestCase):
self.assertIsNone(resource_helper.generate_cfg())
def test_stop_collect(self):
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -957,7 +975,7 @@ class TestResourceHelper(unittest.TestCase):
self.assertIsNone(resource_helper.stop_collect())
def test_stop_collect_none(self):
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -966,6 +984,7 @@ class TestResourceHelper(unittest.TestCase):
self.assertIsNone(resource_helper.stop_collect())
+
class TestClientResourceHelper(unittest.TestCase):
VNFD_0 = {
@@ -1012,10 +1031,12 @@ class TestClientResourceHelper(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.100.20',
- 'local_mac': '00:00:00:00:00:01'
+ 'local_mac': '00:00:00:00:00:01',
+ 'vld_id': 'uplink_0',
+ 'ifname': 'xe0',
},
'vnfd-connection-point-ref': 'xe0',
'name': 'xe0'
@@ -1028,10 +1049,12 @@ class TestClientResourceHelper(unittest.TestCase):
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
- 'local_mac': '00:00:00:00:00:02'
+ 'local_mac': '00:00:00:00:00:02',
+ 'vld_id': 'downlink_0',
+ 'ifname': 'xe1',
},
'vnfd-connection-point-ref': 'xe1',
'name': 'xe1'
@@ -1044,7 +1067,7 @@ class TestClientResourceHelper(unittest.TestCase):
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 2,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.30',
'local_mac': '00:00:00:00:00:11'
@@ -1095,7 +1118,7 @@ class TestClientResourceHelper(unittest.TestCase):
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.STLError',
new_callable=lambda: MockError)
def test_get_stats_not_connected(self, mock_state_error, mock_logger):
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -1113,11 +1136,6 @@ class TestClientResourceHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
client_resource_helper = ClientResourceHelper(dpdk_setup_helper)
client_resource_helper.client = mock.MagicMock()
- client_resource_helper._vpci_ascending = [
- '0000:05:00.0',
- '0000:05:00.1',
- '0000:05:00.2',
- ]
client_resource_helper.client.get_stats.return_value = {
0: {
'rx_pps': 5.5,
@@ -1151,16 +1169,9 @@ class TestClientResourceHelper(unittest.TestCase):
"in_packets": 0,
"out_packets": 48791,
},
- 'xe2': {
- "rx_throughput_fps": 0.0,
- "tx_throughput_fps": 0.0,
- "rx_throughput_mbps": 0.0,
- "tx_throughput_mbps": 0.0,
- "in_packets": 0,
- "out_packets": 0,
- },
}
- result = client_resource_helper.generate_samples()
+ ports = vnfd_helper.port_nums(vnfd_helper.port_pairs.all_ports)
+ result = client_resource_helper.generate_samples(ports)
self.assertDictEqual(result, expected)
def test_generate_samples_with_key(self):
@@ -1170,10 +1181,6 @@ class TestClientResourceHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
client_resource_helper = ClientResourceHelper(dpdk_setup_helper)
client_resource_helper.client = mock.MagicMock()
- client_resource_helper._vpci_ascending = [
- '0000:05:00.0',
- '0000:05:00.1',
- ]
client_resource_helper.client.get_stats.return_value = {
'key_name': 'key_value',
0: {
@@ -1211,7 +1218,8 @@ class TestClientResourceHelper(unittest.TestCase):
"out_packets": 48791,
},
}
- result = client_resource_helper.generate_samples('key_name')
+ ports = vnfd_helper.port_nums(vnfd_helper.port_pairs.all_ports)
+ result = client_resource_helper.generate_samples(ports, 'key_name')
self.assertDictEqual(result, expected)
def test_generate_samples_with_key_and_default(self):
@@ -1221,10 +1229,6 @@ class TestClientResourceHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
client_resource_helper = ClientResourceHelper(dpdk_setup_helper)
client_resource_helper.client = mock.MagicMock()
- client_resource_helper._vpci_ascending = [
- '0000:05:00.0',
- '0000:05:00.1',
- ]
client_resource_helper.client.get_stats.return_value = {
0: {
'rx_pps': 5.5,
@@ -1261,11 +1265,12 @@ class TestClientResourceHelper(unittest.TestCase):
"out_packets": 48791,
},
}
- result = client_resource_helper.generate_samples('key_name', 'default')
+ ports = vnfd_helper.port_nums(vnfd_helper.port_pairs.all_ports)
+ result = client_resource_helper.generate_samples(ports, 'key_name', 'default')
self.assertDictEqual(result, expected)
def test_clear_stats(self):
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -1276,7 +1281,7 @@ class TestClientResourceHelper(unittest.TestCase):
self.assertEqual(client_resource_helper.client.clear_stats.call_count, 1)
def test_clear_stats_of_ports(self):
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -1287,7 +1292,7 @@ class TestClientResourceHelper(unittest.TestCase):
self.assertEqual(client_resource_helper.client.clear_stats.call_count, 1)
def test_start(self):
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -1298,7 +1303,7 @@ class TestClientResourceHelper(unittest.TestCase):
self.assertEqual(client_resource_helper.client.start.call_count, 1)
def test_start_ports(self):
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -1309,7 +1314,7 @@ class TestClientResourceHelper(unittest.TestCase):
self.assertEqual(client_resource_helper.client.start.call_count, 1)
def test_collect_kpi_with_queue(self):
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -1332,7 +1337,7 @@ class TestClientResourceHelper(unittest.TestCase):
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.STLError',
new_callable=lambda: MockError)
def test__connect_with_failures(self, mock_error, mock_logger, mock_time):
- vnfd_helper = VnfdHelper({})
+ vnfd_helper = VnfdHelper(self.VNFD_0)
ssh_helper = mock.Mock()
scenario_helper = mock.Mock()
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
@@ -1511,8 +1516,9 @@ class TestSampleVNFDeployHelper(unittest.TestCase):
sample_vnf_deploy_helper = SampleVNFDeployHelper(vnfd_helper, ssh_helper)
self.assertIsNone(sample_vnf_deploy_helper.deploy_vnfs('name1'))
- self.assertEqual(ssh_helper.execute.call_count, 0)
- self.assertEqual(ssh_helper.put.call_count, 0)
+ sample_vnf_deploy_helper.DISABLE_DEPLOY = True
+ self.assertEqual(ssh_helper.execute.call_count, 5)
+ self.assertEqual(ssh_helper.put.call_count, 1)
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch('subprocess.check_output')
@@ -1667,7 +1673,7 @@ class TestSampleVnf(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.100.20',
'local_mac': '00:00:00:00:00:01'
@@ -1682,7 +1688,7 @@ class TestSampleVnf(unittest.TestCase):
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_mac': '00:00:00:00:00:02'
@@ -1757,7 +1763,6 @@ class TestSampleVnf(unittest.TestCase):
class MySetupEnvHelper(SetupEnvHelper):
pass
-
class MyResourceHelper(ResourceHelper):
pass
@@ -1895,6 +1900,16 @@ class TestSampleVnf(unittest.TestCase):
self.assertEqual(sample_vnf.wait_for_instantiate(), 0)
+ def test__build_ports(self):
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ sample_vnf = SampleVNF('vnf1', vnfd)
+
+ self.assertIsNone(sample_vnf._build_ports())
+ self.assertIsNotNone(sample_vnf.networks)
+ self.assertIsNotNone(sample_vnf.uplink_ports)
+ self.assertIsNotNone(sample_vnf.downlink_ports)
+ self.assertIsNotNone(sample_vnf.my_ports)
+
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
def test_vnf_execute_with_queue_data(self, mock_time):
queue_size_list = [
@@ -2022,7 +2037,7 @@ class TestSampleVNFTrafficGen(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.100.20',
'local_mac': '00:00:00:00:00:01'
@@ -2038,7 +2053,7 @@ class TestSampleVNFTrafficGen(unittest.TestCase):
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_mac': '00:00:00:00:00:02'
@@ -2046,22 +2061,6 @@ class TestSampleVNFTrafficGen(unittest.TestCase):
'vnfd-connection-point-ref': 'xe1',
'name': 'xe1'
},
- {
- 'virtual-interface': {
- 'dst_mac': '00:00:00:00:00:13',
- 'vpci': '0000:05:00.2',
- 'driver': 'ixgbe',
- 'local_ip': '152.16.40.19',
- 'type': 'PCI-PASSTHROUGH',
- 'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
- 'bandwidth': '10 Gbps',
- 'dst_ip': '152.16.40.30',
- 'local_mac': '00:00:00:00:00:11'
- },
- 'vnfd-connection-point-ref': 'xe2',
- 'name': 'xe2'
- },
],
},
],
@@ -2132,6 +2131,7 @@ class TestSampleVNFTrafficGen(unittest.TestCase):
def test_terminate(self):
sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0)
sample_vnf_tg._traffic_process = mock.Mock()
+ sample_vnf_tg._tg_process = mock.Mock()
sample_vnf_tg.terminate()
@@ -2174,7 +2174,7 @@ class TestSampleVNFTrafficGen(unittest.TestCase):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
- mock_traffic_profile.execute.return_value = "64"
+ mock_traffic_profile.execute_traffic.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0)
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 c65c0ab0a..e6e4b882e 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
@@ -70,7 +70,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'driver': "i40e",
'dst_ip': '152.16.100.20',
@@ -85,7 +85,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
'type': 'PCI-PASSTHROUGH',
'driver': "i40e",
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_iface_name': 'xe1',
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
index 45bbfaea3..c1b2d27eb 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
@@ -20,6 +20,7 @@ from __future__ import absolute_import
import unittest
import mock
from multiprocessing import Queue
+import multiprocessing
from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
from tests.unit import STL_MOCKS
@@ -31,11 +32,40 @@ stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
stl_patch.start()
if stl_patch:
- from yardstick.network_services.vnf_generic.vnf.tg_ping import PingParser, PingTrafficGen
- from yardstick.network_services.traffic_profile.base import TrafficProfile
+ from yardstick.network_services.vnf_generic.vnf.tg_ping import PingParser
+ from yardstick.network_services.vnf_generic.vnf.tg_ping import PingTrafficGen
+ from yardstick.network_services.vnf_generic.vnf.tg_ping import PingResourceHelper
+ from yardstick.network_services.vnf_generic.vnf.tg_ping import PingSetupEnvHelper
from yardstick.network_services.vnf_generic.vnf.sample_vnf import VnfSshHelper
+class TestPingResourceHelper(unittest.TestCase):
+ def test___init__(self):
+ setup_helper = mock.Mock()
+ helper = PingResourceHelper(setup_helper)
+
+ self.assertIsInstance(helper._queue, multiprocessing.queues.Queue)
+ self.assertIsInstance(helper._parser, PingParser)
+
+ def test_run_traffic(self):
+ setup_helper = mock.Mock()
+ traffic_profile = mock.Mock()
+ traffic_profile.params = {
+ 'traffic_profile': {
+ 'frame_size': 64,
+ },
+ }
+
+ helper = PingResourceHelper(setup_helper)
+ helper.cmd_kwargs = {'target_ip': '10.0.0.2',
+ 'local_ip': '10.0.0.1',
+ 'local_if_name': 'eth0',
+ }
+ helper.ssh_helper = mock.Mock()
+ helper.run_traffic(traffic_profile)
+ helper.ssh_helper.run.called_with('ping-s 64 10.0.0.2')
+
+
class TestPingParser(unittest.TestCase):
def test___init__(self):
q_out = Queue()
@@ -69,7 +99,6 @@ class TestPingParser(unittest.TestCase):
class TestPingTrafficGen(unittest.TestCase):
-
VNFD_0_EXT_IF_0 = {
'virtual-interface': {
'dst_mac': '00:00:00:00:00:04',
@@ -77,7 +106,6 @@ class TestPingTrafficGen(unittest.TestCase):
'local_ip': u'152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
'bandwidth': '10 Gbps',
'driver': "i40e",
'dst_ip': u'152.16.100.20',
@@ -96,14 +124,13 @@ class TestPingTrafficGen(unittest.TestCase):
'type': 'PCI-PASSTHROUGH',
'driver': "i40e",
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
'bandwidth': '10 Gbps',
'dst_ip': u'152.16.40.20',
'local_iface_name': 'xe1',
'local_mac': '00:00:00:00:00:01',
},
- 'vnfd-connection-point-ref': 'xe1',
- 'name': 'xe1',
+ 'vnfd-connection-point-ref': 'xe1',
+ 'name': 'xe1',
}
VNFD_0_EXT_IF_LIST = [
@@ -151,7 +178,7 @@ class TestPingTrafficGen(unittest.TestCase):
],
'description': 'Vpe approximation using DPDK',
'mgmt-interface': {
- 'vdu-id': 'vpevnf-baremetal',
+ 'vdu-id': 'vpevnf-baremetal',
'host': '1.1.1.1',
'password': 'r00t',
'user': 'root',
@@ -198,11 +225,20 @@ class TestPingTrafficGen(unittest.TestCase):
},
}
+ CMD_KWARGS = {
+ 'target_ip': u'152.16.100.20',
+ 'local_ip': u'152.16.100.19',
+ 'local_if_name': u'xe0',
+ }
+
@mock.patch("yardstick.ssh.SSH")
def test___init__(self, ssh):
ssh.from_node.return_value.execute.return_value = 0, "success", ""
ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
- self.assertIsNotNone(ping_traffic_gen._queue)
+
+ self.assertIsInstance(ping_traffic_gen.setup_helper, PingSetupEnvHelper)
+ self.assertIsInstance(ping_traffic_gen.resource_helper, PingResourceHelper)
+ self.assertEquals(ping_traffic_gen._result, {})
@mock.patch("yardstick.ssh.SSH")
def test__bind_device_kernel_with_failure(self, ssh):
@@ -234,35 +270,23 @@ class TestPingTrafficGen(unittest.TestCase):
mock_ssh(ssh, spec=VnfSshHelper, exec_result=(0, "success", ""))
ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
ping_traffic_gen.setup_helper.ssh_helper = mock.MagicMock(
- **{"execute.return_value": (0, "", "")})
+ **{"execute.return_value": (0, "success", "")})
self.assertIsInstance(ping_traffic_gen.ssh_helper, mock.Mock)
self.assertEqual(ping_traffic_gen._result, {})
+
self.assertIsNone(ping_traffic_gen.instantiate({}, {}))
+
+ self.assertEqual(
+ ping_traffic_gen.vnfd_helper.interfaces[0]['virtual-interface']['local_iface_name'],
+ 'success')
+ self.assertEqual(self.CMD_KWARGS, ping_traffic_gen.resource_helper.cmd_kwargs)
self.assertIsNotNone(ping_traffic_gen._result)
@mock.patch("yardstick.ssh.SSH")
def test_listen_traffic(self, ssh):
- ssh.from_node.return_value.execute.return_value = 0, "success", ""
ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
self.assertIsNone(ping_traffic_gen.listen_traffic({}))
- @mock.patch(SSH_HELPER)
- def test_run_traffic_process(self, ssh):
- mock_ssh(ssh)
-
- mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
- mock_traffic_profile.get_traffic_definition.return_value = "64"
- mock_traffic_profile.params = self.TRAFFIC_PROFILE
-
- ssh.from_node.return_value.execute.return_value = 0, "success", ""
- ssh.from_node.return_value.run.return_value = 0, "success", ""
-
- sut = PingTrafficGen('vnf1', self.VNFD_0)
- sut._traffic_runner(mock_traffic_profile)
- sut.ssh_helper.run.assert_called_with(
- "ping -s 64 152.16.100.20",
- stdout=sut._parser, keep_stdin_open=True, pty=True)
-
@mock.patch("yardstick.ssh.SSH")
def test_scale_negative(self, ssh):
ssh.from_node.return_value.execute.return_value = 0, "success", ""
@@ -277,4 +301,4 @@ class TestPingTrafficGen(unittest.TestCase):
ssh.from_node.return_value.run.return_value = 0, "success", ""
ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
- self.assertIsNone(ping_traffic_gen.terminate()) \ No newline at end of file
+ self.assertIsNone(ping_traffic_gen.terminate())
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
index a12abb625..23d448c5e 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
@@ -20,7 +20,6 @@ import mock
from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
from tests.unit import STL_MOCKS
-from yardstick.network_services.nfvi.resource import ResourceProfile
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
NAME = 'vnf__1'
@@ -80,7 +79,7 @@ class TestProxTrafficGen(unittest.TestCase):
'type': 'PCI-PASSTHROUGH',
'vld_id': '',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'driver': "i40e",
'dst_ip': '152.16.100.20',
@@ -99,7 +98,7 @@ class TestProxTrafficGen(unittest.TestCase):
'vld_id': '',
'driver': "i40e",
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_iface_name': 'xe1',
@@ -180,7 +179,7 @@ class TestProxTrafficGen(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens513f0',
- 'vld_id': 'public',
+ 'vld_id': ProxTrafficGen.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.20',
'dst_mac': '00:00:00:00:00:01',
@@ -214,7 +213,7 @@ class TestProxTrafficGen(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens785f0',
- 'vld_id': 'private',
+ 'vld_id': ProxTrafficGen.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.20',
'dst_mac': '00:00:00:00:00:02',
@@ -245,7 +244,7 @@ class TestProxTrafficGen(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens786f0',
- 'vld_id': 'private',
+ 'vld_id': ProxTrafficGen.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.19',
'dst_mac': '00:00:00:00:00:04',
@@ -257,7 +256,7 @@ class TestProxTrafficGen(unittest.TestCase):
},
'xe1': {
'local_iface_name': 'ens786f1',
- 'vld_id': 'public',
+ 'vld_id': ProxTrafficGen.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.19',
'dst_mac': '00:00:00:00:00:03',
@@ -331,7 +330,8 @@ class TestProxTrafficGen(unittest.TestCase):
mock_ssh(ssh)
prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0)
- prox_traffic_gen._vnf_wrapper.resource = mock.Mock(autospec=ResourceProfile)
+ prox_traffic_gen._vnf_wrapper.resource_helper.resource = mock.MagicMock(
+ **{"check_if_sa_running.return_value": [False]})
prox_traffic_gen._vnf_wrapper.vnf_execute = mock.Mock(return_value="")
self.assertEqual({}, prox_traffic_gen.collect_kpi())
@@ -349,8 +349,10 @@ class TestProxTrafficGen(unittest.TestCase):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
prox_traffic_gen = ProxTrafficGen(NAME, vnfd)
- prox_traffic_gen.ssh_helper = mock.MagicMock(
+ ssh_helper = mock.MagicMock(
**{"execute.return_value": (0, "", ""), "bin_path": ""})
+ prox_traffic_gen.ssh_helper = ssh_helper
+ prox_traffic_gen.setup_helper.dpdk_bind_helper.ssh_helper = ssh_helper
prox_traffic_gen.setup_helper._setup_resources = mock.MagicMock()
prox_traffic_gen.setup_hugepages = mock.MagicMock()
prox_traffic_gen.generate_prox_config_file = mock.MagicMock()
@@ -369,12 +371,12 @@ class TestProxTrafficGen(unittest.TestCase):
'task_path': '',
'options': {'tg__1': {'prox_args': {'-e': '',
'-t': ''},
- 'prox_config': 'configs/l3-gen-2.cfg',
- 'prox_path': '/root/dppd-PROX-v035/build/prox'},
- 'vnf__1': {'prox_args': {'-t': ''},
- 'prox_config': 'configs/l3-swap-2.cfg',
- 'prox_path': '/root/dppd-PROX-v035/build/prox'}
- }
+ 'prox_config': 'configs/l3-gen-2.cfg',
+ 'prox_path': '/root/dppd-PROX-v035/build/prox'},
+ 'vnf__1': {'prox_args': {'-t': ''},
+ 'prox_config': 'configs/l3-swap-2.cfg',
+ 'prox_path': '/root/dppd-PROX-v035/build/prox'}
+ }
}
prox_traffic_gen.instantiate(scenario_cfg, {})
@@ -384,16 +386,15 @@ class TestProxTrafficGen(unittest.TestCase):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
- mock_traffic_profile.execute.return_value = "64"
+ mock_traffic_profile.execute_traffic.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
sut = ProxTrafficGen(NAME, vnfd)
- sut.prox_config_dict = {}
sut._get_socket = mock.MagicMock()
sut.ssh_helper = mock.Mock()
sut.ssh_helper.run = mock.Mock()
- sut._vpci_ascending = ["0000:05:00.0", "0000:05:00.1"]
+ sut.setup_helper.prox_config_dict = {}
sut._connect_client = mock.Mock(autospec=STLClient)
sut._connect_client.get_stats = mock.Mock(return_value="0")
sut._traffic_runner(mock_traffic_profile)
@@ -425,6 +426,8 @@ class TestProxTrafficGen(unittest.TestCase):
prox_traffic_gen._traffic_process.terminate = mock.Mock()
prox_traffic_gen.ssh_helper = mock.MagicMock()
prox_traffic_gen.setup_helper = mock.MagicMock()
- prox_traffic_gen._vnf_wrapper.setup_helper = mock.MagicMock()
prox_traffic_gen.resource_helper = mock.MagicMock()
+ prox_traffic_gen._vnf_wrapper.setup_helper = mock.MagicMock()
+ prox_traffic_gen._vnf_wrapper._vnf_process = mock.MagicMock()
+ prox_traffic_gen._vnf_wrapper.resource_helper = mock.MagicMock()
self.assertEqual(None, prox_traffic_gen.terminate())
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
index 3c5ccefce..f62a0fb3b 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
@@ -23,7 +23,6 @@ import mock
from tests.unit import STL_MOCKS
-
STLClient = mock.MagicMock()
stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
stl_patch.start()
@@ -36,13 +35,11 @@ if stl_patch:
TEST_FILE_YAML = 'nsb_test_case.yaml'
-
NAME = "tg__1"
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen")
class TestIxiaResourceHelper(unittest.TestCase):
-
def test___init___with_custom_rfc_helper(self, mock_ix_nextgen):
class MyRfcHelper(IxiaRfc2544Helper):
pass
@@ -63,71 +60,71 @@ class TestIxiaResourceHelper(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen")
class TestIXIATrafficGen(unittest.TestCase):
VNFD = {'vnfd:vnfd-catalog':
- {'vnfd':
- [{'short-name': 'VpeVnf',
- 'vdu':
- [{'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'}],
- 'description': 'VPE approximation using DPDK',
- 'name': 'vpevnf-baremetal',
- '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'}],
- 'id': 'vpevnf-baremetal',
- 'external-interface':
- [{'virtual-interface':
- {'dst_mac': '00:00:00:00:00:04',
- 'vpci': '0000:05:00.0',
- 'local_ip': '152.16.100.19',
- 'type': 'PCI-PASSTHROUGH',
- 'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
- 'bandwidth': '10 Gbps',
- 'driver': "i40e",
- 'dst_ip': '152.16.100.20',
- 'local_iface_name': 'xe0',
- 'local_mac': '00:00:00:00:00:02'},
- 'vnfd-connection-point-ref': 'xe0',
- 'name': 'xe0'},
- {'virtual-interface':
- {'dst_mac': '00:00:00:00:00:03',
- 'vpci': '0000:05:00.1',
- 'local_ip': '152.16.40.19',
- 'type': 'PCI-PASSTHROUGH',
- 'driver': "i40e",
- 'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
- 'bandwidth': '10 Gbps',
- 'dst_ip': '152.16.40.20',
- 'local_iface_name': 'xe1',
- 'local_mac': '00:00:00:00:00:01'},
- 'vnfd-connection-point-ref': 'xe1',
- 'name': 'xe1'}]}],
- 'description': 'Vpe approximation using DPDK',
- 'mgmt-interface':
- {'vdu-id': 'vpevnf-baremetal',
- 'host': '1.1.1.1',
- 'password': 'r00t',
- 'user': 'root',
- 'ip': '1.1.1.1'},
- 'benchmark':
- {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
- 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
- {'type': 'VPORT', 'name': 'xe1'}],
- 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
+ {'vnfd':
+ [{'short-name': 'VpeVnf',
+ 'vdu':
+ [{'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'}],
+ 'description': 'VPE approximation using DPDK',
+ 'name': 'vpevnf-baremetal',
+ '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'}],
+ 'id': 'vpevnf-baremetal',
+ 'external-interface':
+ [{'virtual-interface':
+ {'dst_mac': '00:00:00:00:00:04',
+ 'vpci': '0000:05:00.0',
+ 'local_ip': '152.16.100.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 0,
+ 'bandwidth': '10 Gbps',
+ 'driver': "i40e",
+ 'dst_ip': '152.16.100.20',
+ 'local_iface_name': 'xe0',
+ 'local_mac': '00:00:00:00:00:02'},
+ 'vnfd-connection-point-ref': 'xe0',
+ 'name': 'xe0'},
+ {'virtual-interface':
+ {'dst_mac': '00:00:00:00:00:03',
+ 'vpci': '0000:05:00.1',
+ 'local_ip': '152.16.40.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'driver': "i40e",
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 1,
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.40.20',
+ 'local_iface_name': 'xe1',
+ 'local_mac': '00:00:00:00:00:01'},
+ 'vnfd-connection-point-ref': 'xe1',
+ 'name': 'xe1'}]}],
+ 'description': 'Vpe approximation using DPDK',
+ 'mgmt-interface':
+ {'vdu-id': 'vpevnf-baremetal',
+ 'host': '1.1.1.1',
+ 'password': 'r00t',
+ 'user': 'root',
+ 'ip': '1.1.1.1'},
+ 'benchmark':
+ {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
+ 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
+ {'type': 'VPORT', 'name': 'xe1'}],
+ 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
TRAFFIC_PROFILE = {
"schema": "isb:traffic_profile:0.1",
@@ -140,12 +137,12 @@ class TestIXIATrafficGen(unittest.TestCase):
"frame_size": 64}}
TC_YAML = {'scenarios': [{'tc_options':
- {'rfc2544': {'allowed_drop_rate': '0.8 - 1'}},
+ {'rfc2544': {'allowed_drop_rate': '0.8 - 1'}},
'runner': {'duration': 400,
'interval': 35, 'type': 'Duration'},
'traffic_options':
- {'flow': 'ipv4_1flow_Packets_vpe.yaml',
- 'imix': 'imix_voice.yaml'},
+ {'flow': 'ipv4_1flow_Packets_vpe.yaml',
+ 'imix': 'imix_voice.yaml'},
'vnf_options': {'vpe': {'cfg': 'vpe_config'}},
'traffic_profile': 'ipv4_throughput_vpe.yaml',
'type': 'NSPerf',
@@ -195,7 +192,7 @@ class TestIXIATrafficGen(unittest.TestCase):
'vnf_config': {'lb_config': 'SW',
'lb_count': 1,
'worker_config':
- '1C/1T',
+ '1C/1T',
'worker_threads': 1}}
}})
ixnet_traffic_gen.topology = ""
@@ -255,6 +252,8 @@ class TestIXIATrafficGen(unittest.TestCase):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
+ # traffic_profile.ports is standardized on port_num
+ mock_traffic_profile.ports = [0, 1]
mock_ssh_instance = mock.Mock(autospec=mock_ssh.SSH)
mock_ssh_instance.execute.return_value = 0, "", ""
@@ -306,11 +305,10 @@ class TestIXIATrafficGen(unittest.TestCase):
},
]
- mock_traffic_profile.execute.return_value = ['Completed', samples]
+ mock_traffic_profile.execute_traffic.return_value = ['Completed', samples]
mock_traffic_profile.get_drop_percentage.return_value = ['Completed', samples]
sut = IxiaTrafficGen(name, vnfd)
- sut.tg_port_pairs = [[[0], [1]]]
sut.vnf_port_pairs = [[[0], [1]]]
sut.tc_file_name = self._get_file_abspath(TEST_FILE_YAML)
sut.topology = ""
@@ -349,7 +347,12 @@ class TestIXIATrafficGen(unittest.TestCase):
'task_path': '/path/to/task'
}
- with mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open', create=True) as mock_open:
- mock_open.return_value = mock.MagicMock()
+ @mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open', create=True)
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.open',
+ mock.mock_open(), create=True)
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.LOG.exception')
+ def _traffic_runner(*args):
result = sut._traffic_runner(mock_traffic_profile)
self.assertIsNone(result)
+
+ _traffic_runner()
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
index 6f2a9445f..637706fb4 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
@@ -24,7 +24,6 @@ from tests.unit import STL_MOCKS
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
-
STLClient = mock.MagicMock()
stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
stl_patch.start()
@@ -101,8 +100,8 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'vld_id': 'private_1',
- 'dpdk_port_num': '0',
+ 'vld_id': 'uplink_0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'driver': "i40e",
'dst_ip': '152.16.100.20',
@@ -121,8 +120,8 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
'type': 'PCI-PASSTHROUGH',
'driver': "i40e",
'netmask': '255.255.255.0',
- 'vld_id': 'public_1',
- 'dpdk_port_num': '1',
+ 'vld_id': 'downlink_0',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_iface_name': 'xe1',
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
index 9d1ce1520..d08c62e0b 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
@@ -25,7 +25,6 @@ SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper
from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
from tests.unit import STL_MOCKS
-
NAME = 'vnf_1'
STLClient = mock.MagicMock()
@@ -34,77 +33,77 @@ stl_patch.start()
if stl_patch:
from yardstick.network_services.vnf_generic.vnf.tg_trex import \
- TrexTrafficGen, TrexResourceHelper
+ TrexTrafficGen, TrexResourceHelper
from yardstick.network_services.traffic_profile.base import TrafficProfile
class TestTrexTrafficGen(unittest.TestCase):
VNFD = {'vnfd:vnfd-catalog':
- {'vnfd':
- [{'short-name': 'VpeVnf',
- 'vdu':
- [{'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'}],
- 'description': 'VPE approximation using DPDK',
- 'name': 'vpevnf-baremetal',
- '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'}],
- 'id': 'vpevnf-baremetal',
- 'external-interface':
- [{'virtual-interface':
- {'dst_mac': '00:00:00:00:00:04',
- 'vpci': '0000:05:00.0',
- 'local_ip': '152.16.100.19',
- 'type': 'PCI-PASSTHROUGH',
- 'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
- 'bandwidth': '10 Gbps',
- 'driver': "i40e",
- 'dst_ip': '152.16.100.20',
- 'local_iface_name': 'xe0',
- 'local_mac': '00:00:00:00:00:02'},
- 'vnfd-connection-point-ref': 'xe0',
- 'name': 'xe0'},
- {'virtual-interface':
- {'dst_mac': '00:00:00:00:00:03',
- 'vpci': '0000:05:00.1',
- 'local_ip': '152.16.40.19',
- 'type': 'PCI-PASSTHROUGH',
- 'driver': "i40e",
- 'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
- 'bandwidth': '10 Gbps',
- 'dst_ip': '152.16.40.20',
- 'local_iface_name': 'xe1',
- 'local_mac': '00:00:00:00:00:01'},
- 'vnfd-connection-point-ref': 'xe1',
- 'name': 'xe1'}]}],
- 'description': 'Vpe approximation using DPDK',
- 'mgmt-interface':
- {'vdu-id': 'vpevnf-baremetal',
- 'host': '1.1.1.1',
- 'password': 'r00t',
- 'user': 'root',
- 'ip': '1.1.1.1'},
- 'benchmark':
- {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
- 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
- {'type': 'VPORT', 'name': 'xe1'}],
- 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
+ {'vnfd':
+ [{'short-name': 'VpeVnf',
+ 'vdu':
+ [{'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'}],
+ 'description': 'VPE approximation using DPDK',
+ 'name': 'vpevnf-baremetal',
+ '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'}],
+ 'id': 'vpevnf-baremetal',
+ 'external-interface':
+ [{'virtual-interface':
+ {'dst_mac': '00:00:00:00:00:04',
+ 'vpci': '0000:05:00.0',
+ 'local_ip': '152.16.100.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 0,
+ 'bandwidth': '10 Gbps',
+ 'driver': "i40e",
+ 'dst_ip': '152.16.100.20',
+ 'local_iface_name': 'xe0',
+ 'local_mac': '00:00:00:00:00:02'},
+ 'vnfd-connection-point-ref': 'xe0',
+ 'name': 'xe0'},
+ {'virtual-interface':
+ {'dst_mac': '00:00:00:00:00:03',
+ 'vpci': '0000:05:00.1',
+ 'local_ip': '152.16.40.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'driver': "i40e",
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 1,
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.40.20',
+ 'local_iface_name': 'xe1',
+ 'local_mac': '00:00:00:00:00:01'},
+ 'vnfd-connection-point-ref': 'xe1',
+ 'name': 'xe1'}]}],
+ 'description': 'Vpe approximation using DPDK',
+ 'mgmt-interface':
+ {'vdu-id': 'vpevnf-baremetal',
+ 'host': '1.1.1.1',
+ 'password': 'r00t',
+ 'user': 'root',
+ 'ip': '1.1.1.1'},
+ 'benchmark':
+ {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
+ 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
+ {'type': 'VPORT', 'name': 'xe1'}],
+ 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
TRAFFIC_PROFILE = {
"schema": "isb:traffic_profile:0.1",
@@ -166,7 +165,7 @@ class TestTrexTrafficGen(unittest.TestCase):
"interfaces": {
"xe0": {
"local_iface_name": "ens786f0",
- "vld_id": "private",
+ "vld_id": TrafficProfile.UPLINK,
"netmask": "255.255.255.0",
"vpci": "0000:05:00.0",
"local_ip": "152.16.100.19",
@@ -178,7 +177,7 @@ class TestTrexTrafficGen(unittest.TestCase):
},
"xe1": {
"local_iface_name": "ens786f1",
- "vld_id": "public",
+ "vld_id": TrafficProfile.DOWNLINK,
"netmask": "255.255.255.0",
"vpci": "0000:05:00.1",
"local_ip": "152.16.40.19",
@@ -234,7 +233,7 @@ class TestTrexTrafficGen(unittest.TestCase):
"interfaces": {
"xe0": {
"local_iface_name": "ens513f0",
- "vld_id": "public",
+ "vld_id": TrafficProfile.DOWNLINK,
"netmask": "255.255.255.0",
"vpci": "0000:02:00.0",
"local_ip": "152.16.40.20",
@@ -268,7 +267,7 @@ class TestTrexTrafficGen(unittest.TestCase):
"interfaces": {
"xe0": {
"local_iface_name": "ens785f0",
- "vld_id": "private",
+ "vld_id": TrafficProfile.UPLINK,
"netmask": "255.255.255.0",
"vpci": "0000:05:00.0",
"local_ip": "152.16.100.20",
@@ -295,8 +294,6 @@ class TestTrexTrafficGen(unittest.TestCase):
}
}
-
-
@mock.patch(SSH_HELPER)
def test___init__(self, ssh):
mock_ssh(ssh)
@@ -359,6 +356,17 @@ class TestTrexTrafficGen(unittest.TestCase):
trex_traffic_gen = TrexTrafficGen(NAME, vnfd)
trex_traffic_gen.ssh_helper = mock.MagicMock()
trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
+ trex_traffic_gen.scenario_helper.scenario_cfg = {}
+ self.assertIsNone(trex_traffic_gen._start_server())
+
+ @mock.patch(SSH_HELPER)
+ def test__start_server_multiple_queues(self, ssh):
+ mock_ssh(ssh)
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ trex_traffic_gen = TrexTrafficGen(NAME, vnfd)
+ trex_traffic_gen.ssh_helper = mock.MagicMock()
+ trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
+ trex_traffic_gen.scenario_helper.scenario_cfg = {"options": {NAME: {"queues_per_port": 2}}}
self.assertIsNone(trex_traffic_gen._start_server())
@mock.patch(SSH_HELPER)
@@ -367,14 +375,13 @@ class TestTrexTrafficGen(unittest.TestCase):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
- mock_traffic_profile.execute.return_value = "64"
+ mock_traffic_profile.execute_traffic.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
self.sut = TrexTrafficGen(NAME, vnfd)
self.sut.ssh_helper = mock.Mock()
self.sut.ssh_helper.run = mock.Mock()
- self.sut._vpci_ascending = ["0000:05:00.0", "0000:05:00.1"]
self.sut._connect_client = mock.Mock(autospec=STLClient)
self.sut._connect_client.get_stats = mock.Mock(return_value="0")
self.sut.resource_helper.RUN_DURATION = 0
@@ -432,5 +439,6 @@ class TestTrexTrafficGen(unittest.TestCase):
client.connect = mock.Mock(return_value=0)
self.assertIsNotNone(trex_traffic_gen.resource_helper._connect(client))
+
if __name__ == '__main__':
unittest.main()
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 c4ced30fe..d4d3439f3 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
@@ -31,6 +31,7 @@ stl_patch.start()
if stl_patch:
from yardstick.network_services.vnf_generic.vnf.udp_replay import UdpReplayApproxVnf
+ from yardstick.network_services.nfvi.resource import ResourceProfile
from yardstick.network_services.vnf_generic.vnf.sample_vnf import ScenarioHelper
from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
@@ -73,10 +74,12 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
'local_ip': '152.16.100.19',
'local_mac': '00:00:00:00:00:02',
'vpci': '0000:05:00.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'netmask': '255.255.255.0',
'dst_ip': '152.16.100.20',
'type': 'PCI-PASSTHROUGH',
+ 'vld_id': 'uplink_0',
+ 'ifname': 'xe0',
},
'vnfd-connection-point-ref': 'xe0',
'name': 'xe0',
@@ -90,10 +93,12 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
'local_ip': '152.16.40.19',
'local_mac': '00:00:00:00:00:01',
'vpci': '0000:05:00.1',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'netmask': '255.255.255.0',
'dst_ip': '152.16.40.20',
'type': 'PCI-PASSTHROUGH',
+ 'vld_id': 'downlink_0',
+ 'ifname': 'xe1',
},
'vnfd-connection-point-ref': 'xe1',
'name': 'xe1',
@@ -195,7 +200,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
"interfaces": {
"xe0": {
"local_iface_name": "ens786f0",
- "vld_id": "private",
+ "vld_id": UdpReplayApproxVnf.UPLINK,
"netmask": "255.255.255.0",
"vpci": "0000:05:00.0",
"local_ip": "152.16.100.19",
@@ -207,7 +212,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
},
"xe1": {
"local_iface_name": "ens786f1",
- "vld_id": "public",
+ "vld_id": UdpReplayApproxVnf.DOWNLINK,
"netmask": "255.255.255.0",
"vpci": "0000:05:00.1",
"local_ip": "152.16.40.19",
@@ -263,7 +268,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
"interfaces": {
"xe0": {
"local_iface_name": "ens513f0",
- "vld_id": "public",
+ "vld_id": UdpReplayApproxVnf.DOWNLINK,
"netmask": "255.255.255.0",
"vpci": "0000:02:00.0",
"local_ip": "152.16.40.20",
@@ -297,7 +302,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
"interfaces": {
"xe0": {
"local_iface_name": "ens785f0",
- "vld_id": "private",
+ "vld_id": UdpReplayApproxVnf.UPLINK,
"netmask": "255.255.255.0",
"vpci": "0000:05:00.0",
"local_ip": "152.16.100.20",
@@ -342,21 +347,12 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
udp_replay_approx_vnf.q_in = mock.MagicMock()
udp_replay_approx_vnf.q_out = mock.MagicMock()
udp_replay_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
- udp_replay_approx_vnf.all_ports = [0, 1]
+ udp_replay_approx_vnf.all_ports = ["xe0", "xe1"]
udp_replay_approx_vnf.get_stats = mock.Mock(return_value=result)
result = {'collect_stats': {}, 'packets_dropped': 0,
'packets_fwd': 14748451, 'packets_in': 14748472}
self.assertEqual(result, udp_replay_approx_vnf.collect_kpi())
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
- @mock.patch(SSH_HELPER)
- def test_vnf_execute_command(self, ssh, mock_time, _):
- mock_ssh(ssh)
-
- udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
- cmd = "quit"
- self.assertEqual("", udp_replay_approx_vnf.vnf_execute(cmd))
-
@mock.patch(SSH_HELPER)
def test_get_stats(self, ssh, _):
mock_ssh(ssh)
@@ -378,7 +374,6 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
file_path = os.path.join(curr_path, filename)
return file_path
- @mock.patch('yardstick.network_services.vnf_generic.vnf.udp_replay.open')
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
@mock.patch(SSH_HELPER)
def test__build_config(self, ssh, mock_context, *_):
@@ -389,14 +384,14 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
udp_replay_approx_vnf.nfvi_context = mock_context
udp_replay_approx_vnf.nfvi_context.attrs = {'nfvi_type': 'baremetal'}
udp_replay_approx_vnf.setup_helper.bound_pci = []
- udp_replay_approx_vnf.all_ports = [0, 1]
udp_replay_approx_vnf.ssh_helper.provision_tool = mock.MagicMock(return_value="tool_path")
udp_replay_approx_vnf.scenario_helper = ScenarioHelper(name='vnf__1')
udp_replay_approx_vnf.scenario_helper.scenario_cfg = self.SCENARIO_CFG
cmd_line = udp_replay_approx_vnf._build_config()
- expected = "sudo tool_path -c 0x7 -n 4 -w -- -p 0x3 --config='(0, 0, 1)(1, 0, 2)'"
+ expected = \
+ "sudo tool_path --log-level=5 -c 0x7 -n 4 -w -- -p 0x3 --config='(0,0,1),(1,0,2)'"
self.assertEqual(cmd_line, expected)
@mock.patch('yardstick.network_services.vnf_generic.vnf.udp_replay.open')
@@ -404,14 +399,11 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
@mock.patch(SSH_HELPER)
def test__build_pipeline_kwargs(self, ssh, mock_context, *_):
mock_ssh(ssh)
-
udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
- udp_replay_approx_vnf._build_config = mock.MagicMock()
- udp_replay_approx_vnf.queue_wrapper = mock.MagicMock()
udp_replay_approx_vnf.nfvi_context = mock_context
udp_replay_approx_vnf.nfvi_context.attrs = {'nfvi_type': 'baremetal'}
- udp_replay_approx_vnf.setup_helper.bound_pci = []
- udp_replay_approx_vnf.all_ports = [0, 1]
+ udp_replay_approx_vnf.setup_helper.bound_pci = ['0000:00:0.1', '0000:00:0.3']
+ udp_replay_approx_vnf.all_ports = ["xe0", "xe1"]
udp_replay_approx_vnf.ssh_helper.provision_tool = mock.MagicMock(return_value="tool_path")
udp_replay_approx_vnf.scenario_helper = ScenarioHelper(name='vnf__1')
udp_replay_approx_vnf.scenario_helper.scenario_cfg = self.SCENARIO_CFG
@@ -419,12 +411,12 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
udp_replay_approx_vnf._build_pipeline_kwargs()
self.assertEqual(udp_replay_approx_vnf.pipeline_kwargs, {
- 'config': '(0, 0, 1)(1, 0, 2)',
+ 'config': '(0,0,1),(1,0,2)',
'cpu_mask_hex': '0x7',
'hw_csum': '',
- 'ports_len_hex': '0x3',
+ 'port_mask_hex': '0x3',
'tool_path': 'tool_path',
- 'whitelist': ''
+ 'whitelist': '0000:00:0.1 -w 0000:00:0.3'
})
@mock.patch(SSH_HELPER)
@@ -434,6 +426,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
udp_replay_approx_vnf._build_config = mock.MagicMock()
udp_replay_approx_vnf.queue_wrapper = mock.MagicMock()
+ udp_replay_approx_vnf.scenario_helper = mock.MagicMock()
udp_replay_approx_vnf._run()
@@ -444,13 +437,16 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
def test_instantiate(self, ssh, *_):
mock_ssh(ssh)
+ resource = mock.Mock(autospec=ResourceProfile)
+
udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
udp_replay_approx_vnf.q_out.put("Replay>")
udp_replay_approx_vnf.WAIT_TIME = 0
udp_replay_approx_vnf.setup_helper.setup_vnf_environment = mock.Mock()
- self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG,
- self.CONTEXT_CFG))
+ udp_replay_approx_vnf.deploy_helper = mock.MagicMock()
+ udp_replay_approx_vnf.deploy_vnfs = mock.MagicMock()
+ self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG))
udp_replay_approx_vnf._vnf_process.is_alive = mock.Mock(return_value=1)
udp_replay_approx_vnf._vnf_process.exitcode = 0
@@ -466,6 +462,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
udp_replay_approx_vnf.q_out.put("some text PANIC some text")
udp_replay_approx_vnf.setup_helper.setup_vnf_environment = mock.Mock()
+ udp_replay_approx_vnf.deploy_helper = mock.MagicMock()
self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG))
with self.assertRaises(RuntimeError):
udp_replay_approx_vnf.wait_for_instantiate()
@@ -484,8 +481,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
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.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 c3d53ff03..958099a03 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
@@ -73,7 +73,7 @@ class TestFWApproxVnf(unittest.TestCase):
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'driver': "i40e",
'dst_ip': '152.16.100.20',
@@ -88,7 +88,7 @@ class TestFWApproxVnf(unittest.TestCase):
'type': 'PCI-PASSTHROUGH',
'driver': "i40e",
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_iface_name': 'xe1',
@@ -142,7 +142,7 @@ class TestFWApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens513f0',
- 'vld_id': 'public',
+ 'vld_id': FWApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.20',
'dst_mac': '00:00:00:00:00:01',
@@ -170,7 +170,7 @@ class TestFWApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens785f0',
- 'vld_id': 'private',
+ 'vld_id': FWApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.20',
'dst_mac': '00:00:00:00:00:02',
@@ -195,7 +195,7 @@ class TestFWApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens786f0',
- 'vld_id': 'private',
+ 'vld_id': FWApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.19',
'dst_mac': '00:00:00:00:00:04',
@@ -205,7 +205,7 @@ class TestFWApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.0',
'dpdk_port_num': 0},
'xe1': {'local_iface_name': 'ens786f1',
- 'vld_id': 'public',
+ 'vld_id': FWApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.19',
'dst_mac': '00:00:00:00:00:03',
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 ffd0d539b..4103d7825 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
@@ -25,6 +25,7 @@ from multiprocessing import Process, Queue
from tests.unit import STL_MOCKS
from yardstick.network_services.vnf_generic.vnf.base import QueueFileWrapper
+from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -36,8 +37,8 @@ stl_patch.start()
if stl_patch:
from yardstick.network_services.vnf_generic.vnf.vpe_vnf import ConfigCreate
from yardstick.network_services.nfvi.resource import ResourceProfile
- from yardstick.network_services.vnf_generic.vnf import vpe_vnf
- from yardstick.network_services.vnf_generic.vnf.vpe_vnf import VpeApproxVnf
+ from yardstick.network_services.vnf_generic.vnf.vpe_vnf import \
+ VpeApproxVnf, VpeApproxSetupEnvHelper
from tests.unit.network_services.vnf_generic.vnf.test_base import FileAbsPath
from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
@@ -55,14 +56,117 @@ get_file_abspath = MODULE_PATH.get_path
class TestConfigCreate(unittest.TestCase):
+ VNFD_0 = {
+ 'short-name': 'VpeVnf',
+ 'vdu': [
+ {
+ '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'
+ },
+ ],
+ 'description': 'VPE approximation using DPDK',
+ 'name': 'vpevnf-baremetal',
+ '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'
+ },
+ ],
+ 'id': 'vpevnf-baremetal',
+ 'external-interface': [
+ {
+ 'virtual-interface': {
+ 'dst_mac': '00:00:00:00:00:03',
+ 'vpci': '0000:05:00.0',
+ 'local_ip': '152.16.100.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 0,
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.100.20',
+ 'local_mac': '00:00:00:00:00:01',
+ 'vld_id': 'uplink_0',
+ 'ifname': 'xe0',
+ },
+ 'vnfd-connection-point-ref': 'xe0',
+ 'name': 'xe0'
+ },
+ {
+ 'virtual-interface': {
+ 'dst_mac': '00:00:00:00:00:04',
+ 'vpci': '0000:05:00.1',
+ 'local_ip': '152.16.40.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 1,
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.40.20',
+ 'local_mac': '00:00:00:00:00:02',
+ 'vld_id': 'downlink_0',
+ 'ifname': 'xe1',
+ },
+ 'vnfd-connection-point-ref': 'xe1',
+ 'name': 'xe1'
+ },
+ ],
+ },
+ ],
+ 'description': 'Vpe approximation using DPDK',
+ 'mgmt-interface': {
+ 'vdu-id': 'vpevnf-baremetal',
+ 'host': '1.1.1.1',
+ 'password': 'r00t',
+ 'user': 'root',
+ 'ip': '1.1.1.1'
+ },
+ 'benchmark': {
+ 'kpi': [
+ 'packets_in',
+ 'packets_fwd',
+ 'packets_dropped',
+ ],
+ },
+ 'connection-point': [
+ {
+ 'type': 'VPORT',
+ 'name': 'xe0',
+ },
+ {
+ 'type': 'VPORT',
+ 'name': 'xe1',
+ },
+ ],
+ 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'
+ }
+
def test___init__(self):
- config_create = ConfigCreate([0], [1], 2)
- self.assertEqual(config_create.priv_ports, [0])
- self.assertEqual(config_create.pub_ports, [1])
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 2)
+ self.assertEqual(config_create.uplink_ports, ['xe0'])
+ self.assertEqual(config_create.downlink_ports, ['xe1'])
self.assertEqual(config_create.socket, 2)
def test_vpe_initialize(self):
- config_create = ConfigCreate([0], [1], 2)
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 2)
config = configparser.ConfigParser()
config_create.vpe_initialize(config)
self.assertEqual(config.get('EAL', 'log_level'), '0')
@@ -72,14 +176,16 @@ class TestConfigCreate(unittest.TestCase):
self.assertEqual(config.get('MEMPOOL1', 'pool_size'), '2M')
def test_vpe_rxq(self):
- config_create = ConfigCreate([0], [1, 2], 3)
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 2)
config = configparser.ConfigParser()
+ config_create.downlink_ports = ['xe0']
config_create.vpe_rxq(config)
- self.assertEqual(config.get('RXQ1.0', 'mempool'), 'MEMPOOL1')
- self.assertEqual(config.get('RXQ2.0', 'mempool'), 'MEMPOOL1')
+ self.assertEqual(config.get('RXQ0.0', 'mempool'), 'MEMPOOL1')
def test_get_sink_swq(self):
- config_create = ConfigCreate([0], [1], 2)
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 2)
config = configparser.ConfigParser()
config.add_section('PIPELINE0')
config.set('PIPELINE0', 'key1', 'value1')
@@ -96,21 +202,32 @@ class TestConfigCreate(unittest.TestCase):
self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key5', 5), 'SWQ0 SINK1')
def test_generate_vpe_script(self):
- vpe_config_vnf = ConfigCreate([0], [0], 0)
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ vpe_config_vnf = ConfigCreate(vnfd_helper, 2)
intf = [
{
+ "name": 'xe1',
+ "virtual-interface": {
+ "dst_ip": "1.1.1.1",
+ "dst_mac": "00:00:00:00:00:00:02",
+ },
+ },
+ {
+ "name": 'xe2',
"virtual-interface": {
"dst_ip": "1.1.1.1",
"dst_mac": "00:00:00:00:00:00:02",
},
},
]
+ vpe_config_vnf.downlink_ports = ['xe1']
+ vpe_config_vnf.uplink_ports = ['xe2']
result = vpe_config_vnf.generate_vpe_script(intf)
self.assertIsInstance(result, str)
self.assertNotEqual(result, '')
def test_create_vpe_config(self):
- priv_ports = [
+ uplink_ports = [
{
'index': 0,
'dpdk_port_num': 1,
@@ -121,7 +238,7 @@ class TestConfigCreate(unittest.TestCase):
},
]
- pub_ports = [
+ downlink_ports = [
{
'index': 2,
'dpdk_port_num': 3,
@@ -132,7 +249,10 @@ class TestConfigCreate(unittest.TestCase):
},
]
- config_create = ConfigCreate(priv_ports, pub_ports, 23)
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 23)
+ config_create.downlink_ports = ['xe1']
+ config_create.uplink_ports = ['xe1']
curr_path = os.path.dirname(os.path.abspath(__file__))
vpe_cfg = "samples/vnf_samples/nsut/vpe/vpe_config"
vnf_cfg = os.path.join(curr_path, "../../../../..", vpe_cfg)
@@ -185,14 +305,15 @@ class TestVpeApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.0',
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
- 'vld_id': '',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
+ 'dpdk_port_num': 0,
'bandwidth': '10 Gbps',
'driver': "i40e",
'dst_ip': '152.16.100.20',
'local_iface_name': 'xe0',
'local_mac': '00:00:00:00:00:02',
+ 'vld_id': 'uplink_0',
+ 'ifname': 'xe0',
},
'vnfd-connection-point-ref': 'xe0',
'name': 'xe0',
@@ -203,14 +324,15 @@ class TestVpeApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.1',
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
- 'vld_id': '',
'driver': "i40e",
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ 'dpdk_port_num': 1,
'bandwidth': '10 Gbps',
'dst_ip': '152.16.40.20',
'local_iface_name': 'xe1',
'local_mac': '00:00:00:00:00:01',
+ 'vld_id': 'downlink_0',
+ 'ifname': 'xe1',
},
'vnfd-connection-point-ref': 'xe1',
'name': 'xe1',
@@ -258,7 +380,7 @@ class TestVpeApproxVnf(unittest.TestCase):
SCENARIO_CFG = {
'options': {
'packetsize': 64,
- 'traffic_type': 4 ,
+ 'traffic_type': 4,
'rfc2544': {
'allowed_drop_rate': '0.8 - 1',
},
@@ -308,7 +430,7 @@ class TestVpeApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens513f0',
- 'vld_id': 'public',
+ 'vld_id': VpeApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.20',
'dst_mac': '00:00:00:00:00:01',
@@ -342,7 +464,7 @@ class TestVpeApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens785f0',
- 'vld_id': 'private',
+ 'vld_id': VpeApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.20',
'dst_mac': '00:00:00:00:00:02',
@@ -373,7 +495,7 @@ class TestVpeApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens786f0',
- 'vld_id': 'private',
+ 'vld_id': VpeApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.19',
'dst_mac': '00:00:00:00:00:04',
@@ -385,7 +507,7 @@ class TestVpeApproxVnf(unittest.TestCase):
},
'xe1': {
'local_iface_name': 'ens786f1',
- 'vld_id': 'public',
+ 'vld_id': VpeApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.19',
'dst_mac': '00:00:00:00:00:03',
@@ -443,8 +565,9 @@ class TestVpeApproxVnf(unittest.TestCase):
mock_ssh(ssh)
resource = mock.Mock(autospec=ResourceProfile)
- resource.check_if_sa_running.return_value = False, 'error'
+ resource.check_if_sa_running.return_value = 1, ''
resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234}
+ resource.check_if_sa_running.return_value = (1, None)
vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf.q_in = mock.MagicMock()
@@ -466,7 +589,7 @@ class TestVpeApproxVnf(unittest.TestCase):
mock_ssh(ssh)
resource = mock.Mock(autospec=ResourceProfile)
- resource.check_if_sa_running.return_value = True, 'good'
+ resource.check_if_sa_running.return_value = 0, '1234'
resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234}
vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
@@ -499,9 +622,6 @@ class TestVpeApproxVnf(unittest.TestCase):
vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf.tc_file_name = get_file_abspath(TEST_FILE_YAML)
- vpe_approx_vnf.generate_port_pairs = mock.Mock()
- vpe_approx_vnf.tg_port_pairs = [[[0], [1]]]
- vpe_approx_vnf.vnf_port_pairs = [[[0], [1]]]
vpe_approx_vnf.vnf_cfg = {
'lb_config': 'SW',
'lb_count': 1,
@@ -513,16 +633,56 @@ class TestVpeApproxVnf(unittest.TestCase):
NAME: {
'traffic_type': '4',
'topology': 'nsb_test_case.yaml',
+ 'vnf_config': 'vpe_config',
}
}
}
vpe_approx_vnf.topology = "nsb_test_case.yaml"
vpe_approx_vnf.nfvi_type = "baremetal"
vpe_approx_vnf._provide_config_file = mock.Mock()
+ vpe_approx_vnf._build_config = mock.MagicMock()
self.assertIsInstance(vpe_approx_vnf.ssh_helper, mock.Mock)
+ self.assertIsInstance(vpe_approx_vnf.ssh_helper, mock.Mock)
self.assertIsNone(vpe_approx_vnf._run())
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.MultiPortConfig")
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.vpe_vnf.ConfigCreate")
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.vpe_vnf.open")
+ @mock.patch(SSH_HELPER)
+ def test_build_config(self, mock_mul, mock_context, mock_config, mock_open, ssh, _):
+ mock_ssh(ssh)
+ vpe_approx_vnf = VpeApproxSetupEnvHelper(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 = {
+ 'lb_config': 'SW',
+ 'lb_count': 1,
+ 'worker_config': '1C/1T',
+ 'worker_threads': 1,
+ }
+ vpe_approx_vnf.scenario_helper.scenario_cfg = {
+ 'options': {
+ NAME: {
+ 'traffic_type': '4',
+ 'topology': 'nsb_test_case.yaml',
+ 'vnf_config': 'vpe_config',
+ }
+ }
+ }
+ vpe_approx_vnf.topology = "nsb_test_case.yaml"
+ vpe_approx_vnf.nfvi_type = "baremetal"
+ vpe_approx_vnf._provide_config_file = mock.Mock()
+
+ vpe_approx_vnf.ssh_helper = mock.MagicMock()
+ vpe_approx_vnf.scenario_helper = mock.MagicMock()
+ vpe_approx_vnf.ssh_helper.bin_path = mock.Mock()
+ vpe_approx_vnf.ssh_helper.upload_config_file = mock.MagicMock()
+ self.assertIsNone(vpe_approx_vnf._build_vnf_ports())
+ self.assertIsNotNone(vpe_approx_vnf.build_config())
+
@mock.patch(SSH_HELPER)
def test_wait_for_instantiate(self, ssh, _):
mock_ssh(ssh)
diff --git a/tests/unit/orchestrator/test_kubernetes.py b/tests/unit/orchestrator/test_kubernetes.py
index 51718ab86..1a3291c89 100644
--- a/tests/unit/orchestrator/test_kubernetes.py
+++ b/tests/unit/orchestrator/test_kubernetes.py
@@ -62,7 +62,10 @@ service ssh restart;while true ; do sleep 10000; done"
},
"name": "k8s-86096c30-key"
}
- ]
+ ],
+ "nodeSelector": {
+ "kubernetes.io/hostname": "node-01"
+ }
}
}
}
@@ -71,7 +74,8 @@ service ssh restart;while true ; do sleep 10000; done"
'command': '/bin/bash',
'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
service ssh restart;while true ; do sleep 10000; done'],
- 'ssh_key': 'k8s-86096c30-key'
+ 'ssh_key': 'k8s-86096c30-key',
+ 'nodeSelector': { 'kubernetes.io/hostname': 'node-01'}
}
name = 'host-k8s-86096c30'
output_r = KubernetesObject(name, **input_s).get_template()