дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
fix(ci): wait for the MCP listener before restarting on its port
Цей коміт міститься в:
1 джерело
cd8f29ea63
коміт
d857968a65
1 file changed
+19
-9
@@ -881,14 +881,9 @@ async fn the_bridge_picks_the_server_again_when_the_servers_change() {
|
||||
async fn the_bridge_picks_the_server_again_after_a_restart_on_the_same_port() {
|
||||
let (_tmp, base, discovery) = layout(&["proj-a", "proj-b", "proj-c"]);
|
||||
let (proj_a, proj_b, proj_c) = (base.join("proj-a"), base.join("proj-b"), base.join("proj-c"));
|
||||
let port = std::net::TcpListener::bind(("127.0.0.1", 0)).unwrap().local_addr().unwrap().port();
|
||||
let fixed = ServerOptions { port: Some(port), ..Default::default() };
|
||||
let runtime = tokio::runtime::Handle::current();
|
||||
let start_b = |registry: WithBackground| {
|
||||
McpServer::start_with(Arc::new(registry), Some(discovery.clone()), &runtime, fixed.clone()).unwrap()
|
||||
};
|
||||
// Neither serves `proj-b` at `initialize`, which settles on A, the server started last.
|
||||
let server_b = start_b(WithBackground { open: proj_c.clone(), background: Vec::new(), remote: None });
|
||||
let server_b = start_in(&discovery, WithBackground { open: proj_c.clone(), background: Vec::new(), remote: None });
|
||||
let port = server_b.port();
|
||||
let server_a = start_in(&discovery, Registry { project: proj_a.clone() });
|
||||
let mut client = Client::start(&discovery, &proj_b.join("src"));
|
||||
client.ask("initialize", json!({ "protocolVersion": "2025-06-18" })).await;
|
||||
@@ -896,8 +891,23 @@ async fn the_bridge_picks_the_server_again_after_a_restart_on_the_same_port() {
|
||||
assert_eq!(list["result"]["tools"][0]["name"], "everything", "{list}");
|
||||
|
||||
server_b.stop();
|
||||
let server_b = start_b(WithBackground::serving(&proj_c, &proj_b));
|
||||
assert_eq!(server_b.port(), port);
|
||||
// stop signals the accept task; the listener is closed asynchronously. Wait for
|
||||
// the old port to be released, as the IDE does before restarting its server.
|
||||
tokio::time::timeout(std::time::Duration::from_secs(5), async {
|
||||
while std::net::TcpListener::bind(("127.0.0.1", port)).is_err() {
|
||||
tokio::time::sleep(std::time::Duration::from_millis(20)).await;
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("the stopped server should release its port");
|
||||
let server_b = McpServer::start_with(
|
||||
Arc::new(WithBackground::serving(&proj_c, &proj_b)),
|
||||
Some(discovery.clone()),
|
||||
&tokio::runtime::Handle::current(),
|
||||
ServerOptions { port: Some(port), ..Default::default() },
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(server_b.port(), port, "{:?}", server_b.port_unavailable());
|
||||
let list = client.ask("tools/list", json!({})).await;
|
||||
assert_eq!(list["result"]["tools"][0]["description"], format!("Names {}", proj_b.display()), "{list}");
|
||||
client.close().await;
|
||||
|
||||
Reference in new issue
Заблокувати користувача