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: Generate end to end tests for retries #1117

Open
wants to merge 60 commits into
base: main
Choose a base branch
from

Conversation

danieljbruce
Copy link
Contributor

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.

@danieljbruce danieljbruce requested review from a team as code owners June 29, 2022 20:50
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: bigtable Issues related to the googleapis/nodejs-bigtable API. labels Jun 29, 2022
@danieljbruce danieljbruce changed the title Refactor create read stream feat: Generate end to end tests for retries Jun 29, 2022
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Jul 4, 2022
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Jul 8, 2022
}

// TODO: Create interface for this.
callHandler(call: any) {
Copy link
Contributor

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
Copy link
Contributor

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: {}) {
Copy link
Contributor

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', () => {
Copy link
Contributor

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 {
Copy link
Contributor

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
Copy link
Contributor

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the googleapis/nodejs-bigtable API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants