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

Metadata system tests flaky #703

Closed
chrisrossi opened this issue Jul 29, 2021 · 0 comments · Fixed by #726
Closed

Metadata system tests flaky #703

chrisrossi opened this issue Jul 29, 2021 · 0 comments · Fixed by #726
Assignees
Labels
api: datastore Issues related to the googleapis/python-ndb API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: cleanup An internal cleanup or hygiene concern.

Comments

@chrisrossi
Copy link
Contributor

Got what appears to be a transient test failure in Kokoro with PR #696, involving one of the metadata tests:

________ test_get_properties_of_kind_different_namespace[DiffNamespace] ________

dispose_of = <function delete_entity at 0x7f68eb5fdb50>
namespace = 'DiffNamespace'

    @pytest.mark.usefixtures("client_context")
    @pytest.mark.parametrize("namespace", ["DiffNamespace"])
    def test_get_properties_of_kind_different_namespace(dispose_of, namespace):
        from google.cloud.ndb.metadata import get_properties_of_kind

        class AnyKind(ndb.Model):
            foo = ndb.IntegerProperty()
            bar = ndb.StringProperty()
            baz = ndb.IntegerProperty()
            qux = ndb.StringProperty()

        entity1 = AnyKind(foo=1, bar="x", baz=3, qux="y", namespace="DiffNamespace")
        entity1.put()
        dispose_of(entity1.key._key)

        properties = eventually(
            lambda: get_properties_of_kind("AnyKind"), _length_at_least(4)
        )

        assert properties == ["bar", "baz", "foo", "qux"]

        properties = get_properties_of_kind("AnyKind", start="c")
>       assert properties == ["foo", "qux"]
E       AssertionError: assert [] == ['foo', 'qux']
E         Right contains 2 more items, first extra item: 'foo'
E         Full diff:
E         - []
E         + ['foo', 'qux']

tests/system/test_metadata.py:248: AssertionError

Testing the metadata is tricky because of eventual consistency. This failure is particularly odd, though, because first we wait for the get_properties_of_kind call without the start argument to return the right number of properties, so presumably the database has reached an internally consistent state. But then calling get_properties_of_kind with the start parameter, we're back to not finding any properties. Is it possible the first call hit a backend resource that had been udpated with the latest metadata, but then the next call hit a different backend resource that still hadn't been updated?

We might need to look for this pattern in all the metadata tests and make sure all metadata calls use eventually, not just the first call in a test.

@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/python-ndb API. label Jul 29, 2021
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Aug 1, 2021
@dmahugh dmahugh added type: cleanup An internal cleanup or hygiene concern. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Aug 6, 2021
@yoshi-automation yoshi-automation removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Aug 7, 2021
chrisrossi pushed a commit to chrisrossi/python-ndb that referenced this issue Sep 28, 2021
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. priority: p2 Moderately-important priority. Fix may not be included in next release. type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants