diff options
Diffstat (limited to 'tests')
37 files changed, 627 insertions, 1517 deletions
diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh index 5df769c0d..1e1591ce3 100755 --- a/tests/ci/load_images.sh +++ b/tests/ci/load_images.sh @@ -43,6 +43,12 @@ if [ "${YARD_IMG_ARCH}" == "arm64" ]; then fi fi +cleanup_loopbacks() { + # try again to cleanup loopbacks in case of error + losetup -a + losetup -O NAME,BACK-FILE | awk '/yardstick/ { print $1 }' | xargs -l1 losetup -v -d || true +} + build_yardstick_image() { echo @@ -56,6 +62,7 @@ build_yardstick_image() # Build the image. Retry once if the build fails $cmd || $cmd + cleanup_loopbacks if [ ! -f "${RAW_IMAGE}" ]; then echo "Failed building RAW image" exit 1 @@ -70,11 +77,25 @@ build_yardstick_image() -e YARD_IMG_ARCH=${YARD_IMG_ARCH} \ -vvv -i inventory.ini build_yardstick_image.yml + cleanup_loopbacks if [ ! -f "${QCOW_IMAGE}" ]; then echo "Failed building QCOW image" exit 1 fi fi + # DPDK compile is not enabled for arm64 yet so disable for now + # JIRA: YARSTICK-1124 + if [[ ! -f "${QCOW_NSB_IMAGE}" && ${DEPLOY_SCENARIO} == *[_-]ovs_dpdk[_-]* && "${YARD_IMG_ARCH}" != "arm64" ]]; then + ansible-playbook \ + -e img_property="nsb" \ + -e YARD_IMG_ARCH=${YARD_IMG_ARCH} \ + -vvv -i inventory.ini build_yardstick_image.yml + cleanup_loopbacks + if [ ! -f "${QCOW_NSB_IMAGE}" ]; then + echo "Failed building QCOW NSB image" + exit 1 + fi + fi fi } @@ -112,6 +133,18 @@ load_yardstick_image() ${EXTRA_PARAMS} \ --file ${QCOW_IMAGE} \ yardstick-image) + # DPDK compile is not enabled for arm64 yet so disable NSB images for now + # JIRA: YARSTICK-1124 + if [[ $DEPLOY_SCENARIO == *[_-]ovs_dpdk[_-]* && "${YARD_IMG_ARCH}" != "arm64" ]]; then + nsb_output=$(eval openstack ${SECURE} image create \ + --public \ + --disk-format qcow2 \ + --container-format bare \ + ${EXTRA_PARAMS} \ + --file ${QCOW_NSB_IMAGE} \ + yardstick-samplevnfs) + echo "$nsb_output" + fi fi echo "$output" @@ -232,6 +265,7 @@ create_nova_flavor() main() { QCOW_IMAGE="/tmp/workspace/yardstick/yardstick-image.img" + QCOW_NSB_IMAGE="/tmp/workspace/yardstick/yardstick-nsb-image.img" RAW_IMAGE="/tmp/workspace/yardstick/yardstick-image.tar.gz" if [ -f /home/opnfv/images/yardstick-image.img ];then diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc040.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc040.yaml index 7d3f36984..591ce0356 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc040.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc040.yaml @@ -28,4 +28,4 @@ scenarios: context: type: Dummy - + name: Dummy diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc042.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc042.yaml index f46eb8473..ab41912e3 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc042.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc042.yaml @@ -19,6 +19,8 @@ scenarios: options: packetsize: 64 rate: 100 + eth1: ens4 + eth2: ens5 host: demeter.yardstick-TC042 target: poseidon.yardstick-TC042 @@ -34,8 +36,13 @@ scenarios: context: name: yardstick-TC042 - image: yardstick-image-pktgen-ready - flavor: yardstick-pktgen-dpdk.flavor + image: yardstick-samplevnfs + flavor: + vcpus: 4 + ram: 4096 + disk: 7 + extra_specs: + hw:mem_page_size: "large" user: ubuntu placement_groups: diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc050.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc050.yaml index dde3a1077..faddfab28 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc050.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc050.yaml @@ -13,12 +13,9 @@ description: > Yardstick TC050 config file; HA test case: OpenStack Controller Node Network High Availability. -{% set file = file or '/etc/yardstick/pod.yaml' %} {% set attack_host = attack_host or "node1" %} -{% set external_net = external_net or 'br-ex' %} -{% set management_net = management_net or 'br-mgmt' %} -{% set storage_net = storage_net or 'br-storage' %} -{% set internal_net = internal_net or 'br-mesh' %} +{% set interface_name = interface_name or 'br-mgmt' %} +{% set file = file or '/etc/yardstick/pod.yaml' %} scenarios: - @@ -27,43 +24,13 @@ scenarios: attackers: - fault_type: "general-attacker" - host: {{attack_host}} + host: {{ attack_host }} key: "close-br-public" attack_key: "close-interface" action_parameter: - interface: {{external_net}} - rollback_parameter: - interface: {{external_net}} - - - - fault_type: "general-attacker" - host: {{attack_host}} - key: "close-br-mgmt" - attack_key: "close-interface" - action_parameter: - interface: {{management_net}} - rollback_parameter: - interface: {{management_net}} - - - - fault_type: "general-attacker" - host: {{attack_host}} - key: "close-br-storage" - attack_key: "close-interface" - action_parameter: - interface: {{storage_net}} - rollback_parameter: - interface: {{storage_net}} - - - - fault_type: "general-attacker" - host: {{attack_host}} - key: "close-br-private" - attack_key: "close-interface" - action_parameter: - interface: {{internal_net}} + interface: {{ interface_name }} rollback_parameter: - interface: {{internal_net}} + interface: {{ interface_name }} monitors: - @@ -105,48 +72,34 @@ scenarios: steps: - - actionKey: "close-br-public" - actionType: "attacker" - index: 1 - - - - actionKey: "close-br-mgmt" - actionType: "attacker" - index: 2 - - - - actionKey: "close-br-storage" - actionType: "attacker" - index: 3 - - - - actionKey: "close-br-private" - actionType: "attacker" - index: 4 - - - actionKey: "nova-image-list" actionType: "monitor" - index: 5 + index: 1 - actionKey: "neutron-router-list" actionType: "monitor" - index: 6 + index: 2 - actionKey: "heat-stack-list" actionType: "monitor" - index: 7 + index: 3 - actionKey: "cinder-list" actionType: "monitor" - index: 8 + index: 4 + + - + actionKey: "close-br-public" + actionType: "attacker" + index: 5 + nodes: - {{attack_host}}: {{attack_host}}.LF + {{ attack_host }}: {{ attack_host }}.LF runner: type: Duration duration: 1 @@ -157,4 +110,4 @@ scenarios: context: type: Node name: LF - file: {{file}} + file: {{ file }} diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc074.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc074.yaml index ef4f02c9e..fe8423d25 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc074.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc074.yaml @@ -36,3 +36,4 @@ scenarios: context: type: Dummy + name: Dummy diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc090.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc090.yaml new file mode 100644 index 000000000..41372045d --- /dev/null +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc090.yaml @@ -0,0 +1,78 @@ +############################################################################## +# Copyright (c) 2017 14_ykl@tongji.edu.cn 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 +############################################################################## +--- + +schema: "yardstick:task:0.1" +description: > + Yardstick TC090 config file; + HA test case: Control node Openstack service down - database instance. + +{% set file = file or '/etc/yardstick/pod.yaml' %} +{% set attack_host = attack_host or "node1" %} +{% set attack_process = attack_process or "mysql" %} +{% set monitor_time = monitor_time or 30 %} + +scenarios: +- + type: ServiceHA + options: + attackers: + - fault_type: "kill-process" + process_name: "{{ attack_process }}" + host: {{attack_host}} + + monitors: + - monitor_type: "openstack-cmd" + command_name: "openstack image list" + monitor_time: {{monitor_time}} + monitor_number: 3 + sla: + max_outage_time: 5 + - monitor_type: "openstack-cmd" + command_name: "openstack router list" + monitor_time: {{monitor_time}} + monitor_number: 3 + sla: + max_outage_time: 5 + - monitor_type: "openstack-cmd" + command_name: "openstack stack list" + monitor_time: {{monitor_time}} + monitor_number: 3 + sla: + max_outage_time: 5 + - monitor_type: "openstack-cmd" + command_name: "openstack volume list" + monitor_time: {{monitor_time}} + monitor_number: 3 + sla: + max_outage_time: 5 + - monitor_type: "process" + process_name: "{{ attack_process }}" + host: {{attack_host}} + monitor_time: {{monitor_time}} + monitor_number: 3 + sla: + max_recover_time: 30 + + nodes: + {{attack_host}}: {{attack_host}}.LF + + runner: + type: Duration + duration: 1 + sla: + outage_time: 5 + action: monitor + + +context: + type: Node + name: LF + file: {{file}} + diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc091.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc091.yaml new file mode 100644 index 000000000..d952464a1 --- /dev/null +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc091.yaml @@ -0,0 +1,59 @@ +############################################################################## +# Copyright (c) 2017 14_ykl@tongji.edu.cn 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 +############################################################################## +--- + +schema: "yardstick:task:0.1" +description: > + Yardstick TC091 config file; + HA test case: Control node Openstack service down - heat-api. + +{% set file = file or '/etc/yardstick/pod.yaml' %} +{% set attack_host = attack_host or "node1" %} +{% set attack_process = attack_process or "heat-api" %} + +scenarios: +- + type: ServiceHA + options: + attackers: + - fault_type: "kill-process" + process_name: "{{ attack_process }}" + host: {{attack_host}} + + monitors: + - monitor_type: "openstack-cmd" + command_name: "openstack stack list" + monitor_time: 10 + monitor_number: 3 + sla: + max_outage_time: 5 + - monitor_type: "process" + process_name: "{{ attack_process }}" + host: {{attack_host}} + monitor_time: 30 + monitor_number: 3 + sla: + max_recover_time: 30 + + nodes: + {{attack_host}}: {{attack_host}}.LF + + runner: + type: Duration + duration: 1 + sla: + outage_time: 5 + action: monitor + + +context: + type: Node + name: LF + file: {{file}} + diff --git a/tests/opnfv/test_suites/opnfv_vTC_daily.yaml b/tests/opnfv/test_suites/opnfv_k8-canal-lb-noha_daily.yaml index f7efe51fb..80e0fbd39 100644 --- a/tests/opnfv/test_suites/opnfv_vTC_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_k8-canal-lb-noha_daily.yaml @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2017 Ericsson AB and others. +# 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 @@ -7,18 +7,12 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## --- -# ERICSSON POD1 VTC daily task suite +# k8 canal lb noha daily task suite schema: "yardstick:suite:0.1" -name: "opnfv_vTC_daily" +name: "k8-canal-lb-noha" test_cases_dir: "tests/opnfv/test_cases/" test_cases: - - file_name: opnfv_yardstick_tc006.yaml -- - file_name: opnfv_yardstick_tc007.yaml -- - file_name: opnfv_yardstick_tc020.yaml -- - file_name: opnfv_yardstick_tc021.yaml + file_name: opnfv_yardstick_tc080.yaml diff --git a/tests/opnfv/test_suites/opnfv_vTC_weekly.yaml b/tests/opnfv/test_suites/opnfv_k8-multus-lb-noha_daily.yaml index 04f607ed4..6ec4d49c9 100644 --- a/tests/opnfv/test_suites/opnfv_vTC_weekly.yaml +++ b/tests/opnfv/test_suites/opnfv_k8-multus-lb-noha_daily.yaml @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2017 Ericsson AB and others. +# 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 @@ -7,18 +7,12 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## --- -# ERICSSON POD1 VTC weekly task suite +# k8 multus lb noha daily task suite schema: "yardstick:suite:0.1" -name: "opnfv_vTC_weekly" +name: "k8-multus-lb-noha" test_cases_dir: "tests/opnfv/test_cases/" test_cases: - - file_name: opnfv_yardstick_tc006.yaml -- - file_name: opnfv_yardstick_tc007.yaml -- - file_name: opnfv_yardstick_tc020.yaml -- - file_name: opnfv_yardstick_tc021.yaml + file_name: opnfv_yardstick_tc080.yaml diff --git a/tests/opnfv/test_suites/opnfv_k8-multus-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_k8-multus-nofeature-noha_daily.yaml new file mode 100644 index 000000000..8b1ffeb7e --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_k8-multus-nofeature-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 multus nofeature noha daily task suite + +schema: "yardstick:suite:0.1" + +name: "k8-multus-nofeature-noha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc080.yaml diff --git a/tests/opnfv/test_suites/opnfv_k8-nosdn-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_k8-nosdn-nofeature-ha_daily.yaml new file mode 100644 index 000000000..d5386fd52 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_k8-nosdn-nofeature-ha_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 nosdn nofeature ha daily task suite + +schema: "yardstick:suite:0.1" + +name: "k8-nosdn-nofeature-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc080.yaml diff --git a/tests/opnfv/test_suites/opnfv_k8-nosdn-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_k8-nosdn-nofeature-noha_daily.yaml index 4fd76596f..0ce94551a 100644 --- a/tests/opnfv/test_suites/opnfv_k8-nosdn-nofeature-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_k8-nosdn-nofeature-noha_daily.yaml @@ -15,48 +15,4 @@ name: "k8-nosdn-nofeature-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"}' -- - 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"}' -- - 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"}' + file_name: opnfv_yardstick_tc080.yaml diff --git a/tests/opnfv/test_suites/opnfv_k8-nosdn-stor4nfv-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_k8-nosdn-stor4nfv-ha_daily.yaml new file mode 100644 index 000000000..cb2b1311d --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_k8-nosdn-stor4nfv-ha_daily.yaml @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2018 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 nosdn stor4nfv ha daily task suite + +schema: "yardstick:suite:0.1" + +name: "k8-nosdn-stor4nfv-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc080.yaml diff --git a/tests/opnfv/test_suites/opnfv_k8-nosdn-stor4nfv-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_k8-nosdn-stor4nfv-noha_daily.yaml new file mode 100644 index 000000000..961b8da89 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_k8-nosdn-stor4nfv-noha_daily.yaml @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2018 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 nosdn stor4nfv noha daily task suite + +schema: "yardstick:suite:0.1" + +name: "k8-nosdn-stor4nfv-noha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc080.yaml diff --git a/tests/opnfv/test_suites/opnfv_k8-ocl-lb-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_k8-ocl-lb-noha_daily.yaml new file mode 100644 index 000000000..a6ef9e1c9 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_k8-ocl-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 ocl lb noha daily task suite + +schema: "yardstick:suite:0.1" + +name: "k8-ocl-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_k8-sriov-cni-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_k8-sriov-cni-nofeature-noha_daily.yaml new file mode 100644 index 000000000..e0114f4b5 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_k8-sriov-cni-nofeature-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 sriov-cni nofeature noha daily task suite + +schema: "yardstick:suite:0.1" + +name: "k8-sriov-cni-nofeature-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-calipso-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-calipso-noha_daily.yaml new file mode 100644 index 000000000..3f0c4a992 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-calipso-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-calipso-noha daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-nosdn-calipso-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"}' +- + 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"}' +- + 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"}' diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-fdio-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-fdio-noha_daily.yaml index ec0fd224c..bd91a75c7 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-fdio-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-fdio-noha_daily.yaml @@ -21,18 +21,12 @@ test_cases: - file_name: opnfv_yardstick_tc006.yaml - - file_name: opnfv_yardstick_tc007.yaml -- file_name: opnfv_yardstick_tc008.yaml - file_name: opnfv_yardstick_tc009.yaml - file_name: opnfv_yardstick_tc011.yaml - - file_name: opnfv_yardstick_tc020.yaml -- - file_name: opnfv_yardstick_tc021.yaml -- file_name: opnfv_yardstick_tc037.yaml - file_name: opnfv_yardstick_tc038.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs_dpdk-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs_dpdk-ha_daily.yaml index ef47b9f72..201a271cc 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs_dpdk-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs_dpdk-ha_daily.yaml @@ -34,6 +34,11 @@ test_cases: - file_name: opnfv_yardstick_tc037.yaml - + file_name: opnfv_yardstick_tc042.yaml + constraint: + installer: compass + pod: huawei-pod1 +- file_name: opnfv_yardstick_tc055.yaml constraint: installer: compass diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs_dpdk-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs_dpdk-noha_daily.yaml index 2def5c2a6..e8db0de9b 100644 --- a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs_dpdk-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs_dpdk-noha_daily.yaml @@ -34,6 +34,11 @@ test_cases: - file_name: opnfv_yardstick_tc037.yaml - + file_name: opnfv_yardstick_tc042.yaml + constraint: + installer: compass + pod: huawei-pod1 +- file_name: opnfv_yardstick_tc055.yaml constraint: installer: compass 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 fa3c7898b..7c213e2d9 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 @@ -93,12 +93,10 @@ test_cases: file_name: opnfv_yardstick_tc027.yaml constraint: installer: compass,fuel - pod: huawei-pod1,lf-pod2,ericsson-pod3,ericsson-pod4 + pod: huawei-pod1,lf-pod2 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"}' - file_name: opnfv_yardstick_tc074.yaml constraint: @@ -115,72 +113,82 @@ test_cases: file_name: opnfv_yardstick_tc045.yaml constraint: installer: compass,fuel - pod: huawei-pod2,ericsson-pod1 + pod: huawei-pod1,lf-pod2 task_args: - huawei-pod2: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' - ericsson-pod1: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' + huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' - file_name: opnfv_yardstick_tc046.yaml constraint: - installer: fuel + installer: compass,fuel + pod: huawei-pod1,lf-pod2 task_args: - default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' + huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' - file_name: opnfv_yardstick_tc047.yaml constraint: installer: compass,fuel - pod: huawei-pod2,ericsson-pod1 + pod: huawei-pod1,lf-pod2 task_args: - huawei-pod2: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' - ericsson-pod1: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' + huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' - file_name: opnfv_yardstick_tc048.yaml constraint: installer: compass,fuel - pod: huawei-pod2,ericsson-pod1 + pod: huawei-pod1,lf-pod2 task_args: - huawei-pod2: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' - ericsson-pod1: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' + huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' - file_name: opnfv_yardstick_tc049.yaml constraint: - installer: fuel + installer: compass,fuel + pod: huawei-pod1,lf-pod2 task_args: - default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' + huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' - file_name: opnfv_yardstick_tc050.yaml constraint: - installer: fuel + installer: compass,fuel + pod: huawei-pod1,lf-pod2 task_args: - default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' + huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' - file_name: opnfv_yardstick_tc051.yaml constraint: installer: compass,fuel - pod: huawei-pod2,ericsson-pod1 + pod: huawei-pod1,lf-pod2 task_args: - huawei-pod2: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' - ericsson-pod1: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' + huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' - file_name: opnfv_yardstick_tc052.yaml constraint: - installer: fuel + installer: compass,fuel + pod: huawei-pod1,lf-pod2 task_args: - default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' + huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' - file_name: opnfv_yardstick_tc053.yaml constraint: - installer: fuel + installer: compass,fuel + pod: huawei-pod1,lf-pod2 task_args: - default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' + huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' - file_name: opnfv_yardstick_tc019.yaml constraint: installer: compass,fuel - pod: huawei-pod2,ericsson-pod1 + pod: huawei-pod1,lf-pod2 task_args: - huawei-pod2: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' - ericsson-pod1: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' + huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}' + lf-pod2: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml"}' - file_name: opnfv_yardstick_tc025.yaml constraint: diff --git a/tests/opnfv/test_suites/opnfv_os-odl-ovs_dpdk-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-ovs_dpdk-ha_daily.yaml new file mode 100644 index 000000000..734d31d15 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-odl-ovs_dpdk-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-ovs_dpdk-ha daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-odl-ovs_dpdk-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-ovs_dpdk-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-ovs_dpdk-noha_daily.yaml new file mode 100644 index 000000000..e87dba74b --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-odl-ovs_dpdk-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-ovs_dpdk-noha daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-odl-ovs_dpdk-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-ovs_offload-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-ovs_offload-noha_daily.yaml new file mode 100644 index 000000000..27d100a61 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-odl-ovs_offload-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-ovs_offload-noha daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-odl-ovs_offload-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-sriov-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-sriov-noha_daily.yaml new file mode 100644 index 000000000..b6d0dd6af --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-odl-sriov-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-sriov-noha daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-odl-sriov-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_l2-fdio-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-fdio-noha_daily.yaml index 7172979c7..722d885b6 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l2-fdio-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-fdio-noha_daily.yaml @@ -21,18 +21,12 @@ test_cases: - file_name: opnfv_yardstick_tc006.yaml - - file_name: opnfv_yardstick_tc007.yaml -- file_name: opnfv_yardstick_tc008.yaml - file_name: opnfv_yardstick_tc009.yaml - file_name: opnfv_yardstick_tc011.yaml - - file_name: opnfv_yardstick_tc020.yaml -- - file_name: opnfv_yardstick_tc021.yaml -- file_name: opnfv_yardstick_tc037.yaml - file_name: opnfv_yardstick_tc038.yaml diff --git a/tests/unit/network_services/collector/__init__.py b/tests/unit/network_services/collector/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/tests/unit/network_services/collector/__init__.py +++ /dev/null diff --git a/tests/unit/network_services/collector/test_publisher.py b/tests/unit/network_services/collector/test_publisher.py deleted file mode 100644 index 4a175841d..000000000 --- a/tests/unit/network_services/collector/test_publisher.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) 2016-2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Unittest for yardstick.network_services.collector.publisher - -from __future__ import absolute_import -import unittest - -from yardstick.network_services.collector import publisher - - -class PublisherTestCase(unittest.TestCase): - - def setUp(self): - self.test_publisher = publisher.Publisher() - - def test_successful_init(self): - pass - - def test_unsuccessful_init(self): - pass - - def test_start(self): - self.assertIsNone(self.test_publisher.start()) - - def test_stop(self): - self.assertIsNone(self.test_publisher.stop()) diff --git a/tests/unit/network_services/collector/test_subscriber.py b/tests/unit/network_services/collector/test_subscriber.py deleted file mode 100644 index d4b4ecf7a..000000000 --- a/tests/unit/network_services/collector/test_subscriber.py +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright (c) 2016-2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Unittest for yardstick.network_services.collector.subscriber - -from __future__ import absolute_import -import unittest -import mock - -from yardstick.network_services.collector import subscriber - - -class MockVnfAprrox(object): - - def __init__(self): - self.result = {} - self.name = "vnf__1" - - 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 - - -class CollectorTestCase(unittest.TestCase): - - NODES = { - 'node1': {}, - 'node2': { - 'ip': '1.2.3.4', - 'collectd': { - 'plugins': {'abc': 12, 'def': 34}, - 'interval': 987, - }, - }, - } - TRAFFIC_PROFILE = { - 'key1': 'value1', - } - - 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 - - def test_start(self, *_): - self.assertIsNone(self.collector.start()) - - def test_stop(self, *_): - self.assertIsNone(self.collector.stop()) - - 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/test_samplevnf_helper.py b/tests/unit/network_services/helpers/test_samplevnf_helper.py index 3b6c89d3a..dc74b1859 100644 --- a/tests/unit/network_services/helpers/test_samplevnf_helper.py +++ b/tests/unit/network_services/helpers/test_samplevnf_helper.py @@ -143,8 +143,6 @@ class TestMultiPortConfig(unittest.TestCase): def setUp(self): self._mock_open = mock.patch.object(six.moves.builtins, 'open') self.mock_open = self._mock_open.start() - self._mock_os = mock.patch.object(os, 'path') - self.mock_os = self._mock_os.start() self._mock_config_parser = mock.patch.object( samplevnf_helper, 'ConfigParser') self.mock_config_parser = self._mock_config_parser.start() @@ -153,7 +151,6 @@ class TestMultiPortConfig(unittest.TestCase): def _cleanup(self): self._mock_open.stop() - self._mock_os.stop() self._mock_config_parser.stop() def test_validate_ip_and_prefixlen(self): @@ -185,7 +182,8 @@ class TestMultiPortConfig(unittest.TestCase): samplevnf_helper.MultiPortConfig.validate_ip_and_prefixlen( '::1', '129') - def test___init__(self): + @mock.patch.object(os.path, 'isfile', return_value=False) + def test___init__(self, *args): topology_file = mock.Mock() config_tpl = mock.Mock() tmp_file = mock.Mock() @@ -193,8 +191,6 @@ class TestMultiPortConfig(unittest.TestCase): opnfv_vnf = samplevnf_helper.MultiPortConfig( topology_file, config_tpl, tmp_file, vnfd_mock) self.assertEqual(0, opnfv_vnf.swq) - self.mock_os.path = mock.MagicMock() - self.mock_os.path.isfile = mock.Mock(return_value=False) opnfv_vnf = samplevnf_helper.MultiPortConfig( topology_file, config_tpl, tmp_file, vnfd_mock) self.assertEqual(0, opnfv_vnf.swq) diff --git a/tests/unit/network_services/libs/__init__.py b/tests/unit/network_services/libs/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/tests/unit/network_services/libs/__init__.py +++ /dev/null diff --git a/tests/unit/network_services/libs/ixia_libs/__init__.py b/tests/unit/network_services/libs/ixia_libs/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/tests/unit/network_services/libs/ixia_libs/__init__.py +++ /dev/null diff --git a/tests/unit/network_services/libs/ixia_libs/test_IxNet.py b/tests/unit/network_services/libs/ixia_libs/test_IxNet.py deleted file mode 100644 index 2a97048aa..000000000 --- a/tests/unit/network_services/libs/ixia_libs/test_IxNet.py +++ /dev/null @@ -1,874 +0,0 @@ -# Copyright (c) 2016-2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Unittest for yardstick.network_services.libs.ixia_libs.IxNet - -from __future__ import absolute_import -import unittest -import mock - -from yardstick.network_services.libs.ixia_libs.IxNet.IxNet import IxNextgen -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): - ixnet_gen = IxNextgen() - self.assertIsNone(ixnet_gen._bidir) - - @mock.patch("yardstick.network_services.libs.ixia_libs.IxNet.IxNet.sys") - def test_connect(self, *args): - - ixnet_gen = IxNextgen() - ixnet_gen.get_config = mock.MagicMock() - ixnet_gen.get_ixnet = mock.MagicMock() - - self.assertRaises(ImportError, ixnet_gen._connect, {"py_lib_path": "/tmp"}) - - def test_clear_ixia_config(self): - ixnet = mock.MagicMock() - ixnet.execute = mock.Mock() - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.clear_ixia_config() - self.assertIsNone(result) - self.assertEqual(ixnet.execute.call_count, 1) - - def test_load_ixia_profile(self): - ixnet = mock.MagicMock() - ixnet.execute = mock.Mock() - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.load_ixia_profile({}) - self.assertIsNone(result) - self.assertEqual(ixnet.execute.call_count, 1) - - def test_load_ixia_config(self): - ixnet = mock.MagicMock() - ixnet.execute = mock.Mock() - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.ix_load_config({}) - self.assertIsNone(result) - self.assertEqual(ixnet.execute.call_count, 2) - - @mock.patch('yardstick.network_services.libs.ixia_libs.IxNet.IxNet.log') - def test_ix_assign_ports(self, mock_logger): - ixnet = mock.MagicMock() - ixnet.getList.return_value = [0, 1] - ixnet.getAttribute.side_effect = ['up', 'down'] - - config = { - 'chassis': '1.1.1.1', - 'cards': ['1', '2'], - 'ports': ['2', '2'], - } - - ixnet_gen = IxNextgen(ixnet) - ixnet_gen._cfg = config - - result = ixnet_gen.ix_assign_ports() - self.assertIsNone(result) - self.assertEqual(ixnet.execute.call_count, 1) - self.assertEqual(ixnet.commit.call_count, 1) - self.assertEqual(ixnet.getAttribute.call_count, 2) - self.assertEqual(mock_logger.error.call_count, 1) - - def test_ix_update_frame(self): - static_traffic_params = { - UPLINK: { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:03", - "framesPerSecond": True, - "framesize": { - "64B": "100", - "1KB": "0", - }, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l3v4": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - DOWNLINK: { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:04", - "framesPerSecond": False, - "framesize": {"64B": "100"}, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v4": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } - } - - ixnet = mock.MagicMock() - ixnet.remapIds.return_value = ["0"] - ixnet.setMultiAttribute.return_value = [1] - ixnet.commit.return_value = [1] - ixnet.getList.side_effect = [ - [1], - [1], - [1], - [ - "ethernet.header.destinationAddress", - "ethernet.header.sourceAddress", - ], - ] - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.ix_update_frame(static_traffic_params) - self.assertIsNone(result) - self.assertEqual(ixnet.setMultiAttribute.call_count, 7) - self.assertEqual(ixnet.commit.call_count, 2) - - def test_ix_update_udp(self): - ixnet = mock.MagicMock() - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.ix_update_udp({}) - self.assertIsNone(result) - - def test_ix_update_tcp(self): - ixnet = mock.MagicMock() - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.ix_update_tcp({}) - self.assertIsNone(result) - - def test_ix_start_traffic(self): - ixnet = mock.MagicMock() - ixnet.getList.return_value = [0] - ixnet.getAttribute.return_value = 'down' - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.ix_start_traffic() - self.assertIsNone(result) - self.assertEqual(ixnet.getList.call_count, 1) - self.assertEqual(ixnet.execute.call_count, 3) - - def test_ix_stop_traffic(self): - ixnet = mock.MagicMock() - ixnet.getList.return_value = [0] - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.ix_stop_traffic() - self.assertIsNone(result) - self.assertEqual(ixnet.getList.call_count, 1) - self.assertEqual(ixnet.execute.call_count, 1) - - def test_ix_get_statistics(self): - ixnet = mock.MagicMock() - ixnet.execute.return_value = "" - ixnet.getList.side_effect = [ - [ - '::ixNet::OBJ-/statistics/view:"Traffic Item Statistics"', - '::ixNet::OBJ-/statistics/view:"Port Statistics"', - ], - [ - '::ixNet::OBJ-/statistics/view:"Flow Statistics"', - ], - ] - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.ix_get_statistics() - self.assertIsNotNone(result) - self.assertEqual(ixnet.getList.call_count, 1) - self.assertEqual(ixnet.execute.call_count, 20) - - def test_find_view_obj_no_where(self): - views = ['here', 'there', 'everywhere'] - result = IxNextgen.find_view_obj('no_where', views) - self.assertEqual(result, '') - - def test_add_ip_header_v4(self): - static_traffic_params = { - "uplink_0": { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:03", - "framesPerSecond": True, - "framesize": {"64B": "100"}, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "count": 1024, - "ttl": 32 - }, - "outer_l3v4": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - "downlink_0": { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:04", - "framesPerSecond": True, - "framesize": {"64B": "100"}, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v4": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } - } - - ixnet = mock.MagicMock() - ixnet.remapIds.return_value = ["0"] - ixnet.setMultiAttribute.return_value = [1] - ixnet.commit.return_value = [1] - ixnet.getList.side_effect = [[1], [0], [0], ["srcIp", "dstIp"]] - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.add_ip_header(static_traffic_params, IP_VERSION_4) - self.assertIsNone(result) - self.assertGreater(ixnet.setMultiAttribute.call_count, 0) - self.assertEqual(ixnet.commit.call_count, 1) - - def test_add_ip_header_v4_nothing_to_do(self): - static_traffic_params = { - "uplink_0": { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:03", - "framesPerSecond": True, - "framesize": {"64B": "100"}, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "count": 1024, - "ttl": 32 - }, - "outer_l3v4": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - "downlink_0": { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:04", - "framesPerSecond": True, - "framesize": {"64B": "100"}, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v4": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } - } - - ixnet = mock.MagicMock() - ixnet.remapIds.return_value = ["0"] - ixnet.setMultiAttribute.return_value = [1] - ixnet.commit.return_value = [1] - ixnet.getList.side_effect = [[1], [0, 1], [0], ["srcIp", "dstIp"]] - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.add_ip_header(static_traffic_params, IP_VERSION_4) - self.assertIsNone(result) - self.assertGreater(ixnet.setMultiAttribute.call_count, 0) - self.assertEqual(ixnet.commit.call_count, 1) - - def test_add_ip_header_v6(self): - static_traffic_profile = { - "uplink_0": { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:03", - "framesPerSecond": True, - "framesize": {"64B": "100"}, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - "downlink_0": { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:04", - "framesPerSecond": True, - "framesize": {"64B": "100"}, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } - } - - ixnet = mock.MagicMock() - ixnet.getList.side_effect = [[1], [1], [1], ["srcIp", "dstIp"]] - ixnet.remapIds.return_value = ["0"] - ixnet.setMultiAttribute.return_value = [1] - ixnet.commit.return_value = [1] - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.add_ip_header(static_traffic_profile, IP_VERSION_6) - self.assertIsNone(result) - self.assertGreater(ixnet.setMultiAttribute.call_count, 0) - self.assertEqual(ixnet.commit.call_count, 1) - - def test_add_ip_header_v6_nothing_to_do(self): - static_traffic_params = { - "uplink_0": { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:03", - "framesPerSecond": True, - "framesize": {"64B": "100"}, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "count": 1024, - "ttl": 32 - }, - "outer_l3v6": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - "downlink_0": { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:04", - "framesPerSecond": True, - "framesize": {"64B": "100"}, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } - } - - ixnet = mock.MagicMock() - ixnet.getList.side_effect = [[1], [0, 1], [1], ["srcIP", "dstIP"]] - ixnet.remapIds.return_value = ["0"] - ixnet.setMultiAttribute.return_value = [1] - ixnet.commit.return_value = [1] - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.add_ip_header(static_traffic_params, IP_VERSION_6) - self.assertIsNone(result) - self.assertEqual(ixnet.setMultiAttribute.call_count, 0) - - def test_set_random_ip_multi_attributes_bad_ip_version(self): - bad_ip_version = object() - ixnet_gen = IxNextgen(mock.Mock()) - mock1 = mock.Mock() - mock2 = mock.Mock() - mock3 = mock.Mock() - with self.assertRaises(ValueError): - ixnet_gen.set_random_ip_multi_attributes(mock1, bad_ip_version, mock2, mock3) - - def test_get_config(self): - tg_cfg = { - "vdu": [ - { - "external-interface": [ - { - "virtual-interface": { - "vpci": "0000:07:00.1", - }, - }, - { - "virtual-interface": { - "vpci": "0001:08:01.2", - }, - }, - ], - }, - ], - "mgmt-interface": { - "ip": "test1", - "tg-config": { - "dut_result_dir": "test2", - "version": "test3", - "ixchassis": "test4", - "tcl_port": "test5", - "py_lib_path": "test6", - }, - } - } - - expected = { - 'py_lib_path': 'test6', - 'machine': 'test1', - 'port': 'test5', - 'chassis': 'test4', - 'cards': ['0000', '0001'], - 'ports': ['07', '08'], - 'output_dir': 'test2', - 'version': 'test3', - 'bidir': True, - } - - result = IxNextgen.get_config(tg_cfg) - self.assertDictEqual(result, expected) - - def test_ix_update_ether(self): - static_traffic_params = { - "uplink_0": { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:03", - "framesPerSecond": True, - "framesize": 64, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l3v4": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - "downlink_0": { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:04", - "framesPerSecond": True, - "framesize": 64, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v4": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } - } - - ixnet = mock.MagicMock() - ixnet.setMultiAttribute.return_value = [1] - ixnet.commit.return_value = [1] - ixnet.getList.side_effect = [ - [1], - [1], - [1], - [ - "ethernet.header.destinationAddress", - "ethernet.header.sourceAddress", - ], - ] - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.ix_update_ether(static_traffic_params) - self.assertIsNone(result) - self.assertGreater(ixnet.setMultiAttribute.call_count, 0) - - def test_ix_update_ether_nothing_to_do(self): - static_traffic_params = { - "uplink_0": { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l3": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l3v4": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - "downlink_0": { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v4": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l3v6": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } - } - - ixnet = mock.MagicMock() - ixnet.setMultiAttribute.return_value = [1] - ixnet.commit.return_value = [1] - ixnet.getList.side_effect = [ - [1], - [1], - [1], - [ - "ethernet.header.destinationAddress", - "ethernet.header.sourceAddress", - ], - ] - - ixnet_gen = IxNextgen(ixnet) - - result = ixnet_gen.ix_update_ether(static_traffic_params) - self.assertIsNone(result) - self.assertEqual(ixnet.setMultiAttribute.call_count, 0) diff --git a/tests/unit/network_services/nfvi/test_resource.py b/tests/unit/network_services/nfvi/test_resource.py index f5f7f0fe7..9f337c673 100644 --- a/tests/unit/network_services/nfvi/test_resource.py +++ b/tests/unit/network_services/nfvi/test_resource.py @@ -19,7 +19,8 @@ import unittest from yardstick.network_services.nfvi.resource import ResourceProfile from yardstick.network_services.nfvi import resource, collectd - +from yardstick.common.exceptions import ResourceCommandError +from yardstick import ssh class TestResourceProfile(unittest.TestCase): VNFD = {'vnfd:vnfd-catalog': @@ -128,8 +129,31 @@ class TestResourceProfile(unittest.TestCase): self.assertEqual(val, ('error', 'Invalid', '', '')) def test__start_collectd(self): - self.assertIsNone( - self.resource_profile._start_collectd(self.ssh_mock, "/opt/nsb_bin")) + ssh_mock = mock.Mock() + ssh_mock.execute = mock.Mock(return_value=(0, "", "")) + self.assertIsNone(self.resource_profile._start_collectd(ssh_mock, + "/opt/nsb_bin")) + + ssh_mock.execute = mock.Mock(side_effect=ssh.SSHError) + with self.assertRaises(ssh.SSHError): + self.resource_profile._start_collectd(ssh_mock, "/opt/nsb_bin") + + ssh_mock.execute = mock.Mock(return_value=(1, "", "")) + self.assertIsNone(self.resource_profile._start_collectd(ssh_mock, + "/opt/nsb_bin")) + + def test__start_rabbitmq(self): + ssh_mock = mock.Mock() + ssh_mock.execute = mock.Mock(return_value=(0, "RabbitMQ", "")) + self.assertIsNone(self.resource_profile._start_rabbitmq(ssh_mock)) + + ssh_mock.execute = mock.Mock(return_value=(0, "", "")) + with self.assertRaises(ResourceCommandError): + self.resource_profile._start_rabbitmq(ssh_mock) + + ssh_mock.execute = mock.Mock(return_value=(1, "", "")) + with self.assertRaises(ResourceCommandError): + self.resource_profile._start_rabbitmq(ssh_mock) def test__prepare_collectd_conf(self): self.assertIsNone( @@ -154,11 +178,12 @@ class TestResourceProfile(unittest.TestCase): def test_initiate_systemagent(self): self.resource_profile._start_collectd = mock.Mock() + self.resource_profile._start_rabbitmq = mock.Mock() self.assertIsNone( self.resource_profile.initiate_systemagent("/opt/nsb_bin")) def test_initiate_systemagent_raise(self): - self.resource_profile._start_collectd = mock.Mock(side_effect=RuntimeError) + self.resource_profile._start_rabbitmq = mock.Mock(side_effect=RuntimeError) with self.assertRaises(RuntimeError): self.resource_profile.initiate_systemagent("/opt/nsb_bin") diff --git a/tests/unit/network_services/test_utils.py b/tests/unit/network_services/test_utils.py deleted file mode 100644 index bf98a4474..000000000 --- a/tests/unit/network_services/test_utils.py +++ /dev/null @@ -1,143 +0,0 @@ -# Copyright (c) 2016-2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Unittest for yardstick.network_services.utils - -import os -import unittest -import mock - -from yardstick.network_services import utils - - -class UtilsTestCase(unittest.TestCase): - """Test all VNF helper methods.""" - - DPDK_PATH = os.path.join(utils.NSB_ROOT, "dpdk-devbind.py") - - def setUp(self): - super(UtilsTestCase, self).setUp() - - def test_get_nsb_options(self): - result = utils.get_nsb_option("bin_path", None) - self.assertEqual(result, utils.NSB_ROOT) - - def test_get_nsb_option_is_invalid_key(self): - result = utils.get_nsb_option("bin", None) - self.assertEqual(result, None) - - def test_get_nsb_option_default(self): - default = object() - result = utils.get_nsb_option("nosuch", default) - self.assertIs(result, default) - - def test_provision_tool(self): - with mock.patch("yardstick.ssh.SSH") as ssh: - ssh_mock = mock.Mock(autospec=ssh.SSH) - ssh_mock.execute = \ - mock.Mock(return_value=(0, self.DPDK_PATH, "")) - ssh.return_value = ssh_mock - tool_path = utils.provision_tool(ssh_mock, self.DPDK_PATH) - self.assertEqual(tool_path, self.DPDK_PATH) - - def test_provision_tool_no_path(self): - with mock.patch("yardstick.ssh.SSH") as ssh: - ssh_mock = mock.Mock(autospec=ssh.SSH) - ssh_mock.execute = \ - mock.Mock(return_value=(1, self.DPDK_PATH, "")) - ssh.return_value = ssh_mock - tool_path = utils.provision_tool(ssh_mock, self.DPDK_PATH) - self.assertEqual(tool_path, self.DPDK_PATH) - - -class PciAddressTestCase(unittest.TestCase): - - PCI_ADDRESS_DBSF = '000A:07:03.2' - PCI_ADDRESS_BSF = '06:02.1' - PCI_ADDRESS_DBSF_MULTILINE_1 = '0001:08:04.3\nother text\n' - PCI_ADDRESS_DBSF_MULTILINE_2 = 'first line\n 0001:08:04.3 \nother text\n' - # Will match and return the first address found. - PCI_ADDRESS_DBSF_MULTILINE_3 = ' 0001:08:04.1 \n 05:03.1 \nother\n' - PCI_ADDRESS_BSF_MULTILINE_1 = 'first line\n 08:04.3 \n 0002:05:03.1\n' - BAD_INPUT_1 = 'no address found' - BAD_INPUT_2 = '001:08:04.1' - BAD_INPUT_3 = '08:4.1' - - def test_pciaddress_dbsf(self): - pci_address = utils.PciAddress(PciAddressTestCase.PCI_ADDRESS_DBSF) - self.assertEqual('000a', pci_address.domain) - self.assertEqual('07', pci_address.bus) - self.assertEqual('03', pci_address.slot) - self.assertEqual('2', pci_address.function) - - def test_pciaddress_bsf(self): - pci_address = utils.PciAddress(PciAddressTestCase.PCI_ADDRESS_BSF) - self.assertEqual('0000', pci_address.domain) - self.assertEqual('06', pci_address.bus) - self.assertEqual('02', pci_address.slot) - self.assertEqual('1', pci_address.function) - - def test_pciaddress_dbsf_multiline_1(self): - pci_address = utils.PciAddress( - PciAddressTestCase.PCI_ADDRESS_DBSF_MULTILINE_1) - self.assertEqual('0001', pci_address.domain) - self.assertEqual('08', pci_address.bus) - self.assertEqual('04', pci_address.slot) - self.assertEqual('3', pci_address.function) - - def test_pciaddress_dbsf_multiline_2(self): - pci_address = utils.PciAddress( - PciAddressTestCase.PCI_ADDRESS_DBSF_MULTILINE_2) - self.assertEqual('0001', pci_address.domain) - self.assertEqual('08', pci_address.bus) - self.assertEqual('04', pci_address.slot) - self.assertEqual('3', pci_address.function) - - def test_pciaddress_dbsf_multiline_3(self): - pci_address = utils.PciAddress( - PciAddressTestCase.PCI_ADDRESS_DBSF_MULTILINE_3) - self.assertEqual('0001', pci_address.domain) - self.assertEqual('08', pci_address.bus) - self.assertEqual('04', pci_address.slot) - self.assertEqual('1', pci_address.function) - - def test_pciaddress_bsf_multiline_1(self): - pci_address = utils.PciAddress( - PciAddressTestCase.PCI_ADDRESS_BSF_MULTILINE_1) - self.assertEqual('0000', pci_address.domain) - self.assertEqual('08', pci_address.bus) - self.assertEqual('04', pci_address.slot) - self.assertEqual('3', pci_address.function) - - def test_pciaddress_bad_input_no_address(self): - with self.assertRaises(ValueError) as exception: - utils.PciAddress(PciAddressTestCase.BAD_INPUT_1) - self.assertEqual('Invalid PCI address: {}'.format( - PciAddressTestCase.BAD_INPUT_1), str(exception.exception)) - - def test_pciaddress_bad_input_dbsf_bad_formatted(self): - # In this test case, the domain has only 3 characters instead of 4. - pci_address = utils.PciAddress( - PciAddressTestCase.BAD_INPUT_2) - self.assertEqual('0000', pci_address.domain) - self.assertEqual('08', pci_address.bus) - self.assertEqual('04', pci_address.slot) - self.assertEqual('1', pci_address.function) - - def test_pciaddress_bad_input_bsf_bad_formatted(self): - with self.assertRaises(ValueError) as exception: - utils.PciAddress(PciAddressTestCase.BAD_INPUT_3) - self.assertEqual('Invalid PCI address: {}'.format( - PciAddressTestCase.BAD_INPUT_3), str(exception.exception)) diff --git a/tests/unit/network_services/test_yang_model.py b/tests/unit/network_services/test_yang_model.py deleted file mode 100644 index 0b29da701..000000000 --- a/tests/unit/network_services/test_yang_model.py +++ /dev/null @@ -1,135 +0,0 @@ -# Copyright (c) 2016-2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Unittest for yardstick.network_services.utils - -from __future__ import absolute_import - -import unittest -import mock - -import yaml - -from yardstick.network_services.yang_model import YangModel - - -class YangModelTestCase(unittest.TestCase): - """Test all Yang Model methods.""" - - ENTRIES = { - 'access-list1': { - 'acl': { - 'access-list-entries': [{ - 'ace': { - 'ace-oper-data': { - 'match-counter': 0}, - 'actions': 'drop,count', - 'matches': { - 'destination-ipv4-network': - '152.16.40.20/24', - 'destination-port-range': { - 'lower-port': 0, - 'upper-port': 65535}, - 'source-ipv4-network': '0.0.0.0/0', - 'source-port-range': { - 'lower-port': 0, - 'upper-port': 65535}}, - 'rule-name': 'rule1588'}}, - { - 'ace': { - 'ace-oper-data': { - 'match-counter': 0}, - 'actions': 'drop,count', - 'matches': { - 'destination-ipv4-network': - '0.0.0.0/0', - 'destination-port-range': { - 'lower-port': 0, - 'upper-port': 65535}, - 'source-ipv4-network': - '152.16.100.20/24', - 'source-port-range': { - 'lower-port': 0, - 'upper-port': 65535}}, - 'rule-name': 'rule1589'}}], - 'acl-name': 'sample-ipv4-acl', - 'acl-type': 'ipv4-acl'} - } - } - - def test__init__(self): - cfg = "yang.yaml" - y = YangModel(cfg) - self.assertEqual(y.config_file, cfg) - - def test_config_file_setter(self): - cfg = "yang.yaml" - y = YangModel(cfg) - self.assertEqual(y.config_file, cfg) - cfg2 = "yang2.yaml" - y.config_file = cfg2 - self.assertEqual(y.config_file, cfg2) - - def test__get_entries(self): - cfg = "yang.yaml" - y = YangModel(cfg) - y._options = self.ENTRIES - y._get_entries() - self.assertIn("p acl add", y._rules) - - def test__get_entries_no_options(self): - cfg = "yang.yaml" - y = YangModel(cfg) - y._get_entries() - self.assertEqual(y._rules, '') - - @mock.patch('yardstick.network_services.yang_model.yaml_load') - @mock.patch('yardstick.network_services.yang_model.open') - def test__read_config(self, mock_open, mock_safe_load): - cfg = "yang.yaml" - y = YangModel(cfg) - mock_safe_load.return_value = expected = {'key1': 'value1', 'key2': 'value2'} - y._read_config() - self.assertDictEqual(y._options, expected) - - @mock.patch('yardstick.network_services.yang_model.open') - def test__read_config_open_error(self, mock_open): - cfg = "yang.yaml" - y = YangModel(cfg) - mock_open.side_effect = IOError('my error') - - self.assertEqual(y._options, {}) - with self.assertRaises(IOError) as raised: - y._read_config() - - self.assertIn('my error', str(raised.exception)) - self.assertEqual(y._options, {}) - - def test_get_rules(self): - cfg = "yang.yaml" - y = YangModel(cfg) - y._read_config = read_mock = mock.Mock() - y._get_entries = get_mock = mock.Mock() - - y._rules = None - self.assertIsNone(y.get_rules()) - self.assertEqual(read_mock.call_count, 1) - self.assertEqual(get_mock.call_count, 1) - - # True value should prevent calling read and get - y._rules = 999 - self.assertEqual(y.get_rules(), 999) - self.assertEqual(read_mock.call_count, 1) - self.assertEqual(get_mock.call_count, 1) 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 c7d2abcd5..eb59c2837 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 @@ -533,10 +533,12 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): @mock.patch.object(six, 'BytesIO', return_value=six.BytesIO(b'100\n')) @mock.patch.object(utils, 'read_meminfo', return_value={'Hugepagesize': '2048'}) - def test__setup_hugepages(self, mock_meminfo, *args): + def test__setup_hugepages_no_hugepages_defined(self, mock_meminfo, *args): ssh_helper = mock.Mock() + scenario_helper = mock.Mock() + scenario_helper.all_options = {} dpdk_setup_helper = DpdkVnfSetupEnvHelper( - mock.ANY, ssh_helper, mock.ANY) + mock.ANY, ssh_helper, scenario_helper) with mock.patch.object(sample_vnf.LOG, 'info') as mock_info: dpdk_setup_helper._setup_hugepages() mock_info.assert_called_once_with( @@ -544,6 +546,22 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): '%s', 2048, 8192, 100) mock_meminfo.assert_called_once_with(ssh_helper) + @mock.patch.object(six, 'BytesIO', return_value=six.BytesIO(b'100\n')) + @mock.patch.object(utils, 'read_meminfo', + return_value={'Hugepagesize': '1048576'}) + def test__setup_hugepages_8gb_hugepages_defined(self, mock_meminfo, *args): + ssh_helper = mock.Mock() + scenario_helper = mock.Mock() + scenario_helper.all_options = {'hugepages_gb': 8} + dpdk_setup_helper = DpdkVnfSetupEnvHelper( + mock.ANY, ssh_helper, scenario_helper) + with mock.patch.object(sample_vnf.LOG, 'info') as mock_info: + dpdk_setup_helper._setup_hugepages() + mock_info.assert_called_once_with( + 'Hugepages size (kB): %s, number claimed: %s, number set: ' + '%s', 1048576, 8, 100) + mock_meminfo.assert_called_once_with(ssh_helper) + @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.open') @mock.patch.object(utils, 'find_relative_file') @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.MultiPortConfig') @@ -1643,42 +1661,6 @@ class TestSampleVnf(unittest.TestCase): # test the default resource helper is MyResourceHelper, not subclass self.assertEqual(type(sample_vnf.resource_helper), MyResourceHelper) - def test__get_port0localip6(self): - sample_vnf = SampleVNF('vnf1', self.VNFD_0) - expected = '0064:ff9b:0:0:0:0:9810:6414' - result = sample_vnf._get_port0localip6() - self.assertEqual(result, expected) - - def test__get_port1localip6(self): - sample_vnf = SampleVNF('vnf1', self.VNFD_0) - expected = '0064:ff9b:0:0:0:0:9810:2814' - result = sample_vnf._get_port1localip6() - self.assertEqual(result, expected) - - def test__get_port0prefixip6(self): - sample_vnf = SampleVNF('vnf1', self.VNFD_0) - expected = '112' - result = sample_vnf._get_port0prefixlen6() - self.assertEqual(result, expected) - - def test__get_port1prefixip6(self): - sample_vnf = SampleVNF('vnf1', self.VNFD_0) - expected = '112' - result = sample_vnf._get_port1prefixlen6() - self.assertEqual(result, expected) - - def test__get_port0gateway6(self): - sample_vnf = SampleVNF('vnf1', self.VNFD_0) - expected = '0064:ff9b:0:0:0:0:9810:6414' - result = sample_vnf._get_port0gateway6() - self.assertEqual(result, expected) - - def test__get_port1gateway6(self): - sample_vnf = SampleVNF('vnf1', self.VNFD_0) - expected = '0064:ff9b:0:0:0:0:9810:2814' - result = sample_vnf._get_port1gateway6() - self.assertEqual(result, expected) - @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.Process') def test__start_vnf(self, *args): vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] @@ -1767,16 +1749,6 @@ 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, *args): queue_size_list = [ |