Skip to content

Commit 3a37320

Browse files
committed
Merge pull request #35 from ipfs/more-migration-stress
More migration stress
2 parents 39184fb + fc82eeb commit 3a37320

File tree

2 files changed

+107
-6
lines changed

2 files changed

+107
-6
lines changed

sharness/lib/test-lib.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ test "$TEST_VERBOSE" = 1 && verbose=t && echo '# TEST_VERBOSE='"$TEST_VERBOSE"
2121

2222
# Please put fs-repo-migrations specific shell functions and variables below
2323

24+
test "$TEST_EXPENSIVE" = 1 && test_set_prereq EXPENSIVE
25+
2426
DEFAULT_DOCKER_IMG="debian"
2527
DOCKER_IMG="$DEFAULT_DOCKER_IMG"
2628

sharness/t0060-migration-stress.sh

Lines changed: 105 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,28 @@ test_description="Test migration 2 to 3 with lots of objects"
55
. lib/test-lib.sh
66

77
# setup vars for tests
8-
DEPTH=6
9-
PINTOTAL=2000
10-
if [ ! -z "$CI" ]; then
11-
DEPTH=3
12-
PINTOTAL=200
8+
9+
DEPTH=3
10+
NBDIR=3
11+
NBFILE=6
12+
PINTOTAL=20
13+
14+
if test_have_prereq EXPENSIVE
15+
then
16+
DEPTH=6
17+
NBDIR=7
18+
NBFILE=10
19+
PINTOTAL=2000
1320
fi
1421

1522
PINEACH=$(expr $PINTOTAL / 2)
1623

24+
echo "DEPTH: $DEPTH"
25+
echo "NBDIR: $NBDIR"
26+
echo "NBFILE: $NBFILE"
27+
echo "PINTOTAL: $PINTOTAL"
28+
echo "PINEACH: $PINEACH"
29+
1730
test_expect_success "start a docker container" '
1831
DOCID=$(start_docker)
1932
'
@@ -48,7 +61,8 @@ test_init_daemon "$DOCID"
4861
test_start_daemon "$DOCID"
4962

5063
test_expect_success "make a couple files" '
51-
drun "$GUEST_RANDOM_FILES -depth=$DEPTH -dirs=7 -files=10 manyfiles" > filenames
64+
drun "rm -rf manyfiles" &&
65+
drun "$GUEST_RANDOM_FILES -depth=$DEPTH -dirs=$NBDIR -files=$NBFILE manyfiles" > filenames
5266
'
5367

5468
test_expect_success "add a few files" '
@@ -179,6 +193,91 @@ test_expect_success "no pinned objects are missing from local refs" '
179193
test_can_fetch_buggy_hashes missing_pinned_objects
180194
'
181195

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+
182281
test_expect_success "stop docker container" '
183282
stop_docker "$DOCID"
184283
'

0 commit comments

Comments
 (0)