Skip to content

Commit d3bc6bf

Browse files
authored
(temporarily) skip pending kernels unit tests on Windows CI (#673)
1 parent af1ab9a commit d3bc6bf

File tree

3 files changed

+127
-63
lines changed

3 files changed

+127
-63
lines changed

jupyter_server/tests/services/kernels/test_api.py

+33-21
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import json
2+
import os
23
import time
34

5+
import jupyter_client
46
import pytest
57
import tornado
68
from jupyter_client.kernelspec import NATIVE_KERNEL_NAME
79
from tornado.httpclient import HTTPClientError
810

911
from ...utils import expected_http_error
10-
from jupyter_server.services.kernels.kernelmanager import AsyncMappingKernelManager
1112
from jupyter_server.utils import url_path_join
1213

1314

14-
class DummyMappingKernelManager(AsyncMappingKernelManager):
15-
"""A no-op subclass to use in a fixture"""
16-
17-
1815
@pytest.fixture
1916
def pending_kernel_is_ready(jp_serverapp):
2017
async def _(kernel_id):
@@ -27,22 +24,37 @@ async def _(kernel_id):
2724
return _
2825

2926

30-
@pytest.fixture(
31-
params=["MappingKernelManager", "AsyncMappingKernelManager", "DummyMappingKernelManager"]
32-
)
33-
def jp_argv(request):
34-
if request.param == "DummyMappingKernelManager":
35-
extra = []
36-
if hasattr(AsyncMappingKernelManager, "use_pending_kernels"):
37-
extra = ["--AsyncMappingKernelManager.use_pending_kernels=True"]
38-
return [
39-
"--ServerApp.kernel_manager_class=jupyter_server.tests.services.kernels.test_api."
40-
+ request.param
41-
] + extra
42-
return [
43-
"--ServerApp.kernel_manager_class=jupyter_server.services.kernels.kernelmanager."
44-
+ request.param
45-
]
27+
configs = [
28+
{
29+
"ServerApp": {
30+
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.MappingKernelManager"
31+
}
32+
},
33+
{
34+
"ServerApp": {
35+
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.AsyncMappingKernelManager"
36+
}
37+
},
38+
]
39+
40+
41+
# Pending kernels was released in Jupyter Client 7.1
42+
# It is currently broken on Windows (Jan 2022). When fixed, we can remove the Windows check.
43+
# See https://github.com/jupyter-server/jupyter_server/issues/672
44+
if os.name != "nt" and jupyter_client._version.version_info >= (7, 1):
45+
# Add a pending kernels condition
46+
c = {
47+
"ServerApp": {
48+
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.AsyncMappingKernelManager"
49+
},
50+
"AsyncMappingKernelManager": {"use_pending_kernels": True},
51+
}
52+
configs.append(c)
53+
54+
55+
@pytest.fixture(params=configs)
56+
def jp_server_config(request):
57+
return request.param
4658

4759

4860
async def test_no_kernels(jp_fetch):

jupyter_server/tests/services/kernels/test_cull.py

+57-26
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
11
import asyncio
22
import json
3+
import os
34
import platform
45

6+
import jupyter_client
57
import pytest
68
from tornado.httpclient import HTTPClientError
79
from traitlets.config import Config
810

911

10-
@pytest.fixture(params=["MappingKernelManager", "AsyncMappingKernelManager"])
11-
def jp_argv(request):
12-
return [
13-
"--ServerApp.kernel_manager_class=jupyter_server.services.kernels.kernelmanager."
14-
+ request.param
15-
]
16-
17-
1812
CULL_TIMEOUT = 30 if platform.python_implementation() == "PyPy" else 5
1913
CULL_INTERVAL = 1
2014

2115

22-
@pytest.fixture
23-
def jp_server_config():
24-
return Config(
25-
{
26-
"ServerApp": {
27-
"MappingKernelManager": {
28-
"cull_idle_timeout": CULL_TIMEOUT,
29-
"cull_interval": CULL_INTERVAL,
30-
"cull_connected": False,
16+
@pytest.mark.parametrize(
17+
"jp_server_config",
18+
[
19+
# Test the synchronous case
20+
Config(
21+
{
22+
"ServerApp": {
23+
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.MappingKernelManager",
24+
"MappingKernelManager": {
25+
"cull_idle_timeout": CULL_TIMEOUT,
26+
"cull_interval": CULL_INTERVAL,
27+
"cull_connected": False,
28+
},
3129
}
3230
}
33-
}
34-
)
35-
36-
31+
),
32+
# Test the async case
33+
Config(
34+
{
35+
"ServerApp": {
36+
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.AsyncMappingKernelManager",
37+
"AsyncMappingKernelManager": {
38+
"cull_idle_timeout": CULL_TIMEOUT,
39+
"cull_interval": CULL_INTERVAL,
40+
"cull_connected": False,
41+
},
42+
}
43+
}
44+
),
45+
],
46+
)
3747
async def test_cull_idle(jp_fetch, jp_ws_fetch, jp_cleanup_subprocesses):
3848
r = await jp_fetch("api", "kernels", method="POST", allow_nonstandard_methods=True)
3949
kernel = json.loads(r.body.decode())
@@ -53,14 +63,35 @@ async def test_cull_idle(jp_fetch, jp_ws_fetch, jp_cleanup_subprocesses):
5363
await jp_cleanup_subprocesses()
5464

5565

66+
# Pending kernels was released in Jupyter Client 7.1
67+
# It is currently broken on Windows (Jan 2022). When fixed, we can remove the Windows check.
68+
# See https://github.com/jupyter-server/jupyter_server/issues/672
69+
@pytest.mark.skipif(
70+
os.name == "nt" or jupyter_client._version.version_info < (7, 1),
71+
reason="Pending kernels require jupyter_client >= 7.1 on non-Windows",
72+
)
73+
@pytest.mark.parametrize(
74+
"jp_server_config",
75+
[
76+
Config(
77+
{
78+
"ServerApp": {
79+
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.AsyncMappingKernelManager",
80+
"AsyncMappingKernelManager": {
81+
"cull_idle_timeout": CULL_TIMEOUT,
82+
"cull_interval": CULL_INTERVAL,
83+
"cull_connected": False,
84+
"default_kernel_name": "bad",
85+
"use_pending_kernels": True,
86+
},
87+
}
88+
}
89+
)
90+
],
91+
)
5692
async def test_cull_dead(
5793
jp_fetch, jp_ws_fetch, jp_serverapp, jp_cleanup_subprocesses, jp_kernelspecs
5894
):
59-
if not hasattr(jp_serverapp.kernel_manager, "use_pending_kernels"):
60-
return
61-
62-
jp_serverapp.kernel_manager.use_pending_kernels = True
63-
jp_serverapp.kernel_manager.default_kernel_name = "bad"
6495
r = await jp_fetch("api", "kernels", method="POST", allow_nonstandard_methods=True)
6596
kernel = json.loads(r.body.decode())
6697
kid = kernel["id"]

jupyter_server/tests/services/sessions/test_api.py

+37-16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import shutil
44
import time
55

6+
import jupyter_client
67
import pytest
78
import tornado
89
from jupyter_client.ioloop import AsyncIOLoopKernelManager
@@ -36,22 +37,42 @@ def _default_kernel_manager_class(self):
3637
return "jupyter_server.tests.services.sessions.test_api.NewPortsKernelManager"
3738

3839

39-
@pytest.fixture(
40-
params=["MappingKernelManager", "AsyncMappingKernelManager", "NewPortsMappingKernelManager"]
41-
)
42-
def jp_argv(request):
43-
if request.param == "NewPortsMappingKernelManager":
44-
extra = []
45-
if hasattr(AsyncMappingKernelManager, "use_pending_kernels"):
46-
extra = ["--AsyncMappingKernelManager.use_pending_kernels=True"]
47-
return [
48-
"--ServerApp.kernel_manager_class=jupyter_server.tests.services.sessions.test_api."
49-
+ request.param
50-
] + extra
51-
return [
52-
"--ServerApp.kernel_manager_class=jupyter_server.services.kernels.kernelmanager."
53-
+ request.param
54-
]
40+
configs = [
41+
{
42+
"ServerApp": {
43+
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.MappingKernelManager"
44+
}
45+
},
46+
{
47+
"ServerApp": {
48+
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.AsyncMappingKernelManager"
49+
}
50+
},
51+
{
52+
"ServerApp": {
53+
"kernel_manager_class": "jupyter_server.tests.services.sessions.test_api.NewPortsMappingKernelManager"
54+
}
55+
},
56+
]
57+
58+
59+
# Pending kernels was released in Jupyter Client 7.1
60+
# It is currently broken on Windows (Jan 2022). When fixed, we can remove the Windows check.
61+
# See https://github.com/jupyter-server/jupyter_server/issues/672
62+
if os.name != "nt" and jupyter_client._version.version_info >= (7, 1):
63+
# Add a pending kernels condition
64+
c = {
65+
"ServerApp": {
66+
"kernel_manager_class": "jupyter_server.tests.services.sessions.test_api.NewPortsMappingKernelManager"
67+
},
68+
"AsyncMappingKernelManager": {"use_pending_kernels": True},
69+
}
70+
configs.append(c)
71+
72+
73+
@pytest.fixture(params=configs)
74+
def jp_server_config(request):
75+
return request.param
5576

5677

5778
class SessionClient:

0 commit comments

Comments
 (0)