Skip to content
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

test: fix flaky system test #701

Merged
merged 3 commits into from
Jul 29, 2021
Merged

Conversation

chrisrossi
Copy link
Contributor

Normally a unique namespace per test run is used to prevent different
test runs from interfering with each other, but some tests are
specifically for the default namespace. A discriminator is added to this
test that allows us to naorrow the test query to only entities created
in the current test run.

Fixes #700

Normally a unique namespace per test run is used to prevent different
test runs from interfering with each other, but some tests are
specifically for the default namespace. A discriminator is added to this
test that allows us to naorrow the test query to only entities created
in the current test run.

Fixes googleapis#700
@chrisrossi chrisrossi requested a review from tseaver July 29, 2021 16:00
@chrisrossi chrisrossi requested a review from andrewsg as a code owner July 29, 2021 16:00
@chrisrossi chrisrossi requested a review from a team July 29, 2021 16:00
@chrisrossi chrisrossi requested a review from a team as a code owner July 29, 2021 16:00
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 29, 2021
@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/python-ndb API. label Jul 29, 2021
@@ -377,6 +377,7 @@ def test_query_default_namespace_when_context_namespace_is_other(
class SomeKind(ndb.Model):
foo = ndb.IntegerProperty()
bar = ndb.StringProperty()
discriminator = ndb.StringProperty(default=namespace)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused as to why we're using namespace here to populate a field value: is it just because we know it to be unique per run? ISTM it would be clearer to create another value, using str(uuid.uuid4()) (or make a discriminator fixture which does that, if you are contemplating using the value in other testcases).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is the reason. I did waffle a bit on creating a new value for clarity versus using an already available value. You just made the clarity argument, so I'll switch to that. 9228131

@chrisrossi chrisrossi requested a review from tseaver July 29, 2021 18:13
tests/system/test_query.py Outdated Show resolved Hide resolved
@chrisrossi chrisrossi merged commit d94f0d0 into googleapis:master Jul 29, 2021
@chrisrossi chrisrossi deleted the test-700 branch July 29, 2021 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-ndb API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System test test_query_default_namespace_when_context_namespace_is_other is flaky
2 participants