# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from utils.ansible_api import AnsibleApi
+from qtip.utils.ansible_api import AnsibleApi
class TestClass:
##############################################################################
import pytest
import mock
-import utils.args_handler
+import qtip.utils.args_handler
class TestClass:
[('duration', 20), ('protocol', 'tcp'), ('bandwidthGbps', 10)],
[("10.20.0.24", [None]), ("10.20.0.23", [None])], {}])
])
- @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')
+ @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"])
- 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])
+ 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))
import pytest
import mock
import os
-from func.cli import Cli
+from qtip.utils.cli import Cli
from os.path import expanduser
(['-l',
'zte',
'-f',
- 'compute'], "You have specified a lab that is not present under test_plan"),
+ 'compute'], "You have specified a lab that is not present under benchmarks/test_plan"),
(['-l',
'default',
'-f',
'storage'], [('fuel', '/home', 'benchmarks/test_plan/default/storage/fio_bm.yaml'),
('fuel', '/home', 'benchmarks/test_plan/default/storage/fio_vm.yaml')])
])
- @mock.patch('func.cli.args_handler.prepare_and_run_benchmark')
+ @mock.patch('qtip.utils.cli.args_handler.prepare_and_run_benchmark')
def test_cli_successful(self, mock_args_handler, test_input, expected):
k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel', 'PWD': '/home'})
k.start()
import mock
from mock import Mock, MagicMock
import os
-from utils.create_zones import AvailabilityZone
+from qtip.utils.create_zones import AvailabilityZone
return_list = []
'add_host:compute1:10.20.0.4',
'create:compute2:compute2',
'add_host:compute2:10.20.0.5']),
- (['compute1', 'compute1'],
+ (['compute1'],
['create:compute1:compute1',
'add_host:compute1:10.20.0.4']),
])
- @mock.patch('utils.create_zones.client', autospec=True)
- @mock.patch('utils.create_zones.v2', autospec=True)
- @mock.patch('utils.create_zones.session')
+ @mock.patch('qtip.utils.create_zones.client', autospec=True)
+ @mock.patch('qtip.utils.create_zones.v2', autospec=True)
+ @mock.patch('qtip.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()
([],
[]),
])
- @mock.patch('utils.create_zones.client', autospec=True)
- @mock.patch('utils.create_zones.v2', autospec=True)
- @mock.patch('utils.create_zones.session')
+ @mock.patch('qtip.utils.create_zones.client', autospec=True)
+ @mock.patch('qtip.utils.create_zones.v2', autospec=True)
+ @mock.patch('qtip.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
import pytest
import mock
-from utils.driver import Driver
+from qtip.utils.driver import Driver
from os.path import expanduser
HOME_DIR = expanduser('~')
'bandwidthGbps': 0,
"role": "2-host"}])
])
- @mock.patch('utils.driver.AnsibleApi.execute_playbook')
- @mock.patch('utils.driver.AnsibleApi.get_detail_playbook_stats')
+ @mock.patch('qtip.utils.driver.AnsibleApi.execute_playbook')
+ @mock.patch('qtip.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,
import pytest
import filecmp
-from utils.env_setup import Env_setup
+from qtip.utils.env_setup import Env_setup
import mock
-import restful_server.qtip_server as server
+import qtip.api.qtip_server as server
import pytest
import json
import mock
'state_detail': [{u'state': u'finished', u'benchmark': u'dhrystone_vm.yaml'}],
'result': 0})
])
- @mock.patch('restful_server.qtip_server.args_handler.prepare_and_run_benchmark')
+ @mock.patch('qtip.api.qtip_server.args_handler.prepare_and_run_benchmark')
def test_post_get_delete_job_successful(self, mock_args_handler, app_client, body, expected):
mock_args_handler.return_value = {'result': 0,
'detail': {'host': [(u'10.20.6.14', {'unreachable': 0,
['job_id',
'It already has one job running now!'])
])
- @mock.patch('restful_server.qtip_server.args_handler.prepare_and_run_benchmark',
+ @mock.patch('qtip.api.qtip_server.args_handler.prepare_and_run_benchmark',
side_effect=[side_effect_sleep(0.5), side_effect_pass])
def test_post_two_jobs_unsuccessful(self, mock_args_hanler, app_client, body, expected):
reply_1 = app_client.post("/api/v1.0/jobs", data=body[0])
import mock
from mock import Mock, MagicMock
import os
-from utils.spawn_vm import SpawnVM
+from qtip.utils.spawn_vm import SpawnVM
class KeystoneMock(MagicMock):
'role': ['1-server', '2-host']},
[('172.10.0.154', '')]),
])
- @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)
+ @mock.patch('qtip.utils.spawn_vm.Env_setup')
+ @mock.patch('qtip.utils.spawn_vm.AvailabilityZone')
+ @mock.patch('qtip.utils.spawn_vm.keystoneclient.v2_0', autospec=True)
+ @mock.patch('qtip.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()