Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: read time should be used for transaction reads (#1171)
* Allow datastore projectId to be fetched from clien Latency is caused by the call to getProjectId from Google auth. This change allows the project id to be retrieved if it is set in the client at creation time thereby reducing call latency. * Create a file for mocking out commits A test file is created where we mock out commit in the Gapic layer. The mock allows us to get the results passed to the commit endpoint in the Gapic layer. * Create a test to measure latency of call. To prove that the change works to reduce latency, a test is written. The test checks to see that the amount of time that passes between the time when the initial call is made in the user’s code and the time when the call reaches the gapic layer is sufficiently small. It will be a very small amount of time if the program does not need to do an auth lookup. * Run the linting fixes Run the linter so that spacing in the PR gets fixed for some of the lines of code. * Add license header to top of test file The license header needs to be added to the top of the new test file that is used for mocking out commit. * Add comment for test for now This is going to be a test for investigating the latency of the client. * Add a test for the mock server Measure the latency between the original call and the mock server. * Set current retry attempt to 0 * Add a log for call time Do check external to function after async call. Add log for call time. * Add another mock Other mock doesn’t require lazy client initialization. * Eliminate code from the mock file Eliminate the fake datastore client because we need to do assertion checks that are specific to each test. This means there is no point in defining runQuery once in a mock because each test will mock it out differently. * Start off by adding read time to read options Add the code change that will add read time to read options for transactions. # Conflicts: # test/transaction.ts * Update the test to use transactions The idea is to test that read time got passed along for transactions specifically. This will be necessary for snapshot reads to work. * Remove only Need the entire test suite to run * Remove the before hook The before hook is not necessary. Just mock out the data client at the start. * Remove unnecessary cherry picked files Files were cherry-picked that weren’t helpful for solving the problem. Remove them. * Clean up PR diff * clean up PR diff * Update the test so that it is run as a transaction Right now, providing a transaction id is necessary to run the request as a transaction. * Add an integration test The integration test looks at the data from the snapshot read time for transactions and ensures that the read has no data thereby exercising the read time parameter. * Linting fixing indents Fix the indents in the system test folder * Update the header * Fix unit test beginTransaction needs to be mocked out now that a transaction will begin if runQuery is called. * System test changes. Add a sleep. Instead of changing the current test, add a new test because it means the reader of the PR can be sure that test coverage wasn’t reduced which is better. * Modify test Modify the test so that sleeps are long enough to create predictable results and tests actually check for the right values. * Replace with less precise assert The test setup sometimes prepares before data with 0 entries and sometimes prepares before data with 1 entry so a less restrictive test is required in order for it to consistently pass.
- Loading branch information