-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix: --wait flag in ipfs-cluster-ctl and WaitFor function #363
Conversation
@hsanjuan Agreed. Could you help me see where I went wrong with the following sharness tests, as they shouldn't have passed. From
Also, |
ipfs-cluster-ctl/main.go
Outdated
} | ||
|
||
if status.Cid == nil { // no status from "wait" | ||
time.Sleep(1000 * time.Millisecond) |
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.
s/1000*time.Millisecond/1*time.Second
ipfs-cluster-ctl/main.go
Outdated
waitAndFormatStatusResponse( | ||
c, | ||
c.Bool("wait"), | ||
c.Bool("no-status"), |
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 seems weird that waitAndFormatStatusResponse
would handle the --no-status
flag. Maybe handleResponseFormatFlags
would be a better name and then retrieve wait
and no-status
from *cli.Context
. Or the other way, could be to handle no-status
outside of waitAndFormatStatusResponse
. Not sure which would be better? @hsanjuan
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.
did the first
api/rest/client/methods_test.go
Outdated
tapi.SetClient(rpcC) | ||
|
||
testF := func(t *testing.T, c *Client) { | ||
ci, _ := cid.Decode(test.SlowCid) |
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.SlowCid
doesn't exist. Related question, where do the test.TestCid1
, etc, come from when running the tests?
@@ -251,12 +252,10 @@ func (sf *statusFilter) filter(ctx context.Context, fp StatusFilterParams) { | |||
return | |||
} | |||
|
|||
sf.Out <- gblPinInfo |
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.
👍
api/rest/client/methods.go
Outdated
return status, nil | ||
} | ||
case st, ok := <-sf.Out: | ||
if ok { |
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.
Could be simplified to:
if !ok {
return status, nil
}
status = st
The first case in a switch was While those tests verify that the flags are actually valid and usable and that we can call the command with them, they don't fully verify the behavior. I haven't come up with a straightforward way to fully verify |
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, just two last nitpicks sorry.
ipfs-cluster-ctl/main.go
Outdated
c *cli.Context, | ||
ci *cid.Cid, | ||
target api.TrackerStatus, | ||
timeout time.Duration, |
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 access the timeout value via cli.Context
?
return | ||
} | ||
|
||
if status.Cid == nil { // no status from "wait" |
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.
Could this go before the no-status
check as it is related to the wait
flag?
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 couldn't, because I don't need to fetch a status if no-status is set.
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.
Does having --wait
and --no-status
set at the same time make sense though?
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 nvm, I was totally not understanding that correctly
The --wait flag was being completely ignored unless --no-status was passed too, which makes no sense because then it would print the wait status. This waits when --wait and prints the status when --no-status is not passed. If we have been waiting, the status comes from that. Otherwise we request it. License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>
Since no-one is reading sf.Out, sending blocks and everything hangs. License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>
Actually test that WaitFor waits License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>
License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>
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
@lanzafame this was very visibly not working when I tried it. Please test a bit better next time.