Page MenuHomeSoftware Heritage

Non-deterministic failures in test_visit_edges_diamond_pattern[remote]
Open, HighPublic

Description

From time to time, test_visit_edges_diamond_pattern[remote] fails, because the graph returns the wrong edge. Examples I have seen:

  1. non-existent edge 6->1 instead of 6->1.
  2. (obviously non-existent) edge 2->2 instead of 3->2
  3. 8->1 missing
  4. 4->4, 9->1, 4->5 instead of 6->4, 9->8, 6->5

This happens in about 10% of the runs

Example pytest output:

=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.9.2, pytest-7.1.2, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/dev/swh-environment/swh-graph/.hypothesis/examples')
rootdir: /home/dev/swh-environment/swh-graph, configfile: pytest.ini
plugins: hypothesis-6.54.1, requests-mock-1.9.3, django-4.5.2, dash-2.6.1, xdist-2.5.0, mock-3.8.2, django-test-migrations-1.2.0, flask-1.2.0, redis-2.4.0, cov-3.0.0, subtesthack-0.1.2, forked-1.3.0, postgresql-3.1.3, anyio-3.6.1, asyncio-0.19.0, swh.core-2.14.1.dev2+g843a010.d20220902, swh.journal-1.1.0
asyncio: mode=strict
collected 39 items / 1 deselected / 38 selected                                                                                                                                                                   

swh/graph/tests/test_grpc.py::test_stats PASSED                                                                                                                                                             [  2%]
swh/graph/tests/test_grpc.py::test_leaves PASSED                                                                                                                                                            [  5%]
swh/graph/tests/test_grpc.py::test_neighbors PASSED                                                                                                                                                         [  7%]
swh/graph/tests/test_grpc.py::test_visit_nodes PASSED                                                                                                                                                       [ 10%]
swh/graph/tests/test_grpc.py::test_visit_nodes_filtered PASSED                                                                                                                                              [ 13%]
swh/graph/tests/test_grpc.py::test_visit_nodes_filtered_star PASSED                                                                                                                                         [ 15%]
swh/graph/tests/test_http_client.py::test_stats[remote] PASSED                                                                                                                                              [ 18%]
swh/graph/tests/test_http_client.py::test_leaves[remote] PASSED                                                                                                                                             [ 21%]
swh/graph/tests/test_http_client.py::test_neighbors[remote] PASSED                                                                                                                                          [ 23%]
swh/graph/tests/test_http_client.py::test_visit_nodes[remote] PASSED                                                                                                                                        [ 26%]
swh/graph/tests/test_http_client.py::test_visit_nodes_filtered[remote] PASSED                                                                                                                               [ 28%]
swh/graph/tests/test_http_client.py::test_visit_nodes_filtered_star[remote] PASSED                                                                                                                          [ 31%]
swh/graph/tests/test_http_client.py::test_visit_edges[remote] PASSED                                                                                                                                        [ 34%]
swh/graph/tests/test_http_client.py::test_visit_edges_limited[remote] PASSED                                                                                                                                [ 36%]
swh/graph/tests/test_http_client.py::test_visit_edges_diamond_pattern[remote] FAILED                                                                                                                        [ 39%]
swh/graph/tests/test_http_client.py::test_walk[remote] SKIPPED (currently disabled due to T1969)                                                                                                            [ 42%]
swh/graph/tests/test_http_client.py::test_random_walk_dst_is_type[remote] SKIPPED (Random walk is deprecated)                                                                                               [ 44%]
swh/graph/tests/test_http_client.py::test_random_walk_dst_is_node[remote] SKIPPED (Random walk is deprecated)                                                                                               [ 47%]
swh/graph/tests/test_http_client.py::test_count[remote] PASSED                                                                                                                                              [ 50%]
swh/graph/tests/test_http_client.py::test_param_validation[remote] PASSED                                                                                                                                   [ 52%]
swh/graph/tests/test_http_client.py::test_param_validation_walk[remote] SKIPPED (currently disabled due to T1969)                                                                                           [ 55%]
swh/graph/tests/test_http_client.py::test_stats[naive] PASSED                                                                                                                                               [ 57%]
swh/graph/tests/test_http_client.py::test_leaves[naive] PASSED                                                                                                                                              [ 60%]
swh/graph/tests/test_http_client.py::test_neighbors[naive] PASSED                                                                                                                                           [ 63%]
swh/graph/tests/test_http_client.py::test_visit_nodes[naive] PASSED                                                                                                                                         [ 65%]
swh/graph/tests/test_http_client.py::test_visit_nodes_filtered[naive] PASSED                                                                                                                                [ 68%]
swh/graph/tests/test_http_client.py::test_visit_nodes_filtered_star[naive] PASSED                                                                                                                           [ 71%]
swh/graph/tests/test_http_client.py::test_visit_edges[naive] PASSED                                                                                                                                         [ 73%]
swh/graph/tests/test_http_client.py::test_visit_edges_limited[naive] PASSED                                                                                                                                 [ 76%]
swh/graph/tests/test_http_client.py::test_visit_edges_diamond_pattern[naive] PASSED                                                                                                                         [ 78%]
swh/graph/tests/test_http_client.py::test_walk[naive] SKIPPED (currently disabled due to T1969)                                                                                                             [ 81%]
swh/graph/tests/test_http_client.py::test_random_walk_dst_is_type[naive] SKIPPED (Random walk is deprecated)                                                                                                [ 84%]
swh/graph/tests/test_http_client.py::test_random_walk_dst_is_node[naive] SKIPPED (Random walk is deprecated)                                                                                                [ 86%]
swh/graph/tests/test_http_client.py::test_count[naive] PASSED                                                                                                                                               [ 89%]
swh/graph/tests/test_http_client.py::test_param_validation[naive] PASSED                                                                                                                                    [ 92%]
swh/graph/tests/test_http_client.py::test_param_validation_walk[naive] SKIPPED (currently disabled due to T1969)                                                                                            [ 94%]
swh/graph/tests/test_http_server_down.py::test_leaves[remote] PASSED                                                                                                                                        [ 97%]
swh/graph/tests/test_http_server_down.py::test_leaves[naive] SKIPPED (test irrelevant for naive graph client)                                                                                               [100%]

==================================================================================================== FAILURES =====================================================================================================
____________________________________________________________________________________ test_visit_edges_diamond_pattern[remote] _____________________________________________________________________________________

graph_client = <RemoteGraphClient url=http://127.0.0.1:40879/graph/>

    def test_visit_edges_diamond_pattern(graph_client):
        actual = list(
            graph_client.visit_edges(
                "swh:1:rev:0000000000000000000000000000000000000009",
                edges="*",
            )
        )
        expected = [
            (
                "swh:1:rev:0000000000000000000000000000000000000009",
                "swh:1:rev:0000000000000000000000000000000000000003",
            ),
            (
                "swh:1:rev:0000000000000000000000000000000000000009",
                "swh:1:dir:0000000000000000000000000000000000000008",
            ),
            (
                "swh:1:rev:0000000000000000000000000000000000000003",
                "swh:1:dir:0000000000000000000000000000000000000002",
            ),
            (
                "swh:1:dir:0000000000000000000000000000000000000002",
                "swh:1:cnt:0000000000000000000000000000000000000001",
            ),
            (
                "swh:1:dir:0000000000000000000000000000000000000008",
                "swh:1:cnt:0000000000000000000000000000000000000001",
            ),
            (
                "swh:1:dir:0000000000000000000000000000000000000008",
                "swh:1:cnt:0000000000000000000000000000000000000007",
            ),
            (
                "swh:1:dir:0000000000000000000000000000000000000008",
                "swh:1:dir:0000000000000000000000000000000000000006",
            ),
            (
                "swh:1:dir:0000000000000000000000000000000000000006",
                "swh:1:cnt:0000000000000000000000000000000000000004",
            ),
            (
                "swh:1:dir:0000000000000000000000000000000000000006",
                "swh:1:cnt:0000000000000000000000000000000000000005",
            ),
        ]
>       assert set(actual) == set(expected)
E       AssertionError: assert {('swh:1:dir:0000000000000000000000000000000000000002',\n  'swh:1:cnt:0000000000000000000000000000000000000001'),\n ('swh:1:dir:0000000000000000000000000000000000000006',\n  'swh:1:cnt:0000000000000000000000000000000000000001'),\n ('swh:1:dir:0000000000000000000000000000000000000006',\n  'swh:1:cnt:0000000000000000000000000000000000000004'),\n ('swh:1:dir:0000000000000000000000000000000000000008',\n  'swh:1:cnt:0000000000000000000000000000000000000001'),\n ('swh:1:dir:0000000000000000000000000000000000000008',\n  'swh:1:cnt:0000000000000000000000000000000000000007'),\n ('swh:1:dir:0000000000000000000000000000000000000008',\n  'swh:1:dir:0000000000000000000000000000000000000006'),\n ('swh:1:rev:0000000000000000000000000000000000000003',\n  'swh:1:dir:0000000000000000000000000000000000000002'),\n ('swh:1:rev:0000000000000000000000000000000000000009',\n  'swh:1:dir:0000000000000000000000000000000000000008'),\n ('swh:1:rev:0000000000000000000000000000000000000009',\n  'swh:1:rev:0000000000000000000000000000000000000003')} == {('swh:1:dir:0000000000000000000000000000000000000002',\n  'swh:1:cnt:0000000000000000000000000000000000000001'),\n ('swh:1:dir:0000000000000000000000000000000000000006',\n  'swh:1:cnt:0000000000000000000000000000000000000004'),\n ('swh:1:dir:0000000000000000000000000000000000000006',\n  'swh:1:cnt:0000000000000000000000000000000000000005'),\n ('swh:1:dir:0000000000000000000000000000000000000008',\n  'swh:1:cnt:0000000000000000000000000000000000000001'),\n ('swh:1:dir:0000000000000000000000000000000000000008',\n  'swh:1:cnt:0000000000000000000000000000000000000007'),\n ('swh:1:dir:0000000000000000000000000000000000000008',\n  'swh:1:dir:0000000000000000000000000000000000000006'),\n ('swh:1:rev:0000000000000000000000000000000000000003',\n  'swh:1:dir:0000000000000000000000000000000000000002'),\n ('swh:1:rev:0000000000000000000000000000000000000009',\n  'swh:1:dir:0000000000000000000000000000000000000008'),\n ('swh:1:rev:0000000000000000000000000000000000000009',\n  'swh:1:rev:0000000000000000000000000000000000000003')}
E         Extra items in the left set:
E         ('swh:1:dir:0000000000000000000000000000000000000006', 'swh:1:cnt:0000000000000000000000000000000000000001')
E         Extra items in the right set:
E         ('swh:1:dir:0000000000000000000000000000000000000006', 'swh:1:cnt:0000000000000000000000000000000000000005')
E         Full diff:
E           {
E            ('swh:1:dir:0000000000000000000000000000000000000002',
E             'swh:1:cnt:0000000000000000000000000000000000000001'),
E            ('swh:1:dir:0000000000000000000000000000000000000006',
E         +   'swh:1:cnt:0000000000000000000000000000000000000001'),
E         +  ('swh:1:dir:0000000000000000000000000000000000000006',
E             'swh:1:cnt:0000000000000000000000000000000000000004'),
E         -  ('swh:1:dir:0000000000000000000000000000000000000006',
E         -   'swh:1:cnt:0000000000000000000000000000000000000005'),
E            ('swh:1:dir:0000000000000000000000000000000000000008',
E             'swh:1:cnt:0000000000000000000000000000000000000001'),
E            ('swh:1:dir:0000000000000000000000000000000000000008',
E             'swh:1:cnt:0000000000000000000000000000000000000007'),
E            ('swh:1:dir:0000000000000000000000000000000000000008',
E             'swh:1:dir:0000000000000000000000000000000000000006'),
E            ('swh:1:rev:0000000000000000000000000000000000000003',
E             'swh:1:dir:0000000000000000000000000000000000000002'),
E            ('swh:1:rev:0000000000000000000000000000000000000009',
E             'swh:1:dir:0000000000000000000000000000000000000008'),
E            ('swh:1:rev:0000000000000000000000000000000000000009',
E             'swh:1:rev:0000000000000000000000000000000000000003'),
E           }

swh/graph/tests/test_http_client.py:217: AssertionError

Event Timeline

vlorentz triaged this task as High priority.Fri, Sep 9, 2:28 PM
vlorentz created this task.
<seirl> T4521 sounds like a missing copy() issue
<seirl> it corrupts the iterators