test: reproduce commonly cited timeout error
Description
The main intent of this PR is to supply a test confirming that users can see the changes introduced by this PR. Primarily, the runQuery test provides an error stack that users can see so that they can identify the root cause of the timeout errors they are seeing. Confirming this behaviour is in place with a test is crucial for solving issues like https://github.com/googleapis/nodejs-datastore/issues/1176 going forward.
Impact
This is a crucial step towards solving https://github.com/googleapis/nodejs-datastore/issues/1176 giving us the tools we need to explore client library behaviour when the error from the issue occurs. Having this test in place ensures the impact from the fix in Gax is locked in which will assist users with determining the root cause of errors they are seeing in the future.
Testing
This PR only adds tests and no source code changes.
mock-server/datastore-server.ts: Changes are made to the mock server so that test code can provide its own service configuration providing custom responses for different server grpc endpoints.
test/mock-server-tester.ts: This file is meant to be a grpc endpoint agnostic utility file for providing standard grpc services to the mock server. For example, the sendErrorSeries method can be used to make the mock server send a series of errors with the same code and the shutdownServer method shuts down the mock server.
test/with-runquery-mockserver.ts: This file runs a test where runQuery calls return a deterministic set of UNAVAILABLE errors and then it checks the error message to see that it reports the timeout error along with the list of UNAVAILABLE errors in order.
Additional Information
Some related PRs: https://github.com/googleapis/gax-nodejs/pull/1740 https://github.com/googleapis/gax-nodejs/pull/1650
Next Steps
- We have a test for UNAVAILABLE on runQuery now, but we should apply the right fixes for DEADLINE_EXCEEDED errors
- Let's add a test involving transactions