sharness/daemon: improve error detection
Henry committed
May 29, 2015 at 14:20 UTC
37b32a658775dd94d7ebb8d71720e62924c316d6
1 file changed
+15
-8
test/sharness/t0060-daemon.sh
+15
-8
@@ -14,7 +14,9 @@ test_expect_success "setup IPFS_PATH" '
14
'
15
16
# NOTE: this should remove bootstrap peers (needs a flag)
17
-# TODO(cryptix): also default ports - might clash with local clients, failure in that case isn't clear because pollEndpoint just passes too
17
+# TODO(cryptix):
18
+# - we won't see daemon startup failure because we put the daemon in the background - fix: fork with exit code after api listen
19
+# - also default ports: might clash with local clients. Failure in that case isn't clear as well because pollEndpoint just uses the already running node
20
test_expect_success "ipfs daemon --init launches" '
21
ipfs daemon --init >actual_daemon 2>daemon_err &
22
'
@@ -26,9 +28,14 @@ test_expect_success "initialization ended" '
28
test_fsh cat actual_daemon || test_fsh cat daemon_err || test_fsh cat poll_apierr || test_fsh cat poll_apiout
29
'
30
31
+# this errors if daemon didnt --init $IPFS_PATH correctly
32
+test_expect_success "'ipfs config Identity.PeerID' works" '
33
+ ipfs config Identity.PeerID >config_peerId
34
+'
35
+
36
# this is lifted straight from t0020-init.sh
37
test_expect_success "ipfs peer id looks good" '
31
- PEERID=$(ipfs config Identity.PeerID) &&
38
+ PEERID=$(cat config_peerId) &&
39
echo $PEERID | tr -dC "[:alnum:]" | wc -c | tr -d " " >actual_id &&
40
echo "46" >expected_id &&
41
test_cmp_repeat_10_sec expected_id actual_id
@@ -42,7 +49,7 @@ test_expect_success "ipfs peer id looks good" '
49
#
50
# sometimes doesn't show up, so we cannot use test_expect_success yet.
51
#
45
-test_expect_failure "ipfs daemon output looks good" '
52
+test_expect_success "ipfs daemon output looks good" '
53
STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" &&
54
echo "Initializing daemon..." >expected_daemon &&
55
echo "initializing ipfs node at $IPFS_PATH" >>expected_daemon &&
@@ -52,7 +59,7 @@ test_expect_failure "ipfs daemon output looks good" '
59
printf "\\n\\t$STARTFILE\\n\\n" >>expected_daemon &&
60
echo "API server listening on /ip4/127.0.0.1/tcp/5001" >>expected_daemon &&
61
echo "Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080" >>expected_daemon &&
55
- test_cmp_repeat_10_sec expected_daemon actual_daemon
62
+ test_cmp expected_daemon actual_daemon
63
'
64
65
test_expect_success ".ipfs/ has been created" '
@@ -93,11 +100,11 @@ test_expect_success "'ipfs daemon' can be killed" '
100
test_kill_repeat_10_sec $IPFS_PID
101
'
102
96
-test_expect_failure "'ipfs daemon' should be able to run with a pipe attached to stdin (issue #861)" '
97
- yes | ipfs daemon --init >daemon_out 2>daemon_err &
98
- pollEndpoint -ep=/version -v -tout=1s -tries=10 >poll_apiout 2>poll_apierr &&
103
+test_expect_success "'ipfs daemon' should be able to run with a pipe attached to stdin (issue #861)" '
104
+ yes | ipfs daemon --init >stdin_daemon_out 2>stdin_daemon_err &
105
+ pollEndpoint -ep=/version -v -tout=1s -tries=10 >stdin_poll_apiout 2>stdin_poll_apierr &&
106
test_kill_repeat_10_sec $! ||
100
- test_fsh cat daemon_out || test_fsh cat daemon_err || test_fsh cat poll_apiout || test_fsh cat poll_apierr
107
+ test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr
108
'
109
110
test_done