Skip to content
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

fix: add BulkWriter integration tests, java backport changes, delete fix #1117

Merged
merged 8 commits into from
Jun 10, 2020

Conversation

thebrianchen
Copy link

@thebrianchen thebrianchen commented Jun 8, 2020

A few things in this PR:

  • Added integration tests now that the protos are public
  • Backported some unit tests changes from java port (variable names and non-zero mock response times).
  • Add temporary fix to delete times (see b/158502664).

@thebrianchen thebrianchen self-assigned this Jun 8, 2020
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 8, 2020
@codecov
Copy link

codecov bot commented Jun 8, 2020

Codecov Report

Merging #1117 into node10 will decrease coverage by 0.00%.
The diff coverage is 98.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##           node10    #1117      +/-   ##
==========================================
- Coverage   98.60%   98.59%   -0.01%     
==========================================
  Files          28       28              
  Lines       18366    18310      -56     
  Branches     1414     1405       -9     
==========================================
- Hits        18109    18053      -56     
  Misses        254      254              
  Partials        3        3              
Impacted Files Coverage Δ
dev/src/v1/firestore_client.ts 97.86% <98.74%> (ø)
dev/src/bulk-writer.ts 98.43% <100.00%> (+<0.01%) ⬆️
dev/src/write-batch.ts 100.00% <100.00%> (ø)
dev/src/index.ts 98.17% <0.00%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01b665f...f46b6c1. Read the comment docs.

@@ -575,12 +575,33 @@ export class WriteBatch implements firestore.WriteBatch {
api.BatchWriteResponse
>('batchWrite', request, tag);

return (response.writeResults || []).map((result, i) => {
const writeResults = response.writeResults || [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mind removing GCF_IDLE_TIMEOUT_MS (the unrelated lint complaint above)?

Copy link
Author

Choose a reason for hiding this comment

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

it's being used further down in _shouldCreateTransaction().

dev/src/write-batch.ts Show resolved Hide resolved
return (response.writeResults || []).map((result, i) => {
const writeResults = response.writeResults || [];
let latestTimestamp = Timestamp.fromMillis(0);
writeResults.forEach(result => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Prefer using for ... of loops when possible, as this makes for far easier debugging than inline lambdas.

Copy link
Author

Choose a reason for hiding this comment

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

n/a anymore

return new BatchWriteResult(
result.updateTime ? Timestamp.fromProto(result.updateTime) : null,
isSuccessfulDelete
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know what is going on here :) Can you rewrite this to make it obvious? At the very least, this needs parentheses.

Copy link
Author

Choose a reason for hiding this comment

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

I copied this style from your Transaction PR b/c I thought it seemed really cool! And then I went back and saw you changed it :(

it.skip('can terminate once BulkWriter is closed', async () => {
it('has create() method', async () => {
const ref = randomCol.doc('doc1');
const promise = writer.create(ref, {foo: 'bar'});
Copy link
Contributor

Choose a reason for hiding this comment

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

s/promise/singleOp/ ?

Copy link
Author

Choose a reason for hiding this comment

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

done.

@@ -113,7 +113,7 @@ class BulkCommitBatch {

/**
* Adds a `delete` operation to the WriteBatch. Returns a promise that
* resolves with the result of the delete.
* resolves with the sentinel value for the delete operation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we point out that we are returning Timestamp(0)?

Copy link
Author

Choose a reason for hiding this comment

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

I'll add that to the description.

// sentinel Timestamp value.
// TODO(b/158502664): Use actual delete timestamp.
const isSuccessfulDelete =
result.updateTime === null && error.code === Status.OK;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
result.updateTime === null && error.code === Status.OK;
const DELETE_TIMESTAMP_SENTINEL : api.ITimestamp = {}
const updateTime = error.code === Status.OK
? Timestamp.fromProto(result.updateTime || DELETE_TIMESTAMP_SENTINEL)
: null;

For brevity.

Copy link
Author

Choose a reason for hiding this comment

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

so crisp, so clean.

@thebrianchen thebrianchen merged commit 9224c0f into node10 Jun 10, 2020
@thebrianchen thebrianchen deleted the bc/bulk-sys branch June 10, 2020 19:03
schmidt-sebastian added a commit that referenced this pull request Jun 24, 2020
* fix!: mark v1beta1 client as deprecated (#937)

* feat!: use QueryDocumentSnapshot in FirestoreDataConverter (#965)

* deps: update to gts 2.x (#1013)

* chore!: update settings for Node 10 (#1019)

* deps: drop through2 (#1014)

* feat: support BigInt (#1016)

* fix: make update.sh work on Linux (#1043)

* fix: only use BigInt in BigInt system test (#1044)

* fix: make pbjs compile admin proto again (#1045)

* Add BulkWriter (#1055)

* docs: Add documentation for FirestoreDataConverter (#1059)

* chore: enforce return types (#1065)

* fix: add generic to Firestore.getAll() (#1066)

* chore: remove internal WriteOp (#1067)

* chore: add linter checks for it|describe.only (#1068)

* fix: handle terminate in BulkWriter (#1070)

* chore: run template copying last in synthtool (#1071)

* feat: Firestore Bundles implementation (#1078)

* feat: add support for set() with SetOptions when using FirestoreDataConverter (#1087)

* feat: Add totalDocuments and totalBytes to bundle metadata. (#1085)

* feat: Add totalDocuments and totalBytes to bundle metadata.

* fix: Better comment

* fix: Better testing.

* fix: Improve metadata testing.

* fix: incomplete expect in rate-limiter test (#1092)

* Remove BatchWrite proto, fix conformance tests

* chore: use public API types internally (#1100)

* feat: add Partition and BatchWrite protos (#1110)

* fix: remove GCF transaction fallback (#1112)

* fix: add BulkWriter integration tests, java backport changes, delete fix (#1117)

* chore: merge master (#1218)

* chore: add eslint check for console.log statements (#1229)

* fix: another attempt at fixing the flaky BulkWriter test (#1228)

* Fix comment

* Renames

* Test fix

* Fix unit tests

Co-authored-by: Brian Chen <[email protected]>
Co-authored-by: wu-hui <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants