Skip to content

Commit fc82eeb

Browse files
committed
t0060: add tests for revert migration
1 parent c662693 commit fc82eeb

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

sharness/t0060-migration-stress.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,91 @@ test_expect_success "no pinned objects are missing from local refs" '
193193
test_can_fetch_buggy_hashes missing_pinned_objects
194194
'
195195

196+
test_expect_success "make a couple more files" '
197+
drun "$GUEST_RANDOM_FILES -depth=$DEPTH -dirs=$NBDIR -files=$NBFILE many_more_files" > more_filenames
198+
'
199+
200+
test_expect_success "add the new files" '
201+
drun "ipfs add -r -q many_more_files" | tee more_hashes
202+
'
203+
204+
test_expect_success "unpin root so we can do things ourselves" '
205+
drun "ipfs pin rm $(tail -n1 more_hashes)"
206+
'
207+
208+
test_expect_success "select random subset to pin recursively and directly" '
209+
sort -R more_hashes | head -n$PINTOTAL > more_topin &&
210+
head -n$PINEACH more_topin > more_recurpins &&
211+
tail -n$PINEACH more_topin > more_directpins
212+
'
213+
214+
test_expect_success "pin some objects recursively" '
215+
pin_hashes more_recurpins
216+
'
217+
218+
test_expect_success "pin some objects directly" '
219+
pin_hashes more_directpins "-r=false"
220+
'
221+
222+
test_expect_success "get full ref list" '
223+
drun "ipfs refs local" | sort > more_start_refs
224+
'
225+
226+
test_expect_success "get pin lists" '
227+
drun "ipfs pin ls --type=recursive" | sort > more_start_rec_pins &&
228+
drun "ipfs pin ls --type=direct" | sort > more_start_dir_pins &&
229+
drun "ipfs pin ls --type=indirect" | sort > more_start_ind_pins
230+
'
231+
232+
test_expect_success "'ipfs-2-to-3 -revert' succeeds" '
233+
drun "$GUEST_IPFS_2_TO_3 -revert -path=/root/.ipfs" >actual
234+
'
235+
236+
test_expect_success "'ipfs-2-to-3 -revert' output looks good" '
237+
grep "writing keys:" actual ||
238+
test_fsh cat actual
239+
'
240+
241+
test_install_version "v0.3.11"
242+
243+
test_start_daemon $DOCID
244+
245+
test_expect_success "list all refs after reverting migration" '
246+
drun "ipfs refs local" | sort > after_revert_refs
247+
'
248+
249+
test_expect_success "list all pins after reverting migration" '
250+
drun "ipfs pin ls --type=recursive" | sort > after_revert_rec_pins &&
251+
drun "ipfs pin ls --type=direct" | sort > after_revert_dir_pins &&
252+
drun "ipfs pin ls --type=indirect" | sort > after_revert_ind_pins
253+
'
254+
255+
test_expect_success "refs look right" '
256+
comm -23 more_start_refs after_revert_refs > missing_refs &&
257+
test_cmp missing_refs empty_refs_file
258+
'
259+
260+
test_expect_success "pins all look the same" '
261+
test_cmp more_start_rec_pins after_revert_rec_pins &&
262+
test_cmp more_start_dir_pins after_revert_dir_pins &&
263+
test_cmp more_start_ind_pins after_revert_ind_pins
264+
'
265+
266+
test_expect_success "manually compute gc set" '
267+
cat after_revert_rec_pins after_revert_dir_pins after_revert_ind_pins | sort > after_revert_all_pinned
268+
'
269+
270+
test_expect_success "run a gc" '
271+
drun "ipfs repo gc" | sort > gc_out
272+
'
273+
274+
test_expect_success "no pinned objects were gc'ed" '
275+
comm -12 gc_out after_revert_all_pinned > gced_pinned_objects &&
276+
test_cmp empty_refs_file gced_pinned_objects
277+
'
278+
279+
test_stop_daemon $DOCID
280+
196281
test_expect_success "stop docker container" '
197282
stop_docker "$DOCID"
198283
'

0 commit comments

Comments
 (0)