-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YDA-6082: specify vault resource on copy-to-vault
If a vault resource has been configured, use it when copying data from a research collection to the vault collection. Also use configuration for number of threads when copying data.
- Loading branch information
Showing
5 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Unit tests for the vault functions""" | ||
|
||
__copyright__ = 'Copyright (c) 2023-2024, Utrecht University' | ||
__license__ = 'GPLv3, see LICENSE' | ||
|
||
import sys | ||
from unittest import TestCase | ||
|
||
sys.path.append('..') | ||
|
||
from vault_utils import get_copy_folder_to_vault_irsync_command | ||
|
||
|
||
class VaultTest(TestCase): | ||
|
||
def test_get_copy_folder_to_vault_irsync_command_with_vault_resc(self): | ||
output = get_copy_folder_to_vault_irsync_command("/zoneName/home/research-foo/abc", "/zoneName/home/vault-foo/abc", "vaultResc", True) | ||
self.assertEqual(output, ["irsync", "-rK", "-R", "vaultResc", "i:/zoneName/home/research-foo/abc/", "i:/zoneName/home/vault-foo/abc/original"]) | ||
|
||
def test_get_copy_folder_to_vault_irsync_command_without_vault_resc(self): | ||
output = get_copy_folder_to_vault_irsync_command("/zoneName/home/research-foo/abc", "/zoneName/home/vault-foo/abc", None, True) | ||
self.assertEqual(output, ["irsync", "-rK", "i:/zoneName/home/research-foo/abc/", "i:/zoneName/home/vault-foo/abc/original"]) | ||
|
||
def test_get_copy_folder_to_vault_irsync_command_no_multithreading(self): | ||
output = get_copy_folder_to_vault_irsync_command("/zoneName/home/research-foo/abc", "/zoneName/home/vault-foo/abc", "vaultResc", False) | ||
self.assertEqual(output, ["irsync", "-rK", "-R", "vaultResc", "-N", "0", "i:/zoneName/home/research-foo/abc/", "i:/zoneName/home/vault-foo/abc/original"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Utility functions for vault module.""" | ||
|
||
__copyright__ = 'Copyright (c) 2019-2024, Utrecht University' | ||
__license__ = 'GPLv3, see LICENSE' | ||
|
||
|
||
def get_copy_folder_to_vault_irsync_command(coll, target, vault_resource, multi_threading): | ||
"""Internal function to determine rsync command for copy-to-vault | ||
:param coll: source collection | ||
:param target: target collection | ||
:param vault_resource: resource to store vault data on (can be None) | ||
:param multi_threading: if set to false, disable multi threading, | ||
otherwise use server default | ||
:returns: irsync command with parameters in list format | ||
""" | ||
|
||
irsync_command = ["irsync", "-rK"] | ||
|
||
if vault_resource is not None: | ||
irsync_command.extend(["-R", vault_resource]) | ||
|
||
if not multi_threading: | ||
irsync_command.extend(["-N", "0"]) # 0 means no multi threading | ||
|
||
irsync_command.extend(["i:{}/".format(coll), "i:{}/original".format(target)]) | ||
return irsync_command |