From 539405270b57a5ee7409a164a38b9fdb0b3624e7 Mon Sep 17 00:00:00 2001 From: Yujun Zhang Date: Thu, 17 Nov 2016 13:52:03 +0800 Subject: Architecture evolution skeleton - benchmarks will be driven by qtip.runner - qtip.runner is used by both qtip.cli and qtip.api - unit test for each module will be placed under tests/unit - functional tests will be moved to tests/functional - data as testing sample will be moved to tests/data NOTE: this patch moves files only, it may fails many tests. To be followed up in next step. JIRA: QTIP-148 Change-Id: I27e8169a74783970a1f7818456eb76a7311fb60c Signed-off-by: Yujun Zhang --- tests/unit/utils/args_handler_test.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/unit/utils/args_handler_test.py (limited to 'tests/unit/utils/args_handler_test.py') diff --git a/tests/unit/utils/args_handler_test.py b/tests/unit/utils/args_handler_test.py new file mode 100644 index 00000000..b67fd993 --- /dev/null +++ b/tests/unit/utils/args_handler_test.py @@ -0,0 +1,35 @@ +############################################################################## +# Copyright (c) 2016 ZTE Corp 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 +############################################################################## +import pytest +import mock +import qtip.utils.args_handler + + +class TestClass: + @pytest.mark.parametrize("test_input, expected", [ + (['fuel', '/home', 'benchmarks/test_plan/default/network/iperf_bm.yaml'], + ['fuel', '/home', "iperf", + [('1-server', ['10.20.0.23']), ('2-host', ['10.20.0.24'])], + "iperf_bm.yaml", + [('duration', 20), ('protocol', 'tcp'), ('bandwidthGbps', 10)], + [("10.20.0.24", [None]), ("10.20.0.23", [None])], {}]) + ]) + @mock.patch('qtip.utils.args_handler.Env_setup.call_ping_test') + @mock.patch('qtip.utils.args_handler.Env_setup.call_ssh_test') + @mock.patch('qtip.utils.args_handler.Env_setup.update_ansible') + @mock.patch('qtip.utils.args_handler.SpawnVM') + @mock.patch('qtip.utils.args_handler.Driver.drive_bench') + def test_prepare_and_run_benchmark_successful(self, mock_driver, mock_sqawn_vm, mock_env_setup_ping, + mock_env_setup_ssh, mock_update_ansible, test_input, expected): + mock_ips = mock.Mock(return_value=["10.20.0.23", "10.20.0.24"]) + qtip.utils.args_handler.Env_setup.fetch_compute_ips = mock_ips + qtip.utils.args_handler.prepare_and_run_benchmark(test_input[0], test_input[1], test_input[2]) + call = mock_driver.call_args + call_args, call_kwargs = call + assert sorted(map(sorted, call_args)) == sorted(map(sorted, expected)) -- cgit 1.2.3-korg