Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
63a9ed20
Commit
63a9ed20
authored
Mar 02, 2016
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make t0060 use port zero
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
6d4da612
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
38 deletions
+30
-38
test/sharness/lib/test-lib.sh
test/sharness/lib/test-lib.sh
+19
-13
test/sharness/t0060-daemon.sh
test/sharness/t0060-daemon.sh
+11
-25
No files found.
test/sharness/lib/test-lib.sh
View file @
63a9ed20
...
...
@@ -181,25 +181,15 @@ test_wait_for_file() {
done
}
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
()
{
daemon_output
=
"
$1
"
test_expect_success
"set up address variables"
'
API_MADDR=$(cat "$IPFS_PATH/api") &&
API_ADDR=$(convert_tcp_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_PORT=$(port_from_maddr $GWAY_MADDR)
'
...
...
@@ -210,6 +200,22 @@ test_launch_ipfs_daemon() {
SWARM_MADDR=$(grep "127.0.0.1" addrs_out) &&
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.
test_expect_success
"'ipfs daemon' is ready"
'
...
...
test/sharness/t0060-daemon.sh
View file @
63a9ed20
...
...
@@ -8,27 +8,8 @@ test_description="Test daemon command"
.
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
# this errors if we didn't --init $IPFS_PATH correctly
...
...
@@ -47,11 +28,11 @@ test_expect_success "ipfs peer id looks good" '
# this is for checking SetAllowedOrigins race condition for the api and gateway
# See https://github.com/ipfs/go-ipfs/pull/1966
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"
'
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"
'
...
...
@@ -100,14 +81,14 @@ test_expect_success "nc is available" '
# check transport is 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 &&
test_must_fail grep -q "/multistream/1.0.0" swarmnc ||
test_fsh cat swarmnc
'
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"
'
...
...
@@ -128,7 +109,12 @@ 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)"
'
yes | ipfs daemon --init >stdin_daemon_out 2>stdin_daemon_err &
yes | ipfs daemon >stdin_daemon_out 2>stdin_daemon_err &
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 &&
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment