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
1dcac25c
Unverified
Commit
1dcac25c
authored
Nov 29, 2018
by
Steven Allen
Committed by
GitHub
Nov 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5803 from ipfs/fix/2528-really
really fix netcat race
parents
2d94a3ff
c0f979df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
8 deletions
+72
-8
test/sharness/t0235-cli-request.sh
test/sharness/t0235-cli-request.sh
+36
-4
test/sharness/t0236-cli-api-dns-resolve.sh
test/sharness/t0236-cli-api-dns-resolve.sh
+36
-4
No files found.
test/sharness/t0235-cli-request.sh
View file @
1dcac25c
...
...
@@ -10,11 +10,43 @@ test_description="test http requests made by cli"
test_init_ipfs
test_expect_success
"can make http request against nc server"
'
nc -ld 5005 > nc_out &
test_expect_success
"start nc"
'
rm -f nc_out nc_outp nc_inp && mkfifo nc_inp nc_outp
nc -k -l 127.0.0.1 5005 <nc_inp >nc_outp &
NCPID=$!
go-sleep 0.5s && kill "$NCPID" &
ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005 || true
exec 6>nc_inp 7<nc_outp
while ! nc -z 127.0.0.1 5005; do
go-sleep 100ms
done
'
test_expect_success
"can make http request against nc server"
'
ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005 &
IPFSPID=$!
# handle request
while read line; do
if [[ "$line" == "$(echo -e "\r")" ]]; then
break
fi
echo "$line"
done <&7 >nc_out &&
echo -e "HTTP/1.1 200 OK\r" >&6 &&
echo -e "Content-Type: text/plain\r" >&6 &&
echo -e "Content-Length: 0\r" >&6 &&
echo -e "\r" >&6 &&
exec 6<&- &&
# Wait for IPFS
wait $IPFSPID
'
test_expect_success
"stop nc"
'
kill "$NCPID" && wait "$NCPID" || true
'
test_expect_success
"output does not contain multipart info"
'
...
...
test/sharness/t0236-cli-api-dns-resolve.sh
View file @
1dcac25c
...
...
@@ -10,11 +10,43 @@ test_description="test dns resolution of api endpoint by cli"
test_init_ipfs
test_expect_success
"can make http request against dns resolved nc server"
'
nc -ld 5005 > nc_out &
test_expect_success
"start nc"
'
rm -f nc_out nc_outp nc_inp && mkfifo nc_inp nc_outp
nc -k -l 127.0.0.1 5006 <nc_inp >nc_outp &
NCPID=$!
go-sleep 1s && kill "$NCPID" &
ipfs cat /ipfs/Qmabcdef --api /dns4/localhost/tcp/5005 || true
exec 6>nc_inp 7<nc_outp
while ! nc -z 127.0.0.1 5006; do
go-sleep 100ms
done
'
test_expect_success
"can make http request against dns resolved nc server"
'
ipfs cat /ipfs/Qmabcdef --api /dns4/localhost/tcp/5006 &
IPFSPID=$!
# handle request
while read line; do
if [[ "$line" == "$(echo -e "\r")" ]]; then
break
fi
echo "$line"
done <&7 >nc_out &&
echo -e "HTTP/1.1 200 OK\r" >&6 &&
echo -e "Content-Type: text/plain\r" >&6 &&
echo -e "Content-Length: 0\r" >&6 &&
echo -e "\r" >&6 &&
exec 6<&- &&
# Wait for IPFS
wait $IPFSPID
'
test_expect_success
"stop nc"
'
kill "$NCPID" && wait "$NCPID" || true
'
test_expect_success
"request was received by local nc server"
'
...
...
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