-
-
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
daemon: use fsrepo.IsInitialized to test for initialization #3805
Conversation
test/sharness/t0063-daemon-init.sh
Outdated
test_ipfs_daemon_init | ||
|
||
test_expect_success "create empty \$IPFS_PATH dir" ' | ||
rm -rf "$IPFS_PATH" |
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.
best to put &&
after the rm, I know it "shouldn't" fail but still.
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.
Sorry. The "&&" are too easy to forget about.
7b09b14
to
99f628f
Compare
cmd/ipfs/daemon.go
Outdated
// `IsInitialized` where the quality of the signal can be improved over | ||
// time, and many call-sites can benefit. | ||
if !util.FileExists(req.InvocContext().ConfigRoot) { | ||
if !fsrepo.IsInitialized(req.InvocContext().ConfigRoot) { |
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.
Instead of calling twice the req.InvocContex().ConfigRoot
why not make under initialize something like
if initialize {
cfg := req.InvocContext()
if !fsrepo.IsInitialized(cfg) {
err := initWithDefaults(os.Stdou, cfg)
// code
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.
Address the other comment here then LGTM.
99f628f
to
ddd4aef
Compare
@whyrusleeping okay done |
# server. | ||
|
||
test_expect_success "'ipfs daemon --init' succeeds" ' | ||
ipfs daemon --init >actual_daemon 2>daemon_err & |
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.
This will be problematic with other daemons people have running (port numbers). Not really sure how to solve it.
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'm not sure how to fix it either. We should look into adding a way to specify ports from here.
Though not sure if this should block the PR, Its probably a separate concern
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 will cause the test to fail on users machines who also have an IPFS daemon running. Should we flag it some how? If so I am not sure how.
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.
We could check if ports from config are bound (8080, 4001, 5001) using netcat and if any of those are, skip the test. How that sounds?
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, lets do that. Its better to print a message about why it fails rather than just randomly failing.
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.
You should be able to use nc -z -w1 localhost 5001
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.
Do you still want to do that? The test won't fail currently.
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.
@kevina Hrm... i think we can probably do without for now. Lets add a todo to add a flag for different ports on the daemon
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.
@whyrusleeping do you think we I should reduce the timeout to 1 sec to minimize the chance of this test failing?
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 wouldnt worry about it, lets just make a note to do proper port selection for this later.
Use fsrepo.IsInitialized to test for initialization instead of just testing if the directory exists. Also add test cases for '--init' option, including one the creates an empty directory. License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
ddd4aef
to
2892147
Compare
I added a note as an issue. This should be good to go... |
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.
LGTM, thanks @kevina!
Use fsrepo.IsInitialized to test for initialization instead of just testing if the directory exists.
Also add test cases for '--init' option, including one the creates an empty directory.
Closes #3773.