Open alcarney opened 4 months ago
While this commit appears to have resolved the original cause of flaky-ness, two new sources of flaky-ness appear to have shown themselves...
================================== FAILURES ===================================
_______________ test_get_client_with_many_uris_in_many_projects _______________
server_manager = <function server_manager.<locals>.initialize at 0x000002422877AAC0>
demo_workspace = Uri(scheme='file', authority='', path='/D:/a/esbonio/esbonio/lib/esbonio/tests/workspaces/demo', query='', fragment='')
docs_workspace = Uri(scheme='file', authority='', path='/D:/a/esbonio/esbonio/docs', query='', fragment='')
tmp_path = WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-0/test_get_client_with_many_uris1')
@pytest.mark.asyncio
async def test_get_client_with_many_uris_in_many_projects(
server_manager: ServerManager,
demo_workspace: Uri,
docs_workspace: Uri,
tmp_path: pathlib.Path,
):
"""Ensure that when called in rapid succession, with many uris we only create a
single client instance for each project."""
server, manager = server_manager(
dict(
esbonio=dict(
sphinx=dict(
pythonCommand=[sys.executable],
buildCommand=["sphinx-build", "-M", "dirhtml", ".", str(tmp_path)],
configOverrides={
"html_theme": "alabaster",
"html_theme_options": {},
},
),
),
),
) # Ensure that the server is ready
await server.ready
src_uris = [Uri.for_file(f) for f in pathlib.Path(demo_workspace).glob("**/*.rst")]
src_uris += [Uri.for_file(f) for f in pathlib.Path(docs_workspace).glob("**/*.rst")]
coros = [manager.get_client(s) for s in src_uris]
# As with the other cases, this should only "prime" the system
result = await asyncio.gather(*coros)
assert all([r is None for r in result])
# There should only have been one client created for each project (in addition to
# the 'dummy' global scoped client)
assert len(manager.clients) == 3
demo_client = manager.clients[str(demo_workspace)]
assert demo_client is not None
assert demo_client.state is None
docs_client = manager.clients[str(docs_workspace)]
assert docs_client is not None
assert docs_client.state is None
# Now if we do the same again we should get the same client instance for each case.
coros = [manager.get_client(s) for s in src_uris]
result = await asyncio.gather(*coros)
assert all([(r is demo_client) or (r is docs_client) for r in result])
> assert demo_client.state == ClientState.Running
E assert <ClientState.Errored: 5> == <ClientState.Running: 3>
E + where <ClientState.Errored: 5> = SphinxClient<Errored: database is locked>.state
E + and <ClientState.Running: 3> = ClientState.Running
tests\e2e\test_sphinx_manager.py:284: AssertionError
---------------------------- Captured stdout call -----------------------------
Running Sphinx v6.2.1
loading intersphinx inventory from https://ipython.readthedocs.io/en/stable/objects.inv...
loading intersphinx inventory from https://docs.python.org/3/objects.inv...
loading intersphinx inventory from https://www.sphinx-doc.org/en/master/objects.inv...
myst v3.0.1: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=set(), disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
================================== FAILURES ===================================
_______________ test_get_client_with_many_uris_in_many_projects _______________
server_manager = <function server_manager.<locals>.initialize at 0x0000017E31F1B1A0>
demo_workspace = Uri(scheme='file', authority='', path='/D:/a/esbonio/esbonio/lib/esbonio/tests/workspaces/demo', query='', fragment='')
docs_workspace = Uri(scheme='file', authority='', path='/D:/a/esbonio/esbonio/docs', query='', fragment='')
tmp_path = WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-2/test_get_client_with_many_uris1')
@pytest.mark.asyncio
async def test_get_client_with_many_uris_in_many_projects(
server_manager: ServerManager,
demo_workspace: Uri,
docs_workspace: Uri,
tmp_path: pathlib.Path,
):
"""Ensure that when called in rapid succession, with many uris we only create a
single client instance for each project."""
server, manager = server_manager(
dict(
esbonio=dict(
sphinx=dict(
pythonCommand=[sys.executable],
buildCommand=["sphinx-build", "-M", "dirhtml", ".", str(tmp_path)],
configOverrides={
"html_theme": "alabaster",
"html_theme_options": {},
},
),
),
),
) # Ensure that the server is ready
await server.ready
src_uris = [Uri.for_file(f) for f in pathlib.Path(demo_workspace).glob("**/*.rst")]
src_uris += [Uri.for_file(f) for f in pathlib.Path(docs_workspace).glob("**/*.rst")]
coros = [manager.get_client(s) for s in src_uris]
# As with the other cases, this should only "prime" the system
result = await asyncio.gather(*coros)
assert all([r is None for r in result])
# There should only have been one client created for each project (in addition to
# the 'dummy' global scoped client)
assert len(manager.clients) == 3
demo_client = manager.clients[str(demo_workspace)]
assert demo_client is not None
assert demo_client.state is None
docs_client = manager.clients[str(docs_workspace)]
assert docs_client is not None
assert docs_client.state is None
# Now if we do the same again we should get the same client instance for each case.
coros = [manager.get_client(s) for s in src_uris]
result = await asyncio.gather(*coros)
assert all([(r is demo_client) or (r is docs_client) for r in result])
> assert demo_client.state == ClientState.Running
E AssertionError: assert <ClientState.Errored: 5> == <ClientState.Running: 3>
E + where <ClientState.Errored: 5> = SphinxClient<Errored: [WinError 183] Cannot create a file when that file already exists: 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pytest-of-runneradmin\\pytest-2\\test_get_client_with_many_uris1\\dirhtml'>.state
E + and <ClientState.Running: 3> = ClientState.Running
tests\e2e\test_sphinx_manager.py:284: AssertionError
---------------------------- Captured stdout call -----------------------------
Running Sphinx v8.0.2
loading translations [en]... done
loading intersphinx inventory 'ipython' from https://ipython.readthedocs.io/en/stable//objects.inv ...
loading intersphinx inventory 'python' from https://docs.python.org/3//objects.inv ...
loading intersphinx inventory 'sphinx' from https://www.sphinx-doc.org/en/master/objects.inv ...
intersphinx inventory has moved: https://ipython.readthedocs.io/en/stable//objects.inv -> https://ipython.readthedocs.io/en/stable/objects.inv
myst v4.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=set(), disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_sort=True, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
Expected behavior
The test to pass reliably
Actual behavior
The mechanism that should prevent duplicate clients from being spawned fails and leads to errors
Log output
(Optional) Settings from conf.py
No response