Skip to content

Commit 2560e46

Browse files
authored
Merge pull request #7154 from ipfs/fix/car-sharness
test(sharness): improve CAR tests to remove some potential races
2 parents 01d0d11 + 5772ac7 commit 2560e46

File tree

1 file changed

+29
-38
lines changed

1 file changed

+29
-38
lines changed

test/sharness/t0054-dag-car-import-export.sh

+29-38
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ tab=$'\t'
1414
reset_blockstore() {
1515
node=$1
1616

17-
ipfsi $node pin ls --quiet --type=recursive | ipfsi $node pin rm &>/dev/null
18-
ipfsi $node repo gc &>/dev/null
17+
ipfsi "$node" pin ls --quiet --type=recursive | ipfsi "$node" pin rm &>/dev/null
18+
ipfsi "$node" repo gc &>/dev/null
1919

2020
test_expect_success "pinlist empty" '
2121
[[ -z "$( ipfsi $node pin ls )" ]]
@@ -27,18 +27,20 @@ reset_blockstore() {
2727

2828
# hammer with concurrent gc to ensure nothing clashes
2929
do_import() {
30-
node=$1; shift
30+
node="$1"; shift
31+
(
32+
touch spin.gc
3133

32-
# for tests below expecting this to be non -z
33-
echo "FIXME: BELOW TEST DISABLED FOR THE TIME BEING" > gc_out
34+
while [[ -e spin.gc ]]; do ipfsi "$node" repo gc &>/dev/null; done &
35+
while [[ -e spin.gc ]]; do ipfsi "$node" repo gc &>/dev/null; done &
3436

35-
#touch spin.gc
36-
#timeout -s QUIT 30 bash -c "while [[ -e spin.gc ]]; do ipfsi $node repo gc &>>gc_out; done" & gc1_pid=$!
37-
#timeout -s QUIT 25 bash -c "while [[ -e spin.gc ]]; do ipfsi $node repo gc &>>gc_out; done" & gc2_pid=$!
37+
ipfsi "$node" dag import "$@" 2>&1 && ipfsi "$node" repo verify &>/dev/null
38+
result=$?
3839

39-
timeout -s QUIT 20 bash -c "ipfsi $node dag import $* 2>&1"
40-
41-
rm -f spin.gc || true
40+
rm -f spin.gc &>/dev/null
41+
wait
42+
exit $result
43+
)
4244
}
4345

4446
run_online_imp_exp_tests() {
@@ -66,10 +68,6 @@ EOE
6668
| sort > basic_import_actual
6769
'
6870

69-
# FIXME - positive-test the lack of output when https://github.com/ipfs/go-ipfs/issues/7121 is addressed
70-
test_expect_failure "concurrent GC did not manage to grab anything and remained silent" '
71-
test_cmp /dev/null gc_out
72-
'
7371
test_expect_success "basic import output as expected" '
7472
test_cmp basic_import_expected basic_import_actual
7573
'
@@ -107,37 +105,30 @@ EOE
107105
mkfifo pipe_testnet
108106
mkfifo pipe_devnet
109107

110-
# test that ipfs correctly opens both pipes and deleting them doesn't interfere with cleanup
111-
bash -c '
112-
sleep 1
113-
cat ../t0054-dag-car-import-export-data/lotus_testnet_export_128_shuffled_nulroot.car > pipe_testnet & cat1_pid=$!
114-
cat ../t0054-dag-car-import-export-data/lotus_devnet_genesis_shuffled_nulroot.car > pipe_devnet & cat2_pid=$!
115-
116-
rm pipe_testnet pipe_devnet
108+
test_expect_success "fifo import" '
109+
(
110+
cat ../t0054-dag-car-import-export-data/lotus_testnet_export_128_shuffled_nulroot.car > pipe_testnet &
111+
cat ../t0054-dag-car-import-export-data/lotus_devnet_genesis_shuffled_nulroot.car > pipe_devnet &
117112
118-
# extra safety valve to kill the cat processes in case something goes wrong
119-
bash -c "sleep 60; kill $cat1_pid $cat2_pid 2>/dev/null" &
120-
' &
113+
do_import 0 \
114+
pipe_testnet \
115+
pipe_devnet \
116+
../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
117+
| sort > basic_fifo_import_actual
118+
result=$?
121119
122-
test_expect_success "fifo import" '
123-
do_import 0 \
124-
pipe_testnet \
125-
pipe_devnet \
126-
../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
127-
| sort > basic_fifo_import_actual
120+
wait
121+
exit "$result"
122+
)
128123
'
129-
# FIXME - positive-test the lack of output when https://github.com/ipfs/go-ipfs/issues/7121 is addressed
130-
test_expect_failure "concurrent GC did not manage to grab anything and remained silent" '
131-
test_cmp /dev/null gc_out
124+
125+
test_expect_success "remove fifos" '
126+
rm pipe_testnet pipe_devnet
132127
'
133128

134129
test_expect_success "fifo-import output as expected" '
135130
test_cmp basic_import_expected basic_fifo_import_actual
136131
'
137-
138-
test_expect_success "fifos no longer present" '
139-
! [[ -e pipe_testnet ]] && ! [[ -e pipe_devnet ]]
140-
'
141132
}
142133

143134

0 commit comments

Comments
 (0)