From fc6eddef3d27cf51b3f6da3a523080e55c6bfb70 Mon Sep 17 00:00:00 2001
From: chenjiankun <chenjiankun1@huawei.com>
Date: Thu, 25 May 2017 09:19:04 +0000
Subject: Pass parameters between scenarios

JIRA: YARDSTICK-641

Allowing parameters to pass between scenarios so that the one test case
can be combination of several scenarios.

Change-Id: I55a00855e77d5b719a27a069a3ea195d6bbd0ef8
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
---
 tests/unit/benchmark/core/test_task.py   | 28 ++++++++++++++++++++
 tests/unit/benchmark/runner/__init__.py  |  0
 tests/unit/benchmark/runner/test_base.py | 45 ++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+)
 create mode 100644 tests/unit/benchmark/runner/__init__.py
 create mode 100644 tests/unit/benchmark/runner/test_base.py

(limited to 'tests/unit/benchmark')

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
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()
-- 
cgit