-
Notifications
You must be signed in to change notification settings - Fork 616
get() reimplementation #3887
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
get() reimplementation #3887
Conversation
Coverage Report 1Affected Products
Test Logs
Notes |
Size Report 1Affected Products
Test Logs
Notes |
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.
Reviewed the tests, will review the rest later.
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/SyncPoint.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/SyncPoint.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/SyncTree.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/SyncTree.java
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/SyncTree.java
Outdated
Show resolved
Hide resolved
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.
This is great, those skipDedup + skipListenerSetup parameters make this much easier to think about! I'm ready to approve once these comments are addressed.
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/Repo.java
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/Repo.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/Repo.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/SyncTree.java
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/view/View.java
Outdated
Show resolved
Hide resolved
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.
LGTM, did you run ./gradlew :firebase-database:googleJavaFormat
?
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
DatabaseReference parentReadNode = readDb.getReference().child(parentNodeKey); | ||
IntegrationTestHelpers.waitFor(semaphore); | ||
DataSnapshot snapshot = await(parentReadNode.get()); | ||
assertEquals(snapshot.child(childNodeKey).getValue(), val); |
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.
Just a note, no need to make any changes.
I think in the future for assertions like this we should assert the contents of snapshot
as opposed to indexing into it with .child()
:
assertEquals(MapBuilder.put(childNodeKey, val).build(), snapshot.getValue());
I think in general it's easier to think about "values of references" as on L4765 below. It's also more correct because it tests that unexpected keys don't exist at snapshot.getValue()
.
FirebaseApp readApp = | ||
appForDatabaseUrl(IntegrationTestValues.getDatabaseUrl(), UUID.randomUUID().toString()); | ||
FirebaseApp writeApp = | ||
appForDatabaseUrl(IntegrationTestValues.getDatabaseUrl(), UUID.randomUUID().toString()); | ||
FirebaseDatabase readDb = FirebaseDatabase.getInstance(readApp); | ||
FirebaseDatabase writeDb = FirebaseDatabase.getInstance(writeApp); | ||
String parentKey = UUID.randomUUID().toString(); | ||
DatabaseReference writeRef = writeDb.getReference().child(parentKey); | ||
DatabaseReference child1Ref = readDb.getReference().child(parentKey).child("child1"); |
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.
Feel free to do this in a separate PR, we could definitely abstract some of this setup into a helper, potentially even a some sort of TestFixture class.
Yes. Tests fail otherwise |
firebase-database/src/androidTest/java/com/google/firebase/database/IntegrationTestHelpers.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/IntegrationTestHelpers.java
Outdated
Show resolved
Hide resolved
firebase-database/src/androidTest/java/com/google/firebase/database/QueryTest.java
Outdated
Show resolved
Hide resolved
Fixed `get()` issue where wrong cache paths were being updated in the SyncTree. Co-authored-by: Jan Wyszynski <[email protected]>
new MapBuilder().put("child1", "test1").put("child2", "test2").build(); | ||
try { | ||
await(writeRef.setValue(expected)); | ||
ReadFuture.untilEquals(readRef, expected).timedGet(); |
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.
Was this test supposed to install a listener with a timeout and validate that we don't get two events in some window?
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 believe so
* that location, listen would be called twice on the same query. skipDedup allows us | ||
* to skip this deduping process altogether. | ||
*/ | ||
if (skipDedup) { |
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 think we are leaking the tag created inside keepSynced(true) in Repo.getValue because we never hit L790.
Fixes the issue first seen on iOS: firebase/firebase-ios-sdk#8286. Essentially, the wrong path in the SyncTree was being updated. Before, regardless of what type of query was being sent, we were always updating the default query path. Now, we add the query to the SyncTree (along with Persistence) by adding an event registration (just like for a listener) and then remove the event registration once the data has come back.