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: Generate end to end tests for retries #1117
base: main
Are you sure you want to change the base?
feat: Generate end to end tests for retries #1117
Conversation
…into errors-from-gax-layer
…into errors-from-gax-layer # Conflicts: # package.json
…ce/nodejs-bigtable into refactor-create-read-stream
…into refactor-create-read-stream
…eljbruce/nodejs-bigtable into refactor-create-read-stream
} | ||
|
||
// TODO: Create interface for this. | ||
callHandler(call: any) { |
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 would b good to use a better type for call
, you could potentially just create your own interface:
interface {
emit: () => {}
}
But I wouldn't be surprised if there's a type available in the grpc
library.
@@ -0,0 +1,126 @@ | |||
// Copyright 2022 Google LLC |
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 should have caught this in the last review, since these servers (I believe) will only be used in testing, I'd be tempted to have them in test/util
, rather than src/util
. I think of src
as being components of the library itself, vs., components used during testing.
import {MockService} from '../../../mock-service'; | ||
import {Mutation} from '../../../../../mutation'; | ||
|
||
function rowResponse(rowKey: {}) { |
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.
Is there going to be a different "implementation" file for different test cases, e.g, ensuring that streaming errors are gracefully recovered from?
If so, I would be tempted to name the implementation file after the specific behaviour it's a test for. Then you'll have a bunch of implementation files for a bunch of different regression tests.
return new StreamTester(serviceHandler, streamFetcher); | ||
} | ||
/* | ||
describe('with a mock server that always sends an error back', () => { |
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.
remember to comment these out before you land.
this.streamFetcher = streamFetcher; | ||
} | ||
|
||
checkSnapshots(callback: () => void): void { |
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 like that you've pulled the snapshotting into a helper 😄
@@ -0,0 +1,59 @@ | |||
// Copyright 2022 Google LLC |
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 would have anything related to testing in the test
folder rather than src
(which should exclusively be application logic).
This PR is a work in progress, but contains a test framework that is entirely necessary for end to end testing when we decide to move retry logic into the gax layer. The idea is that we collect snapshots to ensure that the incoming requests match the snapshots that are recorded.