Skip to content

[datastore] fix: handle datastore eventual consistency #3448

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

Merged
merged 2 commits into from
Apr 21, 2020
Merged
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
13 changes: 9 additions & 4 deletions datastore/cloud-ndb/flask_app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

import uuid

import pytest

import backoff
import pytest
from google.cloud import ndb

import flask_app
Expand All @@ -39,9 +40,13 @@ def test_index(test_book):
flask_app.app.testing = True
client = flask_app.app.test_client()

r = client.get('/')
assert r.status_code == 200
assert test_book.title in r.data.decode('utf-8')
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
r = client.get('/')
assert r.status_code == 200
assert test_book.title in r.data.decode('utf-8')

eventually_consistent_test()


def test_ndb_wsgi_middleware():
Expand Down
11 changes: 8 additions & 3 deletions datastore/cloud-ndb/quickstart_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import uuid

import backoff
import pytest

import quickstart
Expand All @@ -34,6 +35,10 @@ def test_book():


def test_quickstart(capsys, test_book):
quickstart.list_books()
out, _ = capsys.readouterr()
assert test_book.title in out
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
quickstart.list_books()
out, _ = capsys.readouterr()
assert test_book.title in out

eventually_consistent_test()
1 change: 1 addition & 0 deletions datastore/cloud-ndb/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
backoff==1.10.0
pytest==5.3.2