From 9066c33ef4e4506bd5068359aab9dfb12418b808 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 10 Jun 2026 23:48:59 +0000 Subject: [PATCH 1/6] wip --- packages/google-cloud-firestore/noxfile.py | 5 +++++ packages/google-cloud-firestore/tests/system/test_system.py | 6 +++--- .../tests/system/test_system_async.py | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/google-cloud-firestore/noxfile.py b/packages/google-cloud-firestore/noxfile.py index ef340c48888a..80fe70fa5798 100644 --- a/packages/google-cloud-firestore/noxfile.py +++ b/packages/google-cloud-firestore/noxfile.py @@ -82,6 +82,7 @@ "pytest-asyncio==0.21.2", "six", "pyyaml", + "pytest-xdist", ] SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [] SYSTEM_TEST_DEPENDENCIES: List[str] = [] @@ -402,6 +403,8 @@ def system(session): if system_test_exists: session.run( "py.test", + "-n", + "auto", "--quiet", f"--junitxml=system_{session.python}_sponge_log.xml", system_test_path, @@ -410,6 +413,8 @@ def system(session): if system_test_folder_exists: session.run( "py.test", + "-n", + "auto", "--quiet", f"--junitxml=system_{session.python}_sponge_log.xml", system_test_folder_path, diff --git a/packages/google-cloud-firestore/tests/system/test_system.py b/packages/google-cloud-firestore/tests/system/test_system.py index 0827c372149d..bcdc96c10f63 100644 --- a/packages/google-cloud-firestore/tests/system/test_system.py +++ b/packages/google-cloud-firestore/tests/system/test_system.py @@ -1268,7 +1268,7 @@ def test_unicode_doc(client, cleanup, database): assert snapshot2.reference.id == explicit_doc_id -@pytest.fixture +@pytest.fixture(scope="module") def query_docs(client, database): collection_id = "qs" + UNIQUE_RESOURCE_ID sub_collection = "child" + UNIQUE_RESOURCE_ID @@ -1297,13 +1297,13 @@ def query_docs(client, database): operation() -@pytest.fixture +@pytest.fixture(scope="module") def collection(query_docs): collection, _, _ = query_docs return collection -@pytest.fixture +@pytest.fixture(scope="module") def query(collection): return collection.where(filter=FieldFilter("a", "==", 1)) diff --git a/packages/google-cloud-firestore/tests/system/test_system_async.py b/packages/google-cloud-firestore/tests/system/test_system_async.py index 34c7eb6d8164..ef8ca5b84d5f 100644 --- a/packages/google-cloud-firestore/tests/system/test_system_async.py +++ b/packages/google-cloud-firestore/tests/system/test_system_async.py @@ -1243,7 +1243,7 @@ async def test_list_collections_with_read_time(client, cleanup, database): } -@pytest_asyncio.fixture +@pytest_asyncio.fixture(scope="module") async def query_docs(client): collection_id = "qs" + UNIQUE_RESOURCE_ID sub_collection = "child" + UNIQUE_RESOURCE_ID @@ -1272,13 +1272,13 @@ async def query_docs(client): await operation() -@pytest_asyncio.fixture +@pytest_asyncio.fixture(scope="module") async def collection(query_docs): collection, _, _ = query_docs yield collection -@pytest_asyncio.fixture +@pytest_asyncio.fixture(scope="module") async def async_query(collection): return collection.where(filter=FieldFilter("a", "==", 1)) From a3b5b1d5244ee07755804cd8079b3facdfa9cb6b Mon Sep 17 00:00:00 2001 From: ohmayr Date: Thu, 11 Jun 2026 04:26:52 +0000 Subject: [PATCH 2/6] update unique resource id --- packages/google-cloud-firestore/tests/system/test__helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google-cloud-firestore/tests/system/test__helpers.py b/packages/google-cloud-firestore/tests/system/test__helpers.py index 83dd476602f2..228bd0e4362a 100644 --- a/packages/google-cloud-firestore/tests/system/test__helpers.py +++ b/packages/google-cloud-firestore/tests/system/test__helpers.py @@ -16,7 +16,7 @@ MISSING_DOCUMENT = "No document to update: " DOCUMENT_EXISTS = "Document already exists: " ENTERPRISE_MODE_ERROR = "only allowed on ENTERPRISE mode" -UNIQUE_RESOURCE_ID = unique_resource_id("-") +UNIQUE_RESOURCE_ID = unique_resource_id("-") + "-" + str(os.getpid()) EMULATOR_CREDS = EmulatorCreds() FIRESTORE_EMULATOR = os.environ.get(_FIRESTORE_EMULATOR_HOST) is not None FIRESTORE_OTHER_DB = os.environ.get("SYSTEM_TESTS_DATABASE", "system-tests-named-db") From e11bb0e3c50bdd086b7817e41d060923f3cd9b94 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Thu, 11 Jun 2026 04:50:00 +0000 Subject: [PATCH 3/6] change sleep time --- .../tests/system/test_system.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/google-cloud-firestore/tests/system/test_system.py b/packages/google-cloud-firestore/tests/system/test_system.py index bcdc96c10f63..e9080a526ab9 100644 --- a/packages/google-cloud-firestore/tests/system/test_system.py +++ b/packages/google-cloud-firestore/tests/system/test_system.py @@ -2336,7 +2336,7 @@ def test_watch_document(client, cleanup, database): doc_ref.set({"first": "Jane", "last": "Doe", "born": 1900}) cleanup(doc_ref.delete) - sleep(1) + sleep(0.2) # Setup listener def on_snapshot(docs, changes, read_time): @@ -2349,12 +2349,12 @@ def on_snapshot(docs, changes, read_time): # Alter document doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815}) - sleep(1) + sleep(0.2) - for _ in range(10): + for _ in range(50): if on_snapshot.called_count > 0: break - sleep(1) + sleep(0.2) if on_snapshot.called_count not in (1, 2): raise AssertionError( @@ -2385,14 +2385,14 @@ def on_snapshot(docs, changes, read_time): collection_ref.on_snapshot(on_snapshot) # delay here so initial on_snapshot occurs and isn't combined with set - sleep(1) + sleep(0.2) doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815}) - for _ in range(10): + for _ in range(50): if on_snapshot.born == 1815: break - sleep(1) + sleep(0.2) if on_snapshot.born != 1815: raise AssertionError( @@ -2411,7 +2411,7 @@ def test_watch_query(client, cleanup, database): doc_ref.set({"first": "Jane", "last": "Doe", "born": 1900}) cleanup(doc_ref.delete) - sleep(1) + sleep(0.2) # Setup listener def on_snapshot(docs, changes, read_time): @@ -2429,10 +2429,10 @@ def on_snapshot(docs, changes, read_time): # Alter document doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815}) - for _ in range(10): + for _ in range(50): if on_snapshot.called_count == 1: return - sleep(1) + sleep(0.2) if on_snapshot.called_count != 1: raise AssertionError( @@ -2806,7 +2806,7 @@ def on_snapshot(docs, changes, read_time): on_snapshot.failed = None query_ref.on_snapshot(on_snapshot) - sleep(1) + sleep(0.2) doc_ref1.set({"first": "Ada", "last": "Lovelace", "born": 1815}) cleanup(doc_ref1.delete) @@ -2823,10 +2823,10 @@ def on_snapshot(docs, changes, read_time): doc_ref5.set({"first": "Ada", "last": "lovelace", "born": 1815}) cleanup(doc_ref5.delete) - for _ in range(10): + for _ in range(50): if on_snapshot.last_doc_count == 5: break - sleep(1) + sleep(0.2) if on_snapshot.failed: raise on_snapshot.failed From 2e448a76b52aedb5298a92df70992abae8e5774f Mon Sep 17 00:00:00 2001 From: ohmayr Date: Thu, 11 Jun 2026 16:17:36 +0000 Subject: [PATCH 4/6] address PR feedback --- .../firestore-integration.yaml | 52 +++++++++++++++++++ .../tests/system/test_system.py | 16 ++++++ 2 files changed, 68 insertions(+) diff --git a/.librarian/generator-input/client-post-processing/firestore-integration.yaml b/.librarian/generator-input/client-post-processing/firestore-integration.yaml index 2114dbabca04..fd5fb175852d 100644 --- a/.librarian/generator-input/client-post-processing/firestore-integration.yaml +++ b/.librarian/generator-input/client-post-processing/firestore-integration.yaml @@ -564,6 +564,9 @@ replacements: "freezegun", ] count: 1 + # TODO(https://github.com/googleapis/google-cloud-python/issues/17429): + # Temporary post-processing rule to add pytest-xdist dependency. + # Remove this once gapic-generator includes pytest-xdist by default. - paths: [ packages/google-cloud-firestore/noxfile.py ] @@ -574,6 +577,7 @@ replacements: "pytest-asyncio", "six", "pyyaml", + "pytest-xdist", ] count: 1 - paths: [ @@ -584,6 +588,54 @@ replacements: after: | "pytest-asyncio==0.21.2", count: 2 + # TODO(https://github.com/googleapis/google-cloud-python/issues/17429): + # Temporary post-processing rule to inject `-n auto` for Firestore parallel tests. + # This rule should be removed once the generator template changes are released + # and the generator version is updated in librarian.yaml. + - paths: [ + packages/google-cloud-firestore/noxfile.py + ] + before: | + # Run py.test against the system tests\. + if system_test_exists: + session\.run\( + "py.test", + "--quiet", + f"--junitxml=system_\{session\.python\}_sponge_log\.xml", + system_test_path, + \*session\.posargs, + \) + if system_test_folder_exists: + session\.run\( + "py.test", + "--quiet", + f"--junitxml=system_\{session\.python\}_sponge_log\.xml", + system_test_folder_path, + \*session\.posargs, + \) + after: | + # Run py.test against the system tests. + if system_test_exists: + session.run( + "py.test", + "-n", + "auto", + "--quiet", + f"--junitxml=system_{session.python}_sponge_log.xml", + system_test_path, + *session.posargs, + ) + if system_test_folder_exists: + session.run( + "py.test", + "-n", + "auto", + "--quiet", + f"--junitxml=system_{session.python}_sponge_log.xml", + system_test_folder_path, + *session.posargs, + ) + count: 1 - paths: [ "packages/google-cloud-firestore/docs/conf.py", ] diff --git a/packages/google-cloud-firestore/tests/system/test_system.py b/packages/google-cloud-firestore/tests/system/test_system.py index e9080a526ab9..fe475206d37f 100644 --- a/packages/google-cloud-firestore/tests/system/test_system.py +++ b/packages/google-cloud-firestore/tests/system/test_system.py @@ -2336,6 +2336,10 @@ def test_watch_document(client, cleanup, database): doc_ref.set({"first": "Jane", "last": "Doe", "born": 1900}) cleanup(doc_ref.delete) + # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): + # Investigate why these sleep/polling delays are needed for listener tests. + # Having arbitrary delays is fragile and can lead to flakiness. + # Explore event-driven synchronization. sleep(0.2) # Setup listener @@ -2384,6 +2388,10 @@ def on_snapshot(docs, changes, read_time): collection_ref.on_snapshot(on_snapshot) + # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): + # Investigate why these sleep/polling delays are needed for listener tests. + # Having arbitrary delays is fragile and can lead to flakiness. + # Explore event-driven synchronization. # delay here so initial on_snapshot occurs and isn't combined with set sleep(0.2) @@ -2411,6 +2419,10 @@ def test_watch_query(client, cleanup, database): doc_ref.set({"first": "Jane", "last": "Doe", "born": 1900}) cleanup(doc_ref.delete) + # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): + # Investigate why these sleep/polling delays are needed for listener tests. + # Having arbitrary delays is fragile and can lead to flakiness. + # Explore event-driven synchronization. sleep(0.2) # Setup listener @@ -2806,6 +2818,10 @@ def on_snapshot(docs, changes, read_time): on_snapshot.failed = None query_ref.on_snapshot(on_snapshot) + # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): + # Investigate why these sleep/polling delays are needed for listener tests. + # Having arbitrary delays is fragile and can lead to flakiness. + # Explore event-driven synchronization. sleep(0.2) doc_ref1.set({"first": "Ada", "last": "Lovelace", "born": 1815}) From 0693fad503608149661a05c52b5fbfc9f1b8995a Mon Sep 17 00:00:00 2001 From: ohmayr Date: Thu, 11 Jun 2026 22:21:47 +0000 Subject: [PATCH 5/6] wip --- packages/google-cloud-firestore/noxfile.py | 5 --- .../tests/system/test__helpers.py | 2 +- .../tests/system/test_system.py | 42 ++++++------------- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/packages/google-cloud-firestore/noxfile.py b/packages/google-cloud-firestore/noxfile.py index 80fe70fa5798..ef340c48888a 100644 --- a/packages/google-cloud-firestore/noxfile.py +++ b/packages/google-cloud-firestore/noxfile.py @@ -82,7 +82,6 @@ "pytest-asyncio==0.21.2", "six", "pyyaml", - "pytest-xdist", ] SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [] SYSTEM_TEST_DEPENDENCIES: List[str] = [] @@ -403,8 +402,6 @@ def system(session): if system_test_exists: session.run( "py.test", - "-n", - "auto", "--quiet", f"--junitxml=system_{session.python}_sponge_log.xml", system_test_path, @@ -413,8 +410,6 @@ def system(session): if system_test_folder_exists: session.run( "py.test", - "-n", - "auto", "--quiet", f"--junitxml=system_{session.python}_sponge_log.xml", system_test_folder_path, diff --git a/packages/google-cloud-firestore/tests/system/test__helpers.py b/packages/google-cloud-firestore/tests/system/test__helpers.py index 228bd0e4362a..83dd476602f2 100644 --- a/packages/google-cloud-firestore/tests/system/test__helpers.py +++ b/packages/google-cloud-firestore/tests/system/test__helpers.py @@ -16,7 +16,7 @@ MISSING_DOCUMENT = "No document to update: " DOCUMENT_EXISTS = "Document already exists: " ENTERPRISE_MODE_ERROR = "only allowed on ENTERPRISE mode" -UNIQUE_RESOURCE_ID = unique_resource_id("-") + "-" + str(os.getpid()) +UNIQUE_RESOURCE_ID = unique_resource_id("-") EMULATOR_CREDS = EmulatorCreds() FIRESTORE_EMULATOR = os.environ.get(_FIRESTORE_EMULATOR_HOST) is not None FIRESTORE_OTHER_DB = os.environ.get("SYSTEM_TESTS_DATABASE", "system-tests-named-db") diff --git a/packages/google-cloud-firestore/tests/system/test_system.py b/packages/google-cloud-firestore/tests/system/test_system.py index fe475206d37f..bcdc96c10f63 100644 --- a/packages/google-cloud-firestore/tests/system/test_system.py +++ b/packages/google-cloud-firestore/tests/system/test_system.py @@ -2336,11 +2336,7 @@ def test_watch_document(client, cleanup, database): doc_ref.set({"first": "Jane", "last": "Doe", "born": 1900}) cleanup(doc_ref.delete) - # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): - # Investigate why these sleep/polling delays are needed for listener tests. - # Having arbitrary delays is fragile and can lead to flakiness. - # Explore event-driven synchronization. - sleep(0.2) + sleep(1) # Setup listener def on_snapshot(docs, changes, read_time): @@ -2353,12 +2349,12 @@ def on_snapshot(docs, changes, read_time): # Alter document doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815}) - sleep(0.2) + sleep(1) - for _ in range(50): + for _ in range(10): if on_snapshot.called_count > 0: break - sleep(0.2) + sleep(1) if on_snapshot.called_count not in (1, 2): raise AssertionError( @@ -2388,19 +2384,15 @@ def on_snapshot(docs, changes, read_time): collection_ref.on_snapshot(on_snapshot) - # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): - # Investigate why these sleep/polling delays are needed for listener tests. - # Having arbitrary delays is fragile and can lead to flakiness. - # Explore event-driven synchronization. # delay here so initial on_snapshot occurs and isn't combined with set - sleep(0.2) + sleep(1) doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815}) - for _ in range(50): + for _ in range(10): if on_snapshot.born == 1815: break - sleep(0.2) + sleep(1) if on_snapshot.born != 1815: raise AssertionError( @@ -2419,11 +2411,7 @@ def test_watch_query(client, cleanup, database): doc_ref.set({"first": "Jane", "last": "Doe", "born": 1900}) cleanup(doc_ref.delete) - # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): - # Investigate why these sleep/polling delays are needed for listener tests. - # Having arbitrary delays is fragile and can lead to flakiness. - # Explore event-driven synchronization. - sleep(0.2) + sleep(1) # Setup listener def on_snapshot(docs, changes, read_time): @@ -2441,10 +2429,10 @@ def on_snapshot(docs, changes, read_time): # Alter document doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815}) - for _ in range(50): + for _ in range(10): if on_snapshot.called_count == 1: return - sleep(0.2) + sleep(1) if on_snapshot.called_count != 1: raise AssertionError( @@ -2818,11 +2806,7 @@ def on_snapshot(docs, changes, read_time): on_snapshot.failed = None query_ref.on_snapshot(on_snapshot) - # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): - # Investigate why these sleep/polling delays are needed for listener tests. - # Having arbitrary delays is fragile and can lead to flakiness. - # Explore event-driven synchronization. - sleep(0.2) + sleep(1) doc_ref1.set({"first": "Ada", "last": "Lovelace", "born": 1815}) cleanup(doc_ref1.delete) @@ -2839,10 +2823,10 @@ def on_snapshot(docs, changes, read_time): doc_ref5.set({"first": "Ada", "last": "lovelace", "born": 1815}) cleanup(doc_ref5.delete) - for _ in range(50): + for _ in range(10): if on_snapshot.last_doc_count == 5: break - sleep(0.2) + sleep(1) if on_snapshot.failed: raise on_snapshot.failed From 6eb18126d91a7d0f20488982ce9cdeb5c9d016c9 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Thu, 11 Jun 2026 22:21:47 +0000 Subject: [PATCH 6/6] wip --- packages/google-cloud-firestore/noxfile.py | 5 --- .../tests/system/test__helpers.py | 2 +- .../tests/system/test_system.py | 42 ++++++------------- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/packages/google-cloud-firestore/noxfile.py b/packages/google-cloud-firestore/noxfile.py index 80fe70fa5798..ef340c48888a 100644 --- a/packages/google-cloud-firestore/noxfile.py +++ b/packages/google-cloud-firestore/noxfile.py @@ -82,7 +82,6 @@ "pytest-asyncio==0.21.2", "six", "pyyaml", - "pytest-xdist", ] SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [] SYSTEM_TEST_DEPENDENCIES: List[str] = [] @@ -403,8 +402,6 @@ def system(session): if system_test_exists: session.run( "py.test", - "-n", - "auto", "--quiet", f"--junitxml=system_{session.python}_sponge_log.xml", system_test_path, @@ -413,8 +410,6 @@ def system(session): if system_test_folder_exists: session.run( "py.test", - "-n", - "auto", "--quiet", f"--junitxml=system_{session.python}_sponge_log.xml", system_test_folder_path, diff --git a/packages/google-cloud-firestore/tests/system/test__helpers.py b/packages/google-cloud-firestore/tests/system/test__helpers.py index 228bd0e4362a..83dd476602f2 100644 --- a/packages/google-cloud-firestore/tests/system/test__helpers.py +++ b/packages/google-cloud-firestore/tests/system/test__helpers.py @@ -16,7 +16,7 @@ MISSING_DOCUMENT = "No document to update: " DOCUMENT_EXISTS = "Document already exists: " ENTERPRISE_MODE_ERROR = "only allowed on ENTERPRISE mode" -UNIQUE_RESOURCE_ID = unique_resource_id("-") + "-" + str(os.getpid()) +UNIQUE_RESOURCE_ID = unique_resource_id("-") EMULATOR_CREDS = EmulatorCreds() FIRESTORE_EMULATOR = os.environ.get(_FIRESTORE_EMULATOR_HOST) is not None FIRESTORE_OTHER_DB = os.environ.get("SYSTEM_TESTS_DATABASE", "system-tests-named-db") diff --git a/packages/google-cloud-firestore/tests/system/test_system.py b/packages/google-cloud-firestore/tests/system/test_system.py index fe475206d37f..bcdc96c10f63 100644 --- a/packages/google-cloud-firestore/tests/system/test_system.py +++ b/packages/google-cloud-firestore/tests/system/test_system.py @@ -2336,11 +2336,7 @@ def test_watch_document(client, cleanup, database): doc_ref.set({"first": "Jane", "last": "Doe", "born": 1900}) cleanup(doc_ref.delete) - # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): - # Investigate why these sleep/polling delays are needed for listener tests. - # Having arbitrary delays is fragile and can lead to flakiness. - # Explore event-driven synchronization. - sleep(0.2) + sleep(1) # Setup listener def on_snapshot(docs, changes, read_time): @@ -2353,12 +2349,12 @@ def on_snapshot(docs, changes, read_time): # Alter document doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815}) - sleep(0.2) + sleep(1) - for _ in range(50): + for _ in range(10): if on_snapshot.called_count > 0: break - sleep(0.2) + sleep(1) if on_snapshot.called_count not in (1, 2): raise AssertionError( @@ -2388,19 +2384,15 @@ def on_snapshot(docs, changes, read_time): collection_ref.on_snapshot(on_snapshot) - # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): - # Investigate why these sleep/polling delays are needed for listener tests. - # Having arbitrary delays is fragile and can lead to flakiness. - # Explore event-driven synchronization. # delay here so initial on_snapshot occurs and isn't combined with set - sleep(0.2) + sleep(1) doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815}) - for _ in range(50): + for _ in range(10): if on_snapshot.born == 1815: break - sleep(0.2) + sleep(1) if on_snapshot.born != 1815: raise AssertionError( @@ -2419,11 +2411,7 @@ def test_watch_query(client, cleanup, database): doc_ref.set({"first": "Jane", "last": "Doe", "born": 1900}) cleanup(doc_ref.delete) - # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): - # Investigate why these sleep/polling delays are needed for listener tests. - # Having arbitrary delays is fragile and can lead to flakiness. - # Explore event-driven synchronization. - sleep(0.2) + sleep(1) # Setup listener def on_snapshot(docs, changes, read_time): @@ -2441,10 +2429,10 @@ def on_snapshot(docs, changes, read_time): # Alter document doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815}) - for _ in range(50): + for _ in range(10): if on_snapshot.called_count == 1: return - sleep(0.2) + sleep(1) if on_snapshot.called_count != 1: raise AssertionError( @@ -2818,11 +2806,7 @@ def on_snapshot(docs, changes, read_time): on_snapshot.failed = None query_ref.on_snapshot(on_snapshot) - # TODO(https://github.com/googleapis/google-cloud-python/issues/17428): - # Investigate why these sleep/polling delays are needed for listener tests. - # Having arbitrary delays is fragile and can lead to flakiness. - # Explore event-driven synchronization. - sleep(0.2) + sleep(1) doc_ref1.set({"first": "Ada", "last": "Lovelace", "born": 1815}) cleanup(doc_ref1.delete) @@ -2839,10 +2823,10 @@ def on_snapshot(docs, changes, read_time): doc_ref5.set({"first": "Ada", "last": "lovelace", "born": 1815}) cleanup(doc_ref5.delete) - for _ in range(50): + for _ in range(10): if on_snapshot.last_doc_count == 5: break - sleep(0.2) + sleep(1) if on_snapshot.failed: raise on_snapshot.failed