diff options
-rw-r--r-- | func/__init__.py | 0 | ||||
-rw-r--r-- | qtip.py | 3 | ||||
-rw-r--r-- | restful_server/qtip_server.py | 2 | ||||
-rw-r--r-- | tests/ansible_api_test.py | 2 | ||||
-rw-r--r-- | tests/args_handler_test.py | 16 | ||||
-rw-r--r-- | tests/create_zones_test.py | 16 | ||||
-rw-r--r-- | tests/data/test.retry | 1 | ||||
-rw-r--r-- | tests/driver_test.py | 6 | ||||
-rw-r--r-- | tests/env_setup_test.py | 4 | ||||
-rw-r--r-- | tests/spawn_vm_test.py | 10 | ||||
-rw-r--r-- | utils/ansible_api.py (renamed from func/ansible_api.py) | 4 | ||||
-rw-r--r-- | utils/args_handler.py (renamed from func/args_handler.py) | 6 | ||||
-rw-r--r-- | utils/cli.py (renamed from func/cli.py) | 2 | ||||
-rw-r--r-- | utils/create_zones.py (renamed from func/create_zones.py) | 2 | ||||
-rw-r--r-- | utils/driver.py (renamed from func/driver.py) | 3 | ||||
-rw-r--r-- | utils/env_setup.py (renamed from func/env_setup.py) | 3 | ||||
-rw-r--r-- | utils/spawn_vm.py (renamed from func/spawn_vm.py) | 6 |
17 files changed, 41 insertions, 45 deletions
diff --git a/func/__init__.py b/func/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/func/__init__.py +++ /dev/null @@ -1,12 +1,13 @@ ############################################################################## # Copyright (c) 2015 Dell Inc and others. +# 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 ############################################################################## -from func.cli import Cli +from utils.cli import Cli def main(): diff --git a/restful_server/qtip_server.py b/restful_server/qtip_server.py index 7b55020a..537b2c05 100644 --- a/restful_server/qtip_server.py +++ b/restful_server/qtip_server.py @@ -12,7 +12,7 @@ from flask_restful_swagger import swagger import threading from copy import copy import db -import func.args_handler as args_handler +import utils.args_handler as args_handler import restful_server.result_handler as result_handler diff --git a/tests/ansible_api_test.py b/tests/ansible_api_test.py index 613d5f7e..a259c422 100644 --- a/tests/ansible_api_test.py +++ b/tests/ansible_api_test.py @@ -6,7 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -from func.ansible_api import AnsibleApi +from utils.ansible_api import AnsibleApi class TestClass: diff --git a/tests/args_handler_test.py b/tests/args_handler_test.py index a5c2223f..625a42f5 100644 --- a/tests/args_handler_test.py +++ b/tests/args_handler_test.py @@ -8,7 +8,7 @@ ############################################################################## import pytest import mock -import func.args_handler +import utils.args_handler class TestClass: @@ -20,16 +20,16 @@ class TestClass: [('duration', 20), ('protocol', 'tcp'), ('bandwidthGbps', 10)], [("10.20.0.24", [None]), ("10.20.0.23", [None])], {}]) ]) - @mock.patch('func.args_handler.Env_setup.call_ping_test') - @mock.patch('func.args_handler.Env_setup.call_ssh_test') - @mock.patch('func.args_handler.Env_setup.update_ansible') - @mock.patch('func.args_handler.SpawnVM') - @mock.patch('func.args_handler.Driver.drive_bench') + @mock.patch('utils.args_handler.Env_setup.call_ping_test') + @mock.patch('utils.args_handler.Env_setup.call_ssh_test') + @mock.patch('utils.args_handler.Env_setup.update_ansible') + @mock.patch('utils.args_handler.SpawnVM') + @mock.patch('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"]) - func.args_handler.Env_setup.fetch_compute_ips = mock_ips - func.args_handler.prepare_and_run_benchmark(test_input[0], test_input[1], test_input[2]) + utils.args_handler.Env_setup.fetch_compute_ips = mock_ips + 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)) diff --git a/tests/create_zones_test.py b/tests/create_zones_test.py index 39e71c17..0f57581d 100644 --- a/tests/create_zones_test.py +++ b/tests/create_zones_test.py @@ -2,7 +2,7 @@ import pytest import mock from mock import Mock, MagicMock import os -from func.create_zones import AvailabilityZone +from utils.create_zones import AvailabilityZone return_list = [] @@ -61,9 +61,9 @@ class TestClass: ['create:compute1:compute1', 'add_host:compute1:10.20.0.4']), ]) - @mock.patch('func.create_zones.client', autospec=True) - @mock.patch('func.create_zones.v2', autospec=True) - @mock.patch('func.create_zones.session') + @mock.patch('utils.create_zones.client', autospec=True) + @mock.patch('utils.create_zones.v2', autospec=True) + @mock.patch('utils.create_zones.session') def test_create_zones_success(self, mock_keystone_session, mock_keystone_v2, mock_nova_client, test_input, expected, capfd): nova_obj = NovaMock() mock_nova_client.Client.return_value = nova_obj() @@ -73,7 +73,7 @@ class TestClass: 'OS_TENANT_NAME': 'admin'}) k.start() azone = AvailabilityZone() - azone.create_agg(test_input) + azone.create_aggs(test_input) k.stop() resout, reserr = capfd.readouterr() for x in expected: @@ -88,9 +88,9 @@ class TestClass: ([], []), ]) - @mock.patch('func.create_zones.client', autospec=True) - @mock.patch('func.create_zones.v2', autospec=True) - @mock.patch('func.create_zones.session') + @mock.patch('utils.create_zones.client', autospec=True) + @mock.patch('utils.create_zones.v2', autospec=True) + @mock.patch('utils.create_zones.session') def test_clean_all_aggregates(self, mock_keystone_session, mock_keystone_v2, mock_nova_client, test_input, expected, capfd): global return_list return_list = test_input diff --git a/tests/data/test.retry b/tests/data/test.retry new file mode 100644 index 00000000..7b9ad531 --- /dev/null +++ b/tests/data/test.retry @@ -0,0 +1 @@ +127.0.0.1 diff --git a/tests/driver_test.py b/tests/driver_test.py index 41a7dee4..d3025bd2 100644 --- a/tests/driver_test.py +++ b/tests/driver_test.py @@ -1,6 +1,6 @@ import pytest import mock -from func.driver import Driver +from utils.driver import Driver from os.path import expanduser HOME_DIR = expanduser('~') @@ -65,8 +65,8 @@ class TestClass: 'bandwidthGbps': 0, "role": "2-host"}]) ]) - @mock.patch('func.driver.AnsibleApi.execute_playbook') - @mock.patch('func.driver.AnsibleApi.get_detail_playbook_stats') + @mock.patch('utils.driver.AnsibleApi.execute_playbook') + @mock.patch('utils.driver.AnsibleApi.get_detail_playbook_stats') def test_driver_success(self, mock_stats, mock_ansible, test_input, expected): mock_ansible.return_value = True mock_stats.return_value = [(u'10.20.6.14', {'unreachable': 0, diff --git a/tests/env_setup_test.py b/tests/env_setup_test.py index a0bbf640..07f426e1 100644 --- a/tests/env_setup_test.py +++ b/tests/env_setup_test.py @@ -9,7 +9,7 @@ import pytest import filecmp -from func.env_setup import Env_setup +from utils.env_setup import Env_setup import mock @@ -38,8 +38,6 @@ class TestClass: 'no_proxy': 'localhost,127.0.0.1,10.20.*,192.168.*'}]) ]) def test_parse_success(self, test_input, expected): - print (test_input) - print (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 diff --git a/tests/spawn_vm_test.py b/tests/spawn_vm_test.py index fca7dd00..c0d87cac 100644 --- a/tests/spawn_vm_test.py +++ b/tests/spawn_vm_test.py @@ -2,7 +2,7 @@ import pytest import mock from mock import Mock, MagicMock import os -from func.spawn_vm import SpawnVM +from utils.spawn_vm import SpawnVM class KeystoneMock(MagicMock): @@ -40,10 +40,10 @@ class TestClass: 'role': ['1-server', '2-host']}, [('172.10.0.154', '')]), ]) - @mock.patch('func.spawn_vm.Env_setup') - @mock.patch('func.spawn_vm.AvailabilityZone') - @mock.patch('func.spawn_vm.keystoneclient.v2_0', autospec=True) - @mock.patch('func.spawn_vm.heatclient.client', autospec=True) + @mock.patch('utils.spawn_vm.Env_setup') + @mock.patch('utils.spawn_vm.AvailabilityZone') + @mock.patch('utils.spawn_vm.keystoneclient.v2_0', autospec=True) + @mock.patch('utils.spawn_vm.heatclient.client', autospec=True) def test_create_zones_success(self, mock_heat, mock_keystone, mock_zone, mock_setup, test_input, expected): open('./config/QtipKey.pub', 'a').close() diff --git a/func/ansible_api.py b/utils/ansible_api.py index 2f02a62e..9e1d249e 100644 --- a/func/ansible_api.py +++ b/utils/ansible_api.py @@ -8,13 +8,11 @@ ############################################################################## import os from collections import namedtuple - from ansible.executor.playbook_executor import PlaybookExecutor from ansible.inventory import Inventory from ansible.parsing.dataloader import DataLoader from ansible.vars import VariableManager - -from utils import logger_utils +import logger_utils logger = logger_utils.QtipLogger('ansible_api').get diff --git a/func/args_handler.py b/utils/args_handler.py index 2eb79e29..879fd204 100644 --- a/func/args_handler.py +++ b/utils/args_handler.py @@ -9,9 +9,9 @@ import os from operator import add import simplejson as json -from func.env_setup import Env_setup -from func.spawn_vm import SpawnVM -from func.driver import Driver +from env_setup import Env_setup +from spawn_vm import SpawnVM +from driver import Driver def get_files_in_suite(suite_name, case_type='all'): diff --git a/func/cli.py b/utils/cli.py index cea55749..def70061 100644 --- a/func/cli.py +++ b/utils/cli.py @@ -11,7 +11,7 @@ import sys import os import args_handler import argparse -from utils import logger_utils +import logger_utils logger = logger_utils.QtipLogger('cli').get diff --git a/func/create_zones.py b/utils/create_zones.py index 30b6ef57..5e378c83 100644 --- a/func/create_zones.py +++ b/utils/create_zones.py @@ -11,7 +11,7 @@ from keystoneclient import session from novaclient import client
import os
import random
-from utils import logger_utils
+import logger_utils
logger = logger_utils.QtipLogger('create_zones').get
diff --git a/func/driver.py b/utils/driver.py index c765728b..9894e0f5 100644 --- a/func/driver.py +++ b/utils/driver.py @@ -6,12 +6,11 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -from utils import logger_utils +import logger_utils from operator import add from ansible_api import AnsibleApi from os.path import expanduser - logger = logger_utils.QtipLogger('driver').get diff --git a/func/env_setup.py b/utils/env_setup.py index e9f9cd2a..7bbedfcf 100644 --- a/func/env_setup.py +++ b/utils/env_setup.py @@ -6,7 +6,6 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - import os import random import socket @@ -16,7 +15,7 @@ from collections import defaultdict from os.path import expanduser import paramiko import yaml -from utils import logger_utils +import logger_utils logger = logger_utils.QtipLogger('env_setup').get diff --git a/func/spawn_vm.py b/utils/spawn_vm.py index 0a24d7a4..f38c9a3a 100644 --- a/func/spawn_vm.py +++ b/utils/spawn_vm.py @@ -12,9 +12,9 @@ import yaml import heatclient.client
import keystoneclient
import time
-from func.env_setup import Env_setup
-from func.create_zones import AvailabilityZone
-from utils import logger_utils
+from env_setup import Env_setup
+from create_zones import AvailabilityZone
+import logger_utils
logger = logger_utils.QtipLogger('spawn_vm').get
|