aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/ci/clean_images.sh16
-rwxr-xr-xtests/ci/load_images.sh36
-rwxr-xr-xtests/ci/prepare_storperf_admin-rc.sh2
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml9
-rw-r--r--tests/unit/benchmark/core/test_task.py28
-rw-r--r--tests/unit/benchmark/runner/__init__.py0
-rw-r--r--tests/unit/benchmark/runner/test_base.py45
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_scenario_general.py2
-rw-r--r--tests/unit/dispatcher/test_influxdb.py4
9 files changed, 118 insertions, 24 deletions
diff --git a/tests/ci/clean_images.sh b/tests/ci/clean_images.sh
index 27da9e279..cb5410ab2 100755
--- a/tests/ci/clean_images.sh
+++ b/tests/ci/clean_images.sh
@@ -15,18 +15,24 @@ cleanup()
echo
echo "========== Cleanup =========="
- if ! openstack image list; then
+ if [ $OS_CACERT ] && [ "$(echo $OS_CACERT | tr '[:upper:]' '[:lower:]')" = "false" ]; then
+ SECURE="--insecure"
+ else
+ SECURE=""
+ fi
+
+ if ! openstack "${SECURE}" image list; then
return
fi
- for image in $(openstack image list | grep -e cirros-0.3.5 -e yardstick-image -e Ubuntu-16.04 \
+ for image in $(openstack "${SECURE}" image list | grep -e cirros-0.3.5 -e yardstick-image -e Ubuntu-16.04 \
| awk '{print $2}'); do
echo "Deleting image $image..."
- openstack image delete $image || true
+ openstack "${SECURE}" image delete $image || true
done
- openstack flavor delete yardstick-flavor &> /dev/null || true
- openstack flavor delete storperf &> /dev/null || true
+ openstack "${SECURE}" flavor delete yardstick-flavor &> /dev/null || true
+ openstack "${SECURE}" flavor delete storperf &> /dev/null || true
}
main()
diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh
index 2e22b83c2..054621c05 100755
--- a/tests/ci/load_images.sh
+++ b/tests/ci/load_images.sh
@@ -88,7 +88,7 @@ load_yardstick_image()
if [ ! -f "${CLOUD_KERNEL}" ]; then
tar xf "${CLOUD_IMAGE}" "${CLOUD_KERNEL##**/}"
fi
- create_kernel=$(openstack image create \
+ create_kernel=$(openstack "${SECURE}" image create \
--public \
--disk-format qcow2 \
--container-format bare \
@@ -119,7 +119,7 @@ load_yardstick_image()
fi
if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
- output=$(eval openstack image create \
+ output=$(eval openstack "${SECURE}" image create \
--public \
--disk-format raw \
--container-format bare \
@@ -127,7 +127,7 @@ load_yardstick_image()
--file ${RAW_IMAGE} \
yardstick-image)
else
- output=$(eval openstack image create \
+ output=$(eval openstack "${SECURE}" image create \
--public \
--disk-format qcow2 \
--container-format bare \
@@ -145,18 +145,12 @@ load_yardstick_image()
exit 1
fi
- if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
- sudo rm -f -- "${RAW_IMAGE}"
- else
- sudo rm -f -- "${QCOW_IMAGE}"
- fi
-
echo "Glance image id: $GLANCE_IMAGE_ID"
}
load_cirros_image()
{
- if [[ -n $(openstack image list | grep -e Cirros-0.3.5) ]]; then
+ if [[ -n $(openstack "${SECURE}" image list | grep -e Cirros-0.3.5) ]]; then
echo "Cirros-0.3.5 image already exist, skip loading cirros image"
else
echo
@@ -170,7 +164,7 @@ load_cirros_image()
EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
fi
- output=$(openstack image create \
+ output=$(openstack "${SECURE}" image create \
--disk-format qcow2 \
--container-format bare \
${EXTRA_PARAMS} \
@@ -201,7 +195,7 @@ load_ubuntu_image()
EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
fi
- output=$(openstack image create \
+ output=$(openstack "${SECURE}" image create \
--disk-format qcow2 \
--container-format bare \
$EXTRA_PARAMS \
@@ -221,26 +215,26 @@ load_ubuntu_image()
create_nova_flavor()
{
- if ! openstack flavor list | grep -q yardstick-flavor; then
+ if ! openstack "${SECURE}" flavor list | grep -q yardstick-flavor; then
echo
echo "========== Creating yardstick-flavor =========="
# Create the nova flavor used by some sample test cases
- openstack flavor create --id 100 --ram 512 --disk 3 --vcpus 1 yardstick-flavor
+ openstack "${SECURE}" flavor create --id 100 --ram 1024 --disk 3 --vcpus 1 yardstick-flavor
# DPDK-enabled OVS requires guest memory to be backed by large pages
if [[ $DEPLOY_SCENARIO == *[_-]ovs[_-]* ]]; then
- openstack flavor set --property hw:mem_page_size=large yardstick-flavor
+ openstack "${SECURE}" flavor set --property hw:mem_page_size=large yardstick-flavor
fi
# VPP requires guest memory to be backed by large pages
if [[ "$DEPLOY_SCENARIO" == *"-fdio-"* ]]; then
- openstack flavor set --property hw:mem_page_size=large yardstick-flavor
+ openstack "${SECURE}" flavor set --property hw:mem_page_size=large yardstick-flavor
fi
fi
- if ! openstack flavor list | grep -q storperf; then
+ if ! openstack "${SECURE}" flavor list | grep -q storperf; then
echo
echo "========== Creating storperf flavor =========="
# Create the nova flavor used by storperf test case
- openstack flavor create --id auto --ram 8192 --disk 4 --vcpus 2 storperf
+ openstack "${SECURE}" flavor create --id auto --ram 8192 --disk 4 --vcpus 2 storperf
fi
}
@@ -256,6 +250,12 @@ main()
RAW_IMAGE='/home/opnfv/images/yardstick-image.tar.gz'
fi
+ if [ $OS_CACERT ] && [ "$(echo $OS_CACERT | tr '[:upper:]' '[:lower:]')" = "false" ]; then
+ SECURE="--insecure"
+ else
+ SECURE=""
+ fi
+
build_yardstick_image
load_yardstick_image
if [ "${YARD_IMG_ARCH}" == "arm64" ]; then
diff --git a/tests/ci/prepare_storperf_admin-rc.sh b/tests/ci/prepare_storperf_admin-rc.sh
index a6cf97bef..979728e84 100755
--- a/tests/ci/prepare_storperf_admin-rc.sh
+++ b/tests/ci/prepare_storperf_admin-rc.sh
@@ -33,3 +33,5 @@ echo "OS_PROJECT_ID="$PROJECT_ID >> ~/storperf_admin-rc
echo "OS_TENANT_NAME="$TENANT_NAME >> ~/storperf_admin-rc
echo "OS_TENANT_ID="$TENANT_ID >> ~/storperf_admin-rc
echo "OS_USER_DOMAIN_ID="$USER_DOMAIN_ID >> ~/storperf_admin-rc
+echo "OS_PROJECT_DOMAIN_NAME="$OS_PROJECT_DOMAIN_NAME >> ~/storperf_admin-rc
+echo "OS_USER_DOMAIN_NAME="$OS_USER_DOMAIN_NAME >> ~/storperf_admin-rc
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
index 443395873..c4ee237e5 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
@@ -11,16 +11,22 @@
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").
{% set file = file or 'etc/yardstick/nodes/fuel_virtual/pod.yaml' %}
+{% set jumphost = jumphost or 'node0' %}
scenarios:
-
type: ServiceHA
options:
attackers:
- - fault_type: "host-shutdown"
+ - fault_type: "bare-metal-down"
host: node1
+ jump_host: {{jumphost}}
monitors:
- monitor_type: "openstack-cmd"
@@ -42,6 +48,7 @@ scenarios:
nodes:
node1: node1.LF
+ node0: node0.LF
runner:
type: Iteration
diff --git a/tests/unit/benchmark/core/test_task.py b/tests/unit/benchmark/core/test_task.py
index cd7ffdebb..8034392f4 100644
--- a/tests/unit/benchmark/core/test_task.py
+++ b/tests/unit/benchmark/core/test_task.py
@@ -64,6 +64,7 @@ class TaskTestCase(unittest.TestCase):
t = task.Task()
runner = mock.Mock()
runner.join.return_value = 0
+ runner.get_output.return_value = {}
mock_base_runner.Runner.get.return_value = runner
t._run([scenario], False, "yardstick.out")
self.assertTrue(runner.run.called)
@@ -155,6 +156,33 @@ class TaskTestCase(unittest.TestCase):
self.assertEqual(task_args_fnames[0], None)
self.assertEqual(task_args_fnames[1], None)
+ def test_parse_options(self):
+ options = {
+ 'openstack': {
+ 'EXTERNAL_NETWORK': '$network'
+ },
+ 'ndoes': ['node1', '$node'],
+ 'host': '$host'
+ }
+
+ t = task.Task()
+ t.outputs = {
+ 'network': 'ext-net',
+ 'node': 'node2',
+ 'host': 'server.yardstick'
+ }
+
+ idle_result = {
+ 'openstack': {
+ 'EXTERNAL_NETWORK': 'ext-net'
+ },
+ 'ndoes': ['node1', 'node2'],
+ 'host': 'server.yardstick'
+ }
+
+ actual_result = t._parse_options(options)
+ self.assertEqual(idle_result, actual_result)
+
def test_change_server_name_host_str(self):
scenario = {'host': 'demo'}
suffix = '-8'
diff --git a/tests/unit/benchmark/runner/__init__.py b/tests/unit/benchmark/runner/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/unit/benchmark/runner/__init__.py
diff --git a/tests/unit/benchmark/runner/test_base.py b/tests/unit/benchmark/runner/test_base.py
new file mode 100644
index 000000000..7880fe5a5
--- /dev/null
+++ b/tests/unit/benchmark/runner/test_base.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import unittest
+import multiprocessing
+import time
+
+from yardstick.benchmark.runners.iteration import IterationRunner
+
+
+class RunnerTestCase(unittest.TestCase):
+
+ def test_get_output(self):
+ queue = multiprocessing.Queue()
+ runner = IterationRunner({}, queue)
+ runner.output_queue.put({'case': 'opnfv_yardstick_tc002'})
+ runner.output_queue.put({'criteria': 'PASS'})
+
+ idle_result = {
+ 'case': 'opnfv_yardstick_tc002',
+ 'criteria': 'PASS'
+ }
+
+ time.sleep(1)
+ actual_result = runner.get_output()
+ self.assertEqual(idle_result, actual_result)
+
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/benchmark/scenarios/availability/test_scenario_general.py b/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
index ea54fbb9b..de2170b16 100644
--- a/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
+++ b/tests/unit/benchmark/scenarios/availability/test_scenario_general.py
@@ -56,6 +56,7 @@ class ScenarioGeneralTestCase(unittest.TestCase):
mock_obj = mock.Mock()
mock_obj.createActionPlayer.side_effect = KeyError('Wrong')
ins.director = mock_obj
+ ins.director.data = {}
ins.run({})
ins.teardown()
@@ -64,5 +65,6 @@ class ScenarioGeneralTestCase(unittest.TestCase):
mock_obj = mock.Mock()
mock_obj.verify.return_value = False
ins.director = mock_obj
+ ins.director.data = {}
ins.run({})
ins.teardown()
diff --git a/tests/unit/dispatcher/test_influxdb.py b/tests/unit/dispatcher/test_influxdb.py
index 0c7b58135..dca3c4189 100644
--- a/tests/unit/dispatcher/test_influxdb.py
+++ b/tests/unit/dispatcher/test_influxdb.py
@@ -14,11 +14,15 @@
from __future__ import absolute_import
import unittest
+
try:
from unittest import mock
except ImportError:
import mock
+from yardstick import _init_logging
+_init_logging()
+
from yardstick.dispatcher.influxdb import InfluxdbDispatcher