提交 39c101cd 作者: Jeromy Johnson

Merge pull request #2433 from ipfs/fix/t0060-port-zero

make t0060 use port zero
...@@ -181,25 +181,15 @@ test_wait_for_file() { ...@@ -181,25 +181,15 @@ test_wait_for_file() {
done done
} }
test_launch_ipfs_daemon() { test_set_address_vars() {
daemon_output="$1"
args="$@"
test_expect_success "'ipfs daemon' succeeds" '
ipfs daemon $args >actual_daemon 2>daemon_err &
'
# wait for api file to show up
test_expect_success "api file shows up" '
test_wait_for_file 20 100ms "$IPFS_PATH/api"
'
test_expect_success "set up address variables" ' test_expect_success "set up address variables" '
API_MADDR=$(cat "$IPFS_PATH/api") && API_MADDR=$(cat "$IPFS_PATH/api") &&
API_ADDR=$(convert_tcp_maddr $API_MADDR) && API_ADDR=$(convert_tcp_maddr $API_MADDR) &&
API_PORT=$(port_from_maddr $API_MADDR) && API_PORT=$(port_from_maddr $API_MADDR) &&
GWAY_MADDR=$(sed -n "s/^Gateway (.*) server listening on //p" actual_daemon) && GWAY_MADDR=$(sed -n "s/^Gateway (.*) server listening on //p" "$daemon_output") &&
GWAY_ADDR=$(convert_tcp_maddr $GWAY_MADDR) && GWAY_ADDR=$(convert_tcp_maddr $GWAY_MADDR) &&
GWAY_PORT=$(port_from_maddr $GWAY_MADDR) GWAY_PORT=$(port_from_maddr $GWAY_MADDR)
' '
...@@ -210,6 +200,22 @@ test_launch_ipfs_daemon() { ...@@ -210,6 +200,22 @@ test_launch_ipfs_daemon() {
SWARM_MADDR=$(grep "127.0.0.1" addrs_out) && SWARM_MADDR=$(grep "127.0.0.1" addrs_out) &&
SWARM_PORT=$(port_from_maddr $SWARM_MADDR) SWARM_PORT=$(port_from_maddr $SWARM_MADDR)
' '
}
test_launch_ipfs_daemon() {
args="$@"
test_expect_success "'ipfs daemon' succeeds" '
ipfs daemon $args >actual_daemon 2>daemon_err &
'
# wait for api file to show up
test_expect_success "api file shows up" '
test_wait_for_file 20 100ms "$IPFS_PATH/api"
'
test_set_address_vars actual_daemon
# we say the daemon is ready when the API server is ready. # we say the daemon is ready when the API server is ready.
test_expect_success "'ipfs daemon' is ready" ' test_expect_success "'ipfs daemon' is ready" '
......
...@@ -8,27 +8,8 @@ test_description="Test daemon command" ...@@ -8,27 +8,8 @@ test_description="Test daemon command"
. lib/test-lib.sh . lib/test-lib.sh
gwyport=8082
apiport=5002
swarmport=4003
# TODO: randomize ports here once we add --config to ipfs daemon
# this needs to be in a different test than "ipfs daemon" below
test_expect_success "setup IPFS_PATH" '
IPFS_PATH="$(pwd)/.ipfs" &&
export IPFS_PATH
'
api_maddr="/ip4/0.0.0.0/tcp/$apiport"
gway_maddr="/ip4/0.0.0.0/tcp/$gwyport"
test_expect_success 'ipfs init & config' '
ipfs init &&
ipfs config Addresses.Gateway $gway_maddr &&
ipfs config Addresses.API $api_maddr &&
ipfs config --json=true Addresses.Swarm "[\"/ip4/0.0.0.0/tcp/4003\"]"
'
test_init_ipfs
test_launch_ipfs_daemon test_launch_ipfs_daemon
# this errors if we didn't --init $IPFS_PATH correctly # this errors if we didn't --init $IPFS_PATH correctly
...@@ -47,11 +28,11 @@ test_expect_success "ipfs peer id looks good" ' ...@@ -47,11 +28,11 @@ test_expect_success "ipfs peer id looks good" '
# this is for checking SetAllowedOrigins race condition for the api and gateway # this is for checking SetAllowedOrigins race condition for the api and gateway
# See https://github.com/ipfs/go-ipfs/pull/1966 # See https://github.com/ipfs/go-ipfs/pull/1966
test_expect_success "ipfs API works with the correct allowed origin port" ' test_expect_success "ipfs API works with the correct allowed origin port" '
curl -s -X GET -H "Origin:http://localhost:$apiport" -I "http://localhost:$apiport/api/v0/version" curl -s -X GET -H "Origin:http://localhost:$API_PORT" -I "http://$API_ADDR/api/v0/version"
' '
test_expect_success "ipfs gateway works with the correct allowed origin port" ' 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:$GWAY_PORT" -I "http://$GWAY_ADDR/api/v0/version"
' '
test_expect_success "ipfs daemon output looks good" ' test_expect_success "ipfs daemon output looks good" '
...@@ -100,14 +81,14 @@ test_expect_success "nc is available" ' ...@@ -100,14 +81,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 '$swarmport' >swarmnc && nc -w 5 localhost $SWARM_PORT >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:'$apiport'/api/v0/stats/bw\?poll=true > statsout test_expect_code 28 curl -m 2 http://localhost:$API_PORT/api/v0/stats/bw\?poll=true > statsout
' '
test_expect_success "output looks good" ' test_expect_success "output looks good" '
...@@ -128,9 +109,15 @@ test_expect_success "'ipfs daemon' can be killed" ' ...@@ -128,9 +109,15 @@ 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 >stdin_daemon_out 2>stdin_daemon_err &
DAEMON_PID=$!
test_wait_for_file 20 100ms "$IPFS_PATH/api" &&
test_set_address_vars stdin_daemon_out
'
test_expect_success "daemon with pipe eventually becomes live" '
pollEndpoint -host='$API_MADDR' -ep=/version -v -tout=1s -tries=10 >stdin_poll_apiout 2>stdin_poll_apierr && pollEndpoint -host='$API_MADDR' -ep=/version -v -tout=1s -tries=10 >stdin_poll_apiout 2>stdin_poll_apierr &&
test_kill_repeat_10_sec $! || test_kill_repeat_10_sec $DAEMON_PID ||
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论