11#! /bin/sh
22
3- test_description=' Test flux-filemap '
3+ test_description=' Test flux-archive '
44
55. ` dirname $0 ` /content/content-helper.sh
66
@@ -33,16 +33,17 @@ if havesparse testholes; then
3333 test_set_prereq HAVE_SPARSE
3434fi
3535
36- test_under_flux 2 minimal
36+ test_under_flux 2 kvs
3737
3838# after test_under_flux is launched, cannot assume what umask is. An
3939# unexpected umask could affect tests below. Hard code to 022 for
4040# these tests.
4141umask 022
4242
43- test_expect_success ' load content module' '
44- flux exec flux module load content
45- '
43+ # Usage: list_mapped_files tag
44+ list_mapped_files () {
45+ flux module stats content | jq -r " .mmap.tags[\" $1 \" ][]"
46+ }
4647
4748test_expect_success ' create copy directory' '
4849 mkdir -p copydir
@@ -53,25 +54,40 @@ test_expect_success 'create test file' '
5354 chmod go=r testfile
5455'
5556test_expect_success ' map nonexistent file fails' '
56- test_must_fail flux filemap map notafile
57+ test_must_fail flux archive create --mmap notafile
58+ '
59+ test_expect_success ' map fails on rank != 0' '
60+ test_must_fail flux exec -r 1 flux archive create --mmap testfile
61+ '
62+ test_expect_success ' map fails with --preserve' '
63+ test_must_fail flux archive create --mmap --preserve testfile
64+ '
65+ test_expect_success ' map fails with --no-force-primary' '
66+ test_must_fail flux archive create --mmap --no-force-primary testfile
5767'
5868test_expect_success ' map unreadable file fails with appropriate error' '
5969 touch unreadable &&
6070 chmod ugo-r unreadable &&
61- test_must_fail flux filemap map unreadable 2>unreadable.err &&
71+ test_must_fail flux archive create --mmap unreadable 2>unreadable.err &&
6272 grep "Permission denied" unreadable.err
6373'
6474test_expect_success ' map test file' '
65- flux filemap map ./testfile
75+ flux archive create --mmap ./testfile &&
76+ flux kvs get --raw archive.main | jq
77+ '
78+ test_expect_success ' content stats show mapped file' '
79+ list_mapped_files main >stats.out &&
80+ realpath ./testfile >stats.exp &&
81+ test_cmp stats.exp stats.out
6682'
6783test_expect_success ' file can be listed' '
68- flux filemap list
84+ flux archive list
6985'
7086test_expect_success ' file can be listed in long form' '
71- flux filemap list --long
87+ flux archive list --long
7288'
7389test_expect_success ' test file can be read through content cache on rank 0' '
74- flux filemap get -C copydir
90+ flux archive extract -C copydir
7591'
7692test_expect_success ' file content is correct' '
7793 test_cmp testfile copydir/testfile
@@ -83,36 +99,38 @@ test_expect_success 'file permissions are correct' '
8399'
84100test_expect_success ' test file can be read through content cache on rank 1' '
85101 rm -f copydir/testfile &&
86- flux exec -r 1 flux filemap get -C copydir &&
102+ flux exec -r 1 flux archive extract -C copydir &&
87103 test_cmp testfile copydir/testfile
88104'
89105test_expect_success ' unmap test file' '
90- flux filemap unmap
106+ flux archive remove
107+ '
108+ test_expect_success ' content stats no longer show mapped file' '
109+ test_must_fail list_mapped_files archive.main
91110'
92111test_expect_success ' drop the cache' '
93112 flux exec -r 1 flux content dropcache &&
94113 flux content dropcache
95114'
96115test_expect_success ' test file is not extracted' '
97116 rm -f copydir/testfile &&
98- flux filemap get -C copydir &&
99- test_must_fail test -f copydir/testfile
117+ test_must_fail flux archive extract
100118'
101- test_expect_success ' map test file with small blobsize ' '
102- flux filemap map --chunksize=10 ./testfile
119+ test_expect_success ' map test file with small chunksize ' '
120+ flux archive create --mmap --chunksize=10 ./testfile
103121'
104122test_expect_success ' test file can be read through content cache on rank 0' '
105123 rm -f copydir/testfile &&
106- flux filemap get -C copydir &&
124+ flux archive extract -C copydir &&
107125 test_cmp testfile copydir/testfile
108126'
109127test_expect_success ' test file can be read through content cache on rank 1' '
110128 rm -f copydir/testfile &&
111- flux exec -r 1 flux filemap get -C copydir &&
129+ flux exec -r 1 flux archive extract -C copydir &&
112130 test_cmp testfile copydir/testfile
113131'
114132test_expect_success ' unmap test file' '
115- flux filemap unmap
133+ flux archive remove
116134'
117135test_expect_success ' drop the cache' '
118136 flux exec -r 1 flux content dropcache &&
@@ -121,43 +139,39 @@ test_expect_success 'drop the cache' '
121139test_expect_success ' create test file' '
122140 echo abcdefghijklmnopqrstuvwxyz >testfile2
123141'
124- test_expect_success ' map test file and get its blobref' '
125- flux filemap map ./testfile2 &&
126- flux filemap list --blobref >testfile2.blobref
142+ test_expect_success ' map test file with small small-file-threshold' '
143+ flux archive create --mmap --small-file-threshold=10 ./testfile2
127144'
128- test_expect_success ' show raw object' '
129- flux filemap list --raw | jq .
130- '
131- test_expect_success ' test file can be read through content cache on rank 1' '
132- flux exec -r 1 flux filemap get -C copydir &&
133- test_cmp testfile2 copydir/testfile2
134- '
135- test_expect_success ' store the duplicate blob on rank 1' '
136- flux content load <testfile2.blobref >testfile2.fileref &&
137- flux exec -r 1 flux content store <testfile2.fileref \
145+ test_expect_success ' extract blobref from mapped file' "
146+ flux kvs get --raw archive.main >testfile2.json &&
147+ jq -r '.[0].data[0][2]' <testfile2.json >testfile2.blobref
148+ "
149+ test_expect_success ' store the duplicate blob to the mapped one on rank 1' '
150+ flux content load <testfile2.blobref >testfile2.data &&
151+ flux exec -r 1 flux content store <testfile2.data \
138152 >testfile2.blobref2 &&
139153 test_cmp testfile2.blobref testfile2.blobref2
140154'
141155test_expect_success ' unmap test file' '
142- flux filemap unmap
156+ flux archive remove
143157'
144158test_expect_success ' drop the cache' '
145159 flux exec -r 1 flux content dropcache &&
146160 flux content dropcache
147161'
148162test_expect_success ' blob can still be read through content cache on rank 1' '
149163 flux exec -r 1 flux content load <testfile2.blobref2 \
150- >testfile2.fileref2 &&
151- test_cmp testfile2.fileref testfile2.fileref2
164+ >testfile2.data2 &&
165+ test_cmp testfile2.data testfile2.data2
152166'
153167test_expect_success HAVE_SPARSE ' create sparse test file' '
154168 truncate --size=8192 testfile3
155169'
156170test_expect_success HAVE_SPARSE ' map test file' '
157- flux filemap map ./testfile3
171+ flux archive create --mmap ./testfile3
158172'
159173test_expect_success HAVE_SPARSE ' test file can be read through content cache' '
160- flux filemap get -C copydir &&
174+ flux archive extract -C copydir &&
161175 test_cmp testfile3 copydir/testfile3
162176'
163177test_expect_success HAVE_SPARSE ' holes were preserved' '
@@ -166,17 +180,17 @@ test_expect_success HAVE_SPARSE 'holes were preserved' '
166180 test_cmp blocks.exp blocks.out
167181'
168182test_expect_success HAVE_SPARSE ' unmap test file' '
169- flux filemap unmap
183+ flux archive remove
170184'
171185test_expect_success HAVE_SPARSE ' create sparse test file with data' '
172186 truncate --size=8192 testfile3b &&
173187 echo more-data >>testfile3b
174188'
175189test_expect_success HAVE_SPARSE ' map test file' '
176- flux filemap map ./testfile3b
190+ flux archive create --mmap ./testfile3b
177191'
178192test_expect_success HAVE_SPARSE ' test file can be read through content cache' '
179- flux filemap get -C copydir &&
193+ flux archive extract -C copydir &&
180194 test_cmp testfile3b copydir/testfile3b
181195'
182196test_expect_success HAVE_SPARSE ' holes were preserved' '
@@ -185,155 +199,112 @@ test_expect_success HAVE_SPARSE 'holes were preserved' '
185199 test_cmp blocks3b.exp blocks3b.out
186200'
187201test_expect_success HAVE_SPARSE ' unmap test file' '
188- flux filemap unmap
202+ flux archive remove
189203'
190204test_expect_success ' create test symlink' '
191205 ln -s /a/b/c/d testfile4
192206'
193207test_expect_success ' map test file' '
194- flux filemap map ./testfile4
208+ flux archive create --mmap ./testfile4
195209'
196210test_expect_success ' show raw object' '
197- flux filemap list --raw | jq .
211+ flux kvs get --raw archive.main | jq .
198212'
199- test_expect_success ' test file can be read through content cache ' '
200- flux filemap get -vv -C copydir
213+ test_expect_success ' test file can be extracted ' '
214+ flux archive extract -v -C copydir
201215'
202216test_expect_success ' copy is a symlink with expected target' '
203217 readlink testfile4 >link.exp &&
204218 readlink copydir/testfile4 >link.out &&
205219 test_cmp link.exp link.out
206220'
207221test_expect_success ' unmap test file' '
208- flux filemap unmap
222+ flux archive remove
209223'
210224test_expect_success ' map file by absolute path' '
211- flux filemap map /etc/group
225+ flux archive create --mmap /etc/group
212226'
213227test_expect_success ' test file lists with relative path' '
214228 cat >list.exp <<-EOT &&
215229 etc/group
216230 EOT
217- flux filemap list >list.out &&
231+ flux archive list >list.out &&
218232 test_cmp list.exp list.out
219233'
220234test_expect_success ' unmap test file' '
221- flux filemap unmap
235+ flux archive remove
222236'
223237test_expect_success ' create test directory' '
224238 mkdir testfile5
225239'
226240test_expect_success ' map test file' '
227- flux filemap map ./testfile5
241+ flux archive create --mmap ./testfile5
228242'
229243test_expect_success ' test file can be read through content cache' '
230- flux filemap get -vv -C copydir
244+ flux archive extract -v -C copydir
231245'
232246test_expect_success ' copy is a directory' '
233247 test -d copydir/testfile5
234248'
235249test_expect_success ' unmap test file' '
236- flux filemap unmap
237- '
238- test_expect_success ' map testfile with tags=red,blue' '
239- flux filemap map --tags=red,blue ./testfile
240- '
241- test_expect_success ' map testfile with tags=green' '
242- flux filemap map --tags=green ./testfile
243- '
244- test_expect_success ' map testfile with tags=green (again)' '
245- flux filemap map --tags=green ./testfile
246- '
247- test_expect_success ' map testfile2 with tags=green' '
248- flux filemap map --tags=green ./testfile2
249- '
250- test_expect_success ' list tags=red,blue,green reports two files' '
251- test $(flux filemap list --tags=red,blue,green | wc -l) -eq 2
252- '
253- test_expect_success ' unmap red tag' '
254- flux filemap unmap --tags=red
255- '
256- test_expect_success ' list tags=red,blue,green reports two files' '
257- test $(flux filemap list --tags=red,blue,green | wc -l) -eq 2
258- '
259- test_expect_success ' unmap tags=blue,green' '
260- flux filemap unmap --tags=blue,green
261- '
262- test_expect_success ' flux filemap list reports no files' '
263- test $(flux filemap list --tags red,blue,green | wc -l) -eq 0
264- '
265- test_expect_success ' map test file without mmap' '
266- rm -f copydir/testfile &&
267- flux filemap map --disable-mmap ./testfile
268- '
269- test_expect_success ' test file did not use blobvec encoding' '
270- flux filemap list --raw | jq -e ".encoding != \"blobvec\""
271- '
272- test_expect_success ' unmap test file' '
273- flux filemap unmap
250+ flux archive remove
274251'
275252test_expect_success ' map small test file with reduced small file threshold' '
276- flux filemap map --small-file-threshold=0 ./testfile2
253+ flux archive create --mmap --small-file-threshold=0 ./testfile2
277254'
278255test_expect_success ' test file used blobvec encoding' '
279- flux filemap list --raw | jq -e ".encoding = \"blobvec\""
256+ flux kvs get --raw archive.main | jq -e ".[0]. encoding = = \"blobvec\""
280257'
281258test_expect_success ' unmap test file' '
282- flux filemap unmap
259+ flux archive remove
283260'
284-
285261test_expect_success ' map test file' '
286262 rm -f copydir/testfile &&
287- flux filemap map ./testfile
263+ flux archive create --mmap ./testfile
288264'
289265test_expect_success ' modify mapped test file without reducing its size' '
290266 dd if=/dev/zero of=testfile bs=4096 count=1 conv=notrunc
291267'
292268test_expect_success ' content change should cause an error' '
293269 rm -f copydir/testfile &&
294- test_must_fail flux filemap get -C copydir 2>changed.err &&
270+ test_must_fail flux archive extract -C copydir 2>changed.err &&
295271 grep changed changed.err
296272'
297273test_expect_success ' drop cache and unmap test file' '
298274 flux content dropcache &&
299- flux filemap unmap
275+ flux archive remove
300276'
301277test_expect_success ' map test file' '
302278 rm -f copydir/testfile &&
303- flux filemap map ./testfile
279+ flux archive create --mmap ./testfile
304280'
305281test_expect_success ' truncate mapped test file' '
306282 cp /dev/null testfile
307283'
308284test_expect_success ' size reduction should cause an error' '
309285 rm -f copydir/testfile &&
310- test_must_fail flux filemap get -C copydir 2>reduced.err &&
286+ test_must_fail flux archive extract -C copydir 2>reduced.err &&
311287 grep changed reduced.err
312288'
313289test_expect_success ' unmap test file' '
314- flux filemap unmap
290+ flux archive remove
315291'
316-
317292test_expect_success ' re-create and map test file' '
318293 ${LPTEST} >testfile &&
319- flux filemap map ./testfile
294+ flux archive create --mmap ./testfile
320295'
321- test_expect_success ' get copydir/testfile' '
296+ test_expect_success ' extract copydir/testfile' '
322297 rm -f copydir/testfile &&
323- flux filemap get -C copydir
298+ flux archive extract -C copydir
324299'
325- test_expect_success ' get --overwrite works' '
326- flux filemap get --overwrite -C copydir
300+ test_expect_success ' extract --overwrite works' '
301+ flux archive extract --overwrite -C copydir
327302'
328- test_expect_success ' get refuses to overwrite without explicit option' '
329- test_must_fail flux filemap get -C copydir
303+ test_expect_success ' extract refuses to overwrite without explicit option' '
304+ test_must_fail flux archive extract -C copydir
330305'
331306test_expect_success ' unmap test file' '
332- flux filemap unmap
333- '
334-
335- test_expect_success ' remove content module' '
336- flux exec flux module remove content
307+ flux archive remove
337308'
338309
339310test_done
0 commit comments