-
Notifications
You must be signed in to change notification settings - Fork 67
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
Conversation
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
tests/system/test_query.py
Outdated
@@ -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) |
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 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).
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.
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
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