Skip to content

chore(testproxy): fix close generated (v2) clients #1249

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

Merged

Conversation

ruyadorno
Copy link
Contributor

Tests for closing the client are failing since a new client object is created on every operation that uses the generated (v2) layer. This changeset fixes it by moving the v2 client creation to testproxy/services/create-client.js alongside the veneer client creation and properly closing that v2 instance on testproxy/services/close-client.js.

Every command using the v2 layer is updated to read the client from the client map instead of creating a new instance.

Three previosly failing tests are now passing with this fix:

  • TestCheckAndMutateRow_Generic_CloseClient
  • TestMutateRow_Generic_CloseClient
  • TestReadModifyWriteRow_Generic_CloseClient

Tests for closing the client are failing since a new client object is
created on every operation that uses the generated (v2) layer. This
changeset fixes it by moving the v2 client creation to
`testproxy/services/create-client.js` alongside the veneer client
creation.

Every command using the v2 layer is updated to read the client from the
client map instead of creating a new instance.

Three previosly failing tests are now passing with this fix:
- TestCheckAndMutateRow_Generic_CloseClient
- TestMutateRow_Generic_CloseClient
- TestReadModifyWriteRow_Generic_CloseClient
@ruyadorno ruyadorno requested review from a team as code owners March 3, 2023 17:55
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: bigtable Issues related to the googleapis/nodejs-bigtable API. labels Mar 3, 2023
@ruyadorno ruyadorno requested a review from danieljbruce March 3, 2023 17:56
Copy link
Contributor

@danieljbruce danieljbruce left a comment

Choose a reason for hiding this comment

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

A couple of suggestions

const closeClient = ({clientMap}) =>
normalizeCallback(async rawRequest => {
const request = rawRequest.request;
const {clientId} = request;
const bigtable = clientMap.get(clientId);

if (bigtable) {
bigtable.close();
await bigtable[v2].close();
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually think this line might not be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point but I just confirmed it's necessary. I tried running the tests without closing the v2 instance (removing this line) and tests fail again without it.

My understanding is that veneer and v2 are completely independent instances so it makes sense that it needs to be closed separately.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. If that is the case then it looks like the code contains a client bug because closing the veneer is supposed to close the clients on the v2 layer. Oh, but the client never gets initialized because we never make calls with the veneer layer and clients are initialized lazily. I suspect though that when we use the veneer layer for the mutateRow calls when mutateRow is exposed then we will not need this line anymore.

Thanks for checking.

@danieljbruce danieljbruce self-requested a review March 3, 2023 18:54
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 6, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 6, 2023
@danieljbruce danieljbruce merged commit 44fab5c into googleapis:main Mar 6, 2023
@ruyadorno ruyadorno deleted the fix-close-generated-v2-client branch March 6, 2023 18:54
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: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants