aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/benchmark/scenarios')
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_qemumigrate.py2
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_check_connectivity.py84
-rw-r--r--tests/unit/benchmark/scenarios/test_base.py53
3 files changed, 138 insertions, 1 deletions
diff --git a/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py b/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
index 9514729ba..1f0ff3c29 100644
--- a/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
+++ b/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
@@ -142,7 +142,7 @@ class QemuMigrateTestCase(unittest.TestCase):
q.setup()
sample_output = '{"totaltime": 15, "downtime": 2, "setuptime": 1}'
-
+
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
self.assertRaises(AssertionError, q.run, result)
diff --git a/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py b/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py
new file mode 100644
index 000000000..1fb2f89ca
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/lib/test_check_connectivity.py
@@ -0,0 +1,84 @@
+##############################################################################
+# 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
+##############################################################################
+
+# Unittest for yardstick.benchmark.scenarios.lib.check_connectivity.CheckConnectivity
+
+from __future__ import absolute_import
+
+import mock
+import unittest
+
+from yardstick.benchmark.scenarios.lib import check_connectivity
+
+
+class CheckConnectivityTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.ctx = {
+ 'host': {
+ 'ip': '172.16.0.137',
+ 'user': 'root',
+ 'key_filename': 'mykey.key',
+ 'ssh_port': '22'
+ },
+ 'target': {
+ 'ipaddr': '172.16.0.138'
+ }
+ }
+
+ @mock.patch('yardstick.benchmark.scenarios.lib.check_connectivity.ssh')
+ def test_check_connectivity(self, mock_ssh):
+
+ args = {
+ 'options': {'src_ip_addr': '192.168.23.2',
+ 'dest_ip_addr': '192.168.23.10',
+ 'ssh_user': 'root',
+ 'ssh_passwd': 'root',
+ 'ssh_port': '22',
+ 'ssh_timeout': 600,
+ 'ping_parameter': "-s 2048"
+ },
+ 'sla': {'status': 'True',
+ 'action': 'assert'}
+ }
+
+ result = {}
+
+ obj = check_connectivity.CheckConnectivity(args, {})
+ obj.setup()
+ mock_ssh.SSH.execute.return_value = (0, '100', '')
+
+
+ @mock.patch('yardstick.benchmark.scenarios.lib.check_connectivity.ssh')
+ def test_check_connectivity_key(self, mock_ssh):
+
+ args = {
+ 'options': {'ssh_user': 'root',
+ 'ssh_key': '/root/.ssh/id_rsa',
+ 'ssh_port': '22',
+ 'ssh_timeout': 600,
+ 'ping_parameter': "-s 2048"
+ },
+ 'sla': {'status': 'True',
+ 'action': 'assert'}
+ }
+
+ result = {}
+
+ obj = check_connectivity.CheckConnectivity(args, self.ctx)
+ obj.setup()
+
+ mock_ssh.SSH.execute.return_value = (0, '100', '')
+
+def main():
+ unittest.main()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/benchmark/scenarios/test_base.py b/tests/unit/benchmark/scenarios/test_base.py
new file mode 100644
index 000000000..78e342978
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/test_base.py
@@ -0,0 +1,53 @@
+# Copyright 2017: Intel Ltd.
+# 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.
+
+import unittest
+
+from yardstick.benchmark.scenarios import base
+
+
+class ScenarioTestCase(unittest.TestCase):
+
+ def test_get_scenario_type(self):
+ scenario_type = 'dummy scenario'
+
+ class DummyScenario(base.Scenario):
+ __scenario_type__ = scenario_type
+
+ self.assertEqual(scenario_type, DummyScenario.get_scenario_type())
+
+ def test_get_scenario_type_not_defined(self):
+ class DummyScenario(base.Scenario):
+ pass
+
+ self.assertEqual(str(None), DummyScenario.get_scenario_type())
+
+ def test_get_description(self):
+ docstring = """First line
+ Second line
+ Third line
+ """
+
+ class DummyScenario(base.Scenario):
+ __doc__ = docstring
+
+ self.assertEqual(docstring.splitlines()[0],
+ DummyScenario.get_description())
+
+ def test_get_description_empty(self):
+ class DummyScenario(base.Scenario):
+ pass
+
+ self.assertEqual(str(None), DummyScenario.get_description())