summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ci/cover.awk25
-rw-r--r--tests/ci/cover.sh121
-rwxr-xr-xtests/ci/load_images.sh15
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml3
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml7
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml3
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml3
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml3
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml3
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc049.yaml3
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc050.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc051.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc052.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml4
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml5
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml5
-rw-r--r--tests/unit/benchmark/contexts/test_heat.py8
-rw-r--r--tests/unit/benchmark/contexts/test_model.py172
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_qemumigrate.py19
22 files changed, 230 insertions, 193 deletions
diff --git a/tests/ci/cover.awk b/tests/ci/cover.awk
deleted file mode 100644
index e4bb816dc..000000000
--- a/tests/ci/cover.awk
+++ /dev/null
@@ -1,25 +0,0 @@
-BEGIN{
- template = "%6s %-75s\n"
- printf template, "Delta", "Module Path"
-}
-
-/^-/{
- s = substr($1, 2)
- x[s] = $3;
-};
-
-/^+/{
- s = substr($1, 2)
- d = $3
- if (s in x)
- d = d - x[s]
- y[s" "d] = d
-}
-
-END{
- asorti(y, z1, "@val_num_asc")
- for (i=1; i <= length(z1); i++){
- split(z1[i], z2, " ")
- printf template, z2[2], z2[1]
- }
-}
diff --git a/tests/ci/cover.sh b/tests/ci/cover.sh
deleted file mode 100644
index 780a85a22..000000000
--- a/tests/ci/cover.sh
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/bin/bash
-##############################################################################
-# Copyright 2015: Mirantis Inc.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-# yardstick comment: this is a modified copy of
-# rally/tests/ci/cover.sh
-##############################################################################
-
-if [[ -n $COVER_DIR_NAME ]]; then
- :
-elif [[ -n $_ ]]; then
- COVER_DIR_NAME=$( dirname $_ )
-else
- COVER_DIR_NAME=$( dirname $0 )
-fi
-
-show_diff () {
- diff -U 0 $1 $2 | awk -f $COVER_DIR_NAME/cover.awk
-}
-
-run_coverage_test() {
-
- ALLOWED_EXTRA_MISSING=10
- # enable debugging
- set -x
-
- # Stash uncommitted changes, checkout master and save coverage report
- uncommited=$(git status --porcelain | grep -v "^??")
- [[ -n ${uncommited} ]] && git stash > /dev/null
- git checkout HEAD^
-
- baseline_report=$(mktemp -t yardstick_coverageXXXXXXX)
- ls -l .testrepository
-
- # workaround 'db type could not be determined' bug
- # https://bugs.launchpad.net/testrepository/+bug/1229445
- rm -rf .testrepository
- find . -type f -name "*.pyc" -delete
-
- #python setup.py testr --coverage --testr-args=""
- python setup.py testr --coverage --slowest --testr-args="$*"
- testr failing
- coverage report > ${baseline_report}
-
- # debug awk
- tail -1 ${baseline_report}
- baseline_missing=$(awk 'END { if (int($3) > 0) print $3 }' ${baseline_report})
-
- if [[ -z $baseline_missing ]]; then
- echo "Failed to determine baseline missing"
- exit 1
- fi
-
- # Checkout back and unstash uncommitted changes (if any)
- git checkout -
- [[ -n ${uncommited} ]] && git stash pop > /dev/null
-
- # Generate and save coverage report
- current_report=$(mktemp -t yardstick_coverageXXXXXXX)
- ls -l .testrepository
-
- # workaround 'db type could not be determined' bug
- # https://bugs.launchpad.net/testrepository/+bug/1229445
- rm -rf .testrepository
- find . -type f -name "*.pyc" -delete
-
- #python setup.py testr --coverage --testr-args=""
- python setup.py testr --coverage --slowest --testr-args="$*"
- testr failing
- coverage report > ${current_report}
-
- rm -rf cover-$PY_VER
- coverage html -d cover-$PY_VER
-
- # debug awk
- tail -1 ${current_report}
- current_missing=$(awk 'END { if (int($3) > 0) print $3 }' ${current_report})
-
- if [[ -z $current_missing ]]; then
- echo "Failed to determine current missing"
- exit 1
- fi
-
- # Show coverage details
- new_missing=$((current_missing - baseline_missing))
-
- echo "Missing lines allowed to introduce : ${ALLOWED_EXTRA_MISSING}"
- echo "Missing lines introduced : ${new_missing}"
- echo "Missing lines in master : ${baseline_missing}"
- echo "Missing lines in proposed change : ${current_missing}"
-
- if [[ ${new_missing} -gt ${ALLOWED_EXTRA_MISSING} ]];
- then
- show_diff ${baseline_report} ${current_report}
- echo "Please write more unit tests, we should keep our test coverage :( "
- rm ${baseline_report} ${current_report}
- exit 1
-
- elif [[ ${new_missing} -gt 0 ]];
- then
- show_diff ${baseline_report} ${current_report}
- echo "I believe you can cover all your code with 100% coverage!"
-
- else
- echo "Thank you! You are awesome! Keep writing unit tests! :)"
- fi
-
- rm ${baseline_report} ${current_report}
-}
diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh
index e73d7e800..666a78b40 100755
--- a/tests/ci/load_images.sh
+++ b/tests/ci/load_images.sh
@@ -63,11 +63,14 @@ build_yardstick_image()
fi
else
if [ ! -f "${QCOW_IMAGE}" ];then
- local cmd
- cmd="sudo $(which yardstick-img-modify) $(pwd)/tools/ubuntu-server-cloudimg-modify.sh"
-
- # Build the image. Retry once if the build fails
- $cmd || $cmd
+ ANSIBLE_SCRIPTS="${0%/*}/../../ansible"
+ cd ${ANSIBLE_SCRIPTS} &&\
+ ansible-playbook \
+ -e img_modify_playbook='ubuntu_server_cloudimg_modify.yml' \
+ -e target_os='Ubuntu' \
+ -e YARD_IMG_ARCH='amd64' \
+ -e ubuntu_img_file="${QCOW_IMAGE}" \
+ -vvv -i inventory.ini build_yardstick_image.yml
if [ ! -f "${QCOW_IMAGE}" ]; then
echo "Failed building QCOW image"
@@ -209,7 +212,7 @@ create_nova_flavor()
echo
echo "========== Creating yardstick-flavor =========="
# Create the nova flavor used by some sample test cases
- openstack ${SECURE} flavor create --id 100 --ram 1024 --disk 3 --vcpus 1 yardstick-flavor
+ openstack ${SECURE} flavor create --id 100 --ram 1024 --disk 10 --vcpus 1 yardstick-flavor
# DPDK-enabled OVS requires guest memory to be backed by large pages
if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
openstack ${SECURE} flavor set --property hw:mem_page_size=large yardstick-flavor
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml
index 852424d8e..d729169a6 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml
@@ -10,7 +10,9 @@
schema: "yardstick:task:0.1"
description: >
- Sample test case for the HA of controller node Openstack service.
+
+ Yardstick TC019 config file;
+ HA test case: HA test case: Control node Openstack service down - nova-api.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set attack_host = attack_host or "node1" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml
index f2cad4cc8..7136a9e7e 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml
@@ -9,6 +9,9 @@
---
schema: "yardstick:task:0.1"
+description: >
+ Yardstick TC023 config file;
+ Measure VM availability during VM live migration.
{% set file = file or "etc/yardstick/nodes/compass_sclab_virtual/pod.yaml" %}
{% set cpu_set = cpu_set or "0,1,2,3" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
index 3e630caf2..ac2db0dbf 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
@@ -10,11 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Sample test case for the HA of OpenStack Controll Node abnormally shutdown.
- In order to power on the shutdown node after testing, the jumphost is
- required to install ipmitool. Ipmi jumphost info and each nodes' ipmi ip,
- username, password are needed in pod file (There is a sample pod file in
- "etc/yardstick/nodes/pod.yaml.ipmi.sample").
+ Yardstick TC025 config file;
+ HA test case: OpenStack Controll Node abnormally shutdown.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set jump_host = jump_host or 'node0' %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml
index f9d9dde48..6a3465cc9 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml
@@ -10,7 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC045 :Control node Openstack service down - neutron server.
+ Yardstick TC045 config file;
+ HA test case: Control node Openstack service down - neutron-server.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set attack_host = attack_host or "node1" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml
index 129489968..200bdfc81 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml
@@ -10,7 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC046 :Control node Openstack service down - keystone.
+ Yardstick TC046 config file;
+ HA test case: Control node Openstack service down - keystone.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set attack_host = attack_host or "node1" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml
index 4a0b65b8d..d7c69c0d3 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml
@@ -10,7 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC047 :Control node Openstack service down - glance api.
+ Yardstick TC047 config file;
+ HA test case: Control node Openstack service down - glance-api.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set attack_host = attack_host or "node1" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml
index a1629c6d0..ddc62bb16 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml
@@ -10,7 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC048 :Control node Openstack service down - cinder api.
+ Yardstick TC048 config file;
+ HA test case: Control node Openstack service down - cinder-api.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set attack_host = attack_host or "node1" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc049.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc049.yaml
index 7b8383e4e..b23bb330f 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc049.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc049.yaml
@@ -10,7 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC049 :Control node Openstack service down - swift proxy.
+ Yardstick TC049 config file;
+ HA test case: Control node Openstack service down - swift-proxy.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set attack_host = attack_host or "node1" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc050.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc050.yaml
index b765feb68..dde3a1077 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc050.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc050.yaml
@@ -10,8 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC050 :OpenStack Controller Node Network High Availability;
- This test case is written by new scenario-based HA testing framework.
+ 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" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc051.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc051.yaml
index aade1aed2..3d4985f38 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc051.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc051.yaml
@@ -10,8 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC051 :OpenStack Controller Node CPU Overload High Availability;
- This test case is written by new scenario-based HA testing framework.
+ Yardstick TC051 config file;
+ HA test case: OpenStack Controller Node CPU Overload High Availability.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set attack_host = attack_host or "node1" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc052.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc052.yaml
index 62cabd1a2..8052f5450 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc052.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc052.yaml
@@ -10,8 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC052 :OpenStack Controller Node Disk I/O Block High Availability;
- This test case is written by new scenario-based HA testing framework.
+ Yardstick TC052 config file;
+ HA test case: OpenStack Controller Node Disk I/O Block High Availability.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set attack_host = attack_host or "node1" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml
index 64c67c0b3..bcf5902fa 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml
@@ -10,8 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC053 :Openstack Controller Load Balance Service High Availability;
- This test case is written by new scenario-based HA testing framework.
+ Yardstick TC053 config file;
+ HA test case: Openstack Controller Load Balance Service High Availability.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set attack_host = attack_host or "node1" %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml
index 5eb34e56a..a1fa38ef0 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml
@@ -10,8 +10,8 @@
schema: "yardstick:task:0.1"
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.
+ Yardstick TC054 config file;
+ HA test case: OpenStack VIP Master Node abnormally shutdown High Availability.
{% set jump_host = jump_host or 'node0' %}
{% set attack_host = attack_host or 'node1' %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml
index 40e8f9c13..0035a1f07 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml
@@ -10,8 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC056 :OpenStack Controller Messaging Queue Service High
- Availability.
+ Yardstick TC056 config file;
+ HA test case: OpenStack Controller Messaging Queue Service High Availability.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set attack_host = attack_host or 'node1' %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml
index 28aa0b6bd..6d710910a 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml
@@ -10,9 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC057 :OpenStack Controller Cluster Management Service High
- Availability;
- This test case is written by scenario-based HA testing framework.
+ Yardstick TC057 config file;
+ HA test case: OpenStack Controller Cluster Management Service High Availability.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set vip_mgmt = vip_mgmt or 'vip__management' %}
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml
index 7fb7daf62..77b9172a9 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml
@@ -10,9 +10,8 @@
schema: "yardstick:task:0.1"
description: >
- Test case for TC058 :OpenStack Controller Virtual Router Service High
- Availability;
- This test case is written by scenario-based HA testing framework.
+ Yardstick TC058 config file;
+ HA test case: OpenStack Controller Virtual Router Service High Availability.
{% set file = file or '/etc/yardstick/pod.yaml' %}
{% set image = image or 'yardstick-image' %}
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py
index 223d64060..f2e725df2 100644
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ b/tests/unit/benchmark/contexts/test_heat.py
@@ -119,8 +119,12 @@ class HeatContextTestCase(unittest.TestCase):
"2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b")
mock_template.add_security_group.assert_called_with("foo-secgroup")
# mock_template.add_network.assert_called_with("bar-fool-network", 'physnet1', None)
- mock_template.add_router.assert_called_with("bar-fool-network-router", netattrs["external_network"], "bar-fool-network-subnet")
- mock_template.add_router_interface.assert_called_with("bar-fool-network-router-if0", "bar-fool-network-router", "bar-fool-network-subnet")
+ mock_template.add_router.assert_called_with("bar-fool-network-router",
+ netattrs["external_network"],
+ "bar-fool-network-subnet")
+ mock_template.add_router_interface.assert_called_with("bar-fool-network-router-if0",
+ "bar-fool-network-router",
+ "bar-fool-network-subnet")
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test_attrs_get(self, mock_template):
diff --git a/tests/unit/benchmark/contexts/test_model.py b/tests/unit/benchmark/contexts/test_model.py
index 48ee01cf0..53b035b82 100644
--- a/tests/unit/benchmark/contexts/test_model.py
+++ b/tests/unit/benchmark/contexts/test_model.py
@@ -282,6 +282,178 @@ class ServerTestCase(unittest.TestCase):
scheduler_hints='hints',
availability_zone='zone')
+ def test_override_ip(self):
+ network_ports = {
+ 'mgmt': ['mgmt'],
+ 'uplink_0': [
+ {'xe0': {'local_ip': '10.44.0.20', 'netmask': '255.255.255.0'}},
+ ],
+ 'downlink_0': [
+ {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
+ ],
+ }
+ attrs = {
+ 'image': 'some-image', 'flavor': 'some-flavor',
+ }
+ test_server = model.Server('foo', self.mock_context, attrs)
+ test_server.interfaces = {
+ "xe0": {
+ "local_ip": "1.2.3.4",
+ "netmask": "255.255.255.0",
+ },
+ "xe1": {
+ "local_ip": "1.2.3.5",
+ "netmask": "255.255.255.0"
+ }
+ }
+ test_server.network_ports = network_ports
+
+ test_server.override_ip("uplink_0", {"port": "xe0"})
+ self.assertEqual(test_server.interfaces["xe0"], network_ports["uplink_0"][0]["xe0"])
+
+ def test_override_ip_multiple(self):
+ network_ports = {
+ 'mgmt': ['mgmt'],
+ 'uplink_0': [
+ {'xe0': {'local_ip': '10.44.0.20', 'netmask': '255.255.255.0'}},
+ {'xe0': {'local_ip': '10.44.0.21', 'netmask': '255.255.255.0'}},
+ ],
+ 'downlink_0': [
+ {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
+ ],
+ }
+ attrs = {
+ 'image': 'some-image', 'flavor': 'some-flavor',
+ }
+ test_server = model.Server('foo', self.mock_context, attrs)
+ test_server.interfaces = {
+ "xe0": {
+ "local_ip": "1.2.3.4",
+ "netmask": "255.255.255.0",
+ },
+ "xe1": {
+ "local_ip": "1.2.3.5",
+ "netmask": "255.255.255.0"
+ }
+ }
+ test_server.network_ports = network_ports
+ test_server.override_ip("uplink_0", {"port": "xe0"})
+ self.assertEqual(test_server.interfaces["xe0"], network_ports["uplink_0"][0]["xe0"])
+
+ def test_override_ip_mixed(self):
+ network_ports = {
+ 'mgmt': ['mgmt'],
+ 'uplink_0': [
+ 'xe0',
+ {'xe0': {'local_ip': '10.44.0.21', 'netmask': '255.255.255.0'}},
+ ],
+ 'downlink_0': [
+ {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
+ ],
+ }
+ attrs = {
+ 'image': 'some-image', 'flavor': 'some-flavor',
+ }
+ test_server = model.Server('foo', self.mock_context, attrs)
+ test_server.interfaces = {
+ "xe0": {
+ "local_ip": "1.2.3.4",
+ "netmask": "255.255.255.0",
+ },
+ "xe1": {
+ "local_ip": "1.2.3.5",
+ "netmask": "255.255.255.0"
+ }
+ }
+ test_server.network_ports = network_ports
+ test_server.override_ip("uplink_0", {"port": "xe0"})
+ self.assertEqual(test_server.interfaces["xe0"], network_ports["uplink_0"][1]["xe0"])
+
+ @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
+ def test__add_instance_with_ip_override_invalid_syntax(self, mock_template):
+ network_ports = {
+ 'mgmt': ['mgmt'],
+ 'uplink_0': 'xe0',
+ 'downlink_0': [
+ {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
+ ],
+ }
+ attrs = {
+ 'image': 'some-image', 'flavor': 'some-flavor',
+ }
+ test_server = model.Server('foo', self.mock_context, attrs)
+ test_server.network_ports = network_ports
+ context = type("Context", (object,), {})
+ # can't use Mock because Mock.name is reserved
+ context.name = "context"
+ networks = [model.Network(n, context, {}) for n in network_ports]
+
+ with self.assertRaises(SyntaxError):
+ test_server._add_instance(mock_template, 'some-server',
+ networks, 'hints')
+
+ @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
+ def test__add_instance_with_ip_override(self, mock_template):
+ network_ports = {
+ 'mgmt': ['mgmt'],
+ 'uplink_0': [
+ {'xe0': {'local_ip': '10.44.0.20', 'netmask': '255.255.255.0'}},
+ ],
+ 'downlink_0': [
+ {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
+ ],
+ }
+ attrs = {
+ 'image': 'some-image', 'flavor': 'some-flavor',
+ }
+ test_server = model.Server('foo', self.mock_context, attrs)
+ test_server.network_ports = network_ports
+ context = type("Context", (object,), {})
+ # can't use Mock because Mock.name is reserved
+ context.name = "context"
+ networks = [model.Network(n, context, {}) for n in network_ports]
+
+ test_server._add_instance(mock_template, 'some-server',
+ networks, 'hints')
+ self.assertEqual(test_server.ports, {
+ 'downlink_0': [{'port': 'xe1', 'stack_name': 'some-server-xe1-port'}],
+ 'mgmt': [{'port': 'mgmt', 'stack_name': 'some-server-mgmt-port'}],
+ 'uplink_0': [{'port': 'xe0', 'stack_name': 'some-server-xe0-port'}]
+ })
+
+ @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
+ def test__add_instance_with_multiple_ip_override(self, mock_template):
+ network_ports = {
+ 'mgmt': ['mgmt'],
+ 'uplink_0': [
+ {'xe0': {'local_ip': '10.44.0.20', 'netmask': '255.255.255.0'}},
+ {'xe0': {'local_ip': '10.44.0.21', 'netmask': '255.255.255.0'}},
+ ],
+ 'downlink_0': [
+ {'xe1': {'local_ip': '10.44.0.30', 'netmask': '255.255.255.0'}},
+ ],
+ }
+ attrs = {
+ 'image': 'some-image', 'flavor': 'some-flavor',
+ }
+ test_server = model.Server('foo', self.mock_context, attrs)
+ test_server.network_ports = network_ports
+ context = type("Context", (object,), {})
+ # can't use Mock because Mock.name is reserved
+ context.name = "context"
+ networks = [model.Network(n, context, {}) for n in network_ports]
+
+ test_server._add_instance(mock_template, 'some-server',
+ networks, 'hints')
+ self.assertEqual(test_server.ports, {
+ 'downlink_0': [{'port': 'xe1', 'stack_name': 'some-server-xe1-port'}],
+ 'mgmt': [{'port': 'mgmt', 'stack_name': 'some-server-mgmt-port'}],
+ 'uplink_0': [{'port': 'xe0', 'stack_name': 'some-server-xe0-port'},
+ # this is not an error, we can produce this, it is left to Heat
+ # to detect duplicate ports and error
+ {'port': 'xe0', 'stack_name': 'some-server-xe0-port'}]
+ })
+
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test__add_instance_with_user_data(self, mock_template):
user_data = "USER_DATA"
diff --git a/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py b/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
index f163f1914..1f0ff3c29 100644
--- a/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
+++ b/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
@@ -16,6 +16,7 @@ from __future__ import absolute_import
import unittest
import mock
+from oslo_serialization import jsonutils
from yardstick.benchmark.scenarios.compute import qemu_migrate
@@ -83,7 +84,7 @@ class QemuMigrateTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
q.run(result)
- expected_result = {}
+ expected_result = jsonutils.loads(sample_output)
self.assertEqual(result, expected_result)
def test_qemu_migrate_successful_sla(self, mock_ssh):
@@ -103,7 +104,7 @@ class QemuMigrateTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
q.run(result)
- expected_result = {}
+ expected_result = jsonutils.loads(sample_output)
self.assertEqual(result, expected_result)
def test_qemu_migrate_unsuccessful_sla_totaltime(self, mock_ssh):
@@ -117,8 +118,7 @@ class QemuMigrateTestCase(unittest.TestCase):
sample_output = '{"totaltime": 15, "downtime": 2, "setuptime": 1}'
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- with self.assertRaises(AssertionError):
- q.run(result)
+ self.assertRaises(AssertionError, q.run, result)
def test_qemu_migrate_unsuccessful_sla_downtime(self, mock_ssh):
@@ -131,8 +131,7 @@ class QemuMigrateTestCase(unittest.TestCase):
sample_output = '{"totaltime": 15, "downtime": 2, "setuptime": 1}'
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- with self.assertRaises(AssertionError):
- q.run(result)
+ self.assertRaises(AssertionError, q.run, result)
def test_qemu_migrate_unsuccessful_sla_setuptime(self, mock_ssh):
@@ -145,8 +144,7 @@ class QemuMigrateTestCase(unittest.TestCase):
sample_output = '{"totaltime": 15, "downtime": 2, "setuptime": 1}'
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
- with self.assertRaises(AssertionError):
- q.run(result)
+ self.assertRaises(AssertionError, q.run, result)
def test_qemu_migrate_unsuccessful_script_error(self, mock_ssh):
@@ -156,9 +154,10 @@ class QemuMigrateTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
q.setup()
+
mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
- with self.assertRaises(RuntimeError):
- q.run(result)
+ self.assertRaises(RuntimeError, q.run, result)
+
def main():
unittest.main()