-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
workflow: Modify the unit test for resharding workflow. Control the workflow through manager. #2596
workflow: Modify the unit test for resharding workflow. Control the workflow through manager. #2596
Conversation
Change looks very good! :) I've left a few comments regarding style issues and how to simplify the topo data creation. Reviewed 4 of 4 files at r1. go/vt/vtctld/workflow.go, line 44 at r1 (raw file):
Please don't remove this. With this change your workflow is no longer registered by default because your package isn't imported (transitively) by the "vtctld" package. Because of that your e2e test should fail now. The other reason is that we want to keep things consistent. Either we register all workflows here or now. Let's register all here. I suggest you keep this and instead do the register in the init() function as well like you did in go/vt/workflow/manager.go, line 462 at r1 (raw file):
runningWorkflow I would not mention "runningWorkflow" because it's an implementation detail. The user cares only about the "Workflow" object. Therefore, I propose: GetWorkflowForTesting returns the "Workflow" object for the running workflow identified by "uuid". go/vt/workflow/manager.go, line 463 at r1 (raw file):
simpler: The method is used in unit tests to inject mocks. go/vt/workflow/resharding/horizontal_resharding_workflow.go, line 318 at r1 (raw file):
This is not obvious and would require a comment. Instead of initializing the fields here, please do this in Instantiate() instead. That's the right place to do it. For that, you'll have to add go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 44 at r1 (raw file):
Some comments on
go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 53 at r1 (raw file):
t.Fatalf go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 65 at r1 (raw file):
TODO notes please always on a separate line and in the format TODO(ldap) or TODO(b/...). But I think you can actually remove this comment? go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 65 at r1 (raw file):
Please rename this to "verifyAllTasksDone" because that better describes what the function does. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 65 at r1 (raw file):
Please don't pass in the testing.T object. This way you cannot trace back which test method called this function. Instead, return an error: if err := verifyAllTasksDone(context.Background(), ts, uuid); err != nil {
t.Fatal(err)
} go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 87 at r1 (raw file):
This is not necessary. It's unlikely that somebody is passing not the ctx and To keep things simple, please use the go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 93 at r1 (raw file):
FYI: You could have passed in context.Background() as well here because it's the same type? But as I said above, just don't check it. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 115 at r1 (raw file):
t.Fatalf go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 117 at r1 (raw file):
You can simplify this. Call The advantage of this approach is that you're not duplicating code from the topology package e.g. for setting the keyrange. It will also automatically not set the serving types for the two later shards because it detects that shard "0" is already serving that key range. Comments from Reviewable |
1ecbdc3
to
ab6ba06
Compare
Review status: all files reviewed at latest revision, 13 unresolved discussions. go/vt/vtctld/workflow.go, line 44 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/manager.go, line 462 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/manager.go, line 463 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow.go, line 318 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 44 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 53 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 65 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 65 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 65 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 87 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 93 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Solved in above comment's reply. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 115 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 117 at r1 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. Comments from Reviewable |
ab6ba06
to
f30d0ad
Compare
Some minor comments. Almost there :) Reviewed 9 of 9 files at r2. go/vt/workflow/manager.go, line 463 at r2 (raw file):
nits:
go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 17 at r2 (raw file):
I think in Go, it's a convention that imports with a blank identifier need a comment. Even if not, a comment is useful here to educate the reader why we're doing this. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 52 at r2 (raw file):
Please use On the other hand, go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 64 at r2 (raw file):
Please remove debug statements. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 66 at r2 (raw file):
ctx go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 67 at r2 (raw file):
resharding workflow go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 71 at r2 (raw file):
ctx go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 72 at r2 (raw file):
Please check the return value and fail the test if != nil. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 91 at r2 (raw file):
unused, please remove go/vt/workflow/resharding/parallel_runner_test.go, line 24 at r2 (raw file):
Same comment as in the other file. Please don't use the Manager context for the calls below and instead use go/vt/workflow/resharding/parallel_runner_test.go, line 41 at r2 (raw file):
FYI:
Can you please change this throughout the file? Comments from Reviewable |
modify the unit tests of resharding workflow.
f30d0ad
to
a776530
Compare
Review status: all files reviewed at latest revision, 12 unresolved discussions. go/vt/workflow/manager.go, line 463 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 17 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
copy comment from G3 code which has the same import. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 52 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 64 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 66 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Not used anymore, using _. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 67 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 71 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 72 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/horizontal_resharding_workflow_test.go, line 91 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/parallel_runner_test.go, line 24 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. go/vt/workflow/resharding/parallel_runner_test.go, line 41 at r2 (raw file): Previously, mberlin-bot (Michael Berlin) wrote…
Done. Comments from Reviewable |
Reviewed 3 of 3 files at r3. Comments from Reviewable |
@alainjobart can you review the [last commit]?(626eea1) |
This change is