summaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorAlex Yang <yangyang1@zte.com.cn>2017-10-12 09:22:54 +0800
committerAlex Yang <yangyang1@zte.com.cn>2017-10-12 09:22:54 +0800
commit445a88ee72cb01d4fd6cba4a0bbc651c75429654 (patch)
tree2b13f10aa04eb6c3ada83b386d4aeb445f1420c8 /tests/unit
parent7fb4a641b9fd176dcad36d881bf5e11035392020 (diff)
Mock sleep() to accelerate the unit test
Change-Id: I664ba714ab4094754fa3d71587da8536555a02ce Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_daisy_server.py2
-rw-r--r--tests/unit/test_environment.py6
2 files changed, 8 insertions, 0 deletions
diff --git a/tests/unit/test_daisy_server.py b/tests/unit/test_daisy_server.py
index 97e0a1e2..65282e82 100644
--- a/tests/unit/test_daisy_server.py
+++ b/tests/unit/test_daisy_server.py
@@ -394,6 +394,7 @@ bin_file_path2 = os.path.join(WORKSPACE, bin_file_name)
@pytest.mark.parametrize('bin_file', [
(bin_file_path1),
(bin_file_path2)])
+@mock.patch('deploy.daisy_server.time.sleep')
@mock.patch.object(daisy_server.DaisyServer, 'delete_dir')
@mock.patch.object(daisy_server.DaisyServer, 'scp_put')
@mock.patch.object(daisy_server.DaisyServer, 'create_dir')
@@ -402,6 +403,7 @@ def test_prepare_files_DaisyServer(mock_update_config,
mock_create_dir,
mock_scp_put,
mock_delete_dir,
+ mock_sleep,
bin_file,
tmpdir):
DaisyServerInst = DaisyServer(daisy_server_info['name'],
diff --git a/tests/unit/test_environment.py b/tests/unit/test_environment.py
index dcd8b046..aed2c73c 100644
--- a/tests/unit/test_environment.py
+++ b/tests/unit/test_environment.py
@@ -244,6 +244,7 @@ def test_create_daisy_server_BareMetalEnvironment(mock_create_daisy_server_vm, m
tmpdir.remove()
+@mock.patch('deploy.environment.time.sleep')
@mock.patch.object(daisy_server.DaisyServer, 'prepare_cluster')
@mock.patch.object(environment.BareMetalEnvironment, 'reboot_nodes')
@mock.patch.object(daisy_server.DaisyServer, 'prepare_host_and_pxe')
@@ -253,6 +254,7 @@ def test_create_daisy_server_BareMetalEnvironment(mock_create_daisy_server_vm, m
def test_deploy_BareMetalEnvironment(mock_post_deploy, mock_check_openstack_installation,
mock_check_os_installation, mock_prepare_host_and_pxe,
mock_reboot_nodes, mock_prepare_cluster,
+ mock_sleep,
tmpdir):
work_dir = os.path.join(tmpdir.dirname, tmpdir.basename, work_dir_name)
storage_dir = os.path.join(tmpdir.dirname, tmpdir.basename, storage_dir_name)
@@ -439,12 +441,14 @@ def test_create_virtual_node_VirtualEnvironment(mock_create_virtual_disk, mock_c
tmpdir.remove()
+@mock.patch('deploy.environment.time.sleep')
@mock.patch('deploy.environment.create_virtual_network')
@mock.patch('deploy.environment.get_vm_mac_addresses')
@mock.patch.object(environment.VirtualEnvironment, 'create_virtual_node')
def test_create_nodes_VirtualEnvironment(mock_create_virtual_node,
mock_get_vm_mac_addresses,
mock_create_virtual_network,
+ mock_sleep,
tmpdir):
keepalived_net_name = 'daisy3'
work_dir = os.path.join(tmpdir.dirname, tmpdir.basename, work_dir_name)
@@ -538,6 +542,7 @@ def test_delete_old_environment_VirtualEnvironment(mock_delete_daisy_server,
tmpdir.remove()
+@mock.patch('deploy.environment.time.sleep')
@mock.patch.object(environment.DaisyServer, 'post_deploy')
@mock.patch.object(environment.DaisyServer, 'check_openstack_installation')
@mock.patch.object(environment.DaisyServer, 'check_os_installation')
@@ -553,6 +558,7 @@ def test_deploy_VirtualEnvironment(mock_create_nodes, mock_reboot_nodes,
mock_copy_new_deploy_config, mock_prepare_host_and_pxe,
mock_install_virtual_nodes, mock_check_os_installation,
mock_check_openstack_installation, mock_post_deploy,
+ mock_sleep,
tmpdir):
work_dir = os.path.join(tmpdir.dirname, tmpdir.basename, work_dir_name)
storage_dir = os.path.join(tmpdir.dirname, tmpdir.basename, storage_dir_name)