Skip to content

Increase culling test idle timeout #5952

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

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions notebook/services/kernels/tests/test_kernels_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,20 @@ def test_config(self):
self.assertEqual(self.notebook.kernel_manager.allowed_message_types, ['kernel_info_request'])


CULL_TIMEOUT = 5
CULL_INTERVAL = 1


class KernelCullingTest(NotebookTestBase):
"""Test kernel culling """

@classmethod
def get_argv(cls):
argv = super(KernelCullingTest, cls).get_argv()

# Enable culling with 2s timeout and 1s intervals
argv.extend(['--MappingKernelManager.cull_idle_timeout=2',
'--MappingKernelManager.cull_interval=1',
# Enable culling with 5s timeout and 1s intervals
argv.extend(['--MappingKernelManager.cull_idle_timeout={}'.format(CULL_TIMEOUT),
'--MappingKernelManager.cull_interval={}'.format(CULL_INTERVAL),
'--MappingKernelManager.cull_connected=False'])
return argv

Expand All @@ -270,14 +274,15 @@ def test_culling(self):
assert self.get_cull_status(kid) # not connected, should be culled

def get_cull_status(self, kid):
frequency = 0.5
culled = False
for i in range(15): # Need max of 3s to ensure culling timeout exceeded
for _ in range(int((CULL_TIMEOUT + CULL_INTERVAL)/frequency)): # Timeout + Interval will ensure cull
try:
self.kern_api.get(kid)
except HTTPError as e:
assert e.response.status_code == 404
culled = True
break
else:
time.sleep(0.2)
time.sleep(frequency)
return culled