This repository was archived by the owner on Feb 20, 2026. It is now read-only.
Commit 73a0a39
authored
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.1 parent 10f85fd commit 73a0a39
File tree
3 files changed
+167
-3
lines changed- src
- system-test
- test/gapic-mocks
3 files changed
+167
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1025 | 1025 | | |
1026 | 1026 | | |
1027 | 1027 | | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
1031 | 1035 | | |
1032 | 1036 | | |
1033 | 1037 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1931 | 1931 | | |
1932 | 1932 | | |
1933 | 1933 | | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
1934 | 1957 | | |
1935 | 1958 | | |
1936 | 1959 | | |
| |||
2031 | 2054 | | |
2032 | 2055 | | |
2033 | 2056 | | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
2034 | 2076 | | |
2035 | 2077 | | |
2036 | 2078 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
0 commit comments