@cryptotaxi247 / kubo / commits / 37bfef884

t0060: reactivate daemon tests

Tests in this script had been deactivated because there was no good way to wait until the daemon was ready. Now that we can use pollEndpoint for that it's time to reactivate the tests. License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>

Christian Couder committed Mar 8, 2015 at 21:54 UTC 37bfef884ca82f18ff3a77fa559bfcdf94f11f3c
1 file changed +23 -13
test/sharness/t0060-daemon.sh
+23 -13
@@ -4,24 +4,25 @@
4 # MIT Licensed; see the LICENSE file in this repository.
5 #
6
7 -echo "currently skipping 'Test daemon command', until we find a better way to wait."
8 -exit 0
9 -
7 test_description="Test daemon command"
8
9 . lib/test-lib.sh
10
11 +# this needs to be in a different test than "ipfs daemon --init" below
12 +test_expect_success "setup IPFS_PATH" '
13 + IPFS_PATH="$(pwd)/.go-ipfs"
14 +'
15 +
16 # NOTE: this should remove bootstrap peers (needs a flag)
17 test_expect_success "ipfs daemon --init launches" '
16 - export IPFS_PATH="$(pwd)/.go-ipfs" &&
17 - ipfs daemon --init 2>&1 >actual_init &
18 + ipfs daemon --init >actual_daemon 2>daemon_err &
19 '
20
20 -# this is because we have no way of knowing the daemon is done except look at
21 -# output. but we can't yet compare it because we dont have the peer ID (config)
21 +# this is like "'ipfs daemon' is ready" in test_launch_ipfs_daemon(), see test-lib.sh
22 test_expect_success "initialization ended" '
23 IPFS_PID=$! &&
24 - test_wait_output_n_lines_60_sec actual_init 6
24 + pollEndpoint -ep=/version -v -tout=1s -tries=60 2>poll_apierr > poll_apiout ||
25 + test_fsh cat actual_daemon || test_fsh cat daemon_err || test_fsh cat poll_apierr || test_fsh cat poll_apiout
26 '
27
28 # this is lifted straight from t0020-init.sh
@@ -32,16 +33,25 @@ test_expect_success "ipfs peer id looks good" '
33 test_cmp_repeat_10_sec expected actual
34 '
35
35 -# note this is almost the same as t0020-init.sh "ipfs init output looks good"
36 -test_expect_success "ipfs daemon output looks good" '
36 +# This is like t0020-init.sh "ipfs init output looks good"
37 +#
38 +# Unfortunately the line:
39 +#
40 +# API server listening on /ip4/127.0.0.1/tcp/5001
41 +#
42 +# sometimes doesn't show up, so we cannot use test_expect_success yet.
43 +#
44 +test_expect_failure "ipfs daemon output looks good" '
45 STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" &&
38 - echo "initializing ipfs node at $IPFS_PATH" >expected &&
46 + echo "Initializing daemon..." >expected &&
47 + echo "initializing ipfs node at $IPFS_PATH" >>expected &&
48 echo "generating 4096-bit RSA keypair...done" >>expected &&
49 echo "peer identity: $PEERID" >>expected &&
50 echo "to get started, enter:" >>expected &&
51 printf "\\n\\t$STARTFILE\\n\\n" >>expected &&
43 - echo "daemon listening on /ip4/127.0.0.1/tcp/5001" >>expected &&
44 - test_cmp_repeat_10_sec expected actual_init
52 + echo "API server listening on /ip4/127.0.0.1/tcp/5001" >>expected &&
53 + echo "Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080" >>expected &&
54 + test_cmp_repeat_10_sec expected actual_daemon
55 '
56
57 test_expect_success ".go-ipfs/ has been created" '