Debian Codegraph @

datalad_next/patches/tests/test_patched_ria_ora.py

raw symbols SCIP
1 """ria-, ora-, ria_utils-, and clone-tests for patched ria/ora code
2
3 This are patched tests that work with the patched ria/ora code.
4
5 The ria-utils-patches use an abstract path representation for RIA-store elements.
6 This patch adapts the tests that use `ria_utils.create_store` and
7 `ria_utils.create_ds_in_store` to these modifications.
8 """
9 from __future__scip-python python python-stdlib 3.11 __future__/__init__: import annotationsscip-python python python-stdlib 3.11 __future__/annotations.annotations.
10
11 import loggingscip-python python python-stdlib 3.11 logging/__init__:
12 import os.pathscip-python python python-stdlib 3.11 `os.path`/__init__: as op
13 import randomscip-python python python-stdlib 3.11 random/__init__:
14 import shutilscip-python python python-stdlib 3.11 shutil/__init__:
15 import statscip-python python python-stdlib 3.11 stat/__init__:
16 import stringscip-python python python-stdlib 3.11 string/__init__:
17 from pathlibscip-python python python-stdlib 3.11 pathlib/__init__: import (
18 Pathscip-python python python-stdlib 3.11 pathlib/Path#,
19 PurePosixPathscip-python python python-stdlib 3.11 pathlib/PurePosixPath#,
20 )
21 from urllib.parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__: import urlparse
22 from urllib.requestscip-python python python-stdlib 3.11 `urllib.request`/__init__: import pathname2url
23
24 from datalad.apiscip-python python datalad 1.3.1 `datalad.api`/__init__: import (
25 Dataset,
26 clone,
27 create_sibling_ria,
28 )
29 from datalad.cmdscip-python python datalad 1.3.1 `datalad.cmd`/__init__: import (
30 WitlessRunner as Runner,
31 NoCapture,
32 )
33 from datalad.customremotes.ria_utilsscip-python python datalad 1.3.1 `datalad.customremotes.ria_utils`/__init__: import (
34 UnknownLayoutVersion,
35 create_ds_in_store,
36 create_store,
37 get_layout_locations,
38 )
39 from datalad.distributed.ora_remotescip-python python datalad 1.3.1 `datalad.distributed.ora_remote`/__init__: import (
40 LocalIO,
41 SSHRemoteIO,
42 )
43 from datalad.distributed.tests.ria_utilsscip-python python datalad 1.3.1 `datalad.distributed.tests.ria_utils`/__init__: import (
44 common_init_opts,
45 get_all_files,
46 populate_dataset,
47 )
48 from datalad.support.exceptionsscip-python python datalad 1.3.1 `datalad.support.exceptions`/__init__: import (
49 CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError#,
50 IncompleteResultsError,
51 )
52 from datalad.support.networkscip-python python datalad 1.3.1 `datalad.support.network`/__init__: import get_local_file_url
53 from datalad.tests.utils_pytestscip-python python datalad 1.3.1 `datalad.tests.utils_pytest`/__init__: import (
54 DEFAULT_REMOTE,
55 SkipTest,
56 assert_equal,
57 assert_false,
58 assert_not_in,
59 assert_not_is_instance,
60 assert_repo_status,
61 assert_result_count,
62 assert_status,
63 assert_true,
64 create_tree,
65 has_symlink_capability,
66 known_failure_windows,
67 ok_,
68 rmtree,
69 serve_path_via_http,
70 skip_if_adjusted_branch,
71 skip_if_root,
72 skip_ssh,
73 slow,
74 turtle,
75 with_tempfile,
76 )
77
78 from datalad_next.testsscip-python python datalad_next 1.5.0 `datalad_next.tests`/__init__: import (
79 assert_in,
80 assert_raises,
81 eq_,
82 swallow_logs,
83 )
84
85
86 def _local_path2pure_posix_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(path): Pathscip-python python python-stdlib 3.11 pathlib/Path# | strscip-python python python-stdlib 3.11 builtins/str#):
87 return PurePosixPathscip-python python python-stdlib 3.11 pathlib/PurePosixPath#(pathname2url(strscip-python python python-stdlib 3.11 builtins/str#(pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(path))))
88
89
90 def _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().(prefixscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().(prefix): strscip-python python python-stdlib 3.11 builtins/str# = '') -> strscip-python python python-stdlib 3.11 builtins/str#:
91 return prefixscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().(prefix) + ''.joinscip-python python python-stdlib 3.11 builtins/str#join().(
92 randomscip-python python python-stdlib 3.11 random/__init__:.choicesscip-python python python-stdlib 3.11 random/choices.(stringscip-python python python-stdlib 3.11 string/__init__:.ascii_lettersscip-python python python-stdlib 3.11 string/ascii_letters.ascii_letters. + stringscip-python python python-stdlib 3.11 string/__init__:.digitsscip-python python python-stdlib 3.11 string/digits.digits., kscip-python python python-stdlib 3.11 random/Random#choices().(k)=8)
93 )
94
95
96 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
97 @with_tempfile
98 def _postclonetest_preparescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(lclscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(lcl), storepathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath), storepath2scip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath2), linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(link)):
99
100 from datalad.customremotes.ria_utilsscip-python python datalad 1.3.1 `datalad.customremotes.ria_utils`/__init__: import (
101 create_ds_in_store,
102 create_store,
103 get_layout_locations,
104 )
105 from datalad.distributed.ora_remotescip-python python datalad 1.3.1 `datalad.distributed.ora_remote`/__init__: import LocalIO
106
107 create_tree(lclscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(lcl),
108 tree={
109 'ds': {
110 'test.txt': 'some',
111 'subdir': {
112 'subds': {'testsub.txt': 'somemore'},
113 'subgit': {'testgit.txt': 'even more'}
114 },
115 },
116 })
117
118 lclscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(lcl) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(lclscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(lcl))
119 storepathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(storepathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath))
120 storepath2scip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath2) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(storepath2scip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath2))
121 # PATCH: introduce `ppp_storepath` and `ppp_storepath2` and use them instead
122 # of `storepath` and `storepath2`.
123 ppp_storepath = _local_path2pure_posix_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(storepathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath))
124 ppp_storepath2 = _local_path2pure_posix_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(storepath2scip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath2))
125 linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(link) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(link))
126 linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(link).symlink_toscip-python python python-stdlib 3.11 pathlib/Path#symlink_to().(storepathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath))
127
128 # create a local dataset with a subdataset
129 subds = Dataset(lclscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(lcl) / 'ds' / 'subdir' / 'subds').create(force=True)
130 subds.save()
131 # add a plain git dataset as well
132 subgit = Dataset(lclscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(lcl) / 'ds' / 'subdir' / 'subgit').create(force=True,
133 annex=False)
134 subgit.save()
135 ds = Dataset(lclscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(lcl) / 'ds').create(force=True)
136 ds.save(version_tag='original')
137 assert_repo_status(ds.path)
138
139 io = LocalIO()
140
141 # Have a second store with valid ORA remote. This should not interfere with
142 # reconfiguration of the first one, when that second store is not the one we
143 # clone from. However, don't push data into it for easier get-based testing
144 # later on.
145 # Doing this first, so datasets in "first"/primary store know about this.
146 create_store(io, ppp_storepath2, '1')
147 url2 = "ria+{}".format(get_local_file_url(strscip-python python python-stdlib 3.11 builtins/str#(storepath2scip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath2))))
148 for d in (ds, subds, subgit):
149 create_ds_in_store(io, ppp_storepath2, d.id, '2', '1')
150 d.create_sibling_ria(url2, "anotherstore", new_store_ok=True)
151 d.push('.', to='anotherstore', data='nothing')
152 store2_loc, _, _ = get_layout_locations(1, storepath2scip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath2), d.id)
153 Runner(cwd=strscip-python python python-stdlib 3.11 builtins/str#(store2_loc)).run(['git', 'update-server-info'])
154
155 # Now the store to clone from:
156 create_store(io, ppp_storepath, '1')
157
158 # URL to use for upload. Point is, that this should be invalid for the clone
159 # so that autoenable would fail. Therefore let it be based on a to be
160 # deleted symlink
161 upl_url = "ria+{}".format(get_local_file_url(strscip-python python python-stdlib 3.11 builtins/str#(linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(link))))
162
163 for d in (ds, subds, subgit):
164
165 # TODO: create-sibling-ria required for config! => adapt to RF'd
166 # creation (missed on rebase?)
167 create_ds_in_store(io, ppp_storepath, d.id, '2', '1')
168 d.create_sibling_ria(upl_url, "store", new_store_ok=True)
169
170 if d is not subgit:
171 # Now, simulate the problem by reconfiguring the special remote to
172 # not be autoenabled.
173 # Note, however, that the actual intention is a URL, that isn't
174 # valid from the point of view of the clone (doesn't resolve, no
175 # credentials, etc.) and therefore autoenabling on git-annex-init
176 # when datalad-cloning would fail to succeed.
177 Runner(cwd=d.path).run(['git', 'annex', 'enableremote',
178 'store-storage',
179 'autoenable=false'])
180 d.push('.', to='store')
181 store_loc, _, _ = get_layout_locations(1, storepathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(storepath), d.id)
182 Runner(cwd=strscip-python python python-stdlib 3.11 builtins/str#(store_loc)).run(['git', 'update-server-info'])
183
184 linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(link).unlinkscip-python python python-stdlib 3.11 pathlib/Path#unlink().()
185 # We should now have a store with datasets that have an autoenabled ORA
186 # remote relying on an inaccessible URL.
187 # datalad-clone is supposed to reconfigure based on the URL we cloned from.
188 # Test this feature for cloning via HTTP, SSH and FILE URLs.
189
190 return ds.id
191
192
193 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732 and patched
194 # and refactored
195 def test_ria_postclone_noannexscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclone_noannex().(existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclone_noannex().(existing_dataset), tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclone_noannex().(tmp_path)):
196 # Test for gh-5186: Cloning from local FS, shouldn't lead to annex
197 # initializing origin.
198 from datalad.customremotes.ria_utilsscip-python python datalad 1.3.1 `datalad.customremotes.ria_utils`/__init__: import (
199 create_ds_in_store,
200 create_store,
201 get_layout_locations,
202 )
203 from datalad.distributed.ora_remotescip-python python datalad 1.3.1 `datalad.distributed.ora_remote`/__init__: import LocalIO
204
205 ds = existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclone_noannex().(existing_dataset)
206 some_file = ds.pathobj / 'a_file.txt'
207 some_file.write_text('irrelevant')
208
209 ria_store_path = tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclone_noannex().(tmp_path) / 'ria_store'
210 url_ria_store_path = _local_path2pure_posix_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(ria_store_path)
211
212 io = LocalIO()
213 create_store(io, url_ria_store_path, '1')
214 lcl_url = "ria+{}".format(get_local_file_url(strscip-python python python-stdlib 3.11 builtins/str#(ria_store_path)))
215 create_ds_in_store(io, url_ria_store_path, ds.id, '2', '1')
216 ds.create_sibling_ria(lcl_url, "store", new_store_ok=True)
217 ds.push('.', to='store')
218
219 # Remove annex-tree from store to check that clone doesn't cause annex to
220 # recreate it.
221 store_loc = get_layout_locations(1, ria_store_path, ds.id)[0]
222 annex = store_loc / 'annex'
223 rmtree(strscip-python python python-stdlib 3.11 builtins/str#(annex))
224 assert_false(annex.exists())
225
226 clone(
227 f"ria+{get_local_file_url(strscip-python python python-stdlib 3.11 builtins/str#(ria_store_path), compatibility='git')}#{ds.id}",
228 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclone_noannex().(tmp_path) / 'cloned_ds'
229 )
230 assert_false(annex.exists())
231
232
233 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
234 def _test_setup_storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(io), store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(store_url), local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(local_store_path)):
235
236 store_url_path = PurePosixPathscip-python python python-stdlib 3.11 pathlib/PurePosixPath#(urlparse(store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(store_url)).path)
237
238 # invalid version raises:
239 assert_raises(
240 UnknownLayoutVersion,
241 create_store, ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(io), store_url_path, '2')
242
243 # non-existing path should work:
244 create_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(io), store_url_path, '1')
245
246 version_file = local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(local_store_path) / 'ria-layout-version'
247 error_logs = local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(local_store_path) / 'error_logs'
248 assert_true(version_file.exists())
249 assert_true(error_logs.exists())
250 assert_true(error_logs.is_dir())
251 assert_equal([f for f in error_logs.iterdir()], [])
252
253 # empty target directory should work as well:
254 rmtree(strscip-python python python-stdlib 3.11 builtins/str#(local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(local_store_path)))
255 local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(local_store_path).mkdir(exist_ok=False)
256 create_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(io), store_url_path, '1')
257 assert_true(version_file.exists())
258 assert_true(error_logs.exists())
259 assert_true(error_logs.is_dir())
260 assert_equal([f for f in error_logs.iterdir()], [])
261
262 # re-execution also fine:
263 create_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(io), store_url_path, '1')
264
265 # but version conflict with existing target isn't:
266 version_file.write_text("2|unknownflags\n")
267 assert_raises(ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#, create_store, ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(io), store_url_path, '1')
268 # TODO: check output reporting conflicting version "2"
269
270
271 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
272 def _test_setup_ds_in_storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(io), store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(store_url), local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(local_store_path)):
273
274 store_url_path = PurePosixPathscip-python python python-stdlib 3.11 pathlib/PurePosixPath#(urlparse(store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(store_url)).path)
275
276 # ATM create_ds_in_store doesn't care what kind of ID is provided
277 dsid = "abc123456"
278
279 ds_path = local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(local_store_path) / dsid[:3] / dsid[3:] # store layout version 1
280 version_file = ds_path / 'ria-layout-version'
281 archives = ds_path / 'archives'
282 objects = ds_path / 'annex' / 'objects'
283 git_config = ds_path / 'config'
284
285 # invalid store version:
286 assert_raises(
287 UnknownLayoutVersion,
288 create_ds_in_store, ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(io), store_url_path, dsid, '1', 'abc'
289 )
290
291 # invalid obj version:
292 assert_raises(
293 UnknownLayoutVersion,
294 create_ds_in_store, ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(io), store_url_path, dsid, 'abc', '1'
295 )
296
297 # version 1
298 create_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(io), store_url_path, '1')
299 create_ds_in_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(io), store_url_path, dsid, '1', '1')
300 for p in [ds_path, archives, objects]:
301 assert_true(p.is_dir(), msg="Not a directory: %s" % strscip-python python python-stdlib 3.11 builtins/str#(p))
302 for p in [version_file]:
303 assert_true(p.is_file(), msg="Not a file: %s" % strscip-python python python-stdlib 3.11 builtins/str#(p))
304 assert_equal(version_file.read_text().strip(), "1")
305
306 # conflicting version exists at target:
307 assert_raises(
308 ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#,
309 create_ds_in_store, ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(io), store_url_path, dsid, '2', '1'
310 )
311
312 # version 2
313 # Note: The only difference between version 1 and 2 are supposed to be the
314 # key paths (dirhashlower vs mixed), which has nothing to do with
315 # setup routine.
316 rmtree(local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(local_store_path))
317 create_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(io), store_url_path, '1')
318 create_ds_in_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(io), store_url_path, dsid, '2', '1')
319 for p in [ds_path, archives, objects]:
320 assert_true(p.is_dir(), msg="Not a directory: %s" % strscip-python python python-stdlib 3.11 builtins/str#(p))
321 for p in [version_file]:
322 assert_true(p.is_file(), msg="Not a file: %s" % strscip-python python python-stdlib 3.11 builtins/str#(p))
323 assert_equal(version_file.read_text().strip(), "2")
324
325
326 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
327 @with_tempfile(mkdir=True)
328 @serve_path_via_http
329 @with_tempfile
330 def test_initremotescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote().(store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote().(store_path)=None, store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote().(store_url)=None, ds_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote().(ds_path)=None):
331 ds = Dataset(ds_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote().(ds_path)).create()
332 store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote().(store_path) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote().(store_path))
333 # PATCH: introduce `ppp_store_path` and use it instead of `store_path`
334 ppp_store_path = _local_path2pure_posix_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote().(store_path))
335 url = "ria+" + store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote().(store_url)
336 init_opts = common_init_opts + ['url={}'.format(url)]
337
338 # fail when there's no RIA store at the destination
339 assert_raises(CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError#, ds.repo.init_remote, 'ora-remote',
340 options=init_opts)
341 # Doesn't actually create a remote if it fails
342 assert_not_in('ora-remote',
343 [cfg['name']
344 for uuid, cfg in ds.repo.get_special_remotes().items()]
345 )
346
347 # now make it a store
348 io = LocalIO()
349 create_store(io, ppp_store_path, '1')
350 create_ds_in_store(io, ppp_store_path, ds.id, '2', '1')
351
352 # fails on non-RIA URL
353 assert_raises(CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError#, ds.repo.init_remote, 'ora-remote',
354 options=common_init_opts + ['url={}'
355 ''.format(store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote().(store_path).as_uriscip-python python python-stdlib 3.11 pathlib/PurePath#as_uri().())]
356 )
357 # Doesn't actually create a remote if it fails
358 assert_not_in('ora-remote',
359 [cfg['name']
360 for uuid, cfg in ds.repo.get_special_remotes().items()]
361 )
362
363 ds.repo.init_remote('ora-remote', options=init_opts)
364 assert_in('ora-remote',
365 [cfg['name']
366 for uuid, cfg in ds.repo.get_special_remotes().items()]
367 )
368 assert_repo_status(ds.path)
369 # git-annex:remote.log should have:
370 # - url
371 # - common_init_opts
372 # - archive_id (which equals ds id)
373 remote_log = ds.repo.call_git(['cat-file', 'blob', 'git-annex:remote.log'],
374 read_only=True)
375 assert_in("url={}".format(url), remote_log)
376 [assert_in(c, remote_log) for c in common_init_opts]
377 assert_in("archive-id={}".format(ds.id), remote_log)
378
379
380 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
381 # TODO: on crippled FS copytree to populate store doesn't seem to work.
382 # Or may be it's just the serving via HTTP that doesn't work.
383 # Either way, after copytree and fsck, whereis doesn't report
384 # the store as an available source.
385 @skip_if_adjusted_branch
386 @known_failure_windows # see gh-4469
387 @with_tempfile(mkdir=True)
388 @serve_path_via_http
389 @with_tempfile
390 def test_read_accessscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_read_access().(store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_read_access().(store_path)=None, store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_read_access().(store_url)=None, ds_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_read_access().(ds_path)=None):
391
392 ds = Dataset(ds_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_read_access().(ds_path)).create()
393 populate_dataset(ds)
394
395 files = [Pathscip-python python python-stdlib 3.11 pathlib/Path#('one.txt'), Pathscip-python python python-stdlib 3.11 pathlib/Path#('subdir') / 'two']
396 store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_read_access().(store_path) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_read_access().(store_path))
397 # PATCH: introduce `ppp_store_path` and use it instead of `store_path`
398 ppp_store_path = _local_path2pure_posix_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_read_access().(store_path))
399 url = "ria+" + store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_read_access().(store_url)
400 init_opts = common_init_opts + ['url={}'.format(url)]
401
402 io = LocalIO()
403 create_store(io, ppp_store_path, '1')
404 create_ds_in_store(io, ppp_store_path, ds.id, '2', '1')
405 ds.repo.init_remote('ora-remote', options=init_opts)
406 fsck_results = ds.repo.fsck(remote='ora-remote', fast=True)
407 # Note: Failures in the special remote will show up as a success=False
408 # result for fsck -> the call itself would not fail.
409 for r in fsck_results:
410 if "note" in r:
411 # we could simply assert "note" to not be in r, but we want proper
412 # error reporting - content of note, not just its unexpected
413 # existence.
414 assert_equal(r["success"], "true",
415 msg="git-annex-fsck failed with ORA over HTTP: %s" % r)
416 assert_equal(r["error-messages"], [])
417 store_uuid = ds.siblings(name='ora-remote',
418 return_type='item-or-list',
419 result_renderer='disabled')['annex-uuid']
420 here_uuid = ds.siblings(name='here',
421 return_type='item-or-list',
422 result_renderer='disabled')['annex-uuid']
423
424 # nothing in store yet:
425 for f in files:
426 known_sources = ds.repo.whereis(strscip-python python python-stdlib 3.11 builtins/str#(f))
427 assert_in(here_uuid, known_sources)
428 assert_not_in(store_uuid, known_sources)
429
430 annex_obj_target = strscip-python python python-stdlib 3.11 builtins/str#(store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_read_access().(store_path) / ds.id[:3] / ds.id[3:]
431 / 'annex' / 'objects')
432 shutilscip-python python python-stdlib 3.11 shutil/__init__:.rmtreescip-python python python-stdlib 3.11 shutil/rmtree.rmtree.(annex_obj_target)
433 shutilscip-python python python-stdlib 3.11 shutil/__init__:.copytreescip-python python python-stdlib 3.11 shutil/copytree().(srcscip-python python python-stdlib 3.11 shutil/copytree().(src)=strscip-python python python-stdlib 3.11 builtins/str#(ds.repo.dot_git / 'annex' / 'objects'),
434 dstscip-python python python-stdlib 3.11 shutil/copytree().(dst)=annex_obj_target)
435
436 ds.repo.fsck(remote='ora-remote', fast=True)
437 # all in store now:
438 for f in files:
439 known_sources = ds.repo.whereis(strscip-python python python-stdlib 3.11 builtins/str#(f))
440 assert_in(here_uuid, known_sources)
441 assert_in(store_uuid, known_sources)
442
443 ds.drop('.')
444 res = ds.get('.')
445 assert_equal(len(res), 4)
446 assert_result_count(res, 4, status='ok', type='file', action='get',
447 message="from ora-remote...")
448
449 # try whether the reported access URL is correct
450 one_url = ds.repo.whereis('one.txt', output='full'
451 )[store_uuid]['urls'].pop()
452 assert_status('ok', ds.download_url(urls=[one_url], path=strscip-python python python-stdlib 3.11 builtins/str#(ds.pathobj / 'dummy')))
453
454
455 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
456 def _test_initremote_basicscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(io), store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(store_url), local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(local_store_path), dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds), linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(link), overwritescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(overwrite) = None):
457
458 populate_dataset(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds))
459
460 store_url_path = overwritescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(overwrite) or PurePosixPathscip-python python python-stdlib 3.11 pathlib/PurePosixPath#(urlparse(store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(store_url)).path)
461 linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(link) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(link))
462
463 init_opts = common_init_opts + [f'url=ria+{store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(store_url)}']
464
465 # fails on non-existing storage location
466 assert_raises(
467 CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError#,
468 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.init_remote, 'ria-remote', options=init_opts
469 )
470 # Doesn't actually create a remote if it fails
471 assert_not_in(
472 'ria-remote',
473 [
474 cfg['name']
475 for uuid, cfg in dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.get_special_remotes().items()
476 ]
477 )
478
479 # fails on non-RIA URL
480 assert_raises(
481 CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError#,
482 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.init_remote, 'ria-remote',
483 options=common_init_opts + [f'url={store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(store_url)}']
484 )
485
486 # Doesn't actually create a remote if it fails
487 assert_not_in(
488 'ria-remote',
489 [
490 cfg['name']
491 for uuid, cfg in dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.get_special_remotes().items()
492 ]
493 )
494
495 # set up store:
496 create_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(io), store_url_path, '1')
497 # still fails, since ds isn't setup in the store
498 assert_raises(
499 CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError#,
500 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.init_remote, 'ria-remote', options=init_opts
501 )
502 # Doesn't actually create a remote if it fails
503 assert_not_in(
504 'ria-remote',
505 [
506 cfg['name']
507 for uuid, cfg in dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.get_special_remotes().items()
508 ]
509 )
510 # set up the dataset as well
511 create_ds_in_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(io), store_url_path, dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).id, '2', '1')
512 # now should work
513 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.init_remote('ria-remote', options=init_opts)
514 assert_in(
515 'ria-remote',
516 [
517 cfg['name']
518 for uuid, cfg in dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.get_special_remotes().items()
519 ]
520 )
521 assert_repo_status(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).path)
522 # git-annex:remote.log should have:
523 # - url
524 # - common_init_opts
525 # - archive_id (which equals ds id)
526 remote_log = dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.call_git(
527 ['cat-file', 'blob', 'git-annex:remote.log'], read_only=True
528 )
529 assert_in(f'url=ria+{store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(store_url)}', remote_log)
530 [assert_in(c, remote_log) for c in common_init_opts]
531 assert_in("archive-id={}".format(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).id), remote_log)
532
533 # re-configure with invalid URL should fail:
534 assert_raises(
535 CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError#,
536 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.call_annex,
537 ['enableremote', 'ria-remote'] + common_init_opts + [
538 'url=ria+file:///non-existing'
539 ]
540 )
541 # but re-configure with valid URL should work
542 if has_symlink_capability():
543 linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(link).symlink_toscip-python python python-stdlib 3.11 pathlib/Path#symlink_to().(local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(local_store_path))
544 new_url = 'ria+{}'.format(linkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(link).as_uriscip-python python python-stdlib 3.11 pathlib/PurePath#as_uri().())
545 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.call_annex(
546 ['enableremote', 'ria-remote'] + common_init_opts + [
547 'url={}'.format(new_url)
548 ]
549 )
550 # git-annex:remote.log should have:
551 # - url
552 # - common_init_opts
553 # - archive_id (which equals ds id)
554 remote_log = dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.call_git(
555 ['cat-file', 'blob', 'git-annex:remote.log'], read_only=True
556 )
557 assert_in("url={}".format(new_url), remote_log)
558 [assert_in(c, remote_log) for c in common_init_opts]
559 assert_in("archive-id={}".format(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).id), remote_log)
560
561 # we can deal with --sameas, which leads to a special remote not having a
562 # 'name' property, but only a 'sameas-name'. See gh-4259
563 try:
564 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(ds).repo.init_remote(
565 'ora2',
566 options=init_opts + ['--sameas', 'ria-remote']
567 )
568 except CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError# as e:
569 if 'Invalid option `--sameas' in e.stderr:
570 # annex too old - doesn't know --sameas
571 pass
572 else:
573 raise
574 # TODO: - check output of failures to verify it's failing the right way
575 # - might require to run initremote directly to get the output
576
577
578 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
579 @known_failure_windows # see gh-4469
580 def _test_remote_layoutscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(io),
581 store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(store_url),
582 archive_store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(archive_store_url),
583 local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(local_store_path),
584 local_archive_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(local_archive_store_path),
585 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds)
586 ):
587
588 populate_dataset(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds))
589 assert_repo_status(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).path)
590
591 store_url_path = PurePosixPathscip-python python python-stdlib 3.11 pathlib/PurePosixPath#(urlparse(store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(store_url)).path)
592 archive_store_url_path = PurePosixPathscip-python python python-stdlib 3.11 pathlib/PurePosixPath#(urlparse(archive_store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(archive_store_url)).path)
593
594 # set up store:
595 create_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(io), store_url_path, '1')
596
597 # TODO: Re-establish test for version 1
598 # version 2: dirhash
599 create_ds_in_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(io), store_url_path, dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).id, '2', '1')
600
601 # add special remote
602 init_opts = common_init_opts + [f'url=ria+{store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(store_url)}']
603 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).repo.init_remote('store', options=init_opts)
604
605 # copy files into the RIA store
606 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).push('.', to='store')
607
608 # we should see the exact same annex object tree
609 dsgit_dir, archive_dir, dsobj_dir = get_layout_locations(
610 1, local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(local_store_path), dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).id
611 )
612 store_objects = get_all_files(dsobj_dir)
613 local_objects = get_all_files(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).pathobj / '.git' / 'annex' / 'objects')
614 assert_equal(len(store_objects), 4)
615
616 if not dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).repo.is_managed_branch():
617 # with managed branches the local repo uses hashdirlower instead
618 # TODO: However, with dataset layout version 1 this should therefore
619 # work on adjusted branch the same way
620 # TODO: Wonder whether export-archive-ora should account for that and
621 # rehash according to target layout.
622 assert_equal(sortedscip-python python python-stdlib 3.11 builtins/sorted().([p for p in store_objects]),
623 sortedscip-python python python-stdlib 3.11 builtins/sorted().([p for p in local_objects])
624 )
625
626 if not ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(io).get_7z():
627 raise SkipTest("No 7z available in RIA store")
628
629 # we can simply pack up the content of the remote into a
630 # 7z archive and place it in the right location to get a functional
631 # archive remote
632
633 create_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(io), archive_store_url_path, '1')
634 create_ds_in_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(io), archive_store_url_path, dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).id, '2', '1')
635
636 whereis = dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).repo.whereis('one.txt')
637 dsgit_dir, archive_dir, dsobj_dir = get_layout_locations(
638 1, local_archive_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(local_archive_store_path), dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).id)
639 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).export_archive_ora(archive_dir / 'archive.7z')
640 init_opts = common_init_opts + [f'url=ria+{archive_store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(archive_store_url)}']
641 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).repo.init_remote('archive', options=init_opts)
642 # now fsck the new remote to get the new special remote indexed
643 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).repo.fsck(remote='archive', fast=True)
644 assert_equal(len(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).repo.whereis('one.txt')), len(whereis) + 1)
645 # test creating an archive with filters on files
646 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).export_archive_ora(archive_dir / 'archive2.7z', annex_wanted='(include=*.txt)')
647 # test with wanted expression of a specific remote
648 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).repo.set_preferred_content("wanted", "include=subdir/*", remote="store")
649 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).export_archive_ora(archive_dir / 'archive3.7z', remote="store")
650 # test with the current sha
651 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).export_archive_ora(
652 archive_dir / 'archive4.7z',
653 froms=dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(ds).repo.get_revisions()[1],
654 )
655
656
657 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
658 def _test_version_checkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(io), store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(store_url), local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(local_store_path), dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds)):
659
660 store_url_path = PurePosixPathscip-python python python-stdlib 3.11 pathlib/PurePosixPath#(urlparse(store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(store_url)).path)
661
662 populate_dataset(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds))
663 assert_repo_status(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).path)
664
665 create_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(io), store_url_path, '1')
666
667 # TODO: Re-establish test for version 1
668 # version 2: dirhash
669 create_ds_in_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(io), store_url_path, dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).id, '2', '1')
670
671 # add special remote
672 init_opts = common_init_opts + [f'url={"ria+" + store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(store_url)}']
673 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).repo.init_remote('store', options=init_opts)
674 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).push('.', to='store')
675
676 # check version files
677 remote_ds_tree_version_file = local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(local_store_path) / 'ria-layout-version'
678 dsgit_dir, archive_dir, dsobj_dir = get_layout_locations(
679 1,
680 local_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(local_store_path),
681 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).id
682 )
683 remote_obj_tree_version_file = dsgit_dir / 'ria-layout-version'
684
685 assert_true(remote_ds_tree_version_file.exists())
686 assert_true(remote_obj_tree_version_file.exists())
687
688 with openscip-python python python-stdlib 3.11 builtins/open().(strscip-python python python-stdlib 3.11 builtins/str#(remote_ds_tree_version_file), 'r') as f:
689 assert_equal(f.readscip-python python python-stdlib 3.11 io/TextIOBase#read().().stripscip-python python python-stdlib 3.11 builtins/str#strip().(), '1')
690 with openscip-python python python-stdlib 3.11 builtins/open().(strscip-python python python-stdlib 3.11 builtins/str#(remote_obj_tree_version_file), 'r') as f:
691 assert_equal(f.readscip-python python python-stdlib 3.11 io/TextIOBase#read().().stripscip-python python python-stdlib 3.11 builtins/str#strip().(), '2')
692
693 # Accessing the remote should not yield any output regarding versioning,
694 # since it's the "correct" version. Note that "fsck" is an arbitrary choice.
695 # We need just something to talk to the special remote.
696 with swallow_logs(new_level=loggingscip-python python python-stdlib 3.11 logging/__init__:.INFOscip-python python python-stdlib 3.11 logging/INFO.INFO., name='datalad.annex') as cml:
697 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).repo.fsck(remote='store', fast=True)
698 # TODO: For some reason didn't get cml.assert_logged to assert
699 # "nothing was logged"
700 assert not cml.out
701
702 # Now fake-change the version
703 with openscip-python python python-stdlib 3.11 builtins/open().(strscip-python python python-stdlib 3.11 builtins/str#(remote_obj_tree_version_file), 'w') as f:
704 f.writescip-python python python-stdlib 3.11 io/TextIOBase#write().('X\n')
705
706 # Now we should see a message about it
707 with swallow_logs(new_level=loggingscip-python python python-stdlib 3.11 logging/__init__:.INFOscip-python python python-stdlib 3.11 logging/INFO.INFO., name='datalad.annex') as cml:
708 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).repo.fsck(remote='store', fast=True)
709 cml.assert_logged(level="INFO",
710 msg="Remote object tree reports version X",
711 regex=False)
712
713 # reading still works:
714 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).drop('.')
715 assert_status('ok', dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).get('.'))
716
717 # but writing doesn't:
718 with openscip-python python python-stdlib 3.11 builtins/open().(strscip-python python python-stdlib 3.11 builtins/str#(Pathscip-python python python-stdlib 3.11 pathlib/Path#(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).path) / 'new_file'), 'w') as f:
719 f.writescip-python python python-stdlib 3.11 io/TextIOBase#write().("arbitrary addition")
720 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).save(message="Add a new_file")
721
722 with assert_raises((CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError#, IncompleteResultsError)):
723 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).push('new_file', to='store')
724
725 # However, we can force it by configuration
726 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).config.add("annex.ora-remote.store.force-write", "true", scope='local')
727 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(ds).push('new_file', to='store')
728
729
730 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
731 # git-annex-testremote is way too slow on crippled FS.
732 # Use is_managed_branch() as a proxy and skip only here
733 # instead of in a decorator
734 @skip_if_adjusted_branch
735 @known_failure_windows # see gh-4469
736 @with_tempfile
737 @with_tempfile
738 def _test_gitannexscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(hostscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(host), storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(store), dspathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(dspath)):
739 dspathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(dspath) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(dspathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(dspath))
740 storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(store) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(store))
741 # PATCH: introduce `ppp_store` and use it instead of `store`
742 ppp_store = _local_path2pure_posix_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(store))
743
744 ds = Dataset(dspathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(dspath)).create()
745
746 populate_dataset(ds)
747 assert_repo_status(ds.path)
748
749 # set up store:
750 io = SSHRemoteIO(hostscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(host)) if hostscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(host) else LocalIO()
751 if hostscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(host):
752 store_url = "ria+{host}{path}".format(
753 host=hostscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(host)[:-1],
754 path=storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(store)
755 )
756 else:
757 store_url = "ria+{}".format(storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(store).as_uriscip-python python python-stdlib 3.11 pathlib/PurePath#as_uri().())
758
759 create_store(io, ppp_store, '1')
760
761 # TODO: Re-establish test for version 1
762 # version 2: dirhash
763 create_ds_in_store(io, ppp_store, ds.id, '2', '1')
764
765 # add special remote
766 init_opts = common_init_opts + ['url={}'.format(store_url)]
767 ds.repo.init_remote('store', options=init_opts)
768
769 from datalad.support.external_versionsscip-python python datalad 1.3.1 `datalad.support.external_versions`/__init__: import external_versions
770 if '8.20200330' < external_versions['cmd:annex'] < '8.20200624':
771 # https://git-annex.branchable.com/bugs/testremote_breeds_way_too_many_instances_of_the_externals_remote/?updated
772 raise SkipTest(
773 "git-annex might lead to overwhelming number of external "
774 "special remote instances")
775
776 # run git-annex-testremote
777 # note, that we don't want to capture output. If something goes wrong we
778 # want to see it in test build's output log.
779 ds.repo._call_annex(['testremote', 'store'], protocol=NoCapture)
780
781
782 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
783 @known_failure_windows
784 @with_tempfile
785 @with_tempfile
786 @with_tempfile
787 def test_push_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(storepathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(storepath)=None, dspathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(dspath)=None, blockfilescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(blockfile)=None):
788
789 dspathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(dspath) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(dspathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(dspath))
790 store = Pathscip-python python python-stdlib 3.11 pathlib/Path#(storepathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(storepath))
791 # PATCH: introduce `ppp_store` and use it instead of `store`
792 ppp_store = _local_path2pure_posix_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(store)
793 blockfilescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(blockfile) = Pathscip-python python python-stdlib 3.11 pathlib/Path#(blockfilescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(blockfile))
794 blockfilescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(blockfile).touchscip-python python python-stdlib 3.11 pathlib/Path#touch().()
795
796 ds = Dataset(dspathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(dspath)).create()
797 populate_dataset(ds)
798 assert_repo_status(ds.path)
799 repo = ds.repo
800
801 # set up store:
802 io = LocalIO()
803 store_url = "ria+{}".format(ppp_store.as_uriscip-python python python-stdlib 3.11 pathlib/PurePath#as_uri().())
804 create_store(io, ppp_store, '1')
805 create_ds_in_store(io, ppp_store, ds.id, '2', '1')
806
807 # initremote fails with invalid url (not a ria+ URL):
808 invalid_url = (store.parentscip-python python python-stdlib 3.11 pathlib/PurePath#parent(). / "non-existent").as_uriscip-python python python-stdlib 3.11 pathlib/PurePath#as_uri().()
809 init_opts = common_init_opts + ['url={}'.format(store_url),
810 'push-url={}'.format(invalid_url)]
811 assert_raises(CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError#, ds.repo.init_remote, 'store', options=init_opts)
812
813 # initremote succeeds with valid but inaccessible URL (pointing to a file
814 # instead of a store):
815 block_url = "ria+" + blockfilescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_push_url().(blockfile).as_uriscip-python python python-stdlib 3.11 pathlib/PurePath#as_uri().()
816 init_opts = common_init_opts + ['url={}'.format(store_url),
817 'push-url={}'.format(block_url)]
818 repo.init_remote('store', options=init_opts)
819
820 store_uuid = ds.siblings(name='store',
821 return_type='item-or-list')['annex-uuid']
822 here_uuid = ds.siblings(name='here',
823 return_type='item-or-list')['annex-uuid']
824
825 # but a push will fail:
826 assert_raises(CommandErrorscip-python python datalad_next 1.5.0 `datalad.runner.exception`/CommandError#, ds.repo.call_annex,
827 ['copy', 'one.txt', '--to', 'store'])
828
829 # reconfigure w/ local overwrite:
830 repo.config.add("remote.store.ora-push-url", store_url, scope='local')
831 # push works now:
832 repo.call_annex(['copy', 'one.txt', '--to', 'store'])
833
834 # remove again (config and file from store)
835 repo.call_annex(['move', 'one.txt', '--from', 'store'])
836 repo.config.unset("remote.store.ora-push-url", scope='local')
837 repo.call_annex(['fsck', '-f', 'store'])
838 known_sources = repo.whereis('one.txt')
839 assert_in(here_uuid, known_sources)
840 assert_not_in(store_uuid, known_sources)
841
842 # reconfigure (this time committed)
843 init_opts = common_init_opts + ['url={}'.format(store_url),
844 'push-url={}'.format(store_url)]
845 repo.enable_remote('store', options=init_opts)
846
847 # push works now:
848 repo.call_annex(['copy', 'one.txt', '--to', 'store'])
849 known_sources = repo.whereis('one.txt')
850 assert_in(here_uuid, known_sources)
851 assert_in(store_uuid, known_sources)
852
853
854 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732, refactored,
855 # and patched.
856 # Skipping on adjusted branch as a proxy for crippledFS. Write permissions of
857 # the owner on a directory can't be revoked on VFAT. "adjusted branch" is a
858 # bit broad but covers the CI cases. And everything RIA/ORA doesn't currently
859 # properly run on crippled/windows anyway. Needs to be more precise when
860 # RF'ing will hopefully lead to support on windows in principle.
861 @skip_if_adjusted_branch
862 def _test_permissionscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(io), store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(store_url), local_ria_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(local_ria_store_path), dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds)):
863
864 # Test whether ORA correctly revokes and obtains write permissions within
865 # the annex object tree. That is: Revoke after ORA pushed a key to store
866 # in order to allow the object tree to safely be used with an ephemeral
867 # clone. And on removal obtain write permissions, like annex would
868 # internally on a drop (but be sure to restore if something went wrong).
869
870 populate_dataset(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds))
871 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).save()
872 assert_repo_status(dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).path)
873 testfile = 'one.txt'
874
875 store_url_path = PurePosixPathscip-python python python-stdlib 3.11 pathlib/PurePosixPath#(urlparse(store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(store_url)).path)
876
877 create_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(io), store_url_path, '1')
878 create_ds_in_store(ioscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(io), store_url_path, dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).id, '2', '1')
879
880 _, _, obj_tree = get_layout_locations(1, local_ria_store_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(local_ria_store_path), dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).id)
881 assert_true(obj_tree.is_dir())
882 file_key_in_store = obj_tree / 'X9' / '6J' / 'MD5E-s8--7e55db001d319a94b0b713529a756623.txt' / 'MD5E-s8--7e55db001d319a94b0b713529a756623.txt'
883
884 init_opts = common_init_opts + [f'url={"ria+" + store_urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(store_url)}']
885 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).repo.init_remote('store', options=init_opts)
886
887 store_uuid = dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).siblings(
888 name='store',
889 return_type='item-or-list'
890 )['annex-uuid']
891 here_uuid = dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).siblings(
892 name='here',
893 return_type='item-or-list'
894 )['annex-uuid']
895
896 known_sources = dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).repo.whereis(testfile)
897 assert_in(here_uuid, known_sources)
898 assert_not_in(store_uuid, known_sources)
899 assert_false(file_key_in_store.exists())
900
901 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).repo.call_annex(['copy', testfile, '--to', 'store'])
902 known_sources = dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).repo.whereis(testfile)
903 assert_in(here_uuid, known_sources)
904 assert_in(store_uuid, known_sources)
905 assert_true(file_key_in_store.exists())
906
907 # Revoke write permissions from parent dir in-store to test whether we
908 # still can drop (if we can obtain the permissions). Note, that this has
909 # no effect on VFAT.
910 file_key_in_store.parent.chmod(
911 file_key_in_store.parent.stat().st_mode & ~statscip-python python python-stdlib 3.11 stat/__init__:.S_IWUSRscip-python python python-stdlib 3.11 _stat/S_ISLNK().
912 )
913 # we can't directly delete; key in store should be protected
914 assert_raises(PermissionErrorscip-python python python-stdlib 3.11 builtins/PermissionError#, file_key_in_store.unlink)
915
916 # ORA can still drop, since it obtains permission to:
917 dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).repo.call_annex(['drop', testfile, '--from', 'store'])
918 known_sources = dsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(ds).repo.whereis(testfile)
919 assert_in(here_uuid, known_sources)
920 assert_not_in(store_uuid, known_sources)
921 assert_false(file_key_in_store.exists())
922
923
924 def _get_host_from_ssh_serverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_get_host_from_ssh_server().(ssh_serverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_get_host_from_ssh_server().(ssh_server)):
925 url_parts = urlparse(ssh_serverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_get_host_from_ssh_server().(ssh_server)[0])
926 return (
927 'ssh://'
928 + ((url_parts.username + '@') if url_parts.username else '')
929 + url_parts.hostname
930 + ((':' + strscip-python python python-stdlib 3.11 builtins/str#(url_parts.port)) if url_parts.port else '')
931 + '/'
932 )
933
934
935 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
936 @slow # 17sec + ? on travis
937 @skip_ssh
938 def test_version_check_sshscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check_ssh().(sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check_ssh().(sshserver), existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check_ssh().(existing_dataset)):
939 store_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('ria-store-')
940 store_url = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check_ssh().(sshserver)[0] + '/' + store_dir
941 _test_version_checkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(
942 SSHRemoteIO(store_url),
943 store_url,
944 sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check_ssh().(sshserver)[1] / store_dir,
945 existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check_ssh().(existing_dataset)
946 )
947
948
949 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
950 def test_version_checkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check().(tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check().(tmp_path), existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check().(existing_dataset)):
951 _test_version_checkscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_version_check().(
952 LocalIO(),
953 'file://' + (tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check().(tmp_path) / 'ria-store').as_uri(),
954 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check().(tmp_path) / 'ria-store',
955 existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_version_check().(existing_dataset)
956 )
957
958
959 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
960 @skip_ssh
961 def test_obtain_permission_sshscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_ssh().(sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_ssh().(sshserver), existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_ssh().(existing_dataset)):
962 store_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('ria-store-')
963 store_url = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_ssh().(sshserver)[0] + '/' + store_dir
964 _test_permissionscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(
965 SSHRemoteIO(store_url),
966 store_url,
967 sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_ssh().(sshserver)[1] / store_dir,
968 existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_ssh().(existing_dataset)
969 )
970
971
972 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
973 @skip_if_root
974 def test_obtain_permission_rootscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_root().(tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_root().(tmp_path), existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_root().(existing_dataset)):
975 _test_permissionscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_permission().(
976 LocalIO(),
977 'file://' + (tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_root().(tmp_path) / 'ria-store').as_uri(),
978 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_root().(tmp_path) / 'ria-store',
979 existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_obtain_permission_root().(existing_dataset)
980 )
981
982
983 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
984 def test_setup_store_localscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_store_local().(tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_store_local().(tmp_path)):
985 _test_setup_storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(
986 LocalIO(),
987 'file://' + (tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_store_local().(tmp_path) / 'ria-store').as_uri(),
988 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_store_local().(tmp_path) / 'ria-store',
989 )
990
991
992 @skip_ssh
993 def test_setup_store_sshscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_store_ssh().(sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_store_ssh().(sshserver)):
994 store_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('ria-store-')
995 store_url = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_store_ssh().(sshserver)[0] + '/' + store_dir
996 _test_setup_storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_store().(
997 SSHRemoteIO(store_url),
998 store_url,
999 sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_store_ssh().(sshserver)[1] / store_dir,
1000 )
1001
1002
1003 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
1004 def test_setup_ds_in_store_localscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_ds_in_store_local().(tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_ds_in_store_local().(tmp_path)):
1005 _test_setup_ds_in_storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(
1006 LocalIO(),
1007 'file://' + (tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_ds_in_store_local().(tmp_path) / 'ria-store').as_uri(),
1008 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_ds_in_store_local().(tmp_path) / 'ria-store',
1009 )
1010
1011
1012 @skip_ssh
1013 def test_setup_ds_in_store_sshscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_ds_in_store_ssh().(sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_ds_in_store_ssh().(sshserver)):
1014 store_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('ria-store-')
1015 store_url = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_ds_in_store_ssh().(sshserver)[0] + '/' + store_dir
1016 _test_setup_ds_in_storescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_setup_ds_in_store().(
1017 SSHRemoteIO(store_url),
1018 store_url,
1019 sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_setup_ds_in_store_ssh().(sshserver)[1] / store_dir,
1020 )
1021
1022
1023 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
1024 @slow # 12sec + ? on travis
1025 @skip_ssh
1026 def test_remote_layout_sshscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout_ssh().(sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout_ssh().(sshserver), existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout_ssh().(existing_dataset)):
1027 store_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('ria-store-')
1028 store_url = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout_ssh().(sshserver)[0] + '/' + store_dir
1029 archive_store_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('ria-archive-store-')
1030 archive_store_url = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout_ssh().(sshserver)[0] + '/' + archive_store_dir
1031 _test_remote_layoutscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(
1032 SSHRemoteIO(store_url),
1033 store_url,
1034 archive_store_url,
1035 sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout_ssh().(sshserver)[1] / store_dir,
1036 sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout_ssh().(sshserver)[1] / archive_store_dir,
1037 existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout_ssh().(existing_dataset),
1038 )
1039
1040
1041 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
1042 def test_remote_layoutscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout().(tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout().(tmp_path), existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout().(existing_dataset)):
1043 _test_remote_layoutscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_remote_layout().(
1044 LocalIO(),
1045 'file://' + (tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout().(tmp_path) / 'ria-store').as_uri(),
1046 'file://' + (tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout().(tmp_path) / 'ria-archive-store').as_uri(),
1047 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout().(tmp_path) / 'ria-store',
1048 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout().(tmp_path) / 'ria-archive-store',
1049 existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_remote_layout().(existing_dataset),
1050 )
1051
1052
1053 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
1054 # PATCH remove @know_failure_windows
1055 @skip_ssh
1056 def test_initremote_basic_sshurlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_sshurl().(sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_sshurl().(sshserver), tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_sshurl().(tmp_path), existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_sshurl().(existing_dataset)):
1057 store_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('ria-store-')
1058 store_url = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_sshurl().(sshserver)[0] + '/' + store_dir
1059 _test_initremote_basicscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(
1060 SSHRemoteIO(store_url),
1061 store_url,
1062 sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_sshurl().(sshserver)[1] / store_dir,
1063 existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_sshurl().(existing_dataset),
1064 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_sshurl().(tmp_path) / _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('link-'),
1065 )
1066
1067
1068 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
1069 # PATCH remove @know_failure_windows
1070 def test_initremote_basic_fileurlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_fileurl().(tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_fileurl().(tmp_path), existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_fileurl().(existing_dataset)):
1071 store_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('ria-store-')
1072 _test_initremote_basicscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(
1073 LocalIO(),
1074 'file://' + (tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_fileurl().(tmp_path) / store_dir).as_uri(),
1075 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_fileurl().(tmp_path) / store_dir,
1076 existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_fileurl().(existing_dataset),
1077 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_fileurl().(tmp_path) / 'link',
1078 )
1079
1080
1081 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
1082 # https://github.com/datalad/datalad/issues/6160
1083 @known_failure_windows
1084 def test_initremote_basic_httpurlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_httpurl().(http_serverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_httpurl().(http_server), tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_httpurl().(tmp_path), existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_httpurl().(existing_dataset)):
1085 # TODO: add a test for https
1086 _test_initremote_basicscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_initremote_basic().(
1087 LocalIO(),
1088 http_serverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_httpurl().(http_server).url,
1089 http_serverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_httpurl().(http_server).path,
1090 existing_datasetscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_httpurl().(existing_dataset),
1091 tmp_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_httpurl().(tmp_path) / _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('link-'),
1092 _local_path2pure_posix_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_local_path2pure_posix_path().(http_serverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_initremote_basic_httpurl().(http_server).path),
1093 )
1094
1095
1096 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
1097 @turtle
1098 # PATCH remove @know_failure_windows
1099 @skip_ssh
1100 def test_gitannex_sshscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_gitannex_ssh().(sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_gitannex_ssh().(sshserver)):
1101 _test_gitannexscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(_get_host_from_ssh_serverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_get_host_from_ssh_server().(sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_gitannex_ssh().(sshserver)))
1102
1103
1104 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
1105 @slow # 41sec on travis
1106 def test_gitannex_localscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_gitannex_local().():
1107 _test_gitannexscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_gitannex().(None)
1108
1109
1110 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
1111 # TODO?: make parametric again on _test_ria_postclonecfg
1112 # PATCH remove @know_failure_windows
1113 @slow # 14 sec on travis
1114 @known_failure_windows # https://github.com/datalad/datalad/issues/5134
1115 def test_ria_postclonecfgscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclonecfg().(sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclonecfg().(sshserver)):
1116
1117 if not has_symlink_capability():
1118 # This is needed to create an ORA remote using an URL for upload,
1119 # that is then invalidated later on (delete the symlink it's based on).
1120 raise SkipTest("Can't create symlinks")
1121
1122 lcl_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('lcl-')
1123 store_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('ria-store-')
1124 store2_dir = _random_namescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_random_name().('ria-store-2-')
1125
1126 lcl = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclonecfg().(sshserver)[1] / lcl_dir
1127 store = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclonecfg().(sshserver)[1] / store_dir
1128 store2 = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclonecfg().(sshserver)[1] / store2_dir
1129
1130 lcl.mkdir(parents=True)
1131 store.mkdir(parents=True)
1132 store2.mkdir(parents=True)
1133
1134 #lcl_url = sshserver[0] + '/' + lcl_dir
1135 store_url = sshserverscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/test_ria_postclonecfg().(sshserver)[0] + '/' + store_dir
1136 #store2_url = sshserver[0] + '/' + store2_dir
1137
1138 id = _postclonetest_preparescip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_postclonetest_prepare().(lcl, store, store2)
1139
1140 # test cloning via ria+file://
1141 _test_ria_postclonecfgscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(
1142 get_local_file_url(store, compatibility='git'), id
1143 )
1144
1145 # Note: HTTP disabled for now. Requires proper implementation in ORA
1146 # remote. See
1147 # https://github.com/datalad/datalad/pull/4203#discussion_r410284649
1148
1149 # # test cloning via ria+http://
1150 # with HTTPPath(store) as url:
1151 # yield _test_ria_postclonecfg, url, id
1152
1153 # test cloning via ria+ssh://
1154 skip_ssh(_test_ria_postclonecfgscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().)(store_url, id)
1155
1156
1157 # taken from datalad-core@864dc4ae24c8aac0ec4003604543b86de4735732
1158 @with_tempfile
1159 @with_tempfile
1160 def _test_ria_postclonecfgscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(url), dsidscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(dsid), clone_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(clone_path), superdsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(superds)):
1161 # Test cloning from RIA store while ORA special remote autoenabling failed
1162 # due to an invalid URL from the POV of the cloner.
1163 # Origin's git-config-file should contain the UUID to enable. This needs to
1164 # work via HTTP, SSH and local cloning.
1165
1166 # Autoenabling should fail initially by git-annex-init and we would report
1167 # on INFO level. Only postclone routine would deal with it.
1168 with swallow_logs(
1169 new_level=loggingscip-python python python-stdlib 3.11 logging/__init__:.INFOscip-python python python-stdlib 3.11 logging/INFO.INFO.,
1170 name='datalad.core.distributed.clone',
1171 ) as cml:
1172 # First, the super ds:
1173 riaclone = clone('ria+{}#{}'.format(urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(url), dsidscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(dsid)), clone_pathscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(clone_path))
1174 cml.assert_logged(msg="access to 1 dataset sibling store-storage not "
1175 "auto-enabled",
1176 level="INFO",
1177 regex=False)
1178
1179 # However, we now can retrieve content since clone should have enabled the
1180 # special remote with new URL (or origin in case of HTTP).
1181 res = riaclone.get('test.txt')
1182 assert_result_count(res, 1,
1183 status='ok',
1184 path=strscip-python python python-stdlib 3.11 builtins/str#(riaclone.pathobj / 'test.txt'),
1185 message="from {}...".format(DEFAULT_REMOTE
1186 if urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(url).startswith('http')
1187 else "store-storage"))
1188
1189 # Second ORA remote is enabled and not reconfigured:
1190 untouched_remote = riaclone.siblings(name='anotherstore-storage',
1191 return_type='item-or-list')
1192 assert_not_is_instance(untouched_remote, listscip-python python python-stdlib 3.11 builtins/list#)
1193 untouched_url = riaclone.repo.get_special_remotes()[
1194 untouched_remote['annex-uuid']]['url']
1195 ok_(untouched_url.startswith("ria+file://"))
1196 ok_(not untouched_url.startswith("ria+{}".format(urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(url))))
1197
1198 # publication dependency was set for store-storage but not for
1199 # anotherstore-storage:
1200 eq_(riaclone.config.get(f"remote.{DEFAULT_REMOTE}.datalad-publish-depends",
1201 get_all=True),
1202 "store-storage")
1203
1204 # same thing for the sub ds (we don't need a store-url and id - get should
1205 # figure those itself):
1206 with swallow_logs(
1207 new_level=loggingscip-python python python-stdlib 3.11 logging/__init__:.INFOscip-python python python-stdlib 3.11 logging/INFO.INFO.,
1208 name='datalad.core.distributed.clone',
1209 ) as cml:
1210 riaclonesub = riaclone.get(
1211 op.joinscip-python python python-stdlib 3.11 ntpath/realpath().('subdir', 'subds'), get_data=False,
1212 result_xfm='datasets', return_type='item-or-list')
1213 cml.assert_logged(msg="access to 1 dataset sibling store-storage not "
1214 "auto-enabled",
1215 level="INFO",
1216 regex=False)
1217 res = riaclonesub.get('testsub.txt')
1218 assert_result_count(res, 1,
1219 status='ok',
1220 path=strscip-python python python-stdlib 3.11 builtins/str#(riaclonesub.pathobj / 'testsub.txt'),
1221 message="from {}...".format(DEFAULT_REMOTE
1222 if urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(url).startswith('http')
1223 else "store-storage"))
1224
1225 # publication dependency was set for store-storage but not for
1226 # anotherstore-storage:
1227 eq_(riaclonesub.config.get(f"remote.{DEFAULT_REMOTE}.datalad-publish-depends",
1228 get_all=True),
1229 "store-storage")
1230
1231 # finally get the plain git subdataset.
1232 # Clone should figure to also clone it from a ria+ URL
1233 # (subdataset-source-candidate), notice that there wasn't an autoenabled ORA
1234 # remote, but shouldn't stumble upon it, since it's a plain git.
1235 res = riaclone.get(op.joinscip-python python python-stdlib 3.11 ntpath/realpath().('subdir', 'subgit', 'testgit.txt'))
1236 assert_result_count(res, 1, status='ok', type='dataset', action='install')
1237 assert_result_count(res, 1, status='notneeded', type='file')
1238 assert_result_count(res, 2)
1239 # no ORA remote, no publication dependency:
1240 riaclonesubgit = Dataset(riaclone.pathobj / 'subdir' / 'subgit')
1241 eq_(riaclonesubgit.config.get(f"remote.{DEFAULT_REMOTE}.datalad-publish-depends",
1242 get_all=True),
1243 None)
1244
1245 # Now, test that if cloning into a dataset, ria-URL is preserved and
1246 # post-clone configuration is triggered again, when we remove the subds and
1247 # retrieve it again via `get`:
1248 ds = Dataset(superdsscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(superds)).create()
1249 ria_url = 'ria+{}#{}'.format(urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(url), dsidscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(dsid))
1250 ds.clone(ria_url, 'sub')
1251 sds = ds.subdatasets('sub')
1252 eq_(len(sds), 1)
1253 eq_(sds[0]['gitmodule_datalad-url'], ria_url)
1254 assert_repo_status(ds.path)
1255 ds.drop('sub', what='all', reckless='kill', recursive=True)
1256 assert_repo_status(ds.path)
1257
1258 # .gitmodules still there:
1259 sds = ds.subdatasets('sub')
1260 eq_(len(sds), 1)
1261 eq_(sds[0]['gitmodule_datalad-url'], ria_url)
1262 # get it again:
1263
1264 # Autoenabling should fail initially by git-annex-init and we would report
1265 # on INFO level. Only postclone routine would deal with it.
1266 with swallow_logs(
1267 new_level=loggingscip-python python python-stdlib 3.11 logging/__init__:.INFOscip-python python python-stdlib 3.11 logging/INFO.INFO.,
1268 name='datalad.core.distributed.clone',
1269 ) as cml:
1270 ds.get('sub', get_data=False)
1271 cml.assert_logged(msg="access to 1 dataset sibling store-storage not "
1272 "auto-enabled",
1273 level="INFO",
1274 regex=False)
1275
1276 subds = Dataset(ds.pathobj / 'sub')
1277 # special remote is fine:
1278 res = subds.get('test.txt')
1279 assert_result_count(res, 1,
1280 status='ok',
1281 path=strscip-python python python-stdlib 3.11 builtins/str#(subds.pathobj / 'test.txt'),
1282 message="from {}...".format(DEFAULT_REMOTE
1283 if urlscip-python python datalad_next 1.5.0 `datalad_next.patches.tests.test_patched_ria_ora`/_test_ria_postclonecfg().(url).startswith('http')
1284 else "store-storage"))