Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(sharness): improve CAR tests to remove some potential races #7154

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 29 additions & 38 deletions test/sharness/t0054-dag-car-import-export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ tab=$'\t'
reset_blockstore() {
node=$1

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

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

# hammer with concurrent gc to ensure nothing clashes
do_import() {
node=$1; shift
node="$1"; shift
(
touch spin.gc

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

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

timeout -s QUIT 20 bash -c "ipfsi $node dag import $* 2>&1"

rm -f spin.gc || true
rm -f spin.gc &>/dev/null
wait
exit $result
)
}

run_online_imp_exp_tests() {
Expand Down Expand Up @@ -66,10 +68,6 @@ EOE
| sort > basic_import_actual
'

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

# test that ipfs correctly opens both pipes and deleting them doesn't interfere with cleanup
bash -c '
sleep 1
cat ../t0054-dag-car-import-export-data/lotus_testnet_export_128_shuffled_nulroot.car > pipe_testnet & cat1_pid=$!
cat ../t0054-dag-car-import-export-data/lotus_devnet_genesis_shuffled_nulroot.car > pipe_devnet & cat2_pid=$!

rm pipe_testnet pipe_devnet
test_expect_success "fifo import" '
(
cat ../t0054-dag-car-import-export-data/lotus_testnet_export_128_shuffled_nulroot.car > pipe_testnet &
cat ../t0054-dag-car-import-export-data/lotus_devnet_genesis_shuffled_nulroot.car > pipe_devnet &

# extra safety valve to kill the cat processes in case something goes wrong
bash -c "sleep 60; kill $cat1_pid $cat2_pid 2>/dev/null" &
' &
do_import 0 \
pipe_testnet \
pipe_devnet \
../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
| sort > basic_fifo_import_actual
result=$?

test_expect_success "fifo import" '
do_import 0 \
pipe_testnet \
pipe_devnet \
../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
| sort > basic_fifo_import_actual
wait
exit "$result"
)
'
# FIXME - positive-test the lack of output when https://github.com/ipfs/go-ipfs/issues/7121 is addressed
test_expect_failure "concurrent GC did not manage to grab anything and remained silent" '
test_cmp /dev/null gc_out

test_expect_success "remove fifos" '
rm pipe_testnet pipe_devnet
'

test_expect_success "fifo-import output as expected" '
test_cmp basic_import_expected basic_fifo_import_actual
'

test_expect_success "fifos no longer present" '
! [[ -e pipe_testnet ]] && ! [[ -e pipe_devnet ]]
'
}


Expand Down