Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.indexer.tests.storage.test_api_client.TestIndexerStorageOriginExtrinsicMetadata::test_origin_extrinsic_metadata_add__deadlock
Failed

TEST RESULT

Run At
Aug 3 2022, 2:46 PM
Details
self = <contextlib.ExitStack object at 0x7f088276b240> exc_details = (<class 'ValueError'>, ValueError("<Token var=<ContextVar name='flask.request_ctx' at 0x7f08955e7f10> at 0x7f0882425ca8> was created in a different Context"), <traceback object at 0x7f088221bac8>) received_exc = False _fix_exception_context = <function ExitStack.__exit__.<locals>._fix_exception_context at 0x7f088278bea0> suppressed_exc = False def __exit__(self, *exc_details): received_exc = exc_details[0] is not None # We manipulate the exception state so it behaves as though # we were actually nesting multiple with statements frame_exc = sys.exc_info()[1] def _fix_exception_context(new_exc, old_exc): # Context may not be correct, so find the end of the chain while 1: exc_context = new_exc.__context__ if exc_context is old_exc: # Context is already set correctly (see issue 20317) return if exc_context is None or exc_context is frame_exc: break new_exc = exc_context # Change the end of the chain to point to the exception # we expect it to reference new_exc.__context__ = old_exc # Callbacks are invoked in LIFO order to match the behaviour of # nested context managers suppressed_exc = False pending_raise = False while self._exit_callbacks: is_sync, cb = self._exit_callbacks.pop() assert is_sync try: > if cb(*exc_details): /usr/lib/python3.7/contextlib.py:496: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ exc_type = None, exc = None, tb = None def _exit_wrapper(exc_type, exc, tb): > return cm_exit(cm, exc_type, exc, tb) /usr/lib/python3.7/contextlib.py:377: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <flask.ctx.AppContext object at 0x7f088276b160>, exc_type = None exc_value = None, tb = None def __exit__( self, exc_type: t.Optional[type], exc_value: t.Optional[BaseException], tb: t.Optional[TracebackType], ) -> None: > self.pop(exc_value) .tox/py3/lib/python3.7/site-packages/flask/ctx.py:275: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <flask.ctx.AppContext object at 0x7f088276b160>, exc = None def pop(self, exc: t.Optional[BaseException] = _sentinel) -> None: # type: ignore """Pops the app context.""" try: if len(self._cv_tokens) == 1: if exc is _sentinel: exc = sys.exc_info()[1] self.app.do_teardown_appcontext(exc) finally: ctx = _cv_app.get() > _cv_app.reset(self._cv_tokens.pop()) E ValueError: <Token var=<ContextVar name='flask.app_ctx' at 0x7f08955e7eb8> at 0x7f0892de3e10> was created in a different Context .tox/py3/lib/python3.7/site-packages/flask/ctx.py:256: ValueError During handling of the above exception, another exception occurred: self = <swh.indexer.tests.storage.test_storage.TestIndexerStorageOriginExtrinsicMetadata object at 0x7f0893065fd0> swh_indexer_storage_with_data = (<RemoteStorage url=mock://example.com/>, {'tools': {'swh-metadata-translator': {'id': 1, 'name': 'swh-metadata-transl...configuration_id=7, tool=None, id=b'\x01\xab\xea+\x95\xa9\xad\x87\x01\xad\xdfJ\xf9-h\xf41\xff:\x08', license=b'MIT')]}) def test_origin_extrinsic_metadata_add__deadlock( self, swh_indexer_storage_with_data: Tuple[IndexerStorageInterface, Any] ) -> None: storage, data = swh_indexer_storage_with_data # given tool_id = data.tools["swh-metadata-detector"]["id"] origins = ["file:///tmp/origin{:02d}".format(i) for i in range(100)] example_data1: Dict[str, Any] = { "metadata": { "version": None, "name": None, }, "mappings": [], } example_data2: Dict[str, Any] = { "metadata": { "version": "v1.1.1", "name": "foo", }, "mappings": [], } data_v1 = [ OriginExtrinsicMetadataRow( id=origin, from_remd_id=b"\x02" * 20, indexer_configuration_id=tool_id, **example_data1, ) for origin in origins ] data_v2 = [ OriginExtrinsicMetadataRow( id=origin, from_remd_id=b"\x02" * 20, indexer_configuration_id=tool_id, **example_data2, ) for origin in origins ] # Remove one item from each, so that both queries have to succeed for # all items to be in the DB. data_v2a = data_v2[1:] data_v2b = list(reversed(data_v2[0:-1])) # given storage.origin_extrinsic_metadata_add(data_v1) # when actual_data = list(storage.origin_extrinsic_metadata_get(origins)) expected_data_v1 = [ OriginExtrinsicMetadataRow( id=origin, from_remd_id=b"\x02" * 20, tool=data.tools["swh-metadata-detector"], **example_data1, ) for origin in origins ] # then assert actual_data == expected_data_v1 # given def f1() -> None: storage.origin_extrinsic_metadata_add(data_v2a) def f2() -> None: storage.origin_extrinsic_metadata_add(data_v2b) t1 = threading.Thread(target=f1) t2 = threading.Thread(target=f2) t2.start() t1.start() t1.join() t2.join() > actual_data = list(storage.origin_extrinsic_metadata_get(origins)) .tox/py3/lib/python3.7/site-packages/swh/indexer/tests/storage/test_storage.py:1640: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:183: in meth_ return self._post(meth._endpoint_path, post_data) .tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:272: in _post **opts, .tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:254: in raw_verb return getattr(self.session, verb)(self._url(endpoint), **opts) .tox/py3/lib/python3.7/site-packages/requests/sessions.py:635: in post return self.request("POST", url, data=data, json=json, **kwargs) .tox/py3/lib/python3.7/site-packages/requests/sessions.py:587: in request resp = self.send(prep, **send_kwargs) .tox/py3/lib/python3.7/site-packages/requests/sessions.py:701: in send r = adapter.send(request, **kwargs) .tox/py3/lib/python3.7/site-packages/swh/core/pytest_plugin.py:300: in send data=request.body, .tox/py3/lib/python3.7/site-packages/flask/testing.py:221: in open self._context_stack.close() /usr/lib/python3.7/contextlib.py:519: in close self.__exit__(None, None, None) /usr/lib/python3.7/contextlib.py:511: in __exit__ raise exc_details[1] /usr/lib/python3.7/contextlib.py:496: in __exit__ if cb(*exc_details): /usr/lib/python3.7/contextlib.py:377: in _exit_wrapper return cm_exit(cm, exc_type, exc, tb) .tox/py3/lib/python3.7/site-packages/flask/ctx.py:432: in __exit__ self.pop(exc_value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <RequestContext 'mock://example.com/origin_extrinsic_metadata/add' [POST] of swh.indexer.storage.api.server> exc = ValueError("<Token var=<ContextVar name='flask.app_ctx' at 0x7f08955e7eb8> at 0x7f0892de3e10> was created in a different Context") def pop(self, exc: t.Optional[BaseException] = _sentinel) -> None: # type: ignore """Pops the request context and unbinds it by doing that. This will also trigger the execution of functions registered by the :meth:`~flask.Flask.teardown_request` decorator. .. versionchanged:: 0.9 Added the `exc` argument. """ clear_request = len(self._cv_tokens) == 1 try: if clear_request: if exc is _sentinel: exc = sys.exc_info()[1] self.app.do_teardown_request(exc) request_close = getattr(self.request, "close", None) if request_close is not None: request_close() finally: ctx = _cv_request.get() token, app_ctx = self._cv_tokens.pop() > _cv_request.reset(token) E ValueError: <Token var=<ContextVar name='flask.request_ctx' at 0x7f08955e7f10> at 0x7f0882425ca8> was created in a different Context .tox/py3/lib/python3.7/site-packages/flask/ctx.py:407: ValueError