-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add sharness test for pubsub #3432
Conversation
53ee3ad
to
1ce4920
Compare
Looks like it fails on sharness (at least on teamcity): http://ci.ipfs.team:8111/viewLog.html?buildId=8663&buildTypeId=GoIpfs_CiTests&tab=buildLog cc @chriscool for review, this is a bit of strange shell hackery |
# ipfs pubsub sub | ||
test_expect_success 'pubsub' ' | ||
echo "testOK" > expected && | ||
mkfifo done && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit confusing to call a fifo "done" as it is a keyword in shell.
while read line; do | ||
echo $line > actual && | ||
echo > done | ||
exit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit strange to have this "exit" here.
It means that the while loop will in fact never loop, so perhaps it could be an if read line; then ... fi
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that is a bit hackish I agree. For some reason this loop even needs two runs, I didn't get why and I was glad it worked.
echo > done | ||
exit | ||
done | ||
) & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be explained why we need to fork a process like this, especially as there is a "sleep 1" below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'll add a comment
test_expect_success "start up nodes" ' | ||
iptb start | ||
' | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't is possible to do something less specific by doing something like:
num_nodes="$1"
shift
other_args="$@"
...
if test -n "$other_args"; then
iptb start --args $other_args
else
iptb start
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried iptb start $@
but now I see why that didn't work - its executed in a completely different context. I use your solution now.
|
||
ipfspid=$! | ||
|
||
sleep 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if the two above commands cannot fail it is a good practice to anyway chain them with the commands below by using "&&" after them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll put && after the sleep. Where else do you mean?
ipfsi 1 pubsub pub testTopic "testOK" &> pubErr1 && | ||
|
||
cat done && | ||
test_cmp actual expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_cmp expected actual
is more standard.
7c2b981
to
b1c7f86
Compare
Yeah, it LGTM now, thanks! |
421b68a
to
2444e85
Compare
@chriscool The tests pass for me locally but fail on Travis and Teamcity. Do you have an idea what the problem could be? Do they pass on your machine? |
@keks the problem is with your previous commit. Under the |
This line here: https://github.com/ipfs/go-ipfs/blob/master/core/commands/pubsub.go#L133 Should just return an empty string reader instead of a newline |
2444e85
to
d49ca0c
Compare
Of course! Thank you. "The code is right, it must be the test's fault"... I will move the checks to |
License: MIT Signed-off-by: Jan Winkelmann <[email protected]>
License: MIT Signed-off-by: Jan Winkelmann <[email protected]>
d49ca0c
to
993e781
Compare
@keks Thanks a bunch! This is great to have :) |
finally!