Skip to content

Commit 913ff5e

Browse files
authored
Bump runtimed to include iopub_welcome (JEP 65) support (#72)
Pull in latest runtimed changes that add XPUB socket support and iopub_welcome messages for improved IOPub reliability. Update kernel-testbed to use the new wait_for_iopub_welcome() API and add a conformance test for JEP 65 compliance. Changes: - cargo update: runtimed commits d703acca -> 302c4a2b - Replace 100ms settle time with wait_for_iopub_welcome() (500ms timeout) - Add iopub_welcome_received tracking to KernelUnderTest - Add Tier 1 conformance test for iopub_welcome (JEP 65)
1 parent 0ed5dd2 commit 913ff5e

3 files changed

Lines changed: 69 additions & 32 deletions

File tree

Cargo.lock

Lines changed: 24 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/harness.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use runtimelib::{
1313
create_client_control_connection, create_client_heartbeat_connection,
1414
create_client_iopub_connection, create_client_shell_connection_with_identity,
1515
create_client_stdin_connection_with_identity, peer_identity_for_session, peek_ports,
16-
ClientControlConnection, ClientHeartbeatConnection, ClientIoPubConnection,
17-
ClientShellConnection, ClientStdinConnection, KernelspecDir,
16+
wait_for_iopub_welcome, ClientControlConnection, ClientHeartbeatConnection,
17+
ClientIoPubConnection, ClientShellConnection, ClientStdinConnection, KernelspecDir,
1818
};
1919
use std::net::{IpAddr, Ipv4Addr};
2020
use std::path::PathBuf;
@@ -24,8 +24,9 @@ use thiserror::Error;
2424
use tokio::process::Child;
2525
use tokio::time::timeout;
2626

27-
/// Time to wait for IOPub to settle after connecting
28-
const IOPUB_SETTLE_TIME: Duration = Duration::from_millis(100);
27+
/// Timeout for waiting for iopub_welcome message (JEP 65)
28+
/// Kernels using XPUB sockets will send this immediately, others will timeout gracefully
29+
const IOPUB_WELCOME_TIMEOUT: Duration = Duration::from_millis(500);
2930

3031
#[derive(Error, Debug)]
3132
pub enum HarnessError {
@@ -72,6 +73,8 @@ pub struct KernelUnderTest {
7273
snippets: LanguageSnippets,
7374
/// Per-test timeout
7475
test_timeout: Duration,
76+
/// Whether iopub_welcome was received (JEP 65 support)
77+
iopub_welcome_received: bool,
7578
}
7679

7780
impl KernelUnderTest {
@@ -128,7 +131,7 @@ impl KernelUnderTest {
128131
.await
129132
.map_err(|e| HarnessError::ConnectionFailed(e.to_string()))?;
130133

131-
let iopub = create_client_iopub_connection(&connection_info, "", &session_id)
134+
let mut iopub = create_client_iopub_connection(&connection_info, "", &session_id)
132135
.await
133136
.map_err(|e| HarnessError::ConnectionFailed(e.to_string()))?;
134137

@@ -145,8 +148,13 @@ impl KernelUnderTest {
145148
.await
146149
.map_err(|e| HarnessError::ConnectionFailed(e.to_string()))?;
147150

148-
// Wait for IOPub to settle
149-
tokio::time::sleep(IOPUB_SETTLE_TIME).await;
151+
// Wait for iopub_welcome (JEP 65) or timeout gracefully for legacy kernels
152+
let iopub_welcome_received =
153+
match wait_for_iopub_welcome(&mut iopub, IOPUB_WELCOME_TIMEOUT).await {
154+
Ok(Some(_subscription)) => true,
155+
Ok(None) => false, // Timeout or non-welcome message - kernel doesn't support XPUB
156+
Err(_) => false, // Error during wait - proceed anyway
157+
};
150158

151159
// Default snippets (will be updated after kernel_info)
152160
let snippets = LanguageSnippets::for_language("python");
@@ -164,6 +172,7 @@ impl KernelUnderTest {
164172
kernel_info: None,
165173
snippets,
166174
test_timeout,
175+
iopub_welcome_received,
167176
};
168177

169178
// Get kernel info to determine language
@@ -208,6 +217,11 @@ impl KernelUnderTest {
208217
&self.snippets
209218
}
210219

220+
/// Check if iopub_welcome was received (JEP 65 support).
221+
pub fn iopub_welcome_received(&self) -> bool {
222+
self.iopub_welcome_received
223+
}
224+
211225
/// Send a request on shell and wait for reply.
212226
pub async fn shell_request(
213227
&mut self,

src/tests.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ fn test_heartbeat_responds(
3030
})
3131
}
3232

33+
fn test_iopub_welcome(
34+
kernel: &mut KernelUnderTest,
35+
) -> Pin<Box<dyn Future<Output = TestResult> + Send + '_>> {
36+
Box::pin(async move {
37+
if kernel.iopub_welcome_received() {
38+
TestResult::Pass
39+
} else {
40+
// iopub_welcome is optional (JEP 65) - kernels using legacy PUB sockets won't send it
41+
TestResult::PartialPass {
42+
score: 0.5,
43+
notes: "No iopub_welcome received (kernel may use legacy PUB socket instead of XPUB)"
44+
.to_string(),
45+
}
46+
}
47+
})
48+
}
49+
3350
fn test_kernel_info_reply_valid(
3451
kernel: &mut KernelUnderTest,
3552
) -> Pin<Box<dyn Future<Output = TestResult> + Send + '_>> {
@@ -880,6 +897,13 @@ pub fn all_tests() -> Vec<ConformanceTest> {
880897
message_type: "heartbeat",
881898
run: test_heartbeat_responds,
882899
},
900+
ConformanceTest {
901+
name: "iopub_welcome",
902+
category: TestCategory::Tier1Basic,
903+
description: "Kernel sends iopub_welcome on XPUB subscription (JEP 65)",
904+
message_type: "iopub_welcome",
905+
run: test_iopub_welcome,
906+
},
883907
ConformanceTest {
884908
name: "kernel_info_reply_valid",
885909
category: TestCategory::Tier1Basic,

0 commit comments

Comments
 (0)