-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add Spanner stale read sample. #475
Conversation
Codecov Report
@@ Coverage Diff @@
## master #475 +/- ##
=======================================
Coverage 97.16% 97.16%
=======================================
Files 13 13
Lines 458 458
=======================================
Hits 445 445
Misses 13 13 Continue to review full report at Codecov.
|
57fed2e
to
d5abeb3
Compare
spanner/crud.js
Outdated
const instance = spanner.instance(instanceId); | ||
const database = instance.database(databaseId); | ||
|
||
// Read rows from the Albums table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: inconsistent comment tense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
spanner/crud.js
Outdated
}; | ||
|
||
const options = { | ||
// Guarantees that all writes that have committed more than 10 seconds ago |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: remove that have
and combine into one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
spanner/crud.js
Outdated
|
||
rows.forEach((row) => { | ||
const json = row.toJSON(); | ||
console.log(`SingerId: ${json.SingerId.value}, AlbumId: ${json.AlbumId.value}, AlbumTitle: ${json.AlbumTitle}, MarketingBudget: ${json.MarketingBudget ? json.MarketingBudget.value : ''}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we split these into separate lines? This is a lot to read at once...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
spanner/crud.js
Outdated
@@ -189,10 +233,17 @@ const cli = require(`yargs`) | |||
{}, | |||
(opts) => readData(opts.instanceName, opts.databaseName) | |||
) | |||
.command( | |||
`read-stale <instanceName> <databaseName>`, | |||
`Reads data in an example Cloud Spanner table.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: mention/explain stale reads in the command description?
e.g. Reads _stale_ data in an example Cloud Spanner table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
const output = await tools.runAsync(`${schemaCmd} createDatabase "${INSTANCE_ID}" "${DATABASE_ID}"`, cwd); | ||
t.true(output.includes(`Waiting for operation on ${DATABASE_ID} to complete...`)); | ||
t.true(output.includes(`Created database ${DATABASE_ID} on instance ${INSTANCE_ID}.`)); | ||
const results = await tools.runAsyncWithIO(`${schemaCmd} createDatabase "${INSTANCE_ID}" "${DATABASE_ID}"`, cwd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of this? (Having stderr
in the test printout?)
stderr
should be ignored unless we expect an error to occur. (If an error occurs when it shouldn't, our test should fail - though perhaps not silently.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've discover lately that sometimes tests/commands fail silently (return a 0 exit code), but do print some useful info to stderr. This improves test debuggability.
spanner/system-test/spanner.test.js
Outdated
t.true(output.includes(`Inserted data.`)); | ||
const results = await tools.runAsyncWithIO(`${crudCmd} insert ${INSTANCE_ID} ${DATABASE_ID}`, cwd); | ||
const output = results.stdout + results.stderr; | ||
t.regex(output, new RegExp(`Inserted data.`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace t.regex(output, new RegExp($STRING))
with t.regex(output, /$STRING/)
. Apply this comment throughout your PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
spanner/system-test/spanner.test.js
Outdated
// read-stale-data reads data that is exactly 10 seconds old. So, make sure | ||
// 10 seconds have elapsed since the update_data test. | ||
return new Promise((resolve, reject) => { | ||
setTimeout(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can you promisify the setTimeout()
call, and wrap the tests in a then
as was done here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Comments addressed, merging. |
🤖 I have created a release \*beep\* \*boop\* --- ### [2.4.3](https://www.github.com/googleapis/nodejs-kms/compare/v2.4.2...v2.4.3) (2021-07-12) ### Bug Fixes * **deps:** google-gax v2.17.1 ([#474](https://www.github.com/googleapis/nodejs-kms/issues/474)) ([1e1a3fc](https://www.github.com/googleapis/nodejs-kms/commit/1e1a3fcb437cdfb86e3fcb06ac34a329898b970a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release \*beep\* \*boop\* --- ### [2.4.3](https://www.github.com/googleapis/nodejs-kms/compare/v2.4.2...v2.4.3) (2021-07-12) ### Bug Fixes * **deps:** google-gax v2.17.1 ([#474](https://www.github.com/googleapis/nodejs-kms/issues/474)) ([1e1a3fc](https://www.github.com/googleapis/nodejs-kms/commit/1e1a3fcb437cdfb86e3fcb06ac34a329898b970a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release \*beep\* \*boop\* --- ## [2.4.0](https://www.github.com/googleapis/nodejs-dataproc/compare/v2.3.0...v2.4.0) (2021-04-26) ### Features * a bundle of new features for Dataproc V1 ([#475](https://www.github.com/googleapis/nodejs-dataproc/issues/475)) ([4803be4](https://www.github.com/googleapis/nodejs-dataproc/commit/4803be4f4b63833072aa50e29e8b081c363f6dde)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release \*beep\* \*boop\* --- ## [2.4.0](https://www.github.com/googleapis/nodejs-dataproc/compare/v2.3.0...v2.4.0) (2021-04-26) ### Features * a bundle of new features for Dataproc V1 ([#475](https://www.github.com/googleapis/nodejs-dataproc/issues/475)) ([4803be4](https://www.github.com/googleapis/nodejs-dataproc/commit/4803be4f4b63833072aa50e29e8b081c363f6dde)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
No description provided.