Skip to content
Draft

wip #17437

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions packages/google-cloud-firestore/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"pytest-asyncio==0.21.2",
"six",
"pyyaml",
"pytest-xdist",
]
SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = []
SYSTEM_TEST_DEPENDENCIES: List[str] = []
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
42 changes: 13 additions & 29 deletions packages/google-cloud-firestore/tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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):
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
Loading