-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
daemon: use fsrepo.IsInitialized to test for initialization #3805
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2014 Juan Batiz-Benet | ||
# MIT Licensed; see the LICENSE file in this repository. | ||
# | ||
|
||
test_description="Test daemon --init command" | ||
|
||
. lib/test-lib.sh | ||
|
||
# We don't want the normal test_init_ipfs but we need to make sure the | ||
# IPFS_PATH is set correctly. | ||
export IPFS_PATH="$(pwd)/.ipfs" | ||
|
||
# safety check since we will be removing the directory | ||
if [ -e "$IPFS_PATH" ]; then | ||
echo "$IPFS_PATH exists" | ||
exit 1 | ||
fi | ||
|
||
test_ipfs_daemon_init() { | ||
# Doing it manually since we want to launch the daemon with an | ||
# empty or non-existent repo; the normal | ||
# test_launch_ipfs_daemon does not work since it assumes the | ||
# repo was created a particular way with regard to the API | ||
# server. | ||
|
||
test_expect_success "'ipfs daemon --init' succeeds" ' | ||
ipfs daemon --init >actual_daemon 2>daemon_err & | ||
IPFS_PID=$! | ||
sleep 2 && | ||
if ! kill -0 $IPFS_PID; then cat daemon_err; return 1; fi | ||
' | ||
|
||
test_expect_success "'ipfs daemon' can be killed" ' | ||
test_kill_repeat_10_sec $IPFS_PID | ||
' | ||
} | ||
|
||
test_expect_success "remove \$IPFS_PATH dir" ' | ||
rm -rf "$IPFS_PATH" | ||
' | ||
test_ipfs_daemon_init | ||
|
||
test_expect_success "create empty \$IPFS_PATH dir" ' | ||
rm -rf "$IPFS_PATH" && | ||
mkdir "$IPFS_PATH" | ||
' | ||
|
||
test_ipfs_daemon_init | ||
|
||
test_done |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.