提交 597d6841 作者: Stephen Whitmore

Adds arbitrary port support to t0060-daemon.sh.

Removes all of the hardcoded ports and defaults to non-standard API,
Gateway, and Swarm ports.

License: MIT
Signed-off-by: 's avatarStephen Whitmore <noffle@ipfs.io>
上级 f630f9d9
...@@ -8,29 +8,39 @@ test_description="Test daemon command" ...@@ -8,29 +8,39 @@ test_description="Test daemon command"
. lib/test-lib.sh . lib/test-lib.sh
gwyport=8080 gwyport=8082
apiport=5001 apiport=5002
swarmport=4003
API_ADDR="/ip4/0.0.0.0/tcp/$apiport"
GATEWAY_ADDR="/ip4/0.0.0.0/tcp/$gwyport"
# TODO: randomize ports here once we add --config to ipfs daemon # TODO: randomize ports here once we add --config to ipfs daemon
# this needs to be in a different test than "ipfs daemon --init" below # this needs to be in a different test than "ipfs daemon" below
test_expect_success "setup IPFS_PATH" ' test_expect_success "setup IPFS_PATH" '
IPFS_PATH="$(pwd)/.ipfs" && IPFS_PATH="$(pwd)/.ipfs" &&
export IPFS_PATH export IPFS_PATH
' '
test_expect_success 'ipfs init & config' '
ipfs init &&
ipfs config Addresses.Gateway $GATEWAY_ADDR &&
ipfs config Addresses.API $API_ADDR &&
ipfs config --json=true Addresses.Swarm "[\"/ip4/0.0.0.0/tcp/4003\"]"
'
# NOTE: this should remove bootstrap peers (needs a flag) # NOTE: this should remove bootstrap peers (needs a flag)
# TODO(cryptix): # TODO(cryptix):
# - we won't see daemon startup failure because we put the daemon in the background - fix: fork with exit code after api listen # - we won't see daemon startup failure because we put the daemon in the background - fix: fork with exit code after api listen
# - 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 test_expect_success "ipfs daemon launches" '
test_expect_success "ipfs daemon --init launches" ' ipfs daemon >actual_daemon 2>daemon_err &
ipfs daemon --init >actual_daemon 2>daemon_err &
' '
# this is like "'ipfs daemon' is ready" in test_launch_ipfs_daemon(), see test-lib.sh # this is like "'ipfs daemon' is ready" in test_launch_ipfs_daemon(), see test-lib.sh
test_expect_success "initialization ended" ' test_expect_success "initialization ended" '
IPFS_PID=$! && IPFS_PID=$! &&
pollEndpoint -ep=/version -v -tout=1s -tries=60 2>poll_apierr > poll_apiout || pollEndpoint -host='$API_ADDR' -ep=/version -v -tout=1s -tries=60 2>poll_apierr > poll_apiout ||
test_fsh cat actual_daemon || test_fsh cat daemon_err || test_fsh cat poll_apierr || test_fsh cat poll_apiout test_fsh cat actual_daemon || test_fsh cat daemon_err || test_fsh cat poll_apierr || test_fsh cat poll_apiout
' '
...@@ -57,25 +67,12 @@ test_expect_success "ipfs gateway works with the correct allowed origin port" ' ...@@ -57,25 +67,12 @@ test_expect_success "ipfs gateway works with the correct allowed origin port" '
curl -s -X GET -H "Origin:http://localhost:$gwyport" -I "http://localhost:$gwyport/api/v0/version" curl -s -X GET -H "Origin:http://localhost:$gwyport" -I "http://localhost:$gwyport/api/v0/version"
' '
# This is like t0020-init.sh "ipfs init output looks good"
#
# Unfortunately the line:
#
# API server listening on /ip4/127.0.0.1/tcp/5001
#
# sometimes doesn't show up, so we cannot use test_expect_success yet.
#
test_expect_success "ipfs daemon output looks good" ' test_expect_success "ipfs daemon output looks good" '
STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" && STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" &&
echo "Initializing daemon..." >expected_daemon && echo "Initializing daemon..." >expected_daemon &&
echo "initializing ipfs node at $IPFS_PATH" >>expected_daemon &&
echo "generating 2048-bit RSA keypair...done" >>expected_daemon &&
echo "peer identity: $PEERID" >>expected_daemon &&
echo "to get started, enter:" >>expected_daemon &&
printf "\\n\\t$STARTFILE\\n\\n" >>expected_daemon &&
sed "s/^/Swarm listening on /" local_addrs >>expected_daemon && sed "s/^/Swarm listening on /" local_addrs >>expected_daemon &&
echo "API server listening on /ip4/127.0.0.1/tcp/5001" >>expected_daemon && echo "API server listening on '$API_ADDR'" >>expected_daemon &&
echo "Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080" >>expected_daemon && echo "Gateway (readonly) server listening on '$GATEWAY_ADDR'" >>expected_daemon &&
echo "Daemon is ready" >>expected_daemon && echo "Daemon is ready" >>expected_daemon &&
test_cmp expected_daemon actual_daemon test_cmp expected_daemon actual_daemon
' '
...@@ -116,14 +113,14 @@ test_expect_success "nc is available" ' ...@@ -116,14 +113,14 @@ test_expect_success "nc is available" '
# check transport is encrypted # check transport is encrypted
test_expect_success "transport should be encrypted" ' test_expect_success "transport should be encrypted" '
nc -w 5 localhost 4001 >swarmnc && nc -w 5 localhost '$swarmport' >swarmnc &&
grep -q "AES-256,AES-128" swarmnc && grep -q "AES-256,AES-128" swarmnc &&
test_must_fail grep -q "/multistream/1.0.0" swarmnc || test_must_fail grep -q "/multistream/1.0.0" swarmnc ||
test_fsh cat swarmnc test_fsh cat swarmnc
' '
test_expect_success "output from streaming commands works" ' test_expect_success "output from streaming commands works" '
test_expect_code 28 curl -m 2 http://localhost:5001/api/v0/stats/bw\?poll=true > statsout test_expect_code 28 curl -m 2 http://localhost:'$apiport'/api/v0/stats/bw\?poll=true > statsout
' '
test_expect_success "output looks good" ' test_expect_success "output looks good" '
...@@ -145,7 +142,7 @@ test_expect_success "'ipfs daemon' can be killed" ' ...@@ -145,7 +142,7 @@ test_expect_success "'ipfs daemon' can be killed" '
test_expect_success "'ipfs daemon' should be able to run with a pipe attached to stdin (issue #861)" ' test_expect_success "'ipfs daemon' should be able to run with a pipe attached to stdin (issue #861)" '
yes | ipfs daemon --init >stdin_daemon_out 2>stdin_daemon_err & yes | ipfs daemon --init >stdin_daemon_out 2>stdin_daemon_err &
pollEndpoint -ep=/version -v -tout=1s -tries=10 >stdin_poll_apiout 2>stdin_poll_apierr && pollEndpoint -host='$API_ADDR' -ep=/version -v -tout=1s -tries=10 >stdin_poll_apiout 2>stdin_poll_apierr &&
test_kill_repeat_10_sec $! || test_kill_repeat_10_sec $! ||
test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr
' '
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论