def test_remove_remote_dir_rsync(self, mock_execute, mock_mkdtemp): remotefs.RsyncDriver().remove_dir('host', 'dest', None, None) rsync_call_args = mock.call('rsync', '--archive', '--delete-excluded', '/tmp/Venus/', 'host:dest', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[0], rsync_call_args) rsync_call_args = mock.call('rsync', '--archive', '--delete', '--include', 'dest', '--exclude', '*', '/tmp/Venus/', 'host:', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[1], rsync_call_args) rm_call_args = mock.call('rm', '-rf', '/tmp/Venus') self.assertEqual(mock_execute.mock_calls[2], rm_call_args) self.assertEqual(3, mock_execute.call_count) self.assertEqual(1, mock_mkdtemp.call_count)
def test_create_remote_file_rsync(self, mock_execute, mock_mkdtemp): remotefs.RsyncDriver().create_file('host', 'dest_dir', None, None) mkdir_call_args = mock.call('mkdir', '-p', '/tmp/Mars/', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[0], mkdir_call_args) touch_call_args = mock.call('touch', '/tmp/Mars/dest_dir', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[1], touch_call_args) rsync_call_args = mock.call('rsync', '--archive', '--relative', '--no-implied-dirs', '/tmp/Mars/./dest_dir', 'host:/', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[2], rsync_call_args) rm_call_args = mock.call('rm', '-rf', '/tmp/Mars') self.assertEqual(mock_execute.mock_calls[3], rm_call_args) self.assertEqual(4, mock_execute.call_count) self.assertEqual(1, mock_mkdtemp.call_count)
def test_remote_copy_file_rsync_without_compression(self, mock_execute): remotefs.RsyncDriver().copy_file('1.2.3.4:/home/star_wars', '/home/favourite', None, None, compression=False) mock_execute.assert_called_once_with('rsync', '-r', '--sparse', '1.2.3.4:/home/star_wars', '/home/favourite', on_completion=None, on_execute=None)
def test_rsync_driver_ipv6(self, mock_mkdtemp): with mock.patch('nova.utils.execute') as mock_execute: remotefs.RsyncDriver().create_file('2600::', 'dest_dir', None, None) rsync_call_args = mock.call('rsync', '--archive', '--relative', '--no-implied-dirs', '/tmp/Saturn/./dest_dir', '[2600::]:/', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[2], rsync_call_args) with mock.patch('nova.utils.execute') as mock_execute: remotefs.RsyncDriver().create_dir('2600::', 'dest_dir', None, None) rsync_call_args = mock.call('rsync', '--archive', '--relative', '--no-implied-dirs', '/tmp/Saturn/./dest_dir', '[2600::]:/', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[1], rsync_call_args) with mock.patch('nova.utils.execute') as mock_execute: remotefs.RsyncDriver().remove_file('2600::', 'dest', None, None) rsync_call_args = mock.call('rsync', '--archive', '--delete', '--include', 'dest', '--exclude', '*', '/tmp/Saturn/', '[2600::]:', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[0], rsync_call_args) with mock.patch('nova.utils.execute') as mock_execute: remotefs.RsyncDriver().remove_dir('2600::', 'dest', None, None) rsync_call_args = mock.call('rsync', '--archive', '--delete-excluded', '/tmp/Saturn/', '[2600::]:dest', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[0], rsync_call_args) rsync_call_args = mock.call('rsync', '--archive', '--delete', '--include', 'dest', '--exclude', '*', '/tmp/Saturn/', '[2600::]:', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[1], rsync_call_args)
def test_remove_remote_file_rsync(self, mock_execute): remotefs.RsyncDriver().remove_file('host', 'dest', None, None) rsync_call_args = mock.call('rsync', '--archive', '--delete', '--include', 'dest', '--exclude', '*', mock.ANY, 'host:', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[0], rsync_call_args) self.assertEqual(1, mock_execute.call_count)
def test_create_remote_dir_rsync(self, mock_execute): remotefs.RsyncDriver().create_dir('host', 'dest_dir', None, None) mkdir_call_args = mock.call('mkdir', '-p', mock.ANY, on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[0], mkdir_call_args) rsync_call_args = mock.call('rsync', '--archive', '--relative', '--no-implied-dirs', mock.ANY, 'host:/', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[1], rsync_call_args) self.assertEqual(2, mock_execute.call_count)
def test_remove_remote_file_rsync(self, mock_execute, mock_mkdtemp): remotefs.RsyncDriver().remove_file('host', 'dest', None, None) rsync_call_args = mock.call('rsync', '--archive', '--delete', '--include', 'dest', '--exclude', '*', '/tmp/Mercury/', 'host-infra:', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[0], rsync_call_args) rm_call_args = mock.call('rm', '-rf', '/tmp/Mercury') self.assertEqual(mock_execute.mock_calls[1], rm_call_args) self.assertEqual(2, mock_execute.call_count) self.assertEqual(1, mock_mkdtemp.call_count)
def test_create_remote_dir_rsync(self, mock_execute, mock_mkdtemp): remotefs.RsyncDriver().create_dir('host', 'dest_dir', None, None) mkdir_call_args = mock.call('mkdir', '-p', '/tmp/Jupiter/dest_dir', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[0], mkdir_call_args) rsync_call_args = mock.call('rsync', '--archive', '--relative', '--no-implied-dirs', '/tmp/Jupiter/./dest_dir', 'host-infra:/', on_completion=None, on_execute=None) self.assertEqual(mock_execute.mock_calls[1], rsync_call_args) rm_call_args = mock.call('rm', '-rf', '/tmp/Jupiter') self.assertEqual(mock_execute.mock_calls[2], rm_call_args) self.assertEqual(3, mock_execute.call_count) self.assertEqual(1, mock_mkdtemp.call_count)