-
Notifications
You must be signed in to change notification settings - Fork 620
Test large documents #7040
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
base: main
Are you sure you want to change the base?
Test large documents #7040
Conversation
Firebase AI Mock Responses Check
|
📝 PRs merging into main branchOur main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released. |
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.
Summary of Changes
Hello @milaGGL, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces comprehensive integration tests to validate the Firestore client's robustness when handling documents that are close to the maximum allowed size. The new tests cover fundamental data operations, transactional integrity, and real-time data synchronization via snapshot listeners, ensuring the client can reliably manage large data payloads.
Highlights
- New Test Cases for Large Documents: I've added four new integration tests in
FirestoreTest.java
to thoroughly test the Firestore client's ability to handle documents approaching the maximum size limit. These tests cover various operations including basic CRUD, transactions, and snapshot listeners. - Large Document Content Generation: A new helper method,
getLargestDocContent()
, has been introduced inIntegrationTestUtil.java
. This utility generates aMap
containing aBlob
field filled with random bytes, specifically sized to be just under Firestore's maximum document size limit, enabling realistic large document testing. - CRUD Operations with Large Documents: The
testCanCRUDAndQueryLargeDocuments()
test verifies thatset
,get
,update
,query
, anddelete
operations function correctly when dealing with documents that are near the maximum allowed size. - Transaction Support for Large Documents: The
testCanCRUDLargeDocumentsInsideTransaction()
test ensures that large documents can be successfully read, updated, set, and deleted within a Firestore transaction, confirming atomicity and data integrity for large payloads. - Snapshot Listener Behavior with Large Documents: Two new tests,
listenToLargeQuerySnapshot()
andlistenToLargeDocumentSnapshot()
, validate that snapshot listeners correctly receive and process query and document snapshots containing large documents, ensuring real-time updates work as expected.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
Generated by 🚫 Danger |
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.
Code Review
The code changes introduce new tests to verify CRUD operations and snapshot listeners work correctly with large documents in Firestore. The tests cover basic CRUD operations, transactions, and both query and document snapshot listeners.
@Test | ||
public void testCanCRUDAndQueryLargeDocuments() { | ||
CollectionReference collRef = testCollection(); | ||
DocumentReference docRef = collRef.document(); | ||
Map<String, Object> data = getLargestDocContent(); | ||
|
||
// Set | ||
waitFor(docRef.set(data)); | ||
|
||
// Get | ||
DocumentSnapshot snapshot = waitFor(docRef.get()); | ||
assertEquals(data, snapshot.getData()); | ||
|
||
// Update | ||
Map<String, Object> newData = getLargestDocContent(); | ||
waitFor(docRef.update(newData)); | ||
snapshot = waitFor(docRef.get()); | ||
assertEquals(newData, snapshot.getData()); | ||
|
||
// Query | ||
QuerySnapshot querySnapshot = waitFor(collRef.get()); | ||
assertEquals(querySnapshot.size(), 1); | ||
assertEquals(newData, querySnapshot.getDocuments().get(0).getData()); | ||
|
||
// Delete | ||
waitFor(docRef.delete()); | ||
snapshot = waitFor(docRef.get()); | ||
assertFalse(snapshot.exists()); | ||
} |
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.
firebase-firestore/src/androidTest/java/com/google/firebase/firestore/FirestoreTest.java
Show resolved
Hide resolved
firebase-firestore/src/androidTest/java/com/google/firebase/firestore/FirestoreTest.java
Show resolved
Hide resolved
firebase-firestore/src/androidTest/java/com/google/firebase/firestore/FirestoreTest.java
Show resolved
Hide resolved
Coverage Report 1Affected Products
Test Logs |
Test Results 186 files - 872 186 suites - 872 4m 26s ⏱️ - 31m 26s Results for commit a08a955. ± Comparison against base commit f08e0c7. This pull request removes 4750 tests.
♻️ This comment has been updated with latest results. |
Size Report 1Affected ProductsNo changes between base commit (f08e0c7) and merge commit (8850386).Test Logs |
Startup Time Report 1Note: Layout is sometimes suboptimal due to limited formatting support on GitHub. Please check this report on GCS. Notes
Startup Times
|
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.
Thanks! A minor nit pointed out below.
@@ -125,6 +128,10 @@ public enum TargetBackend { | |||
|
|||
private static boolean backendPrimed = false; | |||
|
|||
private static final Random RANDOM = new Random(); |
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: I think it'd be better to move this into the getLargestDocContent()
function.
final Random random = new Random();
random.nextBytes(bytes);
@@ -125,6 +128,10 @@ public enum TargetBackend { | |||
|
|||
private static boolean backendPrimed = false; | |||
|
|||
private static final Random RANDOM = new Random(); | |||
|
|||
private static final int MAX_BYTES_PER_FIELD_VALUE = 1048487; |
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'm also on the fence about moving this into getLargestDocContent()
. On the one hand, literal constants are usually kept outside the method scope. On the other hand, there are no other usages of it. Leaning a bit towards keeping it here.
Labeling the PR with |
WIP: waiting for the backend to be able to handle large docs