From f1287f48766fb04640cf6630590fc74b892944e9 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 16 Feb 2026 14:49:57 -0800 Subject: [PATCH 01/22] [bfops/smoketest-upgrade]: add test --- crates/core/src/config.rs | 73 ++- .../smoketests/tests/upgrade_chat_to_2_0.rs | 595 ++++++++++++++++++ 2 files changed, 645 insertions(+), 23 deletions(-) create mode 100644 crates/smoketests/tests/upgrade_chat_to_2_0.rs diff --git a/crates/core/src/config.rs b/crates/core/src/config.rs index d1ecc2a16ce..0be76a67588 100644 --- a/crates/core/src/config.rs +++ b/crates/core/src/config.rs @@ -54,39 +54,56 @@ impl MetadataFile { path.write(self.to_string()) } - /// Check if this meta file is compatible with the default meta - /// file of a just-started database, and if so return the metadata - /// to write back to the file. - /// - /// `self` is the metadata file read from a database, and current is - /// the default metadata file that the active database version would - /// right to a new database. - pub fn check_compatibility_and_update(mut self, current: Self) -> anyhow::Result { + fn check_compatibility(previous: &Self, current: &Self) -> anyhow::Result<()> { anyhow::ensure!( - self.edition == current.edition, + previous.edition == current.edition, "metadata.toml indicates that this database is from a different \ - edition of SpacetimeDB (running {:?}, but this database is {:?})", + edition of SpacetimeDB (running {:?}, but this database is {:?})", current.edition, - self.edition, + previous.edition, ); + + // Special-case: SpacetimeDB 2.x can run 1.x databases. + if previous.version.major == 1 && current.version.major == 2 { + return Ok(()); + } + let cmp = semver::Comparator { op: semver::Op::Caret, - major: self.version.major, - minor: Some(self.version.minor), + major: previous.version.major, + minor: Some(previous.version.minor), patch: None, - pre: self.version.pre.clone(), + pre: previous.version.pre.clone(), }; - anyhow::ensure!( - cmp.matches(¤t.version), - "metadata.toml indicates that this database is from a newer, \ - incompatible version of SpacetimeDB (running {:?}, but this \ - database is from {:?})", + + if cmp.matches(¤t.version) { + return Ok(()); + } + + let relation = if previous.version > current.version { + "a newer, incompatible" + } else if previous.version < current.version { + "an older, incompatible" + } else { + "an incompatible" + }; + anyhow::bail!( + "metadata.toml indicates that you are running {relation} database. Your running version is {:?}, but the database on disk is from {:?}.", current.version, - self.version, + previous.version, ); - // bump the version in the file only if it's being run in a newer - // database -- this won't do anything until we release v1.1.0, since we - // set current.version.patch to 0 in Self::new() due to a bug in v1.0.0 + } + + /// Check if this meta file is compatible with the default meta + /// file of a just-started database, and if so return the metadata + /// to write back to the file. + /// + /// `self` is the metadata file read from a database, and current is + /// the default metadata file that the active database version would + /// right to a new database. + pub fn check_compatibility_and_update(mut self, current: Self) -> anyhow::Result { + Self::check_compatibility(&self, ¤t)?; + // bump the version in the file only if it's being run in a newer database. self.version = std::cmp::max(self.version, current.version); Ok(self) } @@ -184,5 +201,15 @@ mod tests { mkmeta(2, 0, 0) .check_compatibility_and_update(mkmeta(1, 3, 5)) .unwrap_err(); + assert_eq!( + mkmeta(1, 12, 0) + .check_compatibility_and_update(mkmeta(2, 0, 0)) + .unwrap() + .version, + mkver(2, 0, 0) + ); + mkmeta(2, 0, 0) + .check_compatibility_and_update(mkmeta(3, 0, 0)) + .unwrap_err(); } } diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0.rs b/crates/smoketests/tests/upgrade_chat_to_2_0.rs new file mode 100644 index 00000000000..cabe60da185 --- /dev/null +++ b/crates/smoketests/tests/upgrade_chat_to_2_0.rs @@ -0,0 +1,595 @@ +#![allow(clippy::disallowed_macros)] + +use std::ffi::OsString; +use std::io::{BufRead, BufReader, ErrorKind, Read, Write}; +use std::net::{TcpListener, TcpStream}; +use std::path::{Path, PathBuf}; +use std::process::{Child, Command, Output, Stdio}; +use std::sync::{Arc, Mutex}; +use std::thread; +use std::time::{Duration, Instant}; + +use anyhow::{anyhow, bail, Context, Result}; +use regex::Regex; +use spacetimedb_smoketests::workspace_root; + +// NOTE: This test is intentionally manual/local-only and not meant for CI. +// +// It validates a 1.0 -> 2.0 upgrade scenario using quickstart-chat: +// 1) install a 1.0 CLI via `spacetime version install` +// 2) build 1.0 server/client/module from this pinned git ref +// 3) start 1.0 server and publish module +// 4) restart as 2.0 server on the same data dir +// 5) run both 1.0 and 2.0 quickstart clients, exchange messages, assert both observed +const V1_GIT_REF: &str = "v1.12.0"; +const V1_RELEASE_VERSION: &str = "1.12.0"; + +fn log_step(msg: &str) { + eprintln!("[manual-upgrade] {msg}"); +} + +fn exe_name(base: &str) -> String { + if cfg!(windows) { + format!("{base}.exe") + } else { + base.to_string() + } +} + +fn run_cmd(args: &[OsString], cwd: &Path) -> Result { + let rendered = args + .iter() + .map(|s| s.to_string_lossy().to_string()) + .collect::>() + .join(" "); + log_step(&format!("run: (cd {}) {rendered}", cwd.display())); + let mut cmd = Command::new(&args[0]); + cmd.args(&args[1..]).current_dir(cwd); + cmd.output() + .with_context(|| format!("failed to execute {:?}", args.iter().collect::>())) +} + +fn run_cmd_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { + let rendered = args + .iter() + .map(|s| s.to_string_lossy().to_string()) + .collect::>() + .join(" "); + log_step(&format!("run (stdin): (cd {}) {rendered}", cwd.display())); + + let mut cmd = Command::new(&args[0]); + cmd.args(&args[1..]) + .current_dir(cwd) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + + let mut child = cmd + .spawn() + .with_context(|| format!("failed to execute {:?}", args.iter().collect::>()))?; + { + let stdin = child.stdin.as_mut().context("missing child stdin")?; + stdin.write_all(stdin_input.as_bytes())?; + } + child + .wait_with_output() + .with_context(|| format!("failed waiting for {:?}", args.iter().collect::>())) +} + +fn run_cmd_ok(args: &[OsString], cwd: &Path) -> Result { + let out = run_cmd(args, cwd)?; + if !out.status.success() { + bail!( + "command failed: {:?}\nstdout: {}\nstderr: {}", + args, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + } + let stdout = String::from_utf8_lossy(&out.stdout).to_string(); + let stderr = String::from_utf8_lossy(&out.stderr).to_string(); + if !stdout.trim().is_empty() { + log_step(&format!("stdout:\n{}", stdout.trim())); + } + if !stderr.trim().is_empty() { + log_step(&format!("stderr:\n{}", stderr.trim())); + } + Ok(stdout) +} + +fn run_cmd_ok_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { + let out = run_cmd_with_stdin(args, cwd, stdin_input)?; + if !out.status.success() { + bail!( + "command failed: {:?}\nstdout: {}\nstderr: {}", + args, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + } + let stdout = String::from_utf8_lossy(&out.stdout).to_string(); + let stderr = String::from_utf8_lossy(&out.stderr).to_string(); + if !stdout.trim().is_empty() { + log_step(&format!("stdout:\n{}", stdout.trim())); + } + if !stderr.trim().is_empty() { + log_step(&format!("stderr:\n{}", stderr.trim())); + } + Ok(stdout) +} + +fn pick_unused_port() -> Result { + let listener = TcpListener::bind("127.0.0.1:0")?; + Ok(listener.local_addr()?.port()) +} + +fn ping_http(server_url: &str) -> Result { + let addr = server_url + .strip_prefix("http://") + .ok_or_else(|| anyhow!("expected http:// URL, got {server_url}"))?; + let mut stream = TcpStream::connect(addr)?; + stream.set_read_timeout(Some(Duration::from_secs(2)))?; + let req = format!("GET /v1/ping HTTP/1.1\r\nHost: {addr}\r\nConnection: close\r\n\r\n"); + stream.write_all(req.as_bytes())?; + let mut body = String::new(); + stream.read_to_string(&mut body)?; + Ok(body.starts_with("HTTP/1.1 200") || body.starts_with("HTTP/1.0 200")) +} + +fn wait_for_ping(server_url: &str, timeout: Duration) -> Result<()> { + log_step(&format!("waiting for server ping at {server_url}")); + let deadline = Instant::now() + timeout; + while Instant::now() < deadline { + if ping_http(server_url).unwrap_or(false) { + log_step(&format!("server is ready at {server_url}")); + return Ok(()); + } + thread::sleep(Duration::from_millis(100)); + } + bail!("timed out waiting for {server_url}/v1/ping") +} + +fn spawn_server(cli_path: &Path, data_dir: &Path, port: u16) -> Result<(Child, Arc>)> { + let listen = format!("127.0.0.1:{port}"); + log_step(&format!( + "starting server via {} on {} using data dir {}", + cli_path.display(), + listen, + data_dir.display() + )); + let mut child = Command::new(cli_path) + .args([ + "start", + "--jwt-key-dir", + &data_dir.display().to_string(), + "--data-dir", + &data_dir.display().to_string(), + "--listen-addr", + &listen, + ]) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .with_context(|| format!("failed to start server via {}", cli_path.display()))?; + log_step(&format!("started server pid={}", child.id())); + let logs = Arc::new(Mutex::new(String::new())); + if let Some(stdout) = child.stdout.take() { + let logs_out = logs.clone(); + thread::spawn(move || { + let mut reader = BufReader::new(stdout); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + let mut s = logs_out.lock().unwrap(); + s.push_str("[stdout] "); + s.push_str(&line); + } + }); + } + if let Some(stderr) = child.stderr.take() { + let logs_err = logs.clone(); + thread::spawn(move || { + let mut reader = BufReader::new(stderr); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + let mut s = logs_err.lock().unwrap(); + s.push_str("[stderr] "); + s.push_str(&line); + } + }); + } + Ok((child, logs)) +} + +fn kill_child(child: &mut Child) { + log_step(&format!("stopping pid={}", child.id())); + #[cfg(not(windows))] + { + let _ = child.kill(); + } + #[cfg(windows)] + { + let _ = Command::new("taskkill") + .args(["/F", "/T", "/PID", &child.id().to_string()]) + .status(); + } + let _ = child.wait(); + log_step("process stopped"); +} + +fn dump_server_logs(label: &str, logs: &Arc>) { + let s = logs.lock().unwrap().clone(); + if s.trim().is_empty() { + log_step(&format!("{label} logs are empty")); + return; + } + eprintln!("[manual-upgrade] {label} logs:\n{s}"); +} + +fn extract_identity(publish_stdout: &str) -> Result { + let re = Regex::new(r"identity: ([0-9a-fA-F]+)")?; + let caps = re + .captures(publish_stdout) + .ok_or_else(|| anyhow!("failed to parse identity from publish output:\n{publish_stdout}"))?; + Ok(caps.get(1).unwrap().as_str().to_string()) +} + +fn spawn_chat_client(label: &str, bin: &Path, server_url: &str, db_name: &str) -> Result<(Child, Arc>)> { + log_step(&format!( + "starting {label} client {} (server={}, db={})", + bin.display(), + server_url, + db_name + )); + let mut child = Command::new(bin) + .env("SPACETIMEDB_HOST", server_url) + .env("SPACETIMEDB_SERVER", server_url) + .env("SPACETIMEDB_DB_NAME", db_name) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .with_context(|| format!("failed to spawn chat client {}", bin.display()))?; + log_step(&format!("started client pid={}", child.id())); + + let logs = Arc::new(Mutex::new(String::new())); + + if let Some(stdout) = child.stdout.take() { + let logs_out = logs.clone(); + let label = label.to_string(); + thread::spawn(move || { + let mut reader = BufReader::new(stdout); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + eprintln!("[{label} recv] {}", line.trim_end()); + let mut s = logs_out.lock().unwrap(); + s.push_str(&line); + } + }); + } + if let Some(stderr) = child.stderr.take() { + let logs_err = logs.clone(); + let label = label.to_string(); + thread::spawn(move || { + let mut reader = BufReader::new(stderr); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + eprintln!("[{label} stderr] {}", line.trim_end()); + let mut s = logs_err.lock().unwrap(); + s.push_str(&line); + } + }); + } + + Ok((child, logs)) +} + +fn write_line(child: &mut Child, line: &str) -> Result<()> { + log_step(&format!("sending to pid {}: {}", child.id(), line)); + let stdin = child.stdin.as_mut().context("child stdin missing")?; + if let Err(e) = stdin.write_all(line.as_bytes()) { + if e.kind() == ErrorKind::BrokenPipe { + log_step(&format!( + "stdin broken pipe for pid {} while sending {:?}; continuing", + child.id(), + line + )); + return Ok(()); + } + return Err(e).context("failed writing line to client stdin"); + } + if let Err(e) = stdin.write_all(b"\n") { + if e.kind() == ErrorKind::BrokenPipe { + log_step(&format!( + "stdin broken pipe for pid {} while sending newline; continuing", + child.id() + )); + return Ok(()); + } + return Err(e).context("failed writing newline to client stdin"); + } + if let Err(e) = stdin.flush() { + if e.kind() == ErrorKind::BrokenPipe { + log_step(&format!( + "stdin broken pipe for pid {} on flush; continuing", + child.id() + )); + return Ok(()); + } + return Err(e).context("failed flushing client stdin"); + } + Ok(()) +} + +#[test] +#[ignore = "manual local-only: long-running, networked, and builds historical artifacts"] +fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { + log_step("starting manual upgrade mixed-clients quickstart test"); + log_step(&format!( + "pinned old source ref={}, old release version={}", + V1_GIT_REF, V1_RELEASE_VERSION + )); + let repo = workspace_root(); + let temp = tempfile::tempdir()?; + let temp_path = temp.path(); + let old_worktree = temp_path.join("old"); + let data_dir = temp_path.join("db-data"); + std::fs::create_dir_all(&data_dir)?; + log_step(&format!("workspace={}", repo.display())); + log_step(&format!("temp root={}", temp_path.display())); + log_step(&format!("data dir={}", data_dir.display())); + + // Prepare current binaries (including update helper needed by `version install` from target dir). + log_step("building current spacetimedb-cli and spacetimedb-update"); + run_cmd_ok( + &[ + OsString::from("cargo"), + OsString::from("build"), + OsString::from("-p"), + OsString::from("spacetimedb-cli"), + OsString::from("-p"), + OsString::from("spacetimedb-standalone"), + OsString::from("-p"), + OsString::from("spacetimedb-update"), + ], + &repo, + )?; + + let current_cli = repo.join("target").join("debug").join(exe_name("spacetimedb-cli")); + anyhow::ensure!( + current_cli.exists(), + "current CLI binary missing at {}", + current_cli.display() + ); + + // Install a pinned 1.0 release via the system `spacetime` command. + log_step(&format!( + "installing and selecting release {} via system spacetime", + V1_RELEASE_VERSION + )); + run_cmd_ok( + &[ + OsString::from("spacetime"), + OsString::from("version"), + OsString::from("install"), + OsString::from(V1_RELEASE_VERSION), + OsString::from("--use"), + OsString::from("--yes"), + ], + &repo, + )?; + let installed_v1_cli = PathBuf::from("spacetime"); + log_step("using system 'spacetime' command as v1 CLI"); + + // Build 1.0 sources from pinned ref. + log_step(&format!("creating worktree at ref {}", V1_GIT_REF)); + run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("worktree"), + OsString::from("add"), + old_worktree.clone().into_os_string(), + OsString::from(V1_GIT_REF), + ], + &repo, + )?; + + let cleanup_worktree = || { + let _ = Command::new("git") + .args(["worktree", "remove", "--force"]) + .arg(&old_worktree) + .current_dir(&repo) + .status(); + }; + + let old_result: Result<()> = (|| { + log_step("running v1 codegen for chat-console-rs (cli generate)"); + run_cmd_ok( + &[ + installed_v1_cli.clone().into_os_string(), + OsString::from("generate"), + OsString::from("--project-path"), + OsString::from("spacetimedb/"), + OsString::from("--out-dir"), + OsString::from("src/module_bindings/"), + OsString::from("--lang"), + OsString::from("rust"), + ], + &old_worktree.join("templates/chat-console-rs"), + )?; + + log_step("building old quickstart chat client"); + run_cmd_ok( + &[OsString::from("cargo"), OsString::from("build")], + &old_worktree.join("templates/chat-console-rs"), + )?; + + run_cmd_ok( + &[ + current_cli.clone().into_os_string(), + OsString::from("generate"), + OsString::from("--module-path"), + OsString::from("spacetimedb/"), + OsString::from("--out-dir"), + OsString::from("src/module_bindings/"), + OsString::from("--lang"), + OsString::from("rust"), + ], + &repo.join("templates/chat-console-rs"), + )?; + + log_step("building current quickstart chat client"); + run_cmd_ok( + &[OsString::from("cargo"), OsString::from("build")], + &repo.join("templates/chat-console-rs"), + )?; + + let old_client = old_worktree + .join("templates/chat-console-rs") + .join("target") + .join("debug") + .join(exe_name("rust-quickstart-chat")); + anyhow::ensure!( + old_client.exists(), + "old chat client not found at {}", + old_client.display() + ); + let new_client = repo + .join("templates/chat-console-rs") + .join("target") + .join("debug") + .join(exe_name("rust-quickstart-chat")); + anyhow::ensure!( + new_client.exists(), + "new chat client not found at {}", + new_client.display() + ); + + log_step(&format!("v1 CLI path={}", installed_v1_cli.display())); + log_step(&format!("old client path={}", old_client.display())); + log_step(&format!("new client path={}", new_client.display())); + + // Start 1.0 server and publish 1.0 quickstart module. + let old_port = pick_unused_port()?; + let old_url = format!("http://127.0.0.1:{old_port}"); + log_step("starting old server for initial publish"); + let (mut old_server, old_server_logs) = spawn_server(&installed_v1_cli, &data_dir, old_port)?; + if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { + dump_server_logs("old server", &old_server_logs); + kill_child(&mut old_server); + return Err(e); + } + + let db_name = format!("manual-upgrade-chat-{}", spacetimedb_smoketests::random_string()); + log_step(&format!("publishing old module to db {}", db_name)); + let publish_out = run_cmd_ok( + &[ + installed_v1_cli.clone().into_os_string(), + OsString::from("publish"), + OsString::from("--server"), + OsString::from(&old_url), + OsString::from("--project-path"), + old_worktree + .join("templates/chat-console-rs/spacetimedb") + .into_os_string(), + OsString::from("--yes"), + OsString::from(&db_name), + ], + &old_worktree, + )?; + let _identity = extract_identity(&publish_out)?; + log_step("old module published successfully; stopping old server"); + kill_child(&mut old_server); + + // Start 2.0 server on the same data dir. + let new_port = pick_unused_port()?; + let new_url = format!("http://127.0.0.1:{new_port}"); + log_step("starting new server on same data dir"); + let (mut new_server, new_server_logs) = spawn_server(¤t_cli, &data_dir, new_port)?; + if let Err(e) = wait_for_ping(&new_url, Duration::from_secs(20)) { + dump_server_logs("new server", &new_server_logs); + kill_child(&mut new_server); + return Err(e); + } + log_step("publishing HEAD module to same database name on 2.0 server"); + run_cmd_ok_with_stdin( + &[ + current_cli.clone().into_os_string(), + OsString::from("publish"), + OsString::from("--server"), + OsString::from(&new_url), + OsString::from("--project-path"), + repo.join("templates/chat-console-rs/spacetimedb").into_os_string(), + OsString::from("--yes"), + OsString::from(&db_name), + ], + &repo, + "upgrade\n", + )?; + + // Spawn 1.0 and 2.0 quickstart clients against the upgraded 2.0 server. + log_step("starting old and new clients"); + let (mut c1, logs1) = spawn_chat_client("client-v1", &old_client, &new_url, &db_name)?; + let (mut c2, logs2) = spawn_chat_client("client-v2", &new_client, &new_url, &db_name)?; + + thread::sleep(Duration::from_secs(2)); + write_line(&mut c1, "/name old-v1")?; + write_line(&mut c2, "/name new-v2")?; + write_line(&mut c1, "hello-from-v1")?; + write_line(&mut c2, "hello-from-v2")?; + + // Both clients should observe both messages in their output. + log_step("waiting for both clients to observe both messages"); + let deadline = Instant::now() + Duration::from_secs(20); + let mut ok = false; + while Instant::now() < deadline { + let l1 = logs1.lock().unwrap().clone(); + let l2 = logs2.lock().unwrap().clone(); + let saw_v1 = l1.contains("old-v1: hello-from-v1") && l2.contains("old-v1: hello-from-v1"); + let saw_v2 = l1.contains("new-v2: hello-from-v2") && l2.contains("new-v2: hello-from-v2"); + if saw_v1 && saw_v2 { + log_step("success condition met: both clients saw both messages"); + ok = true; + break; + } + thread::sleep(Duration::from_millis(200)); + } + + log_step("stopping clients and new server"); + kill_child(&mut c1); + kill_child(&mut c2); + kill_child(&mut new_server); + + if !ok { + let l1 = logs1.lock().unwrap().clone(); + let l2 = logs2.lock().unwrap().clone(); + bail!( + "message exchange incomplete.\nclient-v1 logs:\n{}\n\nclient-v2 logs:\n{}", + l1, + l2 + ); + } + + Ok(()) + })(); + + log_step("cleaning up temporary git worktree"); + cleanup_worktree(); + log_step("manual test finished"); + old_result +} From d3786417927a7063dc33ad6af56418807571aba5 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 16 Feb 2026 14:50:17 -0800 Subject: [PATCH 02/22] [bfops/smoketest-upgrade]: WIP --- templates/chat-console-rs/Cargo.lock | 2749 ++++++++++++++++++++++++++ 1 file changed, 2749 insertions(+) create mode 100644 templates/chat-console-rs/Cargo.lock diff --git a/templates/chat-console-rs/Cargo.lock b/templates/chat-console-rs/Cargo.lock new file mode 100644 index 00000000000..c6be590683d --- /dev/null +++ b/templates/chat-console-rs/Cargo.lock @@ -0,0 +1,2749 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75ea" + +[[package]] +name = "anymap" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" + +[[package]] +name = "approx" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" +dependencies = [ + "num-traits", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "blake3" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2468ef7d57b3fb7e16b576e8377cdbde2320c60e1491e961d11da40fc4f02a2d" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", + "cpufeatures", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "brotli" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "bumpalo" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" + +[[package]] +name = "bytemuck" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "bytestring" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "113b4343b5f6617e7ad401ced8de3cc8b012e73a594347c307b90db3e9271289" +dependencies = [ + "bytes", + "serde_core", +] + +[[package]] +name = "castaway" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" +dependencies = [ + "rustversion", +] + +[[package]] +name = "cc" +version = "1.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chrono" +version = "0.4.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fac4744fb15ae8337dc853fee7fb3f4e48c0fbaa23d0afe49c447b4fab126118" +dependencies = [ + "iana-time-zone", + "num-traits", + "serde", + "windows-link", +] + +[[package]] +name = "console" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "windows-sys 0.59.0", +] + +[[package]] +name = "constant_time_eq" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "data-encoding" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea" + +[[package]] +name = "decorum" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "281759d3c8a14f5c3f0c49363be56810fcd7f910422f97f2db850c2920fde5cf" +dependencies = [ + "approx", + "num-traits", +] + +[[package]] +name = "deranged" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc3dc5ad92c2e2d1c193bbbbdf2ea477cb81331de4f3103f267ca18368b988c4" +dependencies = [ + "powerfmt", + "serde_core", +] + +[[package]] +name = "derive_more" +version = "0.99.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + +[[package]] +name = "enum-as-inner" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "enum-map" +version = "2.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6866f3bfdf8207509a033af1a75a7b08abda06bbaaeae6669323fd5a097df2e9" +dependencies = [ + "enum-map-derive", +] + +[[package]] +name = "enum-map-derive" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "ethnum" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca81e6b4777c89fd810c25a4be2b1bd93ea034fbe58e6a75216a34c6b82c539b" +dependencies = [ + "serde", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flate2" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "equivalent", + "rayon", + "serde", + "serde_core", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "home" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "humantime" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424" + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "insta" +version = "1.46.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e82db8c87c7f1ccecb34ce0c24399b8a73081427f3c7c50a5d597925356115e4" +dependencies = [ + "console", + "once_cell", + "regex", + "serde", + "similar", + "tempfile", + "toml_edit", + "toml_writer", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "js-sys" +version = "0.3.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb26cec98cce3a3d96cbb7bced3c4b16e3d13f27ec56dbd62cbc8f39cfb9d653" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lean_string" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "962df00ba70ac8d5ca5c064e17e5c3d090c087fd8d21aa45096c716b169da514" +dependencies = [ + "castaway", + "itoa", + "ryu", +] + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.182" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" + +[[package]] +name = "linux-raw-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "native-tls" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5d26952a508f321b4d3d2e80e78fc2603eaefcdf0c30783867f19586518bdc" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "num-conv" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "openssl" +version = "0.10.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap 2.13.0", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prometheus" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d33c28a30771f7f96db69893f78b857f7450d7e0237e9c8fc6427a81bae7ed1" +dependencies = [ + "cfg-if", + "fnv", + "lazy_static", + "memchr", + "parking_lot", + "protobuf", + "thiserror 1.0.69", +] + +[[package]] +name = "protobuf" +version = "2.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" + +[[package]] +name = "quote" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rayon" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4c" + +[[package]] +name = "rust-quickstart-chat" +version = "0.1.0" +dependencies = [ + "spacetimedb-sdk", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "schannel" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "schemars" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2b42f36aa1cd011945615b92222f6bf73c599a102a300334cd7f8dbeec726cc" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "second-stack" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4904c83c6e51f1b9b08bfa5a86f35a51798e8307186e6f5513852210a219c0bb" + +[[package]] +name = "security-framework" +version = "3.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d17b898a6d6948c3a8ee4372c17cb384f90d2e6e912ef00895b14fd7ab54ec38" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "321c8673b092a9a42605034a9879d73cb79101ed5fd117bc9a597b89b4e9e61a" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_spanned" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_with" +version = "3.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fa237f2807440d238e0364a218270b98f767a00d3dada77b1c53ae88940e2e7" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.13.0", + "schemars 0.9.0", + "schemars 1.2.1", + "serde_core", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a8e3ca0ca629121f70ab50f95249e5a6f925cc0f6ffe8256c45b728875706c" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" + +[[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "spacetimedb-bindings-macro" +version = "2.0.0" +dependencies = [ + "heck 0.4.1", + "humantime", + "proc-macro2", + "quote", + "spacetimedb-primitives", + "syn", +] + +[[package]] +name = "spacetimedb-client-api-messages" +version = "2.0.0" +dependencies = [ + "bytes", + "bytestring", + "chrono", + "derive_more", + "enum-as-inner", + "serde", + "serde_json", + "serde_with", + "smallvec", + "spacetimedb-lib", + "spacetimedb-primitives", + "spacetimedb-sats", + "strum", + "thiserror 1.0.69", +] + +[[package]] +name = "spacetimedb-data-structures" +version = "2.0.0" +dependencies = [ + "ahash", + "crossbeam-queue", + "either", + "hashbrown 0.16.1", + "nohash-hasher", + "smallvec", + "thiserror 1.0.69", +] + +[[package]] +name = "spacetimedb-lib" +version = "2.0.0" +dependencies = [ + "anyhow", + "bitflags", + "blake3", + "chrono", + "derive_more", + "enum-as-inner", + "enum-map", + "hex", + "itertools", + "log", + "serde", + "spacetimedb-bindings-macro", + "spacetimedb-metrics", + "spacetimedb-primitives", + "spacetimedb-sats", + "thiserror 1.0.69", +] + +[[package]] +name = "spacetimedb-memory-usage" +version = "2.0.0" +dependencies = [ + "decorum", + "ethnum", +] + +[[package]] +name = "spacetimedb-metrics" +version = "2.0.0" +dependencies = [ + "arrayvec", + "itertools", + "paste", + "prometheus", +] + +[[package]] +name = "spacetimedb-primitives" +version = "2.0.0" +dependencies = [ + "bitflags", + "either", + "enum-as-inner", + "itertools", + "nohash-hasher", + "spacetimedb-memory-usage", +] + +[[package]] +name = "spacetimedb-query-builder" +version = "2.0.0" +dependencies = [ + "spacetimedb-lib", +] + +[[package]] +name = "spacetimedb-sats" +version = "2.0.0" +dependencies = [ + "anyhow", + "arrayvec", + "bitflags", + "bytemuck", + "bytes", + "bytestring", + "chrono", + "decorum", + "derive_more", + "enum-as-inner", + "ethnum", + "hex", + "itertools", + "lean_string", + "rand", + "second-stack", + "serde", + "sha3", + "smallvec", + "spacetimedb-bindings-macro", + "spacetimedb-memory-usage", + "spacetimedb-metrics", + "spacetimedb-primitives", + "thiserror 1.0.69", + "uuid", +] + +[[package]] +name = "spacetimedb-schema" +version = "2.0.0" +dependencies = [ + "anyhow", + "derive_more", + "enum-as-inner", + "enum-map", + "indexmap 2.13.0", + "insta", + "itertools", + "lazy_static", + "lean_string", + "petgraph", + "serde_json", + "smallvec", + "spacetimedb-data-structures", + "spacetimedb-lib", + "spacetimedb-memory-usage", + "spacetimedb-primitives", + "spacetimedb-sats", + "spacetimedb-sql-parser", + "termcolor", + "thiserror 1.0.69", + "unicode-ident", + "unicode-normalization", +] + +[[package]] +name = "spacetimedb-sdk" +version = "2.0.0" +dependencies = [ + "anymap", + "base64 0.21.7", + "brotli", + "bytes", + "flate2", + "futures", + "futures-channel", + "home", + "http", + "log", + "once_cell", + "prometheus", + "rand", + "spacetimedb-client-api-messages", + "spacetimedb-data-structures", + "spacetimedb-lib", + "spacetimedb-metrics", + "spacetimedb-query-builder", + "spacetimedb-sats", + "spacetimedb-schema", + "thiserror 1.0.69", + "tokio", + "tokio-tungstenite", +] + +[[package]] +name = "spacetimedb-sql-parser" +version = "2.0.0" +dependencies = [ + "derive_more", + "spacetimedb-lib", + "sqlparser", + "thiserror 1.0.69", +] + +[[package]] +name = "sqlparser" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0272b7bb0a225320170c99901b4b5fb3a4384e255a7f2cc228f61e2ba3893e75" +dependencies = [ + "log", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "syn" +version = "2.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df424c70518695237746f84cede799c9c58fcb37450d7b23716568cc8bc69cb" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0136791f7c95b1f6dd99f9cc786b91bb81c3800b639b3478e561ddb7be95e5f1" +dependencies = [ + "fastrand", + "getrandom 0.4.1", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "time-macros" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "489a59b6730eda1b0171fcfda8b121f4bee2b35cba8645ca35c5f7ba3eb736c1" +dependencies = [ + "futures-util", + "log", + "native-tls", + "tokio", + "tokio-native-tls", + "tungstenite", +] + +[[package]] +name = "toml_datetime" +version = "0.7.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.23.10+spec-1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c8b9f757e028cee9fa244aea147aab2a9ec09d5325a9b01e0a49730c2b5269" +dependencies = [ + "indexmap 2.13.0", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.0.9+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "702d4415e08923e7e1ef96cd5727c0dfed80b4d2fa25db9647fe5eb6f7c5a4c4" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.0.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" + +[[package]] +name = "tungstenite" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadc29d668c91fcc564941132e17b28a7ceb2f3ebf0b9dae3e03fd7a6748eb0d" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "native-tls", + "rand", + "sha1", + "thiserror 2.0.18", + "url", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-normalization" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b672338555252d43fd2240c714dc444b8c6fb0a5c5335e65a07bba7742735ddb" +dependencies = [ + "getrandom 0.4.1", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap 2.13.0", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap 2.13.0", + "semver", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "winnow" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck 0.5.0", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck 0.5.0", + "indexmap 2.13.0", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap 2.13.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.13.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4a" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" From a94ed46021d3da8d35a1e0f5d8bc5acfc43a1e3e Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 16 Feb 2026 14:51:01 -0800 Subject: [PATCH 03/22] [bfops/fix-version-check]: Do thing --- crates/core/src/config.rs | 73 +++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/crates/core/src/config.rs b/crates/core/src/config.rs index d1ecc2a16ce..0be76a67588 100644 --- a/crates/core/src/config.rs +++ b/crates/core/src/config.rs @@ -54,39 +54,56 @@ impl MetadataFile { path.write(self.to_string()) } - /// Check if this meta file is compatible with the default meta - /// file of a just-started database, and if so return the metadata - /// to write back to the file. - /// - /// `self` is the metadata file read from a database, and current is - /// the default metadata file that the active database version would - /// right to a new database. - pub fn check_compatibility_and_update(mut self, current: Self) -> anyhow::Result { + fn check_compatibility(previous: &Self, current: &Self) -> anyhow::Result<()> { anyhow::ensure!( - self.edition == current.edition, + previous.edition == current.edition, "metadata.toml indicates that this database is from a different \ - edition of SpacetimeDB (running {:?}, but this database is {:?})", + edition of SpacetimeDB (running {:?}, but this database is {:?})", current.edition, - self.edition, + previous.edition, ); + + // Special-case: SpacetimeDB 2.x can run 1.x databases. + if previous.version.major == 1 && current.version.major == 2 { + return Ok(()); + } + let cmp = semver::Comparator { op: semver::Op::Caret, - major: self.version.major, - minor: Some(self.version.minor), + major: previous.version.major, + minor: Some(previous.version.minor), patch: None, - pre: self.version.pre.clone(), + pre: previous.version.pre.clone(), }; - anyhow::ensure!( - cmp.matches(¤t.version), - "metadata.toml indicates that this database is from a newer, \ - incompatible version of SpacetimeDB (running {:?}, but this \ - database is from {:?})", + + if cmp.matches(¤t.version) { + return Ok(()); + } + + let relation = if previous.version > current.version { + "a newer, incompatible" + } else if previous.version < current.version { + "an older, incompatible" + } else { + "an incompatible" + }; + anyhow::bail!( + "metadata.toml indicates that you are running {relation} database. Your running version is {:?}, but the database on disk is from {:?}.", current.version, - self.version, + previous.version, ); - // bump the version in the file only if it's being run in a newer - // database -- this won't do anything until we release v1.1.0, since we - // set current.version.patch to 0 in Self::new() due to a bug in v1.0.0 + } + + /// Check if this meta file is compatible with the default meta + /// file of a just-started database, and if so return the metadata + /// to write back to the file. + /// + /// `self` is the metadata file read from a database, and current is + /// the default metadata file that the active database version would + /// right to a new database. + pub fn check_compatibility_and_update(mut self, current: Self) -> anyhow::Result { + Self::check_compatibility(&self, ¤t)?; + // bump the version in the file only if it's being run in a newer database. self.version = std::cmp::max(self.version, current.version); Ok(self) } @@ -184,5 +201,15 @@ mod tests { mkmeta(2, 0, 0) .check_compatibility_and_update(mkmeta(1, 3, 5)) .unwrap_err(); + assert_eq!( + mkmeta(1, 12, 0) + .check_compatibility_and_update(mkmeta(2, 0, 0)) + .unwrap() + .version, + mkver(2, 0, 0) + ); + mkmeta(2, 0, 0) + .check_compatibility_and_update(mkmeta(3, 0, 0)) + .unwrap_err(); } } From 1b650fc7baf3344d8e43a54477f17fd1bdc3ae31 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Mon, 16 Feb 2026 15:27:13 -0800 Subject: [PATCH 04/22] [bfops/smoketest-upgrade]: WIP --- crates/smoketests/tests/upgrade_chat_to_2_0.rs | 2 +- templates/chat-console-rs/src/module_bindings/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0.rs b/crates/smoketests/tests/upgrade_chat_to_2_0.rs index cabe60da185..a9052514fa2 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0.rs @@ -533,7 +533,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { OsString::from("publish"), OsString::from("--server"), OsString::from(&new_url), - OsString::from("--project-path"), + OsString::from("--module-path"), repo.join("templates/chat-console-rs/spacetimedb").into_os_string(), OsString::from("--yes"), OsString::from(&db_name), diff --git a/templates/chat-console-rs/src/module_bindings/mod.rs b/templates/chat-console-rs/src/module_bindings/mod.rs index 5503526e0a5..effda19d611 100644 --- a/templates/chat-console-rs/src/module_bindings/mod.rs +++ b/templates/chat-console-rs/src/module_bindings/mod.rs @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 2.0.0 (commit 9e0e81a6aaec6bf3619cfb9f7916743d86ab7ffc). +// This was generated using spacetimedb cli version 2.0.0 (commit 08ff1e1c119b17c9c747f2dd486b4d4a9ea9f6b8). #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; From f60948379a7e97de241099135831e8a7a286b8a0 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Tue, 17 Feb 2026 10:32:09 -0800 Subject: [PATCH 05/22] [bfops/smoketest-upgrade]: update test with debug logs --- .../smoketests/tests/upgrade_chat_to_2_0.rs | 37 +++++++++++-------- sdks/rust/src/credentials.rs | 1 + templates/chat-console-rs/src/main.rs | 8 +++- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0.rs b/crates/smoketests/tests/upgrade_chat_to_2_0.rs index a9052514fa2..fa148c1bb66 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0.rs @@ -526,28 +526,32 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { kill_child(&mut new_server); return Err(e); } - log_step("publishing HEAD module to same database name on 2.0 server"); - run_cmd_ok_with_stdin( - &[ - current_cli.clone().into_os_string(), - OsString::from("publish"), - OsString::from("--server"), - OsString::from(&new_url), - OsString::from("--module-path"), - repo.join("templates/chat-console-rs/spacetimedb").into_os_string(), - OsString::from("--yes"), - OsString::from(&db_name), - ], - &repo, - "upgrade\n", - )?; + + let publish_new = false; + if publish_new { + log_step("publishing HEAD module to same database name on 2.0 server"); + run_cmd_ok_with_stdin( + &[ + current_cli.clone().into_os_string(), + OsString::from("publish"), + OsString::from("--server"), + OsString::from(&new_url), + OsString::from("--module-path"), + repo.join("templates/chat-console-rs/spacetimedb").into_os_string(), + OsString::from("--yes"), + OsString::from(&db_name), + ], + &repo, + "upgrade\n", + )?; + } // Spawn 1.0 and 2.0 quickstart clients against the upgraded 2.0 server. log_step("starting old and new clients"); let (mut c1, logs1) = spawn_chat_client("client-v1", &old_client, &new_url, &db_name)?; let (mut c2, logs2) = spawn_chat_client("client-v2", &new_client, &new_url, &db_name)?; - thread::sleep(Duration::from_secs(2)); + thread::sleep(Duration::from_secs(5)); write_line(&mut c1, "/name old-v1")?; write_line(&mut c2, "/name new-v2")?; write_line(&mut c1, "hello-from-v1")?; @@ -578,6 +582,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { if !ok { let l1 = logs1.lock().unwrap().clone(); let l2 = logs2.lock().unwrap().clone(); + dump_server_logs("new server", &new_server_logs); bail!( "message exchange incomplete.\nclient-v1 logs:\n{}\n\nclient-v2 logs:\n{}", l1, diff --git a/sdks/rust/src/credentials.rs b/sdks/rust/src/credentials.rs index bdef761048c..7dc47f0d3ff 100644 --- a/sdks/rust/src/credentials.rs +++ b/sdks/rust/src/credentials.rs @@ -137,6 +137,7 @@ impl File { /// ``` pub fn load(self) -> Result, CredentialFileError> { let path = self.path()?; + println!("Loading credentials from {path:?}"); let bytes = match std::fs::read(&path) { Ok(bytes) => bytes, diff --git a/templates/chat-console-rs/src/main.rs b/templates/chat-console-rs/src/main.rs index bace4c0036f..6d4a7a8a82b 100644 --- a/templates/chat-console-rs/src/main.rs +++ b/templates/chat-console-rs/src/main.rs @@ -34,7 +34,11 @@ fn connect_to_db() -> DbConnection { // The module name we chose when we published our module. let db_name: String = env::var("SPACETIMEDB_DB_NAME").unwrap_or("quickstart-chat".to_string()); + println!("Conneting to {host}/{db_name}"); + let creds_store = creds_store(); + let token = creds_store.load().expect("Error loading credentials"); + println!("Loaded token: {token:?}"); DbConnection::builder() // Register our `on_connect` callback, which will save our auth token. .on_connect(on_connected) @@ -45,7 +49,7 @@ fn connect_to_db() -> DbConnection { // If the user has previously connected, we'll have saved a token in the `on_connect` callback. // In that case, we'll load it and pass it to `with_token`, // so we can re-authenticate as the same `Identity`. - .with_token(creds_store().load().expect("Error loading credentials")) + .with_token(token) // Set the database name we chose when we called `spacetime publish`. .with_database_name(db_name) // Set the URI of the SpacetimeDB host that's running our database. @@ -58,7 +62,7 @@ fn connect_to_db() -> DbConnection { // ### Save credentials fn creds_store() -> credentials::File { - credentials::File::new("quickstart-chat") + credentials::File::new("quickstart-chat-new") } /// Our `on_connect` callback: save our credentials to a file. From 2772036d511ab8ead00c132e484a057b1bdb6bd4 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Tue, 17 Feb 2026 16:25:53 -0800 Subject: [PATCH 06/22] [bfops/smoketest-upgrade]: WIP kill_after_publish_test --- crates/smoketests/tests/kill_after_publish.rs | 313 ++++++++++++++++++ 1 file changed, 313 insertions(+) create mode 100644 crates/smoketests/tests/kill_after_publish.rs diff --git a/crates/smoketests/tests/kill_after_publish.rs b/crates/smoketests/tests/kill_after_publish.rs new file mode 100644 index 00000000000..c3586f5c174 --- /dev/null +++ b/crates/smoketests/tests/kill_after_publish.rs @@ -0,0 +1,313 @@ +#![allow(clippy::disallowed_macros)] + +use std::ffi::OsString; +use std::io::{BufRead, BufReader, Read, Write}; +use std::net::{TcpListener, TcpStream}; +use std::path::Path; +use std::process::{Child, Command, Output, Stdio}; +use std::sync::{Arc, Mutex}; +use std::thread; +use std::time::{Duration, Instant}; + +use anyhow::{anyhow, bail, Context, Result}; +use spacetimedb_smoketests::workspace_root; + +// NOTE: This test is intentionally manual/local-only and not meant for CI. +// +// It validates a kill/restart scenario at a pinned historical version: +// 1) build CLI/server from this pinned git ref in a temporary worktree +// 2) start server and publish module +// 3) restart server immediately on the same data dir and same version +// 4) verify `spacetime logs` succeeds +const V1_GIT_REF: &str = "v1.12.0"; + +fn log_step(msg: &str) { + eprintln!("[manual-upgrade] {msg}"); +} + +fn exe_name(base: &str) -> String { + if cfg!(windows) { + format!("{base}.exe") + } else { + base.to_string() + } +} + +fn run_cmd(args: &[OsString], cwd: &Path) -> Result { + let rendered = args + .iter() + .map(|s| s.to_string_lossy().to_string()) + .collect::>() + .join(" "); + log_step(&format!("run: (cd {}) {rendered}", cwd.display())); + let mut cmd = Command::new(&args[0]); + cmd.args(&args[1..]).current_dir(cwd); + cmd.output() + .with_context(|| format!("failed to execute {:?}", args.iter().collect::>())) +} + +fn run_cmd_ok(args: &[OsString], cwd: &Path) -> Result { + let out = run_cmd(args, cwd)?; + if !out.status.success() { + bail!( + "command failed: {:?}\nstdout: {}\nstderr: {}", + args, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + } + let stdout = String::from_utf8_lossy(&out.stdout).to_string(); + let stderr = String::from_utf8_lossy(&out.stderr).to_string(); + if !stdout.trim().is_empty() { + log_step(&format!("stdout:\n{}", stdout.trim())); + } + if !stderr.trim().is_empty() { + log_step(&format!("stderr:\n{}", stderr.trim())); + } + Ok(stdout) +} + +fn pick_unused_port() -> Result { + let listener = TcpListener::bind("127.0.0.1:0")?; + Ok(listener.local_addr()?.port()) +} + +fn ping_http(server_url: &str) -> Result { + let addr = server_url + .strip_prefix("http://") + .ok_or_else(|| anyhow!("expected http:// URL, got {server_url}"))?; + let mut stream = TcpStream::connect(addr)?; + stream.set_read_timeout(Some(Duration::from_secs(2)))?; + let req = format!("GET /v1/ping HTTP/1.1\r\nHost: {addr}\r\nConnection: close\r\n\r\n"); + stream.write_all(req.as_bytes())?; + let mut body = String::new(); + stream.read_to_string(&mut body)?; + Ok(body.starts_with("HTTP/1.1 200") || body.starts_with("HTTP/1.0 200")) +} + +fn wait_for_ping(server_url: &str, timeout: Duration) -> Result<()> { + log_step(&format!("waiting for server ping at {server_url}")); + let deadline = Instant::now() + timeout; + while Instant::now() < deadline { + if ping_http(server_url).unwrap_or(false) { + log_step(&format!("server is ready at {server_url}")); + return Ok(()); + } + thread::sleep(Duration::from_millis(100)); + } + bail!("timed out waiting for {server_url}/v1/ping") +} + +fn spawn_server(cli_path: &Path, data_dir: &Path, port: u16) -> Result<(Child, Arc>)> { + let listen = format!("127.0.0.1:{port}"); + log_step(&format!( + "starting server via {} on {} using data dir {}", + cli_path.display(), + listen, + data_dir.display() + )); + let mut child = Command::new(cli_path) + .args([ + "start", + "--jwt-key-dir", + &data_dir.display().to_string(), + "--data-dir", + &data_dir.display().to_string(), + "--listen-addr", + &listen, + ]) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .with_context(|| format!("failed to start server via {}", cli_path.display()))?; + log_step(&format!("started server pid={}", child.id())); + let logs = Arc::new(Mutex::new(String::new())); + if let Some(stdout) = child.stdout.take() { + let logs_out = logs.clone(); + thread::spawn(move || { + let mut reader = BufReader::new(stdout); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + let mut s = logs_out.lock().unwrap(); + s.push_str("[stdout] "); + s.push_str(&line); + } + }); + } + if let Some(stderr) = child.stderr.take() { + let logs_err = logs.clone(); + thread::spawn(move || { + let mut reader = BufReader::new(stderr); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + let mut s = logs_err.lock().unwrap(); + s.push_str("[stderr] "); + s.push_str(&line); + } + }); + } + Ok((child, logs)) +} + +fn kill_child(child: &mut Child) { + log_step(&format!("stopping pid={}", child.id())); + #[cfg(not(windows))] + { + let _ = child.kill(); + } + #[cfg(windows)] + { + let _ = Command::new("taskkill") + .args(["/F", "/T", "/PID", &child.id().to_string()]) + .status(); + } + let _ = child.wait(); + log_step("process stopped"); +} + +fn dump_server_logs(label: &str, logs: &Arc>) { + let s = logs.lock().unwrap().clone(); + if s.trim().is_empty() { + log_step(&format!("{label} logs are empty")); + return; + } + eprintln!("[manual-upgrade] {label} logs:\n{s}"); +} + +#[test] +#[ignore = "manual local-only: long-running, networked, and builds historical artifacts"] +fn kill_after_publish_logs_after_restart() -> Result<()> { + log_step("starting manual kill-after-publish test"); + log_step(&format!("pinned source ref={}", V1_GIT_REF)); + let repo = workspace_root(); + let temp = tempfile::tempdir()?; + let temp_path = temp.path(); + let old_worktree = temp_path.join("old"); + let data_dir = temp_path.join("db-data"); + std::fs::create_dir_all(&data_dir)?; + log_step(&format!("workspace={}", repo.display())); + log_step(&format!("temp root={}", temp_path.display())); + log_step(&format!("data dir={}", data_dir.display())); + + // Build pinned sources from a temporary worktree. + log_step(&format!("creating worktree at ref {}", V1_GIT_REF)); + run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("worktree"), + OsString::from("add"), + old_worktree.clone().into_os_string(), + OsString::from(V1_GIT_REF), + ], + &repo, + )?; + + let cleanup_worktree = || { + let _ = Command::new("git") + .args(["worktree", "remove", "--force"]) + .arg(&old_worktree) + .current_dir(&repo) + .status(); + }; + + let old_result: Result<()> = (|| { + log_step("building pinned spacetimedb-cli and spacetimedb-standalone"); + run_cmd_ok( + &[ + OsString::from("cargo"), + OsString::from("build"), + OsString::from("-p"), + OsString::from("spacetimedb-cli"), + OsString::from("-p"), + OsString::from("spacetimedb-standalone"), + ], + &old_worktree, + )?; + + let old_cli = old_worktree + .join("target") + .join("debug") + .join(exe_name("spacetimedb-cli")); + anyhow::ensure!( + old_cli.exists(), + "pinned CLI binary not found at {}", + old_cli.display() + ); + + log_step(&format!("pinned CLI path={}", old_cli.display())); + + // Start pinned server and publish pinned quickstart module. + let old_port = pick_unused_port()?; + let old_url = format!("http://127.0.0.1:{old_port}"); + log_step("starting pinned server for initial publish"); + let (mut old_server, old_server_logs) = spawn_server(&old_cli, &data_dir, old_port)?; + if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { + dump_server_logs("pinned server", &old_server_logs); + kill_child(&mut old_server); + return Err(e); + } + + let db_name = format!("kill-after-publish-{}", spacetimedb_smoketests::random_string()); + log_step(&format!("publishing pinned module to db {}", db_name)); + run_cmd_ok( + &[ + old_cli.clone().into_os_string(), + OsString::from("publish"), + OsString::from("--server"), + OsString::from(&old_url), + OsString::from("--project-path"), + old_worktree + .join("templates/chat-console-rs/spacetimedb") + .into_os_string(), + OsString::from("--yes"), + OsString::from(&db_name), + ], + &old_worktree, + )?; + log_step("module published successfully; stopping server"); + kill_child(&mut old_server); + + // Restart pinned server on the same data dir and verify logs command succeeds. + let restart_port = pick_unused_port()?; + let restart_url = format!("http://127.0.0.1:{restart_port}"); + log_step("restarting pinned server on same data dir"); + let (mut restarted_server, restarted_server_logs) = spawn_server(&old_cli, &data_dir, restart_port)?; + if let Err(e) = wait_for_ping(&restart_url, Duration::from_secs(20)) { + dump_server_logs("restarted server", &restarted_server_logs); + kill_child(&mut restarted_server); + return Err(e); + } + + log_step("running `spacetime logs` against restarted server"); + run_cmd_ok( + &[ + old_cli.clone().into_os_string(), + OsString::from("logs"), + OsString::from("--server"), + OsString::from(&restart_url), + OsString::from("-n"), + OsString::from("20"), + OsString::from(&db_name), + ], + &old_worktree, + )?; + + log_step("stopping restarted server"); + kill_child(&mut restarted_server); + + Ok(()) + })(); + + log_step("cleaning up temporary git worktree"); + cleanup_worktree(); + log_step("manual test finished"); + old_result +} From d9a0774bbc71751c95ae40e1c298c2bfd967be00 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Tue, 17 Feb 2026 16:36:35 -0800 Subject: [PATCH 07/22] [bfops/smoketest-upgrade]: kill after publish test working --- crates/smoketests/tests/kill_after_publish.rs | 117 +++++++++++++----- 1 file changed, 88 insertions(+), 29 deletions(-) diff --git a/crates/smoketests/tests/kill_after_publish.rs b/crates/smoketests/tests/kill_after_publish.rs index c3586f5c174..777c4ed35bf 100644 --- a/crates/smoketests/tests/kill_after_publish.rs +++ b/crates/smoketests/tests/kill_after_publish.rs @@ -19,7 +19,8 @@ use spacetimedb_smoketests::workspace_root; // 2) start server and publish module // 3) restart server immediately on the same data dir and same version // 4) verify `spacetime logs` succeeds -const V1_GIT_REF: &str = "v1.12.0"; +const V1_GIT_REF: &str = "2772036d511ab8ead00c132e484a057b1bdb6bd4"; +const MODULE_PATH_FLAG_CUTOFF_COMMIT: &str = "4c962b9170c577b6e6c7afeecf05a60635fa1536"; fn log_step(msg: &str) { eprintln!("[manual-upgrade] {msg}"); @@ -67,6 +68,55 @@ fn run_cmd_ok(args: &[OsString], cwd: &Path) -> Result { Ok(stdout) } +fn is_strictly_before_commit(repo: &Path, candidate_ref: &str, boundary_commit: &str) -> Result { + let candidate = run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("rev-parse"), + OsString::from(candidate_ref), + ], + repo, + )? + .trim() + .to_string(); + let boundary = run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("rev-parse"), + OsString::from(boundary_commit), + ], + repo, + )? + .trim() + .to_string(); + + if candidate == boundary { + return Ok(false); + } + + let out = run_cmd( + &[ + OsString::from("git"), + OsString::from("merge-base"), + OsString::from("--is-ancestor"), + OsString::from(&candidate), + OsString::from(&boundary), + ], + repo, + )?; + match out.status.code() { + Some(0) => Ok(true), + Some(1) => Ok(false), + _ => bail!( + "failed checking commit ancestry between {} and {}:\nstdout: {}\nstderr: {}", + candidate, + boundary, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ), + } +} + fn pick_unused_port() -> Result { let listener = TcpListener::bind("127.0.0.1:0")?; Ok(listener.local_addr()?.port()) @@ -188,35 +238,41 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { log_step("starting manual kill-after-publish test"); log_step(&format!("pinned source ref={}", V1_GIT_REF)); let repo = workspace_root(); + let stable_worktree_dir = repo + .join("target") + .join("smoketest-worktrees") + .join("kill-after-publish-v1"); let temp = tempfile::tempdir()?; let temp_path = temp.path(); - let old_worktree = temp_path.join("old"); + let old_worktree = stable_worktree_dir; let data_dir = temp_path.join("db-data"); std::fs::create_dir_all(&data_dir)?; log_step(&format!("workspace={}", repo.display())); + log_step(&format!("worktree={}", old_worktree.display())); log_step(&format!("temp root={}", temp_path.display())); log_step(&format!("data dir={}", data_dir.display())); // Build pinned sources from a temporary worktree. - log_step(&format!("creating worktree at ref {}", V1_GIT_REF)); - run_cmd_ok( - &[ - OsString::from("git"), - OsString::from("worktree"), - OsString::from("add"), - old_worktree.clone().into_os_string(), - OsString::from(V1_GIT_REF), - ], - &repo, - )?; - - let cleanup_worktree = || { - let _ = Command::new("git") - .args(["worktree", "remove", "--force"]) - .arg(&old_worktree) - .current_dir(&repo) - .status(); - }; + if !old_worktree.exists() { + let parent = old_worktree + .parent() + .ok_or_else(|| anyhow!("worktree path has no parent: {}", old_worktree.display()))?; + std::fs::create_dir_all(parent) + .with_context(|| format!("failed to create worktree parent {}", parent.display()))?; + log_step(&format!("creating worktree at ref {}", V1_GIT_REF)); + run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("worktree"), + OsString::from("add"), + old_worktree.clone().into_os_string(), + OsString::from(V1_GIT_REF), + ], + &repo, + )?; + } else { + log_step("reusing existing worktree"); + } let old_result: Result<()> = (|| { log_step("building pinned spacetimedb-cli and spacetimedb-standalone"); @@ -236,13 +292,18 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { .join("target") .join("debug") .join(exe_name("spacetimedb-cli")); - anyhow::ensure!( - old_cli.exists(), - "pinned CLI binary not found at {}", - old_cli.display() - ); + anyhow::ensure!(old_cli.exists(), "pinned CLI binary not found at {}", old_cli.display()); log_step(&format!("pinned CLI path={}", old_cli.display())); + let publish_path_flag = if is_strictly_before_commit(&repo, V1_GIT_REF, MODULE_PATH_FLAG_CUTOFF_COMMIT)? { + "--project-path" + } else { + "--module-path" + }; + log_step(&format!( + "using {} for publish path (cutoff {})", + publish_path_flag, MODULE_PATH_FLAG_CUTOFF_COMMIT + )); // Start pinned server and publish pinned quickstart module. let old_port = pick_unused_port()?; @@ -263,7 +324,7 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { OsString::from("publish"), OsString::from("--server"), OsString::from(&old_url), - OsString::from("--project-path"), + OsString::from(publish_path_flag), old_worktree .join("templates/chat-console-rs/spacetimedb") .into_os_string(), @@ -306,8 +367,6 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { Ok(()) })(); - log_step("cleaning up temporary git worktree"); - cleanup_worktree(); log_step("manual test finished"); old_result } From 48adf0ee5a5ceb49fe8032a30c421a87ce27d6e2 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Tue, 17 Feb 2026 17:54:18 -0800 Subject: [PATCH 08/22] [bfops/smoketest-upgrade]: WIP --- crates/smoketests/tests/kill_after_publish.rs | 314 +++++++++++++++--- .../smoketests/tests/upgrade_chat_to_2_0.rs | 261 ++++++++++++++- 2 files changed, 527 insertions(+), 48 deletions(-) diff --git a/crates/smoketests/tests/kill_after_publish.rs b/crates/smoketests/tests/kill_after_publish.rs index 777c4ed35bf..90e5440d235 100644 --- a/crates/smoketests/tests/kill_after_publish.rs +++ b/crates/smoketests/tests/kill_after_publish.rs @@ -1,15 +1,16 @@ #![allow(clippy::disallowed_macros)] use std::ffi::OsString; -use std::io::{BufRead, BufReader, Read, Write}; +use std::io::{BufRead, BufReader, ErrorKind, Read, Write}; use std::net::{TcpListener, TcpStream}; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::process::{Child, Command, Output, Stdio}; use std::sync::{Arc, Mutex}; use std::thread; use std::time::{Duration, Instant}; use anyhow::{anyhow, bail, Context, Result}; +use regex::Regex; use spacetimedb_smoketests::workspace_root; // NOTE: This test is intentionally manual/local-only and not meant for CI. @@ -19,7 +20,7 @@ use spacetimedb_smoketests::workspace_root; // 2) start server and publish module // 3) restart server immediately on the same data dir and same version // 4) verify `spacetime logs` succeeds -const V1_GIT_REF: &str = "2772036d511ab8ead00c132e484a057b1bdb6bd4"; +const V1_GIT_REF: &str = "v1.12.0"; const MODULE_PATH_FLAG_CUTOFF_COMMIT: &str = "4c962b9170c577b6e6c7afeecf05a60635fa1536"; fn log_step(msg: &str) { @@ -47,6 +48,33 @@ fn run_cmd(args: &[OsString], cwd: &Path) -> Result { .with_context(|| format!("failed to execute {:?}", args.iter().collect::>())) } +fn run_cmd_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { + let rendered = args + .iter() + .map(|s| s.to_string_lossy().to_string()) + .collect::>() + .join(" "); + log_step(&format!("run (stdin): (cd {}) {rendered}", cwd.display())); + + let mut cmd = Command::new(&args[0]); + cmd.args(&args[1..]) + .current_dir(cwd) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + + let mut child = cmd + .spawn() + .with_context(|| format!("failed to execute {:?}", args.iter().collect::>()))?; + { + let stdin = child.stdin.as_mut().context("missing child stdin")?; + stdin.write_all(stdin_input.as_bytes())?; + } + child + .wait_with_output() + .with_context(|| format!("failed waiting for {:?}", args.iter().collect::>())) +} + fn run_cmd_ok(args: &[OsString], cwd: &Path) -> Result { let out = run_cmd(args, cwd)?; if !out.status.success() { @@ -68,6 +96,27 @@ fn run_cmd_ok(args: &[OsString], cwd: &Path) -> Result { Ok(stdout) } +fn run_cmd_ok_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { + let out = run_cmd_with_stdin(args, cwd, stdin_input)?; + if !out.status.success() { + bail!( + "command failed: {:?}\nstdout: {}\nstderr: {}", + args, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + } + let stdout = String::from_utf8_lossy(&out.stdout).to_string(); + let stderr = String::from_utf8_lossy(&out.stderr).to_string(); + if !stdout.trim().is_empty() { + log_step(&format!("stdout:\n{}", stdout.trim())); + } + if !stderr.trim().is_empty() { + log_step(&format!("stderr:\n{}", stderr.trim())); + } + Ok(stdout) +} + fn is_strictly_before_commit(repo: &Path, candidate_ref: &str, boundary_commit: &str) -> Result { let candidate = run_cmd_ok( &[ @@ -232,6 +281,109 @@ fn dump_server_logs(label: &str, logs: &Arc>) { eprintln!("[manual-upgrade] {label} logs:\n{s}"); } +fn extract_identity(publish_stdout: &str) -> Result { + let re = Regex::new(r"identity: ([0-9a-fA-F]+)")?; + let caps = re + .captures(publish_stdout) + .ok_or_else(|| anyhow!("failed to parse identity from publish output:\n{publish_stdout}"))?; + Ok(caps.get(1).unwrap().as_str().to_string()) +} + +fn spawn_chat_client(label: &str, bin: &Path, server_url: &str, db_name: &str) -> Result<(Child, Arc>)> { + log_step(&format!( + "starting {label} client {} (server={}, db={})", + bin.display(), + server_url, + db_name + )); + let mut child = Command::new(bin) + .env("SPACETIMEDB_HOST", server_url) + .env("SPACETIMEDB_SERVER", server_url) + .env("SPACETIMEDB_DB_NAME", db_name) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .with_context(|| format!("failed to spawn chat client {}", bin.display()))?; + log_step(&format!("started client pid={}", child.id())); + + let logs = Arc::new(Mutex::new(String::new())); + + if let Some(stdout) = child.stdout.take() { + let logs_out = logs.clone(); + let label = label.to_string(); + thread::spawn(move || { + let mut reader = BufReader::new(stdout); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + eprintln!("[{label} recv] {}", line.trim_end()); + let mut s = logs_out.lock().unwrap(); + s.push_str(&line); + } + }); + } + if let Some(stderr) = child.stderr.take() { + let logs_err = logs.clone(); + let label = label.to_string(); + thread::spawn(move || { + let mut reader = BufReader::new(stderr); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + eprintln!("[{label} stderr] {}", line.trim_end()); + let mut s = logs_err.lock().unwrap(); + s.push_str(&line); + } + }); + } + + Ok((child, logs)) +} + +fn write_line(child: &mut Child, line: &str) -> Result<()> { + log_step(&format!("sending to pid {}: {}", child.id(), line)); + let stdin = child.stdin.as_mut().context("child stdin missing")?; + if let Err(e) = stdin.write_all(line.as_bytes()) { + if e.kind() == ErrorKind::BrokenPipe { + log_step(&format!( + "stdin broken pipe for pid {} while sending {:?}; continuing", + child.id(), + line + )); + return Ok(()); + } + return Err(e).context("failed writing line to client stdin"); + } + if let Err(e) = stdin.write_all(b"\n") { + if e.kind() == ErrorKind::BrokenPipe { + log_step(&format!( + "stdin broken pipe for pid {} while sending newline; continuing", + child.id() + )); + return Ok(()); + } + return Err(e).context("failed writing newline to client stdin"); + } + if let Err(e) = stdin.flush() { + if e.kind() == ErrorKind::BrokenPipe { + log_step(&format!( + "stdin broken pipe for pid {} on flush; continuing", + child.id() + )); + return Ok(()); + } + return Err(e).context("failed flushing client stdin"); + } + Ok(()) +} + #[test] #[ignore = "manual local-only: long-running, networked, and builds historical artifacts"] fn kill_after_publish_logs_after_restart() -> Result<()> { @@ -249,7 +401,6 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { std::fs::create_dir_all(&data_dir)?; log_step(&format!("workspace={}", repo.display())); log_step(&format!("worktree={}", old_worktree.display())); - log_step(&format!("temp root={}", temp_path.display())); log_step(&format!("data dir={}", data_dir.display())); // Build pinned sources from a temporary worktree. @@ -272,30 +423,78 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { )?; } else { log_step("reusing existing worktree"); + log_step(&format!("forcing existing worktree to ref {}", V1_GIT_REF)); + + run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("-C"), + old_worktree.clone().into_os_string(), + OsString::from("checkout"), + OsString::from("--force"), + OsString::from(V1_GIT_REF), + ], + &old_worktree, + )?; } + // Prepare current binaries (including update helper needed by `version install` from target dir). + log_step("building current spacetimedb-cli and spacetimedb-update"); + run_cmd_ok( + &[ + OsString::from("cargo"), + OsString::from("build"), + OsString::from("-p"), + OsString::from("spacetimedb-cli"), + OsString::from("-p"), + OsString::from("spacetimedb-standalone"), + OsString::from("-p"), + OsString::from("spacetimedb-update"), + ], + &old_worktree, + )?; + + let old_cli = old_worktree.join("target").join("debug").join(exe_name("spacetimedb-cli")); + anyhow::ensure!( + old_cli.exists(), + "old CLI binary missing at {}", + old_cli.display() + ); + let old_result: Result<()> = (|| { - log_step("building pinned spacetimedb-cli and spacetimedb-standalone"); + log_step("running codegen for chat-console-rs (cli generate)"); run_cmd_ok( &[ - OsString::from("cargo"), - OsString::from("build"), - OsString::from("-p"), - OsString::from("spacetimedb-cli"), - OsString::from("-p"), - OsString::from("spacetimedb-standalone"), + old_cli.clone().into_os_string(), + OsString::from("generate"), + OsString::from("--project-path"), + OsString::from("spacetimedb/"), + OsString::from("--out-dir"), + OsString::from("src/module_bindings/"), + OsString::from("--lang"), + OsString::from("rust"), ], - &old_worktree, + &old_worktree.join("templates/chat-console-rs"), )?; - let old_cli = old_worktree + log_step("building quickstart chat client"); + run_cmd_ok( + &[OsString::from("cargo"), OsString::from("build")], + &old_worktree.join("templates/chat-console-rs"), + )?; + + let old_client = old_worktree + .join("templates/chat-console-rs") .join("target") .join("debug") - .join(exe_name("spacetimedb-cli")); - anyhow::ensure!(old_cli.exists(), "pinned CLI binary not found at {}", old_cli.display()); + .join(exe_name("rust-quickstart-chat")); + anyhow::ensure!( + old_client.exists(), + "old chat client not found at {}", + old_client.display() + ); - log_step(&format!("pinned CLI path={}", old_cli.display())); - let publish_path_flag = if is_strictly_before_commit(&repo, V1_GIT_REF, MODULE_PATH_FLAG_CUTOFF_COMMIT)? { + let publish_path_flag = if ! is_strictly_before_commit(&repo, MODULE_PATH_FLAG_CUTOFF_COMMIT, V1_GIT_REF)? { "--project-path" } else { "--module-path" @@ -305,20 +504,23 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { publish_path_flag, MODULE_PATH_FLAG_CUTOFF_COMMIT )); - // Start pinned server and publish pinned quickstart module. + log_step(&format!("old CLI path={}", old_cli.display())); + log_step(&format!("old client path={}", old_client.display())); + + // Start 1.0 server and publish 1.0 quickstart module. let old_port = pick_unused_port()?; let old_url = format!("http://127.0.0.1:{old_port}"); - log_step("starting pinned server for initial publish"); + log_step("starting old server for initial publish"); let (mut old_server, old_server_logs) = spawn_server(&old_cli, &data_dir, old_port)?; if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { - dump_server_logs("pinned server", &old_server_logs); + dump_server_logs("old server", &old_server_logs); kill_child(&mut old_server); return Err(e); } - let db_name = format!("kill-after-publish-{}", spacetimedb_smoketests::random_string()); - log_step(&format!("publishing pinned module to db {}", db_name)); - run_cmd_ok( + let db_name = format!("manual-upgrade-chat-{}", spacetimedb_smoketests::random_string()); + log_step(&format!("publishing old module to db {}", db_name)); + let publish_out = run_cmd_ok( &[ old_cli.clone().into_os_string(), OsString::from("publish"), @@ -333,36 +535,54 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { ], &old_worktree, )?; - log_step("module published successfully; stopping server"); + let _identity = extract_identity(&publish_out)?; + log_step("old module published successfully; stopping old server"); kill_child(&mut old_server); - // Restart pinned server on the same data dir and verify logs command succeeds. - let restart_port = pick_unused_port()?; - let restart_url = format!("http://127.0.0.1:{restart_port}"); - log_step("restarting pinned server on same data dir"); - let (mut restarted_server, restarted_server_logs) = spawn_server(&old_cli, &data_dir, restart_port)?; - if let Err(e) = wait_for_ping(&restart_url, Duration::from_secs(20)) { - dump_server_logs("restarted server", &restarted_server_logs); - kill_child(&mut restarted_server); + let new_port = pick_unused_port()?; + let new_url = format!("http://127.0.0.1:{new_port}"); + log_step("starting new server on same data dir"); + let (mut new_server, new_server_logs) = spawn_server(&old_cli, &data_dir, new_port)?; + if let Err(e) = wait_for_ping(&new_url, Duration::from_secs(20)) { + dump_server_logs("new server", &new_server_logs); + kill_child(&mut new_server); return Err(e); } - log_step("running `spacetime logs` against restarted server"); - run_cmd_ok( - &[ - old_cli.clone().into_os_string(), - OsString::from("logs"), - OsString::from("--server"), - OsString::from(&restart_url), - OsString::from("-n"), - OsString::from("20"), - OsString::from(&db_name), - ], - &old_worktree, - )?; + log_step("starting client"); + let (mut c1, logs1) = spawn_chat_client("client-v1", &old_client, &new_url, &db_name)?; + + thread::sleep(Duration::from_secs(5)); + write_line(&mut c1, "/name old-v1")?; + write_line(&mut c1, "hello-from-v1")?; - log_step("stopping restarted server"); - kill_child(&mut restarted_server); + // Both clients should observe both messages in their output. + log_step("waiting for both clients to observe both messages"); + let deadline = Instant::now() + Duration::from_secs(20); + let mut ok = false; + while Instant::now() < deadline { + let l1 = logs1.lock().unwrap().clone(); + let saw_v1 = l1.contains("old-v1: hello-from-v1"); + if saw_v1 { + log_step("success condition met: both clients saw both messages"); + ok = true; + break; + } + thread::sleep(Duration::from_millis(200)); + } + + log_step("stopping clients and new server"); + kill_child(&mut c1); + kill_child(&mut new_server); + + if !ok { + let l1 = logs1.lock().unwrap().clone(); + dump_server_logs("new server", &new_server_logs); + bail!( + "message exchange incomplete.\nclient-v1 logs:\n{}\n", + l1, + ); + } Ok(()) })(); diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0.rs b/crates/smoketests/tests/upgrade_chat_to_2_0.rs index fa148c1bb66..7e104b5c8fe 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0.rs @@ -21,8 +21,9 @@ use spacetimedb_smoketests::workspace_root; // 3) start 1.0 server and publish module // 4) restart as 2.0 server on the same data dir // 5) run both 1.0 and 2.0 quickstart clients, exchange messages, assert both observed -const V1_GIT_REF: &str = "v1.12.0"; +const V1_GIT_REF: &str = "origin/master"; const V1_RELEASE_VERSION: &str = "1.12.0"; +const MODULE_PATH_FLAG_CUTOFF_COMMIT: &str = "4c962b9170c577b6e6c7afeecf05a60635fa1536"; fn log_step(msg: &str) { eprintln!("[manual-upgrade] {msg}"); @@ -118,6 +119,55 @@ fn run_cmd_ok_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Re Ok(stdout) } +fn is_strictly_before_commit(repo: &Path, candidate_ref: &str, boundary_commit: &str) -> Result { + let candidate = run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("rev-parse"), + OsString::from(candidate_ref), + ], + repo, + )? + .trim() + .to_string(); + let boundary = run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("rev-parse"), + OsString::from(boundary_commit), + ], + repo, + )? + .trim() + .to_string(); + + if candidate == boundary { + return Ok(false); + } + + let out = run_cmd( + &[ + OsString::from("git"), + OsString::from("merge-base"), + OsString::from("--is-ancestor"), + OsString::from(&candidate), + OsString::from(&boundary), + ], + repo, + )?; + match out.status.code() { + Some(0) => Ok(true), + Some(1) => Ok(false), + _ => bail!( + "failed checking commit ancestry between {} and {}:\nstdout: {}\nstderr: {}", + candidate, + boundary, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ), + } +} + fn pick_unused_port() -> Result { let listener = TcpListener::bind("127.0.0.1:0")?; Ok(listener.local_addr()?.port()) @@ -598,3 +648,212 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { log_step("manual test finished"); old_result } + +#[test] +#[ignore = "manual local-only: long-running, networked, and builds historical artifacts"] +fn kill_after_publish_logs_after_restart() -> Result<()> { + log_step("starting manual upgrade mixed-clients quickstart test"); + log_step(&format!( + "pinned old source ref={}, old release version={}", + V1_GIT_REF, V1_RELEASE_VERSION + )); + let repo = workspace_root(); + let stable_worktree_dir = repo + .join("target") + .join("smoketest-worktrees") + .join("kill-after-publish-v1"); + let old_worktree = stable_worktree_dir; + let temp = tempfile::tempdir()?; + let temp_path = temp.path(); + let data_dir = temp_path.join("db-data"); + std::fs::create_dir_all(&data_dir)?; + log_step(&format!("workspace={}", repo.display())); + log_step(&format!("temp root={}", temp_path.display())); + log_step(&format!("data dir={}", data_dir.display())); + + if !old_worktree.exists() { + let parent = old_worktree + .parent() + .ok_or_else(|| anyhow!("worktree path has no parent: {}", old_worktree.display()))?; + std::fs::create_dir_all(parent) + .with_context(|| format!("failed to create worktree parent {}", parent.display()))?; + log_step(&format!("creating worktree at ref {}", V1_GIT_REF)); + run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("worktree"), + OsString::from("add"), + old_worktree.clone().into_os_string(), + OsString::from(V1_GIT_REF), + ], + &repo, + )?; + } else { + log_step("reusing existing worktree"); + log_step(&format!("forcing existing worktree to ref {}", V1_GIT_REF)); + + run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("-C"), + old_worktree.clone().into_os_string(), + OsString::from("checkout"), + OsString::from("--force"), + OsString::from(V1_GIT_REF), + ], + &old_worktree, + )?; + } + + log_step("building current spacetimedb-cli and spacetimedb-update"); + run_cmd_ok( + &[ + OsString::from("cargo"), + OsString::from("build"), + OsString::from("-p"), + OsString::from("spacetimedb-cli"), + OsString::from("-p"), + OsString::from("spacetimedb-standalone"), + OsString::from("-p"), + OsString::from("spacetimedb-update"), + ], + &old_worktree, + )?; + + let old_cli = old_worktree.join("target").join("debug").join(exe_name("spacetimedb-cli")); + anyhow::ensure!( + old_cli.exists(), + "old CLI binary missing at {}", + old_cli.display() + ); + + let publish_path_flag = if ! is_strictly_before_commit(&repo, MODULE_PATH_FLAG_CUTOFF_COMMIT, V1_GIT_REF)? { + "--project-path" + } else { + "--module-path" + }; + log_step(&format!( + "using {} for publish path (cutoff {})", + publish_path_flag, MODULE_PATH_FLAG_CUTOFF_COMMIT + )); + + let old_result: Result<()> = (|| { + log_step("running v1 codegen for chat-console-rs (cli generate)"); + run_cmd_ok( + &[ + old_cli.clone().into_os_string(), + OsString::from("generate"), + OsString::from(publish_path_flag), + OsString::from("spacetimedb/"), + OsString::from("--out-dir"), + OsString::from("src/module_bindings/"), + OsString::from("--lang"), + OsString::from("rust"), + ], + &old_worktree.join("templates/chat-console-rs"), + )?; + + log_step("building old quickstart chat client"); + run_cmd_ok( + &[OsString::from("cargo"), OsString::from("build")], + &old_worktree.join("templates/chat-console-rs"), + )?; + + let old_client = old_worktree + .join("templates/chat-console-rs") + .join("target") + .join("debug") + .join(exe_name("rust-quickstart-chat")); + anyhow::ensure!( + old_client.exists(), + "old chat client not found at {}", + old_client.display() + ); + + log_step(&format!("v1 CLI path={}", old_cli.display())); + log_step(&format!("old client path={}", old_client.display())); + + // Start 1.0 server and publish 1.0 quickstart module. + let old_port = pick_unused_port()?; + let old_url = format!("http://127.0.0.1:{old_port}"); + log_step("starting old server for initial publish"); + let (mut old_server, old_server_logs) = spawn_server(&old_cli, &data_dir, old_port)?; + if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { + dump_server_logs("old server", &old_server_logs); + kill_child(&mut old_server); + return Err(e); + } + + let db_name = format!("manual-upgrade-chat-{}", spacetimedb_smoketests::random_string()); + log_step(&format!("publishing old module to db {}", db_name)); + let publish_out = run_cmd_ok( + &[ + old_cli.clone().into_os_string(), + OsString::from("publish"), + OsString::from("--server"), + OsString::from(&old_url), + OsString::from(publish_path_flag), + old_worktree + .join("templates/chat-console-rs/spacetimedb") + .into_os_string(), + OsString::from("--yes"), + OsString::from(&db_name), + ], + &old_worktree, + )?; + let _identity = extract_identity(&publish_out)?; + log_step("old module published successfully; stopping old server"); + kill_child(&mut old_server); + + // Start server on the same data dir. + let new_port = pick_unused_port()?; + let new_url = format!("http://127.0.0.1:{new_port}"); + log_step("restarting server on same data dir"); + let (mut new_server, new_server_logs) = spawn_server(&old_cli, &data_dir, new_port)?; + if let Err(e) = wait_for_ping(&new_url, Duration::from_secs(20)) { + dump_server_logs("restarted server", &new_server_logs); + kill_child(&mut new_server); + return Err(e); + } + + log_step("starting old client"); + let (mut c1, logs1) = spawn_chat_client("client-v1", &old_client, &new_url, &db_name)?; + + thread::sleep(Duration::from_secs(5)); + write_line(&mut c1, "/name old-v1")?; + write_line(&mut c1, "hello-from-v1")?; + + // Client should observe both messages in their output. + log_step("waiting for both clients to observe both messages"); + let deadline = Instant::now() + Duration::from_secs(20); + let mut ok = false; + while Instant::now() < deadline { + let l1 = logs1.lock().unwrap().clone(); + let saw_v1 = l1.contains("old-v1: hello-from-v1"); + if saw_v1 { + log_step("success condition met: both clients saw both messages"); + ok = true; + break; + } + thread::sleep(Duration::from_millis(200)); + } + + log_step("stopping clients and new server"); + kill_child(&mut c1); + kill_child(&mut new_server); + + if !ok { + let l1 = logs1.lock().unwrap().clone(); + dump_server_logs("new server", &new_server_logs); + bail!( + "message exchange incomplete.\nclient-v1 logs:\n{}", + l1, + ); + } + + Ok(()) + })(); + + log_step("manual test finished"); + old_result +} From ef8c6f2e59b25b46974364b0464023236a18156f Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Tue, 17 Feb 2026 18:24:35 -0800 Subject: [PATCH 09/22] [bfops/smoketest-upgrade]: refactored --- crates/smoketests/tests/kill_after_publish.rs | 120 +---- crates/smoketests/tests/test_util.rs | 248 ++++++++++ .../smoketests/tests/upgrade_chat_to_2_0.rs | 448 ++---------------- 3 files changed, 307 insertions(+), 509 deletions(-) create mode 100644 crates/smoketests/tests/test_util.rs diff --git a/crates/smoketests/tests/kill_after_publish.rs b/crates/smoketests/tests/kill_after_publish.rs index 90e5440d235..ec2c3e9c935 100644 --- a/crates/smoketests/tests/kill_after_publish.rs +++ b/crates/smoketests/tests/kill_after_publish.rs @@ -3,7 +3,7 @@ use std::ffi::OsString; use std::io::{BufRead, BufReader, ErrorKind, Read, Write}; use std::net::{TcpListener, TcpStream}; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::process::{Child, Command, Output, Stdio}; use std::sync::{Arc, Mutex}; use std::thread; @@ -13,6 +13,9 @@ use anyhow::{anyhow, bail, Context, Result}; use regex::Regex; use spacetimedb_smoketests::workspace_root; +mod pinned_chat_workspace; +use pinned_chat_workspace::prepare_pinned_chat_workspace; + // NOTE: This test is intentionally manual/local-only and not meant for CI. // // It validates a kill/restart scenario at a pinned historical version: @@ -21,7 +24,6 @@ use spacetimedb_smoketests::workspace_root; // 3) restart server immediately on the same data dir and same version // 4) verify `spacetime logs` succeeds const V1_GIT_REF: &str = "v1.12.0"; -const MODULE_PATH_FLAG_CUTOFF_COMMIT: &str = "4c962b9170c577b6e6c7afeecf05a60635fa1536"; fn log_step(msg: &str) { eprintln!("[manual-upgrade] {msg}"); @@ -390,120 +392,26 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { log_step("starting manual kill-after-publish test"); log_step(&format!("pinned source ref={}", V1_GIT_REF)); let repo = workspace_root(); - let stable_worktree_dir = repo + let worktree_dir = repo .join("target") .join("smoketest-worktrees") .join("kill-after-publish-v1"); let temp = tempfile::tempdir()?; let temp_path = temp.path(); - let old_worktree = stable_worktree_dir; let data_dir = temp_path.join("db-data"); std::fs::create_dir_all(&data_dir)?; log_step(&format!("workspace={}", repo.display())); - log_step(&format!("worktree={}", old_worktree.display())); log_step(&format!("data dir={}", data_dir.display())); - // Build pinned sources from a temporary worktree. - if !old_worktree.exists() { - let parent = old_worktree - .parent() - .ok_or_else(|| anyhow!("worktree path has no parent: {}", old_worktree.display()))?; - std::fs::create_dir_all(parent) - .with_context(|| format!("failed to create worktree parent {}", parent.display()))?; - log_step(&format!("creating worktree at ref {}", V1_GIT_REF)); - run_cmd_ok( - &[ - OsString::from("git"), - OsString::from("worktree"), - OsString::from("add"), - old_worktree.clone().into_os_string(), - OsString::from(V1_GIT_REF), - ], - &repo, - )?; - } else { - log_step("reusing existing worktree"); - log_step(&format!("forcing existing worktree to ref {}", V1_GIT_REF)); - - run_cmd_ok( - &[ - OsString::from("git"), - OsString::from("-C"), - old_worktree.clone().into_os_string(), - OsString::from("checkout"), - OsString::from("--force"), - OsString::from(V1_GIT_REF), - ], - &old_worktree, - )?; - } - - // Prepare current binaries (including update helper needed by `version install` from target dir). - log_step("building current spacetimedb-cli and spacetimedb-update"); - run_cmd_ok( - &[ - OsString::from("cargo"), - OsString::from("build"), - OsString::from("-p"), - OsString::from("spacetimedb-cli"), - OsString::from("-p"), - OsString::from("spacetimedb-standalone"), - OsString::from("-p"), - OsString::from("spacetimedb-update"), - ], - &old_worktree, - )?; - - let old_cli = old_worktree.join("target").join("debug").join(exe_name("spacetimedb-cli")); - anyhow::ensure!( - old_cli.exists(), - "old CLI binary missing at {}", - old_cli.display() - ); + let prepared = prepare_pinned_chat_workspace(&repo, &worktree_dir, V1_GIT_REF)?; + let old_worktree = prepared.worktree_dir; + let old_cli = prepared.cli_path; + let old_client = prepared.client_path; + let publish_path_flag = prepared.publish_path_flag; + let old_module_dir = prepared.module_dir; + log_step(&format!("worktree={}", old_worktree.display())); let old_result: Result<()> = (|| { - log_step("running codegen for chat-console-rs (cli generate)"); - run_cmd_ok( - &[ - old_cli.clone().into_os_string(), - OsString::from("generate"), - OsString::from("--project-path"), - OsString::from("spacetimedb/"), - OsString::from("--out-dir"), - OsString::from("src/module_bindings/"), - OsString::from("--lang"), - OsString::from("rust"), - ], - &old_worktree.join("templates/chat-console-rs"), - )?; - - log_step("building quickstart chat client"); - run_cmd_ok( - &[OsString::from("cargo"), OsString::from("build")], - &old_worktree.join("templates/chat-console-rs"), - )?; - - let old_client = old_worktree - .join("templates/chat-console-rs") - .join("target") - .join("debug") - .join(exe_name("rust-quickstart-chat")); - anyhow::ensure!( - old_client.exists(), - "old chat client not found at {}", - old_client.display() - ); - - let publish_path_flag = if ! is_strictly_before_commit(&repo, MODULE_PATH_FLAG_CUTOFF_COMMIT, V1_GIT_REF)? { - "--project-path" - } else { - "--module-path" - }; - log_step(&format!( - "using {} for publish path (cutoff {})", - publish_path_flag, MODULE_PATH_FLAG_CUTOFF_COMMIT - )); - log_step(&format!("old CLI path={}", old_cli.display())); log_step(&format!("old client path={}", old_client.display())); @@ -527,9 +435,7 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { OsString::from("--server"), OsString::from(&old_url), OsString::from(publish_path_flag), - old_worktree - .join("templates/chat-console-rs/spacetimedb") - .into_os_string(), + old_module_dir.clone().into_os_string(), OsString::from("--yes"), OsString::from(&db_name), ], diff --git a/crates/smoketests/tests/test_util.rs b/crates/smoketests/tests/test_util.rs new file mode 100644 index 00000000000..89ab10907e2 --- /dev/null +++ b/crates/smoketests/tests/test_util.rs @@ -0,0 +1,248 @@ +use std::ffi::OsString; +use std::io::Write; +use std::path::{Path, PathBuf}; +use std::process::{Command, Output, Stdio}; + +use anyhow::{bail, Context, Result}; + +const MODULE_PATH_FLAG_CUTOFF_COMMIT: &str = "4c962b9170c577b6e6c7afeecf05a60635fa1536"; + +pub struct PreparedChatWorkspace { + pub worktree_dir: PathBuf, + pub cli_path: PathBuf, + pub client_path: PathBuf, + pub module_dir: PathBuf, + pub publish_path_flag: &'static str, +} + +fn log_step(msg: &str) { + eprintln!("[manual-upgrade] {msg}"); +} + +fn exe_name(base: &str) -> String { + if cfg!(windows) { + format!("{base}.exe") + } else { + base.to_string() + } +} + +pub fn run_cmd(args: &[OsString], cwd: &Path) -> Result { + let rendered = args + .iter() + .map(|s| s.to_string_lossy().to_string()) + .collect::>() + .join(" "); + log_step(&format!("run: (cd {}) {rendered}", cwd.display())); + let mut cmd = Command::new(&args[0]); + cmd.args(&args[1..]).current_dir(cwd); + cmd.output() + .with_context(|| format!("failed to execute {:?}", args.iter().collect::>())) +} + +pub fn run_cmd_ok(args: &[OsString], cwd: &Path) -> Result { + let out = run_cmd(args, cwd)?; + if !out.status.success() { + bail!( + "command failed: {:?}\nstdout: {}\nstderr: {}", + args, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + } + Ok(String::from_utf8_lossy(&out.stdout).to_string()) +} + +pub fn run_cmd_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { + let rendered = args + .iter() + .map(|s| s.to_string_lossy().to_string()) + .collect::>() + .join(" "); + log_step(&format!("run (stdin): (cd {}) {rendered}", cwd.display())); + + let mut cmd = Command::new(&args[0]); + cmd.args(&args[1..]) + .current_dir(cwd) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + + let mut child = cmd + .spawn() + .with_context(|| format!("failed to execute {:?}", args.iter().collect::>()))?; + { + let stdin = child.stdin.as_mut().context("missing child stdin")?; + stdin.write_all(stdin_input.as_bytes())?; + } + child + .wait_with_output() + .with_context(|| format!("failed waiting for {:?}", args.iter().collect::>())) +} + +pub fn run_cmd_ok_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { + let out = run_cmd_with_stdin(args, cwd, stdin_input)?; + if !out.status.success() { + bail!( + "command failed: {:?}\nstdout: {}\nstderr: {}", + args, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + } + let stdout = String::from_utf8_lossy(&out.stdout).to_string(); + let stderr = String::from_utf8_lossy(&out.stderr).to_string(); + if !stdout.trim().is_empty() { + log_step(&format!("stdout:\n{}", stdout.trim())); + } + if !stderr.trim().is_empty() { + log_step(&format!("stderr:\n{}", stderr.trim())); + } + Ok(stdout) +} + +fn is_strictly_before_commit(repo: &Path, candidate_ref: &str, boundary_commit: &str) -> Result { + let candidate = run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("rev-parse"), + OsString::from(candidate_ref), + ], + repo, + )? + .trim() + .to_string(); + let boundary = run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("rev-parse"), + OsString::from(boundary_commit), + ], + repo, + )? + .trim() + .to_string(); + + if candidate == boundary { + return Ok(false); + } + + let out = run_cmd( + &[ + OsString::from("git"), + OsString::from("merge-base"), + OsString::from("--is-ancestor"), + OsString::from(&candidate), + OsString::from(&boundary), + ], + repo, + )?; + match out.status.code() { + Some(0) => Ok(true), + Some(1) => Ok(false), + _ => bail!( + "failed checking commit ancestry between {} and {}:\nstdout: {}\nstderr: {}", + candidate, + boundary, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ), + } +} + +pub fn prepare_pinned_chat_workspace( + workspace_dir: &Path, + worktree_dir: &Path, + git_ref: &str, +) -> Result { + if !worktree_dir.exists() { + let parent = worktree_dir + .parent() + .ok_or_else(|| anyhow::anyhow!("worktree path has no parent: {}", worktree_dir.display()))?; + std::fs::create_dir_all(parent) + .with_context(|| format!("failed to create worktree parent {}", parent.display()))?; + run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("worktree"), + OsString::from("add"), + worktree_dir.to_path_buf().into_os_string(), + OsString::from(git_ref), + ], + workspace_dir, + )?; + } else { + run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("-C"), + worktree_dir.to_path_buf().into_os_string(), + OsString::from("checkout"), + OsString::from("--force"), + OsString::from(git_ref), + ], + workspace_dir, + )?; + } + + run_cmd_ok( + &[ + OsString::from("cargo"), + OsString::from("build"), + OsString::from("-p"), + OsString::from("spacetimedb-cli"), + OsString::from("-p"), + OsString::from("spacetimedb-standalone"), + ], + &worktree_dir, + )?; + + let cli_path = worktree_dir + .join("target") + .join("debug") + .join(exe_name("spacetimedb-cli")); + anyhow::ensure!( + cli_path.exists(), + "pinned CLI binary not found at {}", + cli_path.display() + ); + + let publish_path_flag = if is_strictly_before_commit(workspace_dir, MODULE_PATH_FLAG_CUTOFF_COMMIT, git_ref)? { + "--module-path" + } else { + "--project-path" + }; + let chat_client_dir = worktree_dir.join("templates/chat-console-rs"); + run_cmd_ok( + &[ + cli_path.clone().into_os_string(), + OsString::from("generate"), + OsString::from(publish_path_flag), + OsString::from("spacetimedb/"), + OsString::from("--out-dir"), + OsString::from("src/module_bindings/"), + OsString::from("--lang"), + OsString::from("rust"), + ], + &chat_client_dir, + )?; + run_cmd_ok(&[OsString::from("cargo"), OsString::from("build")], &chat_client_dir)?; + + let client_path = chat_client_dir + .join("target") + .join("debug") + .join(exe_name("rust-quickstart-chat")); + anyhow::ensure!( + client_path.exists(), + "pinned chat client not found at {}", + client_path.display() + ); + + Ok(PreparedChatWorkspace { + worktree_dir: worktree_dir.to_path_buf(), + cli_path, + client_path, + module_dir: worktree_dir.join("templates/chat-console-rs/spacetimedb"), + publish_path_flag, + }) +} diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0.rs b/crates/smoketests/tests/upgrade_chat_to_2_0.rs index 7e104b5c8fe..33455ad795e 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0.rs @@ -3,7 +3,7 @@ use std::ffi::OsString; use std::io::{BufRead, BufReader, ErrorKind, Read, Write}; use std::net::{TcpListener, TcpStream}; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::process::{Child, Command, Output, Stdio}; use std::sync::{Arc, Mutex}; use std::thread; @@ -13,6 +13,9 @@ use anyhow::{anyhow, bail, Context, Result}; use regex::Regex; use spacetimedb_smoketests::workspace_root; +mod test_util; +use test_util::{prepare_pinned_chat_workspace, run_cmd_ok, run_cmd_ok_with_stdin}; + // NOTE: This test is intentionally manual/local-only and not meant for CI. // // It validates a 1.0 -> 2.0 upgrade scenario using quickstart-chat: @@ -22,152 +25,11 @@ use spacetimedb_smoketests::workspace_root; // 4) restart as 2.0 server on the same data dir // 5) run both 1.0 and 2.0 quickstart clients, exchange messages, assert both observed const V1_GIT_REF: &str = "origin/master"; -const V1_RELEASE_VERSION: &str = "1.12.0"; -const MODULE_PATH_FLAG_CUTOFF_COMMIT: &str = "4c962b9170c577b6e6c7afeecf05a60635fa1536"; fn log_step(msg: &str) { eprintln!("[manual-upgrade] {msg}"); } -fn exe_name(base: &str) -> String { - if cfg!(windows) { - format!("{base}.exe") - } else { - base.to_string() - } -} - -fn run_cmd(args: &[OsString], cwd: &Path) -> Result { - let rendered = args - .iter() - .map(|s| s.to_string_lossy().to_string()) - .collect::>() - .join(" "); - log_step(&format!("run: (cd {}) {rendered}", cwd.display())); - let mut cmd = Command::new(&args[0]); - cmd.args(&args[1..]).current_dir(cwd); - cmd.output() - .with_context(|| format!("failed to execute {:?}", args.iter().collect::>())) -} - -fn run_cmd_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { - let rendered = args - .iter() - .map(|s| s.to_string_lossy().to_string()) - .collect::>() - .join(" "); - log_step(&format!("run (stdin): (cd {}) {rendered}", cwd.display())); - - let mut cmd = Command::new(&args[0]); - cmd.args(&args[1..]) - .current_dir(cwd) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()); - - let mut child = cmd - .spawn() - .with_context(|| format!("failed to execute {:?}", args.iter().collect::>()))?; - { - let stdin = child.stdin.as_mut().context("missing child stdin")?; - stdin.write_all(stdin_input.as_bytes())?; - } - child - .wait_with_output() - .with_context(|| format!("failed waiting for {:?}", args.iter().collect::>())) -} - -fn run_cmd_ok(args: &[OsString], cwd: &Path) -> Result { - let out = run_cmd(args, cwd)?; - if !out.status.success() { - bail!( - "command failed: {:?}\nstdout: {}\nstderr: {}", - args, - String::from_utf8_lossy(&out.stdout), - String::from_utf8_lossy(&out.stderr) - ); - } - let stdout = String::from_utf8_lossy(&out.stdout).to_string(); - let stderr = String::from_utf8_lossy(&out.stderr).to_string(); - if !stdout.trim().is_empty() { - log_step(&format!("stdout:\n{}", stdout.trim())); - } - if !stderr.trim().is_empty() { - log_step(&format!("stderr:\n{}", stderr.trim())); - } - Ok(stdout) -} - -fn run_cmd_ok_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { - let out = run_cmd_with_stdin(args, cwd, stdin_input)?; - if !out.status.success() { - bail!( - "command failed: {:?}\nstdout: {}\nstderr: {}", - args, - String::from_utf8_lossy(&out.stdout), - String::from_utf8_lossy(&out.stderr) - ); - } - let stdout = String::from_utf8_lossy(&out.stdout).to_string(); - let stderr = String::from_utf8_lossy(&out.stderr).to_string(); - if !stdout.trim().is_empty() { - log_step(&format!("stdout:\n{}", stdout.trim())); - } - if !stderr.trim().is_empty() { - log_step(&format!("stderr:\n{}", stderr.trim())); - } - Ok(stdout) -} - -fn is_strictly_before_commit(repo: &Path, candidate_ref: &str, boundary_commit: &str) -> Result { - let candidate = run_cmd_ok( - &[ - OsString::from("git"), - OsString::from("rev-parse"), - OsString::from(candidate_ref), - ], - repo, - )? - .trim() - .to_string(); - let boundary = run_cmd_ok( - &[ - OsString::from("git"), - OsString::from("rev-parse"), - OsString::from(boundary_commit), - ], - repo, - )? - .trim() - .to_string(); - - if candidate == boundary { - return Ok(false); - } - - let out = run_cmd( - &[ - OsString::from("git"), - OsString::from("merge-base"), - OsString::from("--is-ancestor"), - OsString::from(&candidate), - OsString::from(&boundary), - ], - repo, - )?; - match out.status.code() { - Some(0) => Ok(true), - Some(1) => Ok(false), - _ => bail!( - "failed checking commit ancestry between {} and {}:\nstdout: {}\nstderr: {}", - candidate, - boundary, - String::from_utf8_lossy(&out.stdout), - String::from_utf8_lossy(&out.stderr) - ), - } -} - fn pick_unused_port() -> Result { let listener = TcpListener::bind("127.0.0.1:0")?; Ok(listener.local_addr()?.port()) @@ -389,148 +251,37 @@ fn write_line(child: &mut Child, line: &str) -> Result<()> { #[test] #[ignore = "manual local-only: long-running, networked, and builds historical artifacts"] fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { + let old_git_ref = "v1.12.0"; + let new_git_ref = "origin/master"; log_step("starting manual upgrade mixed-clients quickstart test"); - log_step(&format!( - "pinned old source ref={}, old release version={}", - V1_GIT_REF, V1_RELEASE_VERSION - )); + log_step(&format!("pinned refs: old={old_git_ref}, new={new_git_ref}")); let repo = workspace_root(); let temp = tempfile::tempdir()?; - let temp_path = temp.path(); - let old_worktree = temp_path.join("old"); - let data_dir = temp_path.join("db-data"); + let temp = temp.path(); + let old_worktree_dir = repo.join("target").join("smoketest-worktrees").join("old"); + let new_worktree_dir = repo.join("target").join("smoketest-worktrees").join("new"); + let data_dir = temp.join("db-data"); std::fs::create_dir_all(&data_dir)?; log_step(&format!("workspace={}", repo.display())); - log_step(&format!("temp root={}", temp_path.display())); log_step(&format!("data dir={}", data_dir.display())); - // Prepare current binaries (including update helper needed by `version install` from target dir). - log_step("building current spacetimedb-cli and spacetimedb-update"); - run_cmd_ok( - &[ - OsString::from("cargo"), - OsString::from("build"), - OsString::from("-p"), - OsString::from("spacetimedb-cli"), - OsString::from("-p"), - OsString::from("spacetimedb-standalone"), - OsString::from("-p"), - OsString::from("spacetimedb-update"), - ], - &repo, - )?; - - let current_cli = repo.join("target").join("debug").join(exe_name("spacetimedb-cli")); - anyhow::ensure!( - current_cli.exists(), - "current CLI binary missing at {}", - current_cli.display() - ); - - // Install a pinned 1.0 release via the system `spacetime` command. - log_step(&format!( - "installing and selecting release {} via system spacetime", - V1_RELEASE_VERSION - )); - run_cmd_ok( - &[ - OsString::from("spacetime"), - OsString::from("version"), - OsString::from("install"), - OsString::from(V1_RELEASE_VERSION), - OsString::from("--use"), - OsString::from("--yes"), - ], - &repo, - )?; - let installed_v1_cli = PathBuf::from("spacetime"); - log_step("using system 'spacetime' command as v1 CLI"); - - // Build 1.0 sources from pinned ref. - log_step(&format!("creating worktree at ref {}", V1_GIT_REF)); - run_cmd_ok( - &[ - OsString::from("git"), - OsString::from("worktree"), - OsString::from("add"), - old_worktree.clone().into_os_string(), - OsString::from(V1_GIT_REF), - ], - &repo, - )?; - - let cleanup_worktree = || { - let _ = Command::new("git") - .args(["worktree", "remove", "--force"]) - .arg(&old_worktree) - .current_dir(&repo) - .status(); - }; + let old_prepared = prepare_pinned_chat_workspace(&repo, &old_worktree_dir, old_git_ref)?; + let old_worktree = old_prepared.worktree_dir; + let old_cli = old_prepared.cli_path; + let old_client = old_prepared.client_path; + let old_module_dir = old_prepared.module_dir; + let old_publish_path_flag = old_prepared.publish_path_flag; - let old_result: Result<()> = (|| { - log_step("running v1 codegen for chat-console-rs (cli generate)"); - run_cmd_ok( - &[ - installed_v1_cli.clone().into_os_string(), - OsString::from("generate"), - OsString::from("--project-path"), - OsString::from("spacetimedb/"), - OsString::from("--out-dir"), - OsString::from("src/module_bindings/"), - OsString::from("--lang"), - OsString::from("rust"), - ], - &old_worktree.join("templates/chat-console-rs"), - )?; - - log_step("building old quickstart chat client"); - run_cmd_ok( - &[OsString::from("cargo"), OsString::from("build")], - &old_worktree.join("templates/chat-console-rs"), - )?; - - run_cmd_ok( - &[ - current_cli.clone().into_os_string(), - OsString::from("generate"), - OsString::from("--module-path"), - OsString::from("spacetimedb/"), - OsString::from("--out-dir"), - OsString::from("src/module_bindings/"), - OsString::from("--lang"), - OsString::from("rust"), - ], - &repo.join("templates/chat-console-rs"), - )?; + let new_prepared = prepare_pinned_chat_workspace(&repo, &new_worktree_dir, new_git_ref)?; + let new_worktree = new_prepared.worktree_dir; + let new_cli = new_prepared.cli_path; + let new_client = new_prepared.client_path; + let new_module_dir = new_prepared.module_dir; + let new_publish_path_flag = new_prepared.publish_path_flag; - log_step("building current quickstart chat client"); - run_cmd_ok( - &[OsString::from("cargo"), OsString::from("build")], - &repo.join("templates/chat-console-rs"), - )?; - - let old_client = old_worktree - .join("templates/chat-console-rs") - .join("target") - .join("debug") - .join(exe_name("rust-quickstart-chat")); - anyhow::ensure!( - old_client.exists(), - "old chat client not found at {}", - old_client.display() - ); - let new_client = repo - .join("templates/chat-console-rs") - .join("target") - .join("debug") - .join(exe_name("rust-quickstart-chat")); - anyhow::ensure!( - new_client.exists(), - "new chat client not found at {}", - new_client.display() - ); - - log_step(&format!("v1 CLI path={}", installed_v1_cli.display())); + let old_result: Result<()> = (|| { + log_step(&format!("v1 CLI path={}", old_cli.display())); + log_step(&format!("v2 CLI path={}", new_cli.display())); log_step(&format!("old client path={}", old_client.display())); log_step(&format!("new client path={}", new_client.display())); @@ -538,7 +289,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { let old_port = pick_unused_port()?; let old_url = format!("http://127.0.0.1:{old_port}"); log_step("starting old server for initial publish"); - let (mut old_server, old_server_logs) = spawn_server(&installed_v1_cli, &data_dir, old_port)?; + let (mut old_server, old_server_logs) = spawn_server(&old_cli, &data_dir, old_port)?; if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { dump_server_logs("old server", &old_server_logs); kill_child(&mut old_server); @@ -549,14 +300,12 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { log_step(&format!("publishing old module to db {}", db_name)); let publish_out = run_cmd_ok( &[ - installed_v1_cli.clone().into_os_string(), + old_cli.clone().into_os_string(), OsString::from("publish"), OsString::from("--server"), OsString::from(&old_url), - OsString::from("--project-path"), - old_worktree - .join("templates/chat-console-rs/spacetimedb") - .into_os_string(), + OsString::from(old_publish_path_flag), + old_module_dir.clone().into_os_string(), OsString::from("--yes"), OsString::from(&db_name), ], @@ -570,7 +319,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { let new_port = pick_unused_port()?; let new_url = format!("http://127.0.0.1:{new_port}"); log_step("starting new server on same data dir"); - let (mut new_server, new_server_logs) = spawn_server(¤t_cli, &data_dir, new_port)?; + let (mut new_server, new_server_logs) = spawn_server(&new_cli, &data_dir, new_port)?; if let Err(e) = wait_for_ping(&new_url, Duration::from_secs(20)) { dump_server_logs("new server", &new_server_logs); kill_child(&mut new_server); @@ -582,16 +331,16 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { log_step("publishing HEAD module to same database name on 2.0 server"); run_cmd_ok_with_stdin( &[ - current_cli.clone().into_os_string(), + new_cli.clone().into_os_string(), OsString::from("publish"), OsString::from("--server"), OsString::from(&new_url), - OsString::from("--module-path"), - repo.join("templates/chat-console-rs/spacetimedb").into_os_string(), + OsString::from(new_publish_path_flag), + new_module_dir.clone().into_os_string(), OsString::from("--yes"), OsString::from(&db_name), ], - &repo, + &new_worktree, "upgrade\n", )?; } @@ -601,7 +350,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { let (mut c1, logs1) = spawn_chat_client("client-v1", &old_client, &new_url, &db_name)?; let (mut c2, logs2) = spawn_chat_client("client-v2", &new_client, &new_url, &db_name)?; - thread::sleep(Duration::from_secs(5)); + thread::sleep(Duration::from_secs(2)); write_line(&mut c1, "/name old-v1")?; write_line(&mut c2, "/name new-v2")?; write_line(&mut c1, "hello-from-v1")?; @@ -643,8 +392,6 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { Ok(()) })(); - log_step("cleaning up temporary git worktree"); - cleanup_worktree(); log_step("manual test finished"); old_result } @@ -653,123 +400,25 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { #[ignore = "manual local-only: long-running, networked, and builds historical artifacts"] fn kill_after_publish_logs_after_restart() -> Result<()> { log_step("starting manual upgrade mixed-clients quickstart test"); - log_step(&format!( - "pinned old source ref={}, old release version={}", - V1_GIT_REF, V1_RELEASE_VERSION - )); + log_step(&format!("pinned old source ref={}", V1_GIT_REF)); let repo = workspace_root(); - let stable_worktree_dir = repo - .join("target") - .join("smoketest-worktrees") - .join("kill-after-publish-v1"); - let old_worktree = stable_worktree_dir; let temp = tempfile::tempdir()?; let temp_path = temp.path(); + let old_worktree_dir = temp_path.join("old"); let data_dir = temp_path.join("db-data"); std::fs::create_dir_all(&data_dir)?; log_step(&format!("workspace={}", repo.display())); log_step(&format!("temp root={}", temp_path.display())); log_step(&format!("data dir={}", data_dir.display())); - if !old_worktree.exists() { - let parent = old_worktree - .parent() - .ok_or_else(|| anyhow!("worktree path has no parent: {}", old_worktree.display()))?; - std::fs::create_dir_all(parent) - .with_context(|| format!("failed to create worktree parent {}", parent.display()))?; - log_step(&format!("creating worktree at ref {}", V1_GIT_REF)); - run_cmd_ok( - &[ - OsString::from("git"), - OsString::from("worktree"), - OsString::from("add"), - old_worktree.clone().into_os_string(), - OsString::from(V1_GIT_REF), - ], - &repo, - )?; - } else { - log_step("reusing existing worktree"); - log_step(&format!("forcing existing worktree to ref {}", V1_GIT_REF)); - - run_cmd_ok( - &[ - OsString::from("git"), - OsString::from("-C"), - old_worktree.clone().into_os_string(), - OsString::from("checkout"), - OsString::from("--force"), - OsString::from(V1_GIT_REF), - ], - &old_worktree, - )?; - } - - log_step("building current spacetimedb-cli and spacetimedb-update"); - run_cmd_ok( - &[ - OsString::from("cargo"), - OsString::from("build"), - OsString::from("-p"), - OsString::from("spacetimedb-cli"), - OsString::from("-p"), - OsString::from("spacetimedb-standalone"), - OsString::from("-p"), - OsString::from("spacetimedb-update"), - ], - &old_worktree, - )?; - - let old_cli = old_worktree.join("target").join("debug").join(exe_name("spacetimedb-cli")); - anyhow::ensure!( - old_cli.exists(), - "old CLI binary missing at {}", - old_cli.display() - ); - - let publish_path_flag = if ! is_strictly_before_commit(&repo, MODULE_PATH_FLAG_CUTOFF_COMMIT, V1_GIT_REF)? { - "--project-path" - } else { - "--module-path" - }; - log_step(&format!( - "using {} for publish path (cutoff {})", - publish_path_flag, MODULE_PATH_FLAG_CUTOFF_COMMIT - )); + let prepared = prepare_pinned_chat_workspace(&repo, &old_worktree_dir, V1_GIT_REF)?; + let old_worktree = prepared.worktree_dir; + let old_cli = prepared.cli_path; + let old_client = prepared.client_path; + let old_module_dir = prepared.module_dir; + let publish_path_flag = prepared.publish_path_flag; let old_result: Result<()> = (|| { - log_step("running v1 codegen for chat-console-rs (cli generate)"); - run_cmd_ok( - &[ - old_cli.clone().into_os_string(), - OsString::from("generate"), - OsString::from(publish_path_flag), - OsString::from("spacetimedb/"), - OsString::from("--out-dir"), - OsString::from("src/module_bindings/"), - OsString::from("--lang"), - OsString::from("rust"), - ], - &old_worktree.join("templates/chat-console-rs"), - )?; - - log_step("building old quickstart chat client"); - run_cmd_ok( - &[OsString::from("cargo"), OsString::from("build")], - &old_worktree.join("templates/chat-console-rs"), - )?; - - let old_client = old_worktree - .join("templates/chat-console-rs") - .join("target") - .join("debug") - .join(exe_name("rust-quickstart-chat")); - anyhow::ensure!( - old_client.exists(), - "old chat client not found at {}", - old_client.display() - ); - log_step(&format!("v1 CLI path={}", old_cli.display())); log_step(&format!("old client path={}", old_client.display())); @@ -793,9 +442,7 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { OsString::from("--server"), OsString::from(&old_url), OsString::from(publish_path_flag), - old_worktree - .join("templates/chat-console-rs/spacetimedb") - .into_os_string(), + old_module_dir.clone().into_os_string(), OsString::from("--yes"), OsString::from(&db_name), ], @@ -845,10 +492,7 @@ fn kill_after_publish_logs_after_restart() -> Result<()> { if !ok { let l1 = logs1.lock().unwrap().clone(); dump_server_logs("new server", &new_server_logs); - bail!( - "message exchange incomplete.\nclient-v1 logs:\n{}", - l1, - ); + bail!("message exchange incomplete.\nclient-v1 logs:\n{}", l1,); } Ok(()) From 91f1a09f563f09440d38cd83315c25680085ffc6 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 08:02:30 -0800 Subject: [PATCH 10/22] [bfops/smoketest-upgrade]: update --- .../tests/upgrade_chat_to_2_0_working.rs | 594 ++++++++++++++++++ 1 file changed, 594 insertions(+) create mode 100644 crates/smoketests/tests/upgrade_chat_to_2_0_working.rs diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs new file mode 100644 index 00000000000..eba7b85c50a --- /dev/null +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -0,0 +1,594 @@ +#![allow(clippy::disallowed_macros)] + +use std::ffi::OsString; +use std::io::{BufRead, BufReader, ErrorKind, Read, Write}; +use std::net::{TcpListener, TcpStream}; +use std::path::Path; +use std::process::{Child, Command, Output, Stdio}; +use std::sync::{Arc, Mutex}; +use std::thread; +use std::time::{Duration, Instant}; + +use anyhow::{anyhow, bail, Context, Result}; +use regex::Regex; +use spacetimedb_smoketests::workspace_root; + +// NOTE: This test is intentionally manual/local-only and not meant for CI. +// +// It validates a 1.0 -> 2.0 upgrade scenario using quickstart-chat: +// 1) build 1.0 CLI/server/client/module from this pinned git ref +// 3) start 1.0 server and publish module +// 4) restart as 2.0 server on the same data dir +// 5) run both 1.0 and 2.0 quickstart clients, exchange messages, assert both observed +const V1_GIT_REF: &str = "v1.12.0"; + +fn log_step(msg: &str) { + eprintln!("[manual-upgrade] {msg}"); +} + +fn exe_name(base: &str) -> String { + if cfg!(windows) { + format!("{base}.exe") + } else { + base.to_string() + } +} + +fn run_cmd(args: &[OsString], cwd: &Path) -> Result { + let rendered = args + .iter() + .map(|s| s.to_string_lossy().to_string()) + .collect::>() + .join(" "); + log_step(&format!("run: (cd {}) {rendered}", cwd.display())); + let mut cmd = Command::new(&args[0]); + cmd.args(&args[1..]).current_dir(cwd); + cmd.output() + .with_context(|| format!("failed to execute {:?}", args.iter().collect::>())) +} + +fn run_cmd_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { + let rendered = args + .iter() + .map(|s| s.to_string_lossy().to_string()) + .collect::>() + .join(" "); + log_step(&format!("run (stdin): (cd {}) {rendered}", cwd.display())); + + let mut cmd = Command::new(&args[0]); + cmd.args(&args[1..]) + .current_dir(cwd) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + + let mut child = cmd + .spawn() + .with_context(|| format!("failed to execute {:?}", args.iter().collect::>()))?; + { + let stdin = child.stdin.as_mut().context("missing child stdin")?; + stdin.write_all(stdin_input.as_bytes())?; + } + child + .wait_with_output() + .with_context(|| format!("failed waiting for {:?}", args.iter().collect::>())) +} + +fn run_cmd_ok(args: &[OsString], cwd: &Path) -> Result { + let out = run_cmd(args, cwd)?; + if !out.status.success() { + bail!( + "command failed: {:?}\nstdout: {}\nstderr: {}", + args, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + } + let stdout = String::from_utf8_lossy(&out.stdout).to_string(); + let stderr = String::from_utf8_lossy(&out.stderr).to_string(); + if !stdout.trim().is_empty() { + log_step(&format!("stdout:\n{}", stdout.trim())); + } + if !stderr.trim().is_empty() { + log_step(&format!("stderr:\n{}", stderr.trim())); + } + Ok(stdout) +} + +fn run_cmd_ok_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { + let out = run_cmd_with_stdin(args, cwd, stdin_input)?; + if !out.status.success() { + bail!( + "command failed: {:?}\nstdout: {}\nstderr: {}", + args, + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + } + let stdout = String::from_utf8_lossy(&out.stdout).to_string(); + let stderr = String::from_utf8_lossy(&out.stderr).to_string(); + if !stdout.trim().is_empty() { + log_step(&format!("stdout:\n{}", stdout.trim())); + } + if !stderr.trim().is_empty() { + log_step(&format!("stderr:\n{}", stderr.trim())); + } + Ok(stdout) +} + +fn pick_unused_port() -> Result { + let listener = TcpListener::bind("127.0.0.1:0")?; + Ok(listener.local_addr()?.port()) +} + +fn ping_http(server_url: &str) -> Result { + let addr = server_url + .strip_prefix("http://") + .ok_or_else(|| anyhow!("expected http:// URL, got {server_url}"))?; + let mut stream = TcpStream::connect(addr)?; + stream.set_read_timeout(Some(Duration::from_secs(2)))?; + let req = format!("GET /v1/ping HTTP/1.1\r\nHost: {addr}\r\nConnection: close\r\n\r\n"); + stream.write_all(req.as_bytes())?; + let mut body = String::new(); + stream.read_to_string(&mut body)?; + Ok(body.starts_with("HTTP/1.1 200") || body.starts_with("HTTP/1.0 200")) +} + +fn wait_for_ping(server_url: &str, timeout: Duration) -> Result<()> { + log_step(&format!("waiting for server ping at {server_url}")); + let deadline = Instant::now() + timeout; + while Instant::now() < deadline { + if ping_http(server_url).unwrap_or(false) { + log_step(&format!("server is ready at {server_url}")); + return Ok(()); + } + thread::sleep(Duration::from_millis(100)); + } + bail!("timed out waiting for {server_url}/v1/ping") +} + +fn spawn_server(cli_path: &Path, data_dir: &Path, port: u16) -> Result<(Child, Arc>)> { + let listen = format!("127.0.0.1:{port}"); + log_step(&format!( + "starting server via {} on {} using data dir {}", + cli_path.display(), + listen, + data_dir.display() + )); + let mut child = Command::new(cli_path) + .args([ + "start", + "--jwt-key-dir", + &data_dir.display().to_string(), + "--data-dir", + &data_dir.display().to_string(), + "--listen-addr", + &listen, + ]) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .with_context(|| format!("failed to start server via {}", cli_path.display()))?; + log_step(&format!("started server pid={}", child.id())); + let logs = Arc::new(Mutex::new(String::new())); + if let Some(stdout) = child.stdout.take() { + let logs_out = logs.clone(); + thread::spawn(move || { + let mut reader = BufReader::new(stdout); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + let mut s = logs_out.lock().unwrap(); + s.push_str("[stdout] "); + s.push_str(&line); + } + }); + } + if let Some(stderr) = child.stderr.take() { + let logs_err = logs.clone(); + thread::spawn(move || { + let mut reader = BufReader::new(stderr); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + let mut s = logs_err.lock().unwrap(); + s.push_str("[stderr] "); + s.push_str(&line); + } + }); + } + Ok((child, logs)) +} + +fn kill_child(child: &mut Child) { + log_step(&format!("stopping pid={}", child.id())); + #[cfg(not(windows))] + { + let _ = child.kill(); + } + #[cfg(windows)] + { + let _ = Command::new("taskkill") + .args(["/F", "/T", "/PID", &child.id().to_string()]) + .status(); + } + let _ = child.wait(); + log_step("process stopped"); +} + +fn dump_server_logs(label: &str, logs: &Arc>) { + let s = logs.lock().unwrap().clone(); + if s.trim().is_empty() { + log_step(&format!("{label} logs are empty")); + return; + } + eprintln!("[manual-upgrade] {label} logs:\n{s}"); +} + +fn extract_identity(publish_stdout: &str) -> Result { + let re = Regex::new(r"identity: ([0-9a-fA-F]+)")?; + let caps = re + .captures(publish_stdout) + .ok_or_else(|| anyhow!("failed to parse identity from publish output:\n{publish_stdout}"))?; + Ok(caps.get(1).unwrap().as_str().to_string()) +} + +fn spawn_chat_client(label: &str, bin: &Path, server_url: &str, db_name: &str) -> Result<(Child, Arc>)> { + log_step(&format!( + "starting {label} client {} (server={}, db={})", + bin.display(), + server_url, + db_name + )); + let mut child = Command::new(bin) + .env("SPACETIMEDB_HOST", server_url) + .env("SPACETIMEDB_SERVER", server_url) + .env("SPACETIMEDB_DB_NAME", db_name) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .with_context(|| format!("failed to spawn chat client {}", bin.display()))?; + log_step(&format!("started client pid={}", child.id())); + + let logs = Arc::new(Mutex::new(String::new())); + + if let Some(stdout) = child.stdout.take() { + let logs_out = logs.clone(); + let label = label.to_string(); + thread::spawn(move || { + let mut reader = BufReader::new(stdout); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + eprintln!("[{label} recv] {}", line.trim_end()); + let mut s = logs_out.lock().unwrap(); + s.push_str(&line); + } + }); + } + if let Some(stderr) = child.stderr.take() { + let logs_err = logs.clone(); + let label = label.to_string(); + thread::spawn(move || { + let mut reader = BufReader::new(stderr); + let mut line = String::new(); + loop { + line.clear(); + if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { + break; + } + eprintln!("[{label} stderr] {}", line.trim_end()); + let mut s = logs_err.lock().unwrap(); + s.push_str(&line); + } + }); + } + + Ok((child, logs)) +} + +fn write_line(child: &mut Child, line: &str) -> Result<()> { + log_step(&format!("sending to pid {}: {}", child.id(), line)); + let stdin = child.stdin.as_mut().context("child stdin missing")?; + if let Err(e) = stdin.write_all(line.as_bytes()) { + if e.kind() == ErrorKind::BrokenPipe { + log_step(&format!( + "stdin broken pipe for pid {} while sending {:?}; continuing", + child.id(), + line + )); + return Ok(()); + } + return Err(e).context("failed writing line to client stdin"); + } + if let Err(e) = stdin.write_all(b"\n") { + if e.kind() == ErrorKind::BrokenPipe { + log_step(&format!( + "stdin broken pipe for pid {} while sending newline; continuing", + child.id() + )); + return Ok(()); + } + return Err(e).context("failed writing newline to client stdin"); + } + if let Err(e) = stdin.flush() { + if e.kind() == ErrorKind::BrokenPipe { + log_step(&format!( + "stdin broken pipe for pid {} on flush; continuing", + child.id() + )); + return Ok(()); + } + return Err(e).context("failed flushing client stdin"); + } + Ok(()) +} + +#[test] +#[ignore = "manual local-only: long-running, networked, and builds historical artifacts"] +fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { + log_step("starting manual upgrade mixed-clients quickstart test"); + log_step(&format!("pinned old source ref={}", V1_GIT_REF)); + let repo = workspace_root(); + let temp = tempfile::tempdir()?; + let temp_path = temp.path(); + let old_worktree = temp_path.join("old"); + let data_dir = temp_path.join("db-data"); + std::fs::create_dir_all(&data_dir)?; + log_step(&format!("workspace={}", repo.display())); + log_step(&format!("temp root={}", temp_path.display())); + log_step(&format!("data dir={}", data_dir.display())); + + // Prepare current binaries (including update helper needed by `version install` from target dir). + log_step("building current spacetimedb-cli and spacetimedb-update"); + run_cmd_ok( + &[ + OsString::from("cargo"), + OsString::from("build"), + OsString::from("-p"), + OsString::from("spacetimedb-cli"), + OsString::from("-p"), + OsString::from("spacetimedb-standalone"), + OsString::from("-p"), + OsString::from("spacetimedb-update"), + ], + &repo, + )?; + + let current_cli = repo.join("target").join("debug").join(exe_name("spacetimedb-cli")); + anyhow::ensure!( + current_cli.exists(), + "current CLI binary missing at {}", + current_cli.display() + ); + + // Build 1.0 sources from pinned ref. + log_step(&format!("creating worktree at ref {}", V1_GIT_REF)); + run_cmd_ok( + &[ + OsString::from("git"), + OsString::from("worktree"), + OsString::from("add"), + old_worktree.clone().into_os_string(), + OsString::from(V1_GIT_REF), + ], + &repo, + )?; + + let cleanup_worktree = || { + let _ = Command::new("git") + .args(["worktree", "remove", "--force"]) + .arg(&old_worktree) + .current_dir(&repo) + .status(); + }; + + let old_result: Result<()> = (|| { + log_step("building old spacetimedb-cli and spacetimedb-standalone"); + run_cmd_ok( + &[ + OsString::from("cargo"), + OsString::from("build"), + OsString::from("-p"), + OsString::from("spacetimedb-cli"), + OsString::from("-p"), + OsString::from("spacetimedb-standalone"), + ], + &old_worktree, + )?; + let old_cli = old_worktree + .join("target") + .join("debug") + .join(exe_name("spacetimedb-cli")); + anyhow::ensure!(old_cli.exists(), "old CLI binary missing at {}", old_cli.display()); + + log_step("running v1 codegen for chat-console-rs (cli generate)"); + run_cmd_ok( + &[ + old_cli.clone().into_os_string(), + OsString::from("generate"), + OsString::from("--project-path"), + OsString::from("spacetimedb/"), + OsString::from("--out-dir"), + OsString::from("src/module_bindings/"), + OsString::from("--lang"), + OsString::from("rust"), + ], + &old_worktree.join("templates/chat-console-rs"), + )?; + + log_step("building old quickstart chat client"); + run_cmd_ok( + &[OsString::from("cargo"), OsString::from("build")], + &old_worktree.join("templates/chat-console-rs"), + )?; + + run_cmd_ok( + &[ + current_cli.clone().into_os_string(), + OsString::from("generate"), + OsString::from("--module-path"), + OsString::from("spacetimedb/"), + OsString::from("--out-dir"), + OsString::from("src/module_bindings/"), + OsString::from("--lang"), + OsString::from("rust"), + ], + &repo.join("templates/chat-console-rs"), + )?; + + log_step("building current quickstart chat client"); + run_cmd_ok( + &[OsString::from("cargo"), OsString::from("build")], + &repo.join("templates/chat-console-rs"), + )?; + + let old_client = old_worktree + .join("templates/chat-console-rs") + .join("target") + .join("debug") + .join(exe_name("rust-quickstart-chat")); + anyhow::ensure!( + old_client.exists(), + "old chat client not found at {}", + old_client.display() + ); + let new_client = repo + .join("templates/chat-console-rs") + .join("target") + .join("debug") + .join(exe_name("rust-quickstart-chat")); + anyhow::ensure!( + new_client.exists(), + "new chat client not found at {}", + new_client.display() + ); + + log_step(&format!("v1 CLI path={}", old_cli.display())); + log_step(&format!("old client path={}", old_client.display())); + log_step(&format!("new client path={}", new_client.display())); + + // Start 1.0 server and publish 1.0 quickstart module. + let old_port = pick_unused_port()?; + let old_url = format!("http://127.0.0.1:{old_port}"); + log_step("starting old server for initial publish"); + let (mut old_server, old_server_logs) = spawn_server(&old_cli, &data_dir, old_port)?; + if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { + dump_server_logs("old server", &old_server_logs); + kill_child(&mut old_server); + return Err(e); + } + + let db_name = format!("manual-upgrade-chat-{}", spacetimedb_smoketests::random_string()); + log_step(&format!("publishing old module to db {}", db_name)); + let publish_out = run_cmd_ok( + &[ + old_cli.clone().into_os_string(), + OsString::from("publish"), + OsString::from("--server"), + OsString::from(&old_url), + OsString::from("--project-path"), + old_worktree + .join("templates/chat-console-rs/spacetimedb") + .into_os_string(), + OsString::from("--yes"), + OsString::from(&db_name), + ], + &old_worktree, + )?; + let _identity = extract_identity(&publish_out)?; + log_step("old module published successfully; stopping old server"); + kill_child(&mut old_server); + + // Start 2.0 server on the same data dir. + let new_port = pick_unused_port()?; + let new_url = format!("http://127.0.0.1:{new_port}"); + log_step("starting new server on same data dir"); + let (mut new_server, new_server_logs) = spawn_server(¤t_cli, &data_dir, new_port)?; + if let Err(e) = wait_for_ping(&new_url, Duration::from_secs(20)) { + dump_server_logs("new server", &new_server_logs); + kill_child(&mut new_server); + return Err(e); + } + + let publish_new = false; + if publish_new { + log_step("publishing HEAD module to same database name on 2.0 server"); + run_cmd_ok_with_stdin( + &[ + current_cli.clone().into_os_string(), + OsString::from("publish"), + OsString::from("--server"), + OsString::from(&new_url), + OsString::from("--module-path"), + repo.join("templates/chat-console-rs/spacetimedb").into_os_string(), + OsString::from("--yes"), + OsString::from(&db_name), + ], + &repo, + "upgrade\n", + )?; + } + + // Spawn 1.0 and 2.0 quickstart clients against the upgraded 2.0 server. + log_step("starting old and new clients"); + let (mut c1, logs1) = spawn_chat_client("client-v1", &old_client, &new_url, &db_name)?; + let (mut c2, logs2) = spawn_chat_client("client-v2", &new_client, &new_url, &db_name)?; + + thread::sleep(Duration::from_secs(5)); + write_line(&mut c1, "/name old-v1")?; + write_line(&mut c2, "/name new-v2")?; + write_line(&mut c1, "hello-from-v1")?; + write_line(&mut c2, "hello-from-v2")?; + + // Both clients should observe both messages in their output. + log_step("waiting for both clients to observe both messages"); + let deadline = Instant::now() + Duration::from_secs(20); + let mut ok = false; + while Instant::now() < deadline { + let l1 = logs1.lock().unwrap().clone(); + let l2 = logs2.lock().unwrap().clone(); + let saw_v1 = l1.contains("old-v1: hello-from-v1") && l2.contains("old-v1: hello-from-v1"); + let saw_v2 = l1.contains("new-v2: hello-from-v2") && l2.contains("new-v2: hello-from-v2"); + if saw_v1 && saw_v2 { + log_step("success condition met: both clients saw both messages"); + ok = true; + break; + } + thread::sleep(Duration::from_millis(200)); + } + + log_step("stopping clients and new server"); + kill_child(&mut c1); + kill_child(&mut c2); + kill_child(&mut new_server); + + if !ok { + let l1 = logs1.lock().unwrap().clone(); + let l2 = logs2.lock().unwrap().clone(); + dump_server_logs("new server", &new_server_logs); + bail!( + "message exchange incomplete.\nclient-v1 logs:\n{}\n\nclient-v2 logs:\n{}", + l1, + l2 + ); + } + + Ok(()) + })(); + + log_step("cleaning up temporary git worktree"); + cleanup_worktree(); + log_step("manual test finished"); + old_result +} From 1f62ee964086cd5d08ba395d26c82e25d6f1a990 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 08:26:27 -0800 Subject: [PATCH 11/22] [bfops/smoketest-upgrade]: still broken in _working test --- .../tests/upgrade_chat_to_2_0_working.rs | 194 ++++-------------- .../src/module_bindings/mod.rs | 2 +- 2 files changed, 41 insertions(+), 155 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index eba7b85c50a..4e5049f1010 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -3,7 +3,7 @@ use std::ffi::OsString; use std::io::{BufRead, BufReader, ErrorKind, Read, Write}; use std::net::{TcpListener, TcpStream}; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::process::{Child, Command, Output, Stdio}; use std::sync::{Arc, Mutex}; use std::thread; @@ -13,14 +13,19 @@ use anyhow::{anyhow, bail, Context, Result}; use regex::Regex; use spacetimedb_smoketests::workspace_root; +mod test_util; +use test_util::{prepare_pinned_chat_workspace, run_cmd_ok, run_cmd_ok_with_stdin}; + // NOTE: This test is intentionally manual/local-only and not meant for CI. // // It validates a 1.0 -> 2.0 upgrade scenario using quickstart-chat: -// 1) build 1.0 CLI/server/client/module from this pinned git ref +// 1) install a 1.0 CLI via `spacetime version install` +// 2) build 1.0 server/client/module from this pinned git ref // 3) start 1.0 server and publish module // 4) restart as 2.0 server on the same data dir // 5) run both 1.0 and 2.0 quickstart clients, exchange messages, assert both observed -const V1_GIT_REF: &str = "v1.12.0"; +const V1_GIT_REF: &str = "668e56624e4525a30a85000af6a984bb5ada0372"; +const V1_RELEASE_VERSION: &str = "1.12.0"; fn log_step(msg: &str) { eprintln!("[manual-upgrade] {msg}"); @@ -34,88 +39,6 @@ fn exe_name(base: &str) -> String { } } -fn run_cmd(args: &[OsString], cwd: &Path) -> Result { - let rendered = args - .iter() - .map(|s| s.to_string_lossy().to_string()) - .collect::>() - .join(" "); - log_step(&format!("run: (cd {}) {rendered}", cwd.display())); - let mut cmd = Command::new(&args[0]); - cmd.args(&args[1..]).current_dir(cwd); - cmd.output() - .with_context(|| format!("failed to execute {:?}", args.iter().collect::>())) -} - -fn run_cmd_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { - let rendered = args - .iter() - .map(|s| s.to_string_lossy().to_string()) - .collect::>() - .join(" "); - log_step(&format!("run (stdin): (cd {}) {rendered}", cwd.display())); - - let mut cmd = Command::new(&args[0]); - cmd.args(&args[1..]) - .current_dir(cwd) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()); - - let mut child = cmd - .spawn() - .with_context(|| format!("failed to execute {:?}", args.iter().collect::>()))?; - { - let stdin = child.stdin.as_mut().context("missing child stdin")?; - stdin.write_all(stdin_input.as_bytes())?; - } - child - .wait_with_output() - .with_context(|| format!("failed waiting for {:?}", args.iter().collect::>())) -} - -fn run_cmd_ok(args: &[OsString], cwd: &Path) -> Result { - let out = run_cmd(args, cwd)?; - if !out.status.success() { - bail!( - "command failed: {:?}\nstdout: {}\nstderr: {}", - args, - String::from_utf8_lossy(&out.stdout), - String::from_utf8_lossy(&out.stderr) - ); - } - let stdout = String::from_utf8_lossy(&out.stdout).to_string(); - let stderr = String::from_utf8_lossy(&out.stderr).to_string(); - if !stdout.trim().is_empty() { - log_step(&format!("stdout:\n{}", stdout.trim())); - } - if !stderr.trim().is_empty() { - log_step(&format!("stderr:\n{}", stderr.trim())); - } - Ok(stdout) -} - -fn run_cmd_ok_with_stdin(args: &[OsString], cwd: &Path, stdin_input: &str) -> Result { - let out = run_cmd_with_stdin(args, cwd, stdin_input)?; - if !out.status.success() { - bail!( - "command failed: {:?}\nstdout: {}\nstderr: {}", - args, - String::from_utf8_lossy(&out.stdout), - String::from_utf8_lossy(&out.stderr) - ); - } - let stdout = String::from_utf8_lossy(&out.stdout).to_string(); - let stderr = String::from_utf8_lossy(&out.stderr).to_string(); - if !stdout.trim().is_empty() { - log_step(&format!("stdout:\n{}", stdout.trim())); - } - if !stderr.trim().is_empty() { - log_step(&format!("stderr:\n{}", stderr.trim())); - } - Ok(stdout) -} - fn pick_unused_port() -> Result { let listener = TcpListener::bind("127.0.0.1:0")?; Ok(listener.local_addr()?.port()) @@ -338,23 +261,34 @@ fn write_line(child: &mut Child, line: &str) -> Result<()> { #[ignore = "manual local-only: long-running, networked, and builds historical artifacts"] fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { log_step("starting manual upgrade mixed-clients quickstart test"); - log_step(&format!("pinned old source ref={}", V1_GIT_REF)); + log_step(&format!( + "pinned old source ref={}, old release version={}", + V1_GIT_REF, V1_RELEASE_VERSION + )); let repo = workspace_root(); let temp = tempfile::tempdir()?; let temp_path = temp.path(); - let old_worktree = temp_path.join("old"); + let old_worktree_dir = temp_path.join("old"); let data_dir = temp_path.join("db-data"); std::fs::create_dir_all(&data_dir)?; log_step(&format!("workspace={}", repo.display())); log_step(&format!("temp root={}", temp_path.display())); log_step(&format!("data dir={}", data_dir.display())); + let old_prepared = prepare_pinned_chat_workspace(&repo, &old_worktree_dir, V1_GIT_REF)?; + let old_worktree = old_prepared.worktree_dir; + let old_cli = old_prepared.cli_path; + let old_client = old_prepared.client_path; + let old_module_dir = old_prepared.module_dir; + let old_publish_path_flag = old_prepared.publish_path_flag; + // Prepare current binaries (including update helper needed by `version install` from target dir). log_step("building current spacetimedb-cli and spacetimedb-update"); run_cmd_ok( &[ OsString::from("cargo"), OsString::from("build"), + OsString::from("--locked"), OsString::from("-p"), OsString::from("spacetimedb-cli"), OsString::from("-p"), @@ -372,67 +306,28 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { current_cli.display() ); - // Build 1.0 sources from pinned ref. - log_step(&format!("creating worktree at ref {}", V1_GIT_REF)); + // Install a pinned 1.0 release via the system `spacetime` command. + log_step(&format!( + "installing and selecting release {} via system spacetime", + V1_RELEASE_VERSION + )); run_cmd_ok( &[ - OsString::from("git"), - OsString::from("worktree"), - OsString::from("add"), - old_worktree.clone().into_os_string(), - OsString::from(V1_GIT_REF), + OsString::from("spacetime"), + OsString::from("version"), + OsString::from("install"), + OsString::from(V1_RELEASE_VERSION), + OsString::from("--use"), + OsString::from("--yes"), ], &repo, )?; + let installed_v1_cli = PathBuf::from("spacetime"); + log_step("using system 'spacetime' command as v1 CLI"); - let cleanup_worktree = || { - let _ = Command::new("git") - .args(["worktree", "remove", "--force"]) - .arg(&old_worktree) - .current_dir(&repo) - .status(); - }; + // Build 1.0 sources from pinned ref. let old_result: Result<()> = (|| { - log_step("building old spacetimedb-cli and spacetimedb-standalone"); - run_cmd_ok( - &[ - OsString::from("cargo"), - OsString::from("build"), - OsString::from("-p"), - OsString::from("spacetimedb-cli"), - OsString::from("-p"), - OsString::from("spacetimedb-standalone"), - ], - &old_worktree, - )?; - let old_cli = old_worktree - .join("target") - .join("debug") - .join(exe_name("spacetimedb-cli")); - anyhow::ensure!(old_cli.exists(), "old CLI binary missing at {}", old_cli.display()); - - log_step("running v1 codegen for chat-console-rs (cli generate)"); - run_cmd_ok( - &[ - old_cli.clone().into_os_string(), - OsString::from("generate"), - OsString::from("--project-path"), - OsString::from("spacetimedb/"), - OsString::from("--out-dir"), - OsString::from("src/module_bindings/"), - OsString::from("--lang"), - OsString::from("rust"), - ], - &old_worktree.join("templates/chat-console-rs"), - )?; - - log_step("building old quickstart chat client"); - run_cmd_ok( - &[OsString::from("cargo"), OsString::from("build")], - &old_worktree.join("templates/chat-console-rs"), - )?; - run_cmd_ok( &[ current_cli.clone().into_os_string(), @@ -453,11 +348,6 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { &repo.join("templates/chat-console-rs"), )?; - let old_client = old_worktree - .join("templates/chat-console-rs") - .join("target") - .join("debug") - .join(exe_name("rust-quickstart-chat")); anyhow::ensure!( old_client.exists(), "old chat client not found at {}", @@ -474,7 +364,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { new_client.display() ); - log_step(&format!("v1 CLI path={}", old_cli.display())); + log_step(&format!("v1 CLI path={}", installed_v1_cli.display())); log_step(&format!("old client path={}", old_client.display())); log_step(&format!("new client path={}", new_client.display())); @@ -482,7 +372,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { let old_port = pick_unused_port()?; let old_url = format!("http://127.0.0.1:{old_port}"); log_step("starting old server for initial publish"); - let (mut old_server, old_server_logs) = spawn_server(&old_cli, &data_dir, old_port)?; + let (mut old_server, old_server_logs) = spawn_server(&installed_v1_cli, &data_dir, old_port)?; if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { dump_server_logs("old server", &old_server_logs); kill_child(&mut old_server); @@ -493,14 +383,12 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { log_step(&format!("publishing old module to db {}", db_name)); let publish_out = run_cmd_ok( &[ - old_cli.clone().into_os_string(), + installed_v1_cli.clone().into_os_string(), OsString::from("publish"), OsString::from("--server"), OsString::from(&old_url), - OsString::from("--project-path"), - old_worktree - .join("templates/chat-console-rs/spacetimedb") - .into_os_string(), + OsString::from(old_publish_path_flag), + old_module_dir.into_os_string(), OsString::from("--yes"), OsString::from(&db_name), ], @@ -587,8 +475,6 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { Ok(()) })(); - log_step("cleaning up temporary git worktree"); - cleanup_worktree(); log_step("manual test finished"); old_result } diff --git a/templates/chat-console-rs/src/module_bindings/mod.rs b/templates/chat-console-rs/src/module_bindings/mod.rs index effda19d611..2c04240b865 100644 --- a/templates/chat-console-rs/src/module_bindings/mod.rs +++ b/templates/chat-console-rs/src/module_bindings/mod.rs @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 2.0.0 (commit 08ff1e1c119b17c9c747f2dd486b4d4a9ea9f6b8). +// This was generated using spacetimedb cli version 2.0.0 (commit d9a0774bbc71751c95ae40e1c298c2bfd967be00). #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; From a108354ba708c761abd67d29e62c6d42d45c3f9f Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 08:35:06 -0800 Subject: [PATCH 12/22] [bfops/smoketest-upgrade]: still broken in _working --- crates/smoketests/tests/upgrade_chat_to_2_0_working.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index 4e5049f1010..7c5c01f0531 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -268,7 +268,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { let repo = workspace_root(); let temp = tempfile::tempdir()?; let temp_path = temp.path(); - let old_worktree_dir = temp_path.join("old"); + let old_worktree_dir = repo.join("target").join("smoketest-worktrees").join("old"); let data_dir = temp_path.join("db-data"); std::fs::create_dir_all(&data_dir)?; log_step(&format!("workspace={}", repo.display())); From 109678724ad23ac1779fdab50c5266c3af31cf78 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 08:36:11 -0800 Subject: [PATCH 13/22] [bfops/smoketest-upgrade]: do not upgrade server --- crates/smoketests/tests/upgrade_chat_to_2_0_working.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index 7c5c01f0531..4d0b1d15a35 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -4,7 +4,7 @@ use std::ffi::OsString; use std::io::{BufRead, BufReader, ErrorKind, Read, Write}; use std::net::{TcpListener, TcpStream}; use std::path::{Path, PathBuf}; -use std::process::{Child, Command, Output, Stdio}; +use std::process::{Child, Command, Stdio}; use std::sync::{Arc, Mutex}; use std::thread; use std::time::{Duration, Instant}; @@ -402,7 +402,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { let new_port = pick_unused_port()?; let new_url = format!("http://127.0.0.1:{new_port}"); log_step("starting new server on same data dir"); - let (mut new_server, new_server_logs) = spawn_server(¤t_cli, &data_dir, new_port)?; + let (mut new_server, new_server_logs) = spawn_server(&installed_v1_cli, &data_dir, new_port)?; if let Err(e) = wait_for_ping(&new_url, Duration::from_secs(20)) { dump_server_logs("new server", &new_server_logs); kill_child(&mut new_server); From e9436d4751b7a22564af32ccf2d58c2b27068f18 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 08:37:47 -0800 Subject: [PATCH 14/22] [bfops/smoketest-upgrade]: still broken --- .../tests/upgrade_chat_to_2_0_working.rs | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index 4d0b1d15a35..43ee11efcce 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -428,16 +428,13 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { )?; } - // Spawn 1.0 and 2.0 quickstart clients against the upgraded 2.0 server. - log_step("starting old and new clients"); + // Spawn 1.0 quickstart client against the upgraded 2.0 server. + log_step("starting old client"); let (mut c1, logs1) = spawn_chat_client("client-v1", &old_client, &new_url, &db_name)?; - let (mut c2, logs2) = spawn_chat_client("client-v2", &new_client, &new_url, &db_name)?; thread::sleep(Duration::from_secs(5)); write_line(&mut c1, "/name old-v1")?; - write_line(&mut c2, "/name new-v2")?; write_line(&mut c1, "hello-from-v1")?; - write_line(&mut c2, "hello-from-v2")?; // Both clients should observe both messages in their output. log_step("waiting for both clients to observe both messages"); @@ -445,10 +442,8 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { let mut ok = false; while Instant::now() < deadline { let l1 = logs1.lock().unwrap().clone(); - let l2 = logs2.lock().unwrap().clone(); - let saw_v1 = l1.contains("old-v1: hello-from-v1") && l2.contains("old-v1: hello-from-v1"); - let saw_v2 = l1.contains("new-v2: hello-from-v2") && l2.contains("new-v2: hello-from-v2"); - if saw_v1 && saw_v2 { + let saw_v1 = l1.contains("old-v1: hello-from-v1"); + if saw_v1 { log_step("success condition met: both clients saw both messages"); ok = true; break; @@ -458,18 +453,12 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { log_step("stopping clients and new server"); kill_child(&mut c1); - kill_child(&mut c2); kill_child(&mut new_server); if !ok { let l1 = logs1.lock().unwrap().clone(); - let l2 = logs2.lock().unwrap().clone(); dump_server_logs("new server", &new_server_logs); - bail!( - "message exchange incomplete.\nclient-v1 logs:\n{}\n\nclient-v2 logs:\n{}", - l1, - l2 - ); + bail!("message exchange incomplete.\nclient-v1 logs:\n{}", l1,); } Ok(()) From 2316fec1f3ec6bb8412bd657f49aaff593ce93a0 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 08:40:36 -0800 Subject: [PATCH 15/22] [bfops/smoketest-upgrade]: still broken --- .../tests/upgrade_chat_to_2_0_working.rs | 57 ------------------- 1 file changed, 57 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index 43ee11efcce..e546bd77997 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -299,13 +299,6 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { &repo, )?; - let current_cli = repo.join("target").join("debug").join(exe_name("spacetimedb-cli")); - anyhow::ensure!( - current_cli.exists(), - "current CLI binary missing at {}", - current_cli.display() - ); - // Install a pinned 1.0 release via the system `spacetime` command. log_step(&format!( "installing and selecting release {} via system spacetime", @@ -328,45 +321,14 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { // Build 1.0 sources from pinned ref. let old_result: Result<()> = (|| { - run_cmd_ok( - &[ - current_cli.clone().into_os_string(), - OsString::from("generate"), - OsString::from("--module-path"), - OsString::from("spacetimedb/"), - OsString::from("--out-dir"), - OsString::from("src/module_bindings/"), - OsString::from("--lang"), - OsString::from("rust"), - ], - &repo.join("templates/chat-console-rs"), - )?; - - log_step("building current quickstart chat client"); - run_cmd_ok( - &[OsString::from("cargo"), OsString::from("build")], - &repo.join("templates/chat-console-rs"), - )?; - anyhow::ensure!( old_client.exists(), "old chat client not found at {}", old_client.display() ); - let new_client = repo - .join("templates/chat-console-rs") - .join("target") - .join("debug") - .join(exe_name("rust-quickstart-chat")); - anyhow::ensure!( - new_client.exists(), - "new chat client not found at {}", - new_client.display() - ); log_step(&format!("v1 CLI path={}", installed_v1_cli.display())); log_step(&format!("old client path={}", old_client.display())); - log_step(&format!("new client path={}", new_client.display())); // Start 1.0 server and publish 1.0 quickstart module. let old_port = pick_unused_port()?; @@ -409,25 +371,6 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { return Err(e); } - let publish_new = false; - if publish_new { - log_step("publishing HEAD module to same database name on 2.0 server"); - run_cmd_ok_with_stdin( - &[ - current_cli.clone().into_os_string(), - OsString::from("publish"), - OsString::from("--server"), - OsString::from(&new_url), - OsString::from("--module-path"), - repo.join("templates/chat-console-rs/spacetimedb").into_os_string(), - OsString::from("--yes"), - OsString::from(&db_name), - ], - &repo, - "upgrade\n", - )?; - } - // Spawn 1.0 quickstart client against the upgraded 2.0 server. log_step("starting old client"); let (mut c1, logs1) = spawn_chat_client("client-v1", &old_client, &new_url, &db_name)?; From 64f5db72c9217e9a2db1f8bdf29e57103e344b2a Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 09:10:34 -0800 Subject: [PATCH 16/22] [bfops/smoketest-upgrade]: still broken --- .../tests/upgrade_chat_to_2_0_working.rs | 139 +++++++----------- 1 file changed, 56 insertions(+), 83 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index e546bd77997..6a056acad57 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -320,93 +320,66 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { // Build 1.0 sources from pinned ref. - let old_result: Result<()> = (|| { - anyhow::ensure!( - old_client.exists(), - "old chat client not found at {}", - old_client.display() - ); - - log_step(&format!("v1 CLI path={}", installed_v1_cli.display())); - log_step(&format!("old client path={}", old_client.display())); - - // Start 1.0 server and publish 1.0 quickstart module. - let old_port = pick_unused_port()?; - let old_url = format!("http://127.0.0.1:{old_port}"); - log_step("starting old server for initial publish"); - let (mut old_server, old_server_logs) = spawn_server(&installed_v1_cli, &data_dir, old_port)?; - if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { - dump_server_logs("old server", &old_server_logs); - kill_child(&mut old_server); - return Err(e); - } - - let db_name = format!("manual-upgrade-chat-{}", spacetimedb_smoketests::random_string()); - log_step(&format!("publishing old module to db {}", db_name)); - let publish_out = run_cmd_ok( - &[ - installed_v1_cli.clone().into_os_string(), - OsString::from("publish"), - OsString::from("--server"), - OsString::from(&old_url), - OsString::from(old_publish_path_flag), - old_module_dir.into_os_string(), - OsString::from("--yes"), - OsString::from(&db_name), - ], - &old_worktree, - )?; - let _identity = extract_identity(&publish_out)?; - log_step("old module published successfully; stopping old server"); + log_step(&format!("v1 CLI path={}", installed_v1_cli.display())); + log_step(&format!("old client path={}", old_client.display())); + + // Start 1.0 server and publish 1.0 quickstart module. + let old_port = pick_unused_port()?; + let old_url = format!("http://127.0.0.1:{old_port}"); + log_step("starting old server for initial publish"); + let (mut old_server, old_server_logs) = spawn_server(&installed_v1_cli, &data_dir, old_port)?; + if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { + dump_server_logs("old server", &old_server_logs); kill_child(&mut old_server); + return Err(e); + } - // Start 2.0 server on the same data dir. - let new_port = pick_unused_port()?; - let new_url = format!("http://127.0.0.1:{new_port}"); - log_step("starting new server on same data dir"); - let (mut new_server, new_server_logs) = spawn_server(&installed_v1_cli, &data_dir, new_port)?; - if let Err(e) = wait_for_ping(&new_url, Duration::from_secs(20)) { - dump_server_logs("new server", &new_server_logs); - kill_child(&mut new_server); - return Err(e); - } - - // Spawn 1.0 quickstart client against the upgraded 2.0 server. - log_step("starting old client"); - let (mut c1, logs1) = spawn_chat_client("client-v1", &old_client, &new_url, &db_name)?; - - thread::sleep(Duration::from_secs(5)); - write_line(&mut c1, "/name old-v1")?; - write_line(&mut c1, "hello-from-v1")?; - - // Both clients should observe both messages in their output. - log_step("waiting for both clients to observe both messages"); - let deadline = Instant::now() + Duration::from_secs(20); - let mut ok = false; - while Instant::now() < deadline { - let l1 = logs1.lock().unwrap().clone(); - let saw_v1 = l1.contains("old-v1: hello-from-v1"); - if saw_v1 { - log_step("success condition met: both clients saw both messages"); - ok = true; - break; - } - thread::sleep(Duration::from_millis(200)); - } - - log_step("stopping clients and new server"); - kill_child(&mut c1); + let db_name = format!("manual-upgrade-chat-{}", spacetimedb_smoketests::random_string()); + log_step(&format!("publishing old module to db {}", db_name)); + let publish_out = run_cmd_ok( + &[ + installed_v1_cli.clone().into_os_string(), + OsString::from("publish"), + OsString::from("--server"), + OsString::from(&old_url), + OsString::from(old_publish_path_flag), + old_module_dir.into_os_string(), + OsString::from("--yes"), + OsString::from(&db_name), + ], + &old_worktree, + )?; + let _identity = extract_identity(&publish_out)?; + log_step("old module published successfully; stopping old server"); + kill_child(&mut old_server); + + // Start 2.0 server on the same data dir. + log_step("starting new server on same data dir"); + let (mut new_server, new_server_logs) = spawn_server(&installed_v1_cli, &data_dir, old_port)?; + if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { + dump_server_logs("new server", &new_server_logs); kill_child(&mut new_server); + return Err(e); + } - if !ok { - let l1 = logs1.lock().unwrap().clone(); - dump_server_logs("new server", &new_server_logs); - bail!("message exchange incomplete.\nclient-v1 logs:\n{}", l1,); - } + let result = run_cmd_ok( + &[ + installed_v1_cli.clone().into_os_string(), + OsString::from("logs"), + OsString::from("--server"), + OsString::from(&old_url), + OsString::from(&db_name), + ], + &old_worktree, + ); - Ok(()) - })(); + log_step("stopping server"); + kill_child(&mut new_server); - log_step("manual test finished"); - old_result + if !result.is_ok() { + dump_server_logs("new server", &new_server_logs); + } + + let _ = result?; + Ok(()) } From b9703948cab6257812f221f3a638fb8160563976 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 09:13:33 -0800 Subject: [PATCH 17/22] [bfops/smoketest-upgrade]: slimmer --- .../tests/upgrade_chat_to_2_0_working.rs | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index 6a056acad57..96221ab3c43 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -14,7 +14,7 @@ use regex::Regex; use spacetimedb_smoketests::workspace_root; mod test_util; -use test_util::{prepare_pinned_chat_workspace, run_cmd_ok, run_cmd_ok_with_stdin}; +use test_util::{prepare_pinned_chat_workspace, run_cmd_ok}; // NOTE: This test is intentionally manual/local-only and not meant for CI. // @@ -39,11 +39,6 @@ fn exe_name(base: &str) -> String { } } -fn pick_unused_port() -> Result { - let listener = TcpListener::bind("127.0.0.1:0")?; - Ok(listener.local_addr()?.port()) -} - fn ping_http(server_url: &str) -> Result { let addr = server_url .strip_prefix("http://") @@ -70,8 +65,8 @@ fn wait_for_ping(server_url: &str, timeout: Duration) -> Result<()> { bail!("timed out waiting for {server_url}/v1/ping") } -fn spawn_server(cli_path: &Path, data_dir: &Path, port: u16) -> Result<(Child, Arc>)> { - let listen = format!("127.0.0.1:{port}"); +fn spawn_server(cli_path: &Path, data_dir: &Path) -> Result<(Child, Arc>)> { + let listen = format!("127.0.0.1:3000"); log_step(&format!( "starting server via {} on {} using data dir {}", cli_path.display(), @@ -282,23 +277,6 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { let old_module_dir = old_prepared.module_dir; let old_publish_path_flag = old_prepared.publish_path_flag; - // Prepare current binaries (including update helper needed by `version install` from target dir). - log_step("building current spacetimedb-cli and spacetimedb-update"); - run_cmd_ok( - &[ - OsString::from("cargo"), - OsString::from("build"), - OsString::from("--locked"), - OsString::from("-p"), - OsString::from("spacetimedb-cli"), - OsString::from("-p"), - OsString::from("spacetimedb-standalone"), - OsString::from("-p"), - OsString::from("spacetimedb-update"), - ], - &repo, - )?; - // Install a pinned 1.0 release via the system `spacetime` command. log_step(&format!( "installing and selecting release {} via system spacetime", @@ -324,10 +302,9 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { log_step(&format!("old client path={}", old_client.display())); // Start 1.0 server and publish 1.0 quickstart module. - let old_port = pick_unused_port()?; - let old_url = format!("http://127.0.0.1:{old_port}"); + let old_url = format!("http://127.0.0.1:3000"); log_step("starting old server for initial publish"); - let (mut old_server, old_server_logs) = spawn_server(&installed_v1_cli, &data_dir, old_port)?; + let (mut old_server, old_server_logs) = spawn_server(&installed_v1_cli, &data_dir)?; if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { dump_server_logs("old server", &old_server_logs); kill_child(&mut old_server); @@ -355,7 +332,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { // Start 2.0 server on the same data dir. log_step("starting new server on same data dir"); - let (mut new_server, new_server_logs) = spawn_server(&installed_v1_cli, &data_dir, old_port)?; + let (mut new_server, new_server_logs) = spawn_server(&installed_v1_cli, &data_dir)?; if let Err(e) = wait_for_ping(&old_url, Duration::from_secs(20)) { dump_server_logs("new server", &new_server_logs); kill_child(&mut new_server); From 33584cbf4a79d8e055ef0c084046e3744f1642e5 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 09:17:08 -0800 Subject: [PATCH 18/22] [bfops/smoketest-upgrade]: slimmer --- .../tests/upgrade_chat_to_2_0_working.rs | 95 ------------------- 1 file changed, 95 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index 96221ab3c43..838d97e09e7 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -157,101 +157,6 @@ fn extract_identity(publish_stdout: &str) -> Result { Ok(caps.get(1).unwrap().as_str().to_string()) } -fn spawn_chat_client(label: &str, bin: &Path, server_url: &str, db_name: &str) -> Result<(Child, Arc>)> { - log_step(&format!( - "starting {label} client {} (server={}, db={})", - bin.display(), - server_url, - db_name - )); - let mut child = Command::new(bin) - .env("SPACETIMEDB_HOST", server_url) - .env("SPACETIMEDB_SERVER", server_url) - .env("SPACETIMEDB_DB_NAME", db_name) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .with_context(|| format!("failed to spawn chat client {}", bin.display()))?; - log_step(&format!("started client pid={}", child.id())); - - let logs = Arc::new(Mutex::new(String::new())); - - if let Some(stdout) = child.stdout.take() { - let logs_out = logs.clone(); - let label = label.to_string(); - thread::spawn(move || { - let mut reader = BufReader::new(stdout); - let mut line = String::new(); - loop { - line.clear(); - if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { - break; - } - eprintln!("[{label} recv] {}", line.trim_end()); - let mut s = logs_out.lock().unwrap(); - s.push_str(&line); - } - }); - } - if let Some(stderr) = child.stderr.take() { - let logs_err = logs.clone(); - let label = label.to_string(); - thread::spawn(move || { - let mut reader = BufReader::new(stderr); - let mut line = String::new(); - loop { - line.clear(); - if reader.read_line(&mut line).ok().filter(|n| *n > 0).is_none() { - break; - } - eprintln!("[{label} stderr] {}", line.trim_end()); - let mut s = logs_err.lock().unwrap(); - s.push_str(&line); - } - }); - } - - Ok((child, logs)) -} - -fn write_line(child: &mut Child, line: &str) -> Result<()> { - log_step(&format!("sending to pid {}: {}", child.id(), line)); - let stdin = child.stdin.as_mut().context("child stdin missing")?; - if let Err(e) = stdin.write_all(line.as_bytes()) { - if e.kind() == ErrorKind::BrokenPipe { - log_step(&format!( - "stdin broken pipe for pid {} while sending {:?}; continuing", - child.id(), - line - )); - return Ok(()); - } - return Err(e).context("failed writing line to client stdin"); - } - if let Err(e) = stdin.write_all(b"\n") { - if e.kind() == ErrorKind::BrokenPipe { - log_step(&format!( - "stdin broken pipe for pid {} while sending newline; continuing", - child.id() - )); - return Ok(()); - } - return Err(e).context("failed writing newline to client stdin"); - } - if let Err(e) = stdin.flush() { - if e.kind() == ErrorKind::BrokenPipe { - log_step(&format!( - "stdin broken pipe for pid {} on flush; continuing", - child.id() - )); - return Ok(()); - } - return Err(e).context("failed flushing client stdin"); - } - Ok(()) -} - #[test] #[ignore = "manual local-only: long-running, networked, and builds historical artifacts"] fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { From debe6c36d992f41602a3e6f70c6c0d5683b6e1c7 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 09:20:46 -0800 Subject: [PATCH 19/22] [bfops/smoketest-upgrade]: clean --- crates/smoketests/tests/upgrade_chat_to_2_0_working.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index 838d97e09e7..e2cabbbb75b 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -31,14 +31,6 @@ fn log_step(msg: &str) { eprintln!("[manual-upgrade] {msg}"); } -fn exe_name(base: &str) -> String { - if cfg!(windows) { - format!("{base}.exe") - } else { - base.to_string() - } -} - fn ping_http(server_url: &str) -> Result { let addr = server_url .strip_prefix("http://") From bf0611ced7bf8e5302741d485c4dcfd6a33cfc30 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 09:21:34 -0800 Subject: [PATCH 20/22] [bfops/smoketest-upgrade]: [bfops/smoketest-upgrade]: optional client build --- crates/smoketests/tests/test_util.rs | 58 +++++++++++-------- .../tests/upgrade_chat_to_2_0_working.rs | 6 +- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/crates/smoketests/tests/test_util.rs b/crates/smoketests/tests/test_util.rs index 89ab10907e2..ce665fa2235 100644 --- a/crates/smoketests/tests/test_util.rs +++ b/crates/smoketests/tests/test_util.rs @@ -10,7 +10,7 @@ const MODULE_PATH_FLAG_CUTOFF_COMMIT: &str = "4c962b9170c577b6e6c7afeecf05a60635 pub struct PreparedChatWorkspace { pub worktree_dir: PathBuf, pub cli_path: PathBuf, - pub client_path: PathBuf, + pub client_path: Option, pub module_dir: PathBuf, pub publish_path_flag: &'static str, } @@ -154,6 +154,7 @@ pub fn prepare_pinned_chat_workspace( workspace_dir: &Path, worktree_dir: &Path, git_ref: &str, + build_client: bool, ) -> Result { if !worktree_dir.exists() { let parent = worktree_dir @@ -212,31 +213,38 @@ pub fn prepare_pinned_chat_workspace( } else { "--project-path" }; - let chat_client_dir = worktree_dir.join("templates/chat-console-rs"); - run_cmd_ok( - &[ - cli_path.clone().into_os_string(), - OsString::from("generate"), - OsString::from(publish_path_flag), - OsString::from("spacetimedb/"), - OsString::from("--out-dir"), - OsString::from("src/module_bindings/"), - OsString::from("--lang"), - OsString::from("rust"), - ], - &chat_client_dir, - )?; - run_cmd_ok(&[OsString::from("cargo"), OsString::from("build")], &chat_client_dir)?; - let client_path = chat_client_dir - .join("target") - .join("debug") - .join(exe_name("rust-quickstart-chat")); - anyhow::ensure!( - client_path.exists(), - "pinned chat client not found at {}", - client_path.display() - ); + let client_path: Option; + if build_client { + let chat_client_dir = worktree_dir.join("templates/chat-console-rs"); + run_cmd_ok( + &[ + cli_path.clone().into_os_string(), + OsString::from("generate"), + OsString::from(publish_path_flag), + OsString::from("spacetimedb/"), + OsString::from("--out-dir"), + OsString::from("src/module_bindings/"), + OsString::from("--lang"), + OsString::from("rust"), + ], + &chat_client_dir, + )?; + run_cmd_ok(&[OsString::from("cargo"), OsString::from("build")], &chat_client_dir)?; + + let the_client_path = chat_client_dir + .join("target") + .join("debug") + .join(exe_name("rust-quickstart-chat")); + anyhow::ensure!( + the_client_path.exists(), + "pinned chat client not found at {}", + the_client_path.display() + ); + client_path = Some(the_client_path); + } else { + client_path = None; + } Ok(PreparedChatWorkspace { worktree_dir: worktree_dir.to_path_buf(), diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index e2cabbbb75b..b7bc4883caf 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -24,7 +24,7 @@ use test_util::{prepare_pinned_chat_workspace, run_cmd_ok}; // 3) start 1.0 server and publish module // 4) restart as 2.0 server on the same data dir // 5) run both 1.0 and 2.0 quickstart clients, exchange messages, assert both observed -const V1_GIT_REF: &str = "668e56624e4525a30a85000af6a984bb5ada0372"; +const V1_GIT_REF: &str = "4fdb8d923f39ed592931ad4c7e6391ed99b9fe3a"; const V1_RELEASE_VERSION: &str = "1.12.0"; fn log_step(msg: &str) { @@ -167,10 +167,9 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { log_step(&format!("temp root={}", temp_path.display())); log_step(&format!("data dir={}", data_dir.display())); - let old_prepared = prepare_pinned_chat_workspace(&repo, &old_worktree_dir, V1_GIT_REF)?; + let old_prepared = prepare_pinned_chat_workspace(&repo, &old_worktree_dir, V1_GIT_REF, false)?; let old_worktree = old_prepared.worktree_dir; let old_cli = old_prepared.cli_path; - let old_client = old_prepared.client_path; let old_module_dir = old_prepared.module_dir; let old_publish_path_flag = old_prepared.publish_path_flag; @@ -196,7 +195,6 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { // Build 1.0 sources from pinned ref. log_step(&format!("v1 CLI path={}", installed_v1_cli.display())); - log_step(&format!("old client path={}", old_client.display())); // Start 1.0 server and publish 1.0 quickstart module. let old_url = format!("http://127.0.0.1:3000"); From d9a249a264ed73740f44994a3985e46c3c4ab229 Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 09:30:20 -0800 Subject: [PATCH 21/22] [bfops/smoketest-upgrade]: simplify --- .../tests/upgrade_chat_to_2_0_working.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index b7bc4883caf..866fe16cd9a 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -58,23 +58,13 @@ fn wait_for_ping(server_url: &str, timeout: Duration) -> Result<()> { } fn spawn_server(cli_path: &Path, data_dir: &Path) -> Result<(Child, Arc>)> { - let listen = format!("127.0.0.1:3000"); log_step(&format!( - "starting server via {} on {} using data dir {}", + "starting server via {} using data dir {}", cli_path.display(), - listen, data_dir.display() )); let mut child = Command::new(cli_path) - .args([ - "start", - "--jwt-key-dir", - &data_dir.display().to_string(), - "--data-dir", - &data_dir.display().to_string(), - "--listen-addr", - &listen, - ]) + .args(["start"]) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn() @@ -206,7 +196,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { return Err(e); } - let db_name = format!("manual-upgrade-chat-{}", spacetimedb_smoketests::random_string()); + let db_name = "quickstart-chat"; log_step(&format!("publishing old module to db {}", db_name)); let publish_out = run_cmd_ok( &[ @@ -216,7 +206,6 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { OsString::from(&old_url), OsString::from(old_publish_path_flag), old_module_dir.into_os_string(), - OsString::from("--yes"), OsString::from(&db_name), ], &old_worktree, From 4537ef78b9e2a7a701efa2eefb451f73ac1900ab Mon Sep 17 00:00:00 2001 From: Zeke Foppa Date: Wed, 18 Feb 2026 11:22:20 -0800 Subject: [PATCH 22/22] [bfops/smoketest-upgrade]: WIP --- crates/smoketests/tests/test_util.rs | 3 ++- .../tests/upgrade_chat_to_2_0_working.rs | 18 +----------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/crates/smoketests/tests/test_util.rs b/crates/smoketests/tests/test_util.rs index ce665fa2235..eca3712c818 100644 --- a/crates/smoketests/tests/test_util.rs +++ b/crates/smoketests/tests/test_util.rs @@ -190,6 +190,7 @@ pub fn prepare_pinned_chat_workspace( &[ OsString::from("cargo"), OsString::from("build"), + OsString::from("--release"), OsString::from("-p"), OsString::from("spacetimedb-cli"), OsString::from("-p"), @@ -200,7 +201,7 @@ pub fn prepare_pinned_chat_workspace( let cli_path = worktree_dir .join("target") - .join("debug") + .join("release") .join(exe_name("spacetimedb-cli")); anyhow::ensure!( cli_path.exists(), diff --git a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs index 866fe16cd9a..ee38622f4b4 100644 --- a/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs +++ b/crates/smoketests/tests/upgrade_chat_to_2_0_working.rs @@ -164,23 +164,7 @@ fn upgrade_chat_to_2_0_mixed_clients() -> Result<()> { let old_publish_path_flag = old_prepared.publish_path_flag; // Install a pinned 1.0 release via the system `spacetime` command. - log_step(&format!( - "installing and selecting release {} via system spacetime", - V1_RELEASE_VERSION - )); - run_cmd_ok( - &[ - OsString::from("spacetime"), - OsString::from("version"), - OsString::from("install"), - OsString::from(V1_RELEASE_VERSION), - OsString::from("--use"), - OsString::from("--yes"), - ], - &repo, - )?; - let installed_v1_cli = PathBuf::from("spacetime"); - log_step("using system 'spacetime' command as v1 CLI"); + let installed_v1_cli = old_cli; // Build 1.0 sources from pinned ref.