aboutsummaryrefslogtreecommitdiffstats
path: root/tests/env_setup_test.py
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2016-11-17 13:52:03 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2016-11-21 10:36:52 +0800
commit539405270b57a5ee7409a164a38b9fdb0b3624e7 (patch)
treec8f9a6fd5d61b8060802ec06bba5f9c94fe66bcb /tests/env_setup_test.py
parentcaa171ac3796bbeacfdac0939713eedfad85e3c3 (diff)
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 <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'tests/env_setup_test.py')
-rw-r--r--tests/env_setup_test.py106
1 files changed, 0 insertions, 106 deletions
diff --git a/tests/env_setup_test.py b/tests/env_setup_test.py
deleted file mode 100644
index e28c6a18..00000000
--- a/tests/env_setup_test.py
+++ /dev/null
@@ -1,106 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 ZTE 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 filecmp
-from qtip.utils.env_setup import Env_setup
-import mock
-
-
-class TestClass:
-
- @pytest.mark.parametrize("test_input, expected", [
- ("tests/test_case/bm_with_proxy.yaml", ["dhrystone",
- {},
- [],
- {'http_proxy': 'http://10.20.0.1:8118',
- 'https_proxy': 'http://10.20.0.1:8118',
- 'no_proxy': 'localhost,127.0.0.1,10.20.*,192.168.*'}]),
- ("tests/test_case/bm_without_proxy.yaml", ["dhrystone",
- {},
- [],
- {}]),
- ("tests/test_case/vm.yaml", ["iperf",
- {'availability_zone': ['compute1', 'compute1'],
- 'OS_image': ['QTIP_CentOS', 'QTIP_CentOS'],
- 'public_network': ['admin-floating_net', 'admin-floating_net'],
- 'flavor': ['m1.large', 'm1.large'],
- 'role': ['1-server', '2-host']},
- [('duration', 20), ('protocol', 'tcp'), ('bandwidthGbps', 0)],
- {'http_proxy': 'http://10.20.0.1:8118',
- 'https_proxy': 'http://10.20.0.1:8118',
- 'no_proxy': 'localhost,127.0.0.1,10.20.*,192.168.*'}])
- ])
- def test_parse_success(self, test_input, expected):
- test_class = Env_setup()
- mock_ips = mock.Mock(return_value=["10.20.0.28", "10.20.0.29"])
- test_class.fetch_compute_ips = mock_ips
- benchmark, vm_para, details, proxy = \
- test_class.parse(test_input)
- assert benchmark == expected[0]
- assert vm_para == expected[1]
- assert sorted(details) == sorted(expected[2])
- assert proxy == expected[3]
-
- def test_parse_vm_error(self):
- test_class = Env_setup()
- mock_ips = mock.Mock(return_value=["10.20.0.28", "10.20.0.29"])
- test_class.fetch_compute_ips = mock_ips
- with pytest.raises(KeyError) as excinfo:
- test_class.parse("tests/test_case/vm_error.yaml")
- assert "benchmark" in str(excinfo.value)
-
- def test_update_ansible(self):
- test_class = Env_setup()
- mock_ips = mock.Mock(return_value=["10.20.0.28", "10.20.0.29"])
- test_class.fetch_compute_ips = mock_ips
- test_class.parse("tests/test_case/bm_without_proxy.yaml")
- test_class.update_ansible()
- result = filecmp.cmp('tests/output/hosts', 'config/hosts')
- assert result
-
- def test_ping(self, capfd):
- test_class = Env_setup()
- mock_ips = mock.Mock(return_value=["127.0.0.1", "10.20.0.29"])
- test_class.fetch_compute_ips = mock_ips
- test_class.parse("tests/test_case/bm_ping.yaml")
- test_class.call_ping_test()
- resout, reserr = capfd.readouterr()
- assert '127.0.0.1 is UP' in resout
-
- def test_check_machine_ips_without_ip(self):
- test_class = Env_setup()
- mock_ips = mock.Mock(return_value=["10.20.0.28", "10.20.0.29"])
- test_class.fetch_compute_ips = mock_ips
- inputs = {"machine_1": {"ip": "", "pw": "", "role": "host"},
- "machine_2": {"ip": "", "pw": "", "role": "host"}}
- test_class.check_machine_ips(inputs)
- assert inputs["machine_1"]['ip'] in ["10.20.0.28", "10.20.0.29"]
- assert inputs["machine_2"]['ip'] in ["10.20.0.28", "10.20.0.29"]
- assert inputs["machine_1"]['ip'] != inputs["machine_2"]['ip']
-
- def test_check_machine_ips_with_ip(self):
- test_class = Env_setup()
- mock_ips = mock.Mock(return_value=["10.20.0.28", "10.20.0.29"])
- test_class.fetch_compute_ips = mock_ips
- inputs = {"machine_1": {"ip": "10.20.0.28", "pw": "", "role": "host"},
- "machine_2": {"ip": "10.20.0.29", "pw": "", "role": "host"}}
- test_class.check_machine_ips(inputs)
- assert inputs["machine_1"]['ip'] in ["10.20.0.28", "10.20.0.29"]
- assert inputs["machine_2"]['ip'] in ["10.20.0.28", "10.20.0.29"]
- assert inputs["machine_1"]['ip'] != inputs["machine_2"]['ip']
-
- def test_check_machine_ips_with_invalid_ip(self):
- test_class = Env_setup()
- mock_ips = mock.Mock(return_value=["10.20.0.28", "10.20.0.29"])
- test_class.fetch_compute_ips = mock_ips
- inputs = {"machine_1": {"ip": "10.20.0.3", "pw": "", "role": "host"},
- "machine_2": {"ip": "10.20.0.4", "pw": "", "role": "host"}}
- with pytest.raises(RuntimeError):
- test_class.check_machine_ips(inputs)