Skip to content
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

feat(bigtable/cmd/cbt): Add a timeout option #4276

Merged
merged 43 commits into from Aug 10, 2021

Conversation

jimfulton
Copy link
Contributor

Fixes: #2492

@jimfulton jimfulton requested review from crwilcox, kolea2, tritone and a team as code owners June 17, 2021 18:02
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jun 17, 2021
@codyoss codyoss changed the title feat(cbt): Add a timeout option feat(bigtable/cmd/cbt): Add a timeout option Jun 17, 2021
@jimfulton jimfulton marked this pull request as draft June 17, 2021 20:20
@jimfulton jimfulton marked this pull request as ready for review June 18, 2021 11:58
@jimfulton
Copy link
Contributor Author

This now has a test! And includes some refactoring that makes some kinds of tests easier.

"os"
)

func captureStdout(f func()) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document this? Wasn't immediately clear to me what f was for.

Copy link
Contributor Author

@jimfulton jimfulton Jun 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Note that here, we're mainly preventing spurious print output. In other branches/PRs, we're making assertions about captured stdout.

@jimfulton jimfulton requested a review from a team as a code owner July 27, 2021 11:32
@@ -581,7 +607,7 @@ func doCount(ctx context.Context, args ...string) {
if len(args) != 1 {
log.Fatal("usage: cbt count <table>")
}
tbl := getClient(bigtable.ClientConfig{}).Open(args[0])
tbl := getTable(bigtable.ClientConfig{}, args[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am having some difficulty fully understanding the need of this refactoring and its relation to the timeout change. Can you describe it a bit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to test that a proper context (with a timeout) was passed to ReadRows.

getTable returns a tableLike object, which simply has ReadRows. (I think I expand it in another PR, IIRC :) )

Normally, getTable calls getClient(clientConf).Open(tableName), but if the global table is set, it returns that.

timeout_test.go sets table to a mock that captures the context passed to ReadRows so we can assert that it was set correctly.

@jimfulton jimfulton merged commit ae8a9a1 into googleapis:master Aug 10, 2021
@jimfulton jimfulton deleted the timeout branch August 10, 2021 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bigtable: ability to set deadlines for cbt commands
3 participants