aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/ci/clean_images.sh15
-rwxr-xr-xtests/ci/load_images.sh47
-rwxr-xr-xtests/ci/prepare_storperf_admin-rc.sh5
-rw-r--r--tests/ci/scp_storperf_admin-rc.sh11
-rwxr-xr-xtests/ci/yardstick-verify8
-rw-r--r--tests/opnfv/test_suites/opnfv_components.yaml16
-rw-r--r--tests/opnfv/test_suites/opnfv_features.yaml52
-rw-r--r--tests/opnfv/test_suites/opnfv_performance.yaml62
-rw-r--r--tests/opnfv/test_suites/opnfv_smoke.yaml14
-rw-r--r--tests/unit/benchmark/core/__init__.py (renamed from tests/unit/cmd/commands/__init__.py)0
-rw-r--r--tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml (renamed from tests/unit/cmd/commands/no_constraint_no_args_scenario_sample.yaml)0
-rw-r--r--tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml (renamed from tests/unit/cmd/commands/no_constraint_with_args_scenario_sample.yaml)0
-rw-r--r--tests/unit/benchmark/core/test_plugin.py (renamed from tests/unit/cmd/commands/test_plugin.py)32
-rw-r--r--tests/unit/benchmark/core/test_task.py (renamed from tests/unit/cmd/commands/test_task.py)88
-rw-r--r--tests/unit/benchmark/core/test_testcase.py (renamed from tests/unit/cmd/commands/test_testcase.py)29
-rw-r--r--tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml (renamed from tests/unit/cmd/commands/with_constraint_no_args_scenario_sample.yaml)0
-rw-r--r--tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml (renamed from tests/unit/cmd/commands/with_constraint_with_args_scenario_sample.yaml)0
-rw-r--r--tests/unit/test_ssh.py36
18 files changed, 315 insertions, 100 deletions
diff --git a/tests/ci/clean_images.sh b/tests/ci/clean_images.sh
index b1942160b..fa4a54df6 100755
--- a/tests/ci/clean_images.sh
+++ b/tests/ci/clean_images.sh
@@ -15,15 +15,22 @@ cleanup()
echo
echo "========== Cleanup =========="
- if ! glance image-list; then
+ if ! openstack image list; then
return
fi
- for image in $(glance image-list | grep -e cirros-0.3.3 -e yardstick-image -e Ubuntu-14.04 \
+ for image in $(openstack image list | grep -e cirros-0.3.3 -e yardstick-image -e Ubuntu-14.04 \
-e yardstick-vivid-kernel | awk '{print $2}'); do
echo "Deleting image $image..."
- glance image-delete $image || true
+ openstack image delete $image || true
done
- nova flavor-delete yardstick-flavor &> /dev/null || true
+ openstack flavor delete yardstick-flavor &> /dev/null || true
}
+
+main()
+{
+ cleanup
+}
+
+main
diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh
index 405d72076..e1d717749 100755
--- a/tests/ci/load_images.sh
+++ b/tests/ci/load_images.sh
@@ -75,11 +75,12 @@ load_yardstick_image()
if [ ! -f $VIVID_KERNEL ]; then
tar zxf $VIVID_IMAGE $(basename $VIVID_KERNEL)
fi
- create_vivid_kernel=$(glance --os-image-api-version 1 image-create \
- --name yardstick-vivid-kernel \
- --is-public true --disk-format qcow2 \
+ create_vivid_kernel=$(openstack image create \
+ --public \
+ --disk-format qcow2 \
--container-format bare \
- --file $VIVID_KERNEL)
+ --file $VIVID_KERNEL \
+ yardstick-vivid-kernel)
GLANCE_KERNEL_ID=$(echo "$create_vivid_kernel" | grep " id " | awk '{print $(NF-1)}')
if [ -z "$GLANCE_KERNEL_ID" ]; then
@@ -101,19 +102,21 @@ load_yardstick_image()
fi
if [[ "$DEPLOY_SCENARIO" == *"-lxd-"* ]]; then
- output=$(eval glance --os-image-api-version 1 image-create \
- --name yardstick-image \
- --is-public true --disk-format root-tar \
+ output=$(eval openstack image create \
+ --public \
+ --disk-format root-tar \
--container-format bare \
$EXTRA_PARAMS \
- --file $RAW_IMAGE)
+ --file $RAW_IMAGE \
+ yardstick-image)
else
- output=$(eval glance --os-image-api-version 1 image-create \
- --name yardstick-image \
- --is-public true --disk-format qcow2 \
+ output=$(eval openstack image create \
+ --public \
+ --disk-format qcow2 \
--container-format bare \
$EXTRA_PARAMS \
- --file $QCOW_IMAGE)
+ --file $QCOW_IMAGE \
+ yardstick-image)
fi
echo "$output"
@@ -147,12 +150,12 @@ load_cirros_image()
EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
fi
- output=$(glance image-create \
- --name cirros-0.3.3 \
+ output=$(openstack image create \
--disk-format qcow2 \
--container-format bare \
$EXTRA_PARAMS \
- --file $image_file)
+ --file $image_file \
+ cirros-0.3.3)
echo "$output"
CIRROS_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
@@ -177,12 +180,12 @@ load_ubuntu_image()
EXTRA_PARAMS=$EXTRA_PARAMS" --property hw_mem_page_size=large"
fi
- output=$(glance image-create \
- --name Ubuntu-14.04 \
+ output=$(openstack image create \
--disk-format qcow2 \
--container-format bare \
$EXTRA_PARAMS \
- --file $ubuntu_image_file)
+ --file $ubuntu_image_file \
+ Ubuntu-14.04)
echo "$output"
UBUNTU_IMAGE_ID=$(echo "$output" | grep " id " | awk '{print $(NF-1)}')
@@ -197,18 +200,18 @@ load_ubuntu_image()
create_nova_flavor()
{
- if ! nova flavor-list | grep -q yardstick-flavor; then
+ if ! openstack flavor list | grep -q yardstick-flavor; then
echo
echo "========== Create nova flavor =========="
# Create the nova flavor used by some sample test cases
- nova flavor-create yardstick-flavor 100 512 3 1
+ openstack flavor create --id 100 --ram 512 --disk 3 --vcpus 1 yardstick-flavor
# DPDK-enabled OVS requires guest memory to be backed by large pages
if [[ "$DEPLOY_SCENARIO" == *"-ovs-"* ]]; then
- nova flavor-key yardstick-flavor set hw:mem_page_size=large
+ openstack 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
- nova flavor-key yardstick-flavor set hw:mem_page_size=large
+ openstack flavor set --property hw:mem_page_size=large yardstick-flavor
fi
fi
}
diff --git a/tests/ci/prepare_storperf_admin-rc.sh b/tests/ci/prepare_storperf_admin-rc.sh
index 0401719ff..b3dc2e58e 100755
--- a/tests/ci/prepare_storperf_admin-rc.sh
+++ b/tests/ci/prepare_storperf_admin-rc.sh
@@ -9,14 +9,15 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+# Prepare storperf_admin-rc for StorPerf.
+
AUTH_URL=${OS_AUTH_URL}
USERNAME=${OS_USERNAME:-admin}
PASSWORD=${OS_PASSWORD:-console}
TENANT_NAME=${OS_TENANT_NAME:-admin}
VOLUME_API_VERSION=${OS_VOLUME_API_VERSION:-2}
PROJECT_NAME=${OS_PROJECT_NAME:-$TENANT_NAME}
-TENANT_ID=`keystone tenant-get admin|grep 'id'|awk -F '|' '{print $3}'|sed -e 's/^[[:space:]]*//'`
-
+TENANT_ID=`openstack project show admin|grep '\bid\b' |awk -F '|' '{print $3}'|sed -e 's/^[[:space:]]*//'`
rm -f ~/storperf_admin-rc
touch ~/storperf_admin-rc
diff --git a/tests/ci/scp_storperf_admin-rc.sh b/tests/ci/scp_storperf_admin-rc.sh
index af2885b01..7c3896d88 100644
--- a/tests/ci/scp_storperf_admin-rc.sh
+++ b/tests/ci/scp_storperf_admin-rc.sh
@@ -1,5 +1,16 @@
#!/bin/bash
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# Copy storperf_admin-rc to deployment location.
+
ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
sshpass -p root scp 2>/dev/null $ssh_options ~/storperf_admin-rc \
root@192.168.200.1:/root/ &> /dev/null
diff --git a/tests/ci/yardstick-verify b/tests/ci/yardstick-verify
index 7644c96c4..f9d98a4da 100755
--- a/tests/ci/yardstick-verify
+++ b/tests/ci/yardstick-verify
@@ -301,8 +301,8 @@ main()
# check OpenStack services
echo "Checking OpenStack services:"
- for cmd in "glance image-list" "nova list" "heat stack-list"; do
- echo " checking ${cmd/%\ */} ..."
+ for cmd in "openstack image list" "openstack server list" "openstack stack list"; do
+ echo " checking ${cmd} ..."
if ! $cmd >/dev/null; then
echo "error: command \"$cmd\" failed"
exit 1
@@ -311,7 +311,7 @@ main()
echo
echo "Checking for External network:"
- for net in $(neutron net-list --router:external True -c name -f value); do
+ for net in $(openstack network list --external -c Name -f value); do
echo " external network: $net"
done
@@ -320,8 +320,6 @@ main()
source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh
- cleanup
-
trap "error_exit" EXIT SIGTERM
source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh
diff --git a/tests/opnfv/test_suites/opnfv_components.yaml b/tests/opnfv/test_suites/opnfv_components.yaml
new file mode 100644
index 000000000..ff4923e03
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_components.yaml
@@ -0,0 +1,16 @@
+---
+# Yardstick components task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "opnfv_yardstick-components"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc074.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"public_network": "ext-net",
+ "StorPerf_ip": "192.168.200.1"}'
diff --git a/tests/opnfv/test_suites/opnfv_features.yaml b/tests/opnfv/test_suites/opnfv_features.yaml
new file mode 100644
index 000000000..3621f1367
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_features.yaml
@@ -0,0 +1,52 @@
+---
+# Yardstick features task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "opnfv_yardstick-features"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc027.yaml
+ constraint:
+ installer: compass,fuel
+ pod: huawei-pod1,lf-pod2
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml"}'
+ lf-pod2: '{"pod_info": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "openrc":"/root/openrc", "external_network":"admin_floating_net"}'
+-
+ file_name: opnfv_yardstick_tc045.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc046.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc047.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc048.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc049.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc050.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc051.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc052.yaml
+ constraint:
+ installer: fuel
+-
+ file_name: opnfv_yardstick_tc053.yaml
+ constraint:
+ installer: fuel
diff --git a/tests/opnfv/test_suites/opnfv_performance.yaml b/tests/opnfv/test_suites/opnfv_performance.yaml
new file mode 100644
index 000000000..71b1e2ef9
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_performance.yaml
@@ -0,0 +1,62 @@
+---
+# Yardstick performance task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "opnfv_yardstick-performance"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc043.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node4.LF","target": "node5.LF"}'
+-
+ file_name: opnfv_yardstick_tc055.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC055"}'
+-
+ file_name: opnfv_yardstick_tc063.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5.yardstick-TC063"}'
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
+-
+ file_name: opnfv_yardstick_tc075.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"pod_info": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node1.LF"}'
diff --git a/tests/opnfv/test_suites/opnfv_smoke.yaml b/tests/opnfv/test_suites/opnfv_smoke.yaml
new file mode 100644
index 000000000..f773bec87
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_smoke.yaml
@@ -0,0 +1,14 @@
+---
+# Yardstick smoke task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "opnfv_yardstick-smoke"
+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_tc012.yaml
diff --git a/tests/unit/cmd/commands/__init__.py b/tests/unit/benchmark/core/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/cmd/commands/__init__.py
+++ b/tests/unit/benchmark/core/__init__.py
diff --git a/tests/unit/cmd/commands/no_constraint_no_args_scenario_sample.yaml b/tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml
index 4933b93ae..4933b93ae 100644
--- a/tests/unit/cmd/commands/no_constraint_no_args_scenario_sample.yaml
+++ b/tests/unit/benchmark/core/no_constraint_no_args_scenario_sample.yaml
diff --git a/tests/unit/cmd/commands/no_constraint_with_args_scenario_sample.yaml b/tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml
index f39df7346..f39df7346 100644
--- a/tests/unit/cmd/commands/no_constraint_with_args_scenario_sample.yaml
+++ b/tests/unit/benchmark/core/no_constraint_with_args_scenario_sample.yaml
diff --git a/tests/unit/cmd/commands/test_plugin.py b/tests/unit/benchmark/core/test_plugin.py
index 2e823fdae..441116a25 100644
--- a/tests/unit/cmd/commands/test_plugin.py
+++ b/tests/unit/benchmark/core/test_plugin.py
@@ -9,12 +9,12 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.cmd.commands.plugin
+# Unittest for yardstick.benchmark.core.plugin
import mock
import unittest
-from yardstick.cmd.commands import plugin
+from yardstick.benchmark.core import plugin
class Arg(object):
@@ -22,30 +22,30 @@ class Arg(object):
self.input_file = ('plugin/sample_config.yaml',)
-@mock.patch('yardstick.cmd.commands.plugin.ssh')
-class pluginCommandsTestCase(unittest.TestCase):
+@mock.patch('yardstick.benchmark.core.plugin.ssh')
+class pluginTestCase(unittest.TestCase):
def setUp(self):
self.result = {}
- def test_do_install(self, mock_ssh):
- p = plugin.PluginCommands()
+ def test_install(self, mock_ssh):
+ p = plugin.Plugin()
mock_ssh.SSH().execute.return_value = (0, '', '')
input_file = Arg()
- p.do_install(input_file)
+ p.install(input_file)
expected_result = {}
self.assertEqual(self.result, expected_result)
- def test_do_remove(self, mock_ssh):
- p = plugin.PluginCommands()
+ def test_remove(self, mock_ssh):
+ p = plugin.Plugin()
mock_ssh.SSH().execute.return_value = (0, '', '')
input_file = Arg()
- p.do_remove(input_file)
+ p.remove(input_file)
expected_result = {}
self.assertEqual(self.result, expected_result)
def test_install_setup_run(self, mock_ssh):
- p = plugin.PluginCommands()
+ p = plugin.Plugin()
mock_ssh.SSH().execute.return_value = (0, '', '')
plugins = {
"name": "sample"
@@ -64,7 +64,7 @@ class pluginCommandsTestCase(unittest.TestCase):
self.assertEqual(self.result, expected_result)
def test_remove_setup_run(self, mock_ssh):
- p = plugin.PluginCommands()
+ p = plugin.Plugin()
mock_ssh.SSH().execute.return_value = (0, '', '')
plugins = {
"name": "sample"
@@ -81,3 +81,11 @@ class pluginCommandsTestCase(unittest.TestCase):
p._run(plugin_name)
expected_result = {}
self.assertEqual(self.result, expected_result)
+
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/cmd/commands/test_task.py b/tests/unit/benchmark/core/test_task.py
index 0177fd08a..463c43e1f 100644
--- a/tests/unit/cmd/commands/test_task.py
+++ b/tests/unit/benchmark/core/test_task.py
@@ -9,18 +9,18 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.cmd.commands.task
+# Unittest for yardstick.benchmark.core.task
import os
import mock
import unittest
-from yardstick.cmd.commands import task
+from yardstick.benchmark.core import task
-class TaskCommandsTestCase(unittest.TestCase):
+class TaskTestCase(unittest.TestCase):
- @mock.patch('yardstick.cmd.commands.task.Context')
+ @mock.patch('yardstick.benchmark.core.task.Context')
def test_parse_nodes_host_target_same_context(self, mock_context):
nodes = {
"host": "node1.LF",
@@ -38,42 +38,45 @@ class TaskCommandsTestCase(unittest.TestCase):
self.assertEqual(context_cfg["host"], server_info)
self.assertEqual(context_cfg["target"], server_info)
- @mock.patch('yardstick.cmd.commands.task.Context')
- @mock.patch('yardstick.cmd.commands.task.base_runner')
+ @mock.patch('yardstick.benchmark.core.task.Context')
+ @mock.patch('yardstick.benchmark.core.task.base_runner')
def test_run(self, mock_base_runner, mock_ctx):
- scenario = \
- {'host': 'athena.demo',
- 'target': 'ares.demo',
- 'runner':
- {'duration': 60,
- 'interval': 1,
- 'type': 'Duration'
- },
- 'type': 'Ping'}
-
- t = task.TaskCommands()
+ scenario = {
+ 'host': 'athena.demo',
+ 'target': 'ares.demo',
+ 'runner': {
+ 'duration': 60,
+ 'interval': 1,
+ 'type': 'Duration'
+ },
+ 'type': 'Ping'
+ }
+
+ t = task.Task()
runner = mock.Mock()
runner.join.return_value = 0
mock_base_runner.Runner.get.return_value = runner
t._run([scenario], False, "yardstick.out")
self.assertTrue(runner.run.called)
- @mock.patch('yardstick.cmd.commands.task.os')
+ @mock.patch('yardstick.benchmark.core.task.os')
def test_check_precondition(self, mock_os):
- cfg = \
- {'precondition':
- {'installer_type': 'compass',
- 'deploy_scenarios': 'os-nosdn',
- 'pod_name': 'huawei-pod1'
- }
+ cfg = {
+ 'precondition': {
+ 'installer_type': 'compass',
+ 'deploy_scenarios': 'os-nosdn',
+ 'pod_name': 'huawei-pod1'
}
+ }
t = task.TaskParser('/opt')
- mock_os.environ.get.side_effect = ['compass', 'os-nosdn', 'huawei-pod1']
+ mock_os.environ.get.side_effect = ['compass',
+ 'os-nosdn',
+ 'huawei-pod1']
result = t._check_precondition(cfg)
self.assertTrue(result)
- @mock.patch('yardstick.cmd.commands.task.os.environ')
+ @mock.patch('yardstick.benchmark.core.task.os.environ')
def test_parse_suite_no_constraint_no_args(self, mock_environ):
SAMPLE_SCENARIO_PATH = "no_constraint_no_args_scenario_sample.yaml"
t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
@@ -82,15 +85,15 @@ class TaskCommandsTestCase(unittest.TestCase):
print ("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
self.assertEqual(task_files[0],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
self.assertEqual(task_files[1],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
self.assertEqual(task_args[0], None)
self.assertEqual(task_args[1], None)
self.assertEqual(task_args_fnames[0], None)
self.assertEqual(task_args_fnames[1], None)
- @mock.patch('yardstick.cmd.commands.task.os.environ')
+ @mock.patch('yardstick.benchmark.core.task.os.environ')
def test_parse_suite_no_constraint_with_args(self, mock_environ):
SAMPLE_SCENARIO_PATH = "no_constraint_with_args_scenario_sample.yaml"
t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
@@ -99,16 +102,16 @@ class TaskCommandsTestCase(unittest.TestCase):
print ("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
self.assertEqual(task_files[0],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
self.assertEqual(task_files[1],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
self.assertEqual(task_args[0], None)
self.assertEqual(task_args[1],
- '{"host": "node1.LF","target": "node2.LF"}')
+ '{"host": "node1.LF","target": "node2.LF"}')
self.assertEqual(task_args_fnames[0], None)
self.assertEqual(task_args_fnames[1], None)
- @mock.patch('yardstick.cmd.commands.task.os.environ')
+ @mock.patch('yardstick.benchmark.core.task.os.environ')
def test_parse_suite_with_constraint_no_args(self, mock_environ):
SAMPLE_SCENARIO_PATH = "with_constraint_no_args_scenario_sample.yaml"
t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
@@ -117,15 +120,15 @@ class TaskCommandsTestCase(unittest.TestCase):
print ("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
self.assertEqual(task_files[0],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
self.assertEqual(task_files[1],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
self.assertEqual(task_args[0], None)
self.assertEqual(task_args[1], None)
self.assertEqual(task_args_fnames[0], None)
self.assertEqual(task_args_fnames[1], None)
- @mock.patch('yardstick.cmd.commands.task.os.environ')
+ @mock.patch('yardstick.benchmark.core.task.os.environ')
def test_parse_suite_with_constraint_with_args(self, mock_environ):
SAMPLE_SCENARIO_PATH = "with_constraint_with_args_scenario_sample.yaml"
t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
@@ -134,12 +137,12 @@ class TaskCommandsTestCase(unittest.TestCase):
print ("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
self.assertEqual(task_files[0],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
self.assertEqual(task_files[1],
- 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+ 'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
self.assertEqual(task_args[0], None)
self.assertEqual(task_args[1],
- '{"host": "node1.LF","target": "node2.LF"}')
+ '{"host": "node1.LF","target": "node2.LF"}')
self.assertEqual(task_args_fnames[0], None)
self.assertEqual(task_args_fnames[1], None)
@@ -148,3 +151,10 @@ class TaskCommandsTestCase(unittest.TestCase):
file_path = os.path.join(curr_path, filename)
return file_path
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/cmd/commands/test_testcase.py b/tests/unit/benchmark/core/test_testcase.py
index c55c367d0..6e0473cc1 100644
--- a/tests/unit/cmd/commands/test_testcase.py
+++ b/tests/unit/benchmark/core/test_testcase.py
@@ -11,26 +11,33 @@
# Unittest for yardstick.cmd.commands.testcase
-import mock
import unittest
-from yardstick.cmd.commands import testcase
-from yardstick.cmd.commands.testcase import TestcaseCommands
+from yardstick.benchmark.core import testcase
+
class Arg(object):
def __init__(self):
- self.casename=('opnfv_yardstick_tc001',)
+ self.casename = ('opnfv_yardstick_tc001',)
+
-class TestcaseCommandsUT(unittest.TestCase):
+class TestcaseUT(unittest.TestCase):
- def test_do_list(self):
- t = testcase.TestcaseCommands()
- result = t.do_list("")
+ def test_list_all(self):
+ t = testcase.Testcase()
+ result = t.list_all("")
self.assertEqual(result, True)
- def test_do_show(self):
- t = testcase.TestcaseCommands()
+ def test_show(self):
+ t = testcase.Testcase()
casename = Arg()
- result = t.do_show(casename)
+ result = t.show(casename)
self.assertEqual(result, True)
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/cmd/commands/with_constraint_no_args_scenario_sample.yaml b/tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml
index 8194a2361..8194a2361 100644
--- a/tests/unit/cmd/commands/with_constraint_no_args_scenario_sample.yaml
+++ b/tests/unit/benchmark/core/with_constraint_no_args_scenario_sample.yaml
diff --git a/tests/unit/cmd/commands/with_constraint_with_args_scenario_sample.yaml b/tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml
index 86c9b2800..86c9b2800 100644
--- a/tests/unit/cmd/commands/with_constraint_with_args_scenario_sample.yaml
+++ b/tests/unit/benchmark/core/with_constraint_with_args_scenario_sample.yaml
diff --git a/tests/unit/test_ssh.py b/tests/unit/test_ssh.py
index 88638a0a8..045ac0f1b 100644
--- a/tests/unit/test_ssh.py
+++ b/tests/unit/test_ssh.py
@@ -310,12 +310,38 @@ class SSHRunTestCase(unittest.TestCase):
@mock.patch("yardstick.ssh.open", create=True)
def test__put_file_shell(self, mock_open):
- self.test_client.run = mock.Mock()
- self.test_client._put_file_shell("localfile", "remotefile", 0o42)
+ with mock.patch.object(self.test_client, "run") as run_mock:
+ self.test_client._put_file_shell("localfile", "remotefile", 0o42)
+ run_mock.assert_called_once_with(
+ 'cat > "remotefile"&& chmod -- 042 "remotefile"',
+ stdin=mock_open.return_value.__enter__.return_value)
- self.test_client.run.assert_called_once_with(
- 'cat > "remotefile"&& chmod -- 042 "remotefile"',
- stdin=mock_open.return_value.__enter__.return_value)
+ @mock.patch("yardstick.ssh.open", create=True)
+ def test__put_file_shell_space(self, mock_open):
+ with mock.patch.object(self.test_client, "run") as run_mock:
+ self.test_client._put_file_shell("localfile",
+ "filename with space", 0o42)
+ run_mock.assert_called_once_with(
+ 'cat > "filename with space"&& chmod -- 042 "filename with '
+ 'space"',
+ stdin=mock_open.return_value.__enter__.return_value)
+
+ @mock.patch("yardstick.ssh.open", create=True)
+ def test__put_file_shell_tilde(self, mock_open):
+ with mock.patch.object(self.test_client, "run") as run_mock:
+ self.test_client._put_file_shell("localfile", "~/remotefile", 0o42)
+ run_mock.assert_called_once_with(
+ 'cat > ~/"remotefile"&& chmod -- 042 ~/"remotefile"',
+ stdin=mock_open.return_value.__enter__.return_value)
+
+ @mock.patch("yardstick.ssh.open", create=True)
+ def test__put_file_shell_tilde_spaces(self, mock_open):
+ with mock.patch.object(self.test_client, "run") as run_mock:
+ self.test_client._put_file_shell("localfile", "~/file with space",
+ 0o42)
+ run_mock.assert_called_once_with(
+ 'cat > ~/"file with space"&& chmod -- 042 ~/"file with space"',
+ stdin=mock_open.return_value.__enter__.return_value)
@mock.patch("yardstick.ssh.os.stat")
def test__put_file_sftp(self, mock_stat):