aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authortjuyinkanglin <14_ykl@tongji.edu.cn>2017-05-04 15:58:55 +0800
committerJing Lu <lvjing5@huawei.com>2017-05-04 12:59:21 +0000
commit1b267df54356da0cba66a33edaf68ee50ecee53d (patch)
tree6ee5b41fa486e747526bb4736f9578d32fcbb6ab /tests/unit
parent20f5b0a8580c0e8c659424bab434a0e30f3c88c1 (diff)
Bugfix: Local Openstack Operation in HA test frameworksdanube.2.RC1danube.2.0
JIRA: YARDSTICK-635 Change-Id: Ic27517714db9325e7a3b1ef623c49af61c36b2b5 Signed-off-by: tjuyinkanglin <14_ykl@tongji.edu.cn> (cherry picked from commit 2fb95fbb9380ea7ce92dcb32cd2f0789b9f91bdc)
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_util.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/unit/benchmark/scenarios/availability/test_util.py b/tests/unit/benchmark/scenarios/availability/test_util.py
new file mode 100644
index 000000000..bb0e6bc79
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/availability/test_util.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+##############################################################################
+# Copyright (c) 2016 Kanglin Yin and others
+# 14_ykl@tongji.edu.cn
+# 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.availability.utils
+
+import mock
+import unittest
+
+from yardstick.benchmark.scenarios.availability import util
+
+@mock.patch('yardstick.benchmark.scenarios.availability.util.subprocess')
+class ExecuteShellTestCase(unittest.TestCase):
+
+ def test__fun_execute_shell_command_successful(self, mock_subprocess):
+ cmd = "env"
+ mock_subprocess.check_output.return_value = (0, 'unittest')
+ exitcode, output = util.execute_shell_command(cmd)
+ self.assertEqual(exitcode, 0)
+
+ def test__fun_execute_shell_command_fail_cmd_exception(self, mock_subprocess):
+ cmd = "env"
+ mock_subprocess.check_output.side_effect = RuntimeError
+ exitcode, output = util.execute_shell_command(cmd)
+ self.assertEqual(exitcode, -1)