summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorZhijiang Hu <hu.zhijiang@zte.com.cn>2017-10-12 03:15:37 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-10-12 03:15:37 +0000
commit164ffc1780a6ffd2634533849f67ed640fb0745b (patch)
tree32282a7f9062a19ae4cde2d0166b765b44f6dcc6 /tests
parentefc34c487858d05e4ae92e90a931497548b6bec7 (diff)
parent445a88ee72cb01d4fd6cba4a0bbc651c75429654 (diff)
Merge "Mock sleep() to accelerate the unit test"
Diffstat (limited to 'tests')
-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)