From 993e7816f84dc4eb6bc8303763a6897d9387ca95 Mon Sep 17 00:00:00 2001 From: Jan Winkelmann Date: Wed, 30 Nov 2016 15:04:37 +0100 Subject: [PATCH] pubsub sharness tests after chriscool feedback License: MIT Signed-off-by: Jan Winkelmann --- test/sharness/lib/iptb-lib.sh | 8 +++++--- test/sharness/t0180-pubsub.sh | 15 +++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/test/sharness/lib/iptb-lib.sh b/test/sharness/lib/iptb-lib.sh index 67841e2e4..89ab77899 100644 --- a/test/sharness/lib/iptb-lib.sh +++ b/test/sharness/lib/iptb-lib.sh @@ -19,11 +19,13 @@ check_has_connection() { startup_cluster() { num_nodes="$1" + shift + other_args="$@" bound=$(expr "$num_nodes" - 1) - if [ "$2" = "--enable-pubsub-experiment" ]; then - test_expect_success "start up nodes with pubsub enabled" ' - iptb start --args --enable-pubsub-experiment + if test -n "$other_args"; then + test_expect_success "start up nodes with additional args" ' + iptb start --args $other_args ' else test_expect_success "start up nodes" ' diff --git a/test/sharness/t0180-pubsub.sh b/test/sharness/t0180-pubsub.sh index 2ca19a343..1f5a619f9 100755 --- a/test/sharness/t0180-pubsub.sh +++ b/test/sharness/t0180-pubsub.sh @@ -24,18 +24,17 @@ test_expect_success 'pubsub' ' mkfifo wait || test_fsh echo init fail + # ipfs pubsub sub is long-running so we need to start it in the background and + # wait put its output somewhere where we can access it ( - ipfsi 0 pubsub sub --enc=ndpayload testTopic | - while read line; do + ipfsi 0 pubsub sub --enc=ndpayload testTopic | if read line; then echo $line > actual && - echo > done - exit - done + echo > wait + fi ) & - ipfspid=$! - - sleep 1 + # wait until ipfs pubsub sub is ready to do work + sleep 1 && # publish something ipfsi 1 pubsub pub testTopic "testOK" &> pubErr &&