forked from rucio/rucio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch.patch
196 lines (179 loc) · 7.34 KB
/
patch.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
From ee0990275bc1939f6017c714fcb0b4fb85477a2f Mon Sep 17 00:00:00 2001
From: rdimaio <[email protected]>
Date: Fri, 25 Oct 2024 18:52:39 +0200
Subject: [PATCH] Transfers: Add TestCollocationPlugin to FTS3 plugin tests
---
tests/test_transfer_plugins.py | 159 ++++++++++++++++++---------------
1 file changed, 86 insertions(+), 73 deletions(-)
diff --git a/tests/test_transfer_plugins.py b/tests/test_transfer_plugins.py
index 1de5be0257..0c40d45b04 100644
--- a/tests/test_transfer_plugins.py
+++ b/tests/test_transfer_plugins.py
@@ -25,6 +25,7 @@
from rucio.core.transfer import ProtocolFactory, build_transfer_paths
from rucio.db.sqla.session import get_session
from rucio.transfertool.fts3 import FTS3Transfertool, build_job_params
+from rucio.transfertool.fts3_plugins import FTS3TapeMetadataPlugin
mock_session = get_session()
@@ -154,89 +155,101 @@ def test_activity_missing(file_config_mock, did_factory, rse_factory, root_accou
assert expected_scheduling_hints == generated_scheduling_hints
[email protected]("file_config_mock", [
- {
- "overrides": [
- ("transfers", "fts3tape_metadata_plugins", "test")
- ]
- }
-], indirect=True)
-def test_collocation_hints(file_config_mock, did_factory, rse_factory, root_account):
- """For a mock collocation algorithm, it can produce the 4 levels of hints required for each did"""
+class TestCollocationHints:
+ class TestCollocationPlugin(FTS3TapeMetadataPlugin):
+ def __init__(self) -> None:
+ self.register(
+ 'test',
+ func=lambda x: self._test_collocation(x))
+ super().__init__('test')
- mock_did = did_factory.random_file_did()
- transfer_path = _make_transfer_path(mock_did, rse_factory, root_account)
+ def _test_collocation(self, hints: dict[str, str]) -> dict[str, dict]:
+ return {"collocation_hints": {"0": "", "1": "", "2": "", "3": ""}}
- # Mock Transfer Tool
- fts3_tool = FTS3Transfertool(TEST_FTS_HOST)
+ TestCollocationPlugin()
- job_params = build_job_params(
- transfer_path=transfer_path,
- bring_online=None,
- default_lifetime=None,
- archive_timeout_override=None,
- max_time_in_queue=None,
- logger=logging.log,
- )
-
- # Get the job params used for each transfer
- job_params = fts3_tool._file_from_transfer(transfer_path[0], job_params)
-
- expected_collocation_hints = {
- "collocation_hints": {
- "0": "",
- "1": "",
- "2": "",
- "3": "",
+ @pytest.mark.parametrize("file_config_mock", [
+ {
+ "overrides": [
+ ("transfers", "fts3tape_metadata_plugins", "test")
+ ]
}
- }
-
- assert "archive_metadata" in job_params
- generated_collocation_hints = job_params["archive_metadata"]["collocation_hints"]
-
- assert (
- expected_collocation_hints["collocation_hints"] == generated_collocation_hints
- )
-
-
[email protected]("file_config_mock", [
- {
- "overrides": [
- ("transfers", "fts3tape_metadata_plugins", "activity, test")
- ]
- }
-], indirect=True)
-def test_multiple_plugin_concat(file_config_mock, did_factory, rse_factory, root_account):
- """When multiple plugins are used (like priority and collocation), both logics are applied"""
+ ], indirect=True)
+ def test_collocation_hints(self, file_config_mock, did_factory, rse_factory, root_account):
+ """For a mock collocation algorithm, it can produce the 4 levels of hints required for each did"""
+
+ mock_did = did_factory.random_file_did()
+ transfer_path = _make_transfer_path(mock_did, rse_factory, root_account)
+
+ # Mock Transfer Tool
+ fts3_tool = FTS3Transfertool(TEST_FTS_HOST)
+
+ job_params = build_job_params(
+ transfer_path=transfer_path,
+ bring_online=None,
+ default_lifetime=None,
+ archive_timeout_override=None,
+ max_time_in_queue=None,
+ logger=logging.log,
+ )
+
+ # Get the job params used for each transfer
+ job_params = fts3_tool._file_from_transfer(transfer_path[0], job_params)
- mock_did = did_factory.random_file_did()
- transfer_path = _make_transfer_path(mock_did, rse_factory, root_account)
+ expected_collocation_hints = {
+ "collocation_hints": {
+ "0": "",
+ "1": "",
+ "2": "",
+ "3": "",
+ }
+ }
- # Mock Transfer Tool
- fts3_tool = FTS3Transfertool(TEST_FTS_HOST)
+ assert "archive_metadata" in job_params
+ generated_collocation_hints = job_params["archive_metadata"]["collocation_hints"]
- job_params = build_job_params(
- transfer_path=transfer_path,
- bring_online=None,
- default_lifetime=None,
- archive_timeout_override=None,
- max_time_in_queue=None,
- logger=logging.log,
- )
+ assert (
+ expected_collocation_hints["collocation_hints"] == generated_collocation_hints
+ )
- # Get the job params used for each transfer
- job_params = fts3_tool._file_from_transfer(transfer_path[0], job_params)
- expected_hints = {
- "scheduling_hints": {"priority": "20"},
- "collocation_hints": {"0": "", "1": "", "2": "", "3": ""},
- }
- assert "archive_metadata" in job_params
+ @pytest.mark.parametrize("file_config_mock", [
+ {
+ "overrides": [
+ ("transfers", "fts3tape_metadata_plugins", "activity, test")
+ ]
+ }
+ ], indirect=True)
+ def test_multiple_plugin_concat(self, file_config_mock, did_factory, rse_factory, root_account):
+ """When multiple plugins are used (like priority and collocation), both logics are applied"""
+
+ mock_did = did_factory.random_file_did()
+ transfer_path = _make_transfer_path(mock_did, rse_factory, root_account)
+
+ # Mock Transfer Tool
+ fts3_tool = FTS3Transfertool(TEST_FTS_HOST)
+
+ job_params = build_job_params(
+ transfer_path=transfer_path,
+ bring_online=None,
+ default_lifetime=None,
+ archive_timeout_override=None,
+ max_time_in_queue=None,
+ logger=logging.log,
+ )
+
+ # Get the job params used for each transfer
+ job_params = fts3_tool._file_from_transfer(transfer_path[0], job_params)
+ expected_hints = {
+ "scheduling_hints": {"priority": "20"},
+ "collocation_hints": {"0": "", "1": "", "2": "", "3": ""},
+ }
+ assert "archive_metadata" in job_params
- generated_collocation_hints = job_params["archive_metadata"]["collocation_hints"]
- assert expected_hints["collocation_hints"] == generated_collocation_hints
+ generated_collocation_hints = job_params["archive_metadata"]["collocation_hints"]
+ assert expected_hints["collocation_hints"] == generated_collocation_hints
- generated_scheduling_hints = job_params["archive_metadata"]["scheduling_hints"]
- assert expected_hints["scheduling_hints"] == generated_scheduling_hints
+ generated_scheduling_hints = job_params["archive_metadata"]["scheduling_hints"]
+ assert expected_hints["scheduling_hints"] == generated_scheduling_hints
@pytest.mark.parametrize("file_config_mock", [