From 5852e826a4a1b9a85631f680b4031f94725c5e74 Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Mon, 31 Mar 2025 21:25:21 -0700 Subject: [PATCH] fix(pegboard): fix manager tests --- Cargo.lock | 10 ++++++++ packages/edge/infra/client/echo/Dockerfile | 3 +-- packages/edge/infra/client/manager/src/ctx.rs | 2 +- .../edge/infra/client/manager/tests/common.rs | 25 ++++++------------- .../manager/tests/container_lifecycle.rs | 10 ++++---- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47e0954098..f364281269 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8840,6 +8840,15 @@ dependencies = [ "libc", ] +[[package]] +name = "lz4_flex" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" +dependencies = [ + "twox-hash", +] + [[package]] name = "lzma-rs" version = "0.3.0" @@ -12669,6 +12678,7 @@ dependencies = [ "hyper 0.14.31", "hyper-tls 0.5.0", "lazy_static", + "lz4_flex", "redis", "reqwest 0.11.27", "rivet-config", diff --git a/packages/edge/infra/client/echo/Dockerfile b/packages/edge/infra/client/echo/Dockerfile index c6a0198457..d7e9dce650 100644 --- a/packages/edge/infra/client/echo/Dockerfile +++ b/packages/edge/infra/client/echo/Dockerfile @@ -5,8 +5,7 @@ COPY . . RUN \ --mount=type=cache,target=/root/.cargo/git \ --mount=type=cache,target=/root/.cargo/registry \ - --mount=type=cache,target=/app/packages/infra/client/target \ - cd packages/infra/client && \ + --mount=type=cache,target=/app/target \ RUSTFLAGS="--cfg tokio_unstable" cargo build --release --bin pegboard-echo-server && \ mkdir -p /app/dist && \ mv /app/target/x86_64-unknown-linux-musl/release/pegboard-echo-server /app/dist/pegboard-echo-server diff --git a/packages/edge/infra/client/manager/src/ctx.rs b/packages/edge/infra/client/manager/src/ctx.rs index 45653bf9f4..e80da558ce 100644 --- a/packages/edge/infra/client/manager/src/ctx.rs +++ b/packages/edge/infra/client/manager/src/ctx.rs @@ -846,7 +846,7 @@ impl Ctx { // Test bindings #[cfg(feature = "test")] impl Ctx { - pub fn actors(&self) -> &RwLock>> { + pub fn actors(&self) -> &RwLock>> { &self.actors } } diff --git a/packages/edge/infra/client/manager/tests/common.rs b/packages/edge/infra/client/manager/tests/common.rs index 76d550b17b..b46311d3f0 100644 --- a/packages/edge/infra/client/manager/tests/common.rs +++ b/packages/edge/infra/client/manager/tests/common.rs @@ -72,6 +72,7 @@ pub async fn start_echo_actor( ) { let cmd = protocol::Command::StartActor { actor_id, + generation: 0, config: Box::new(protocol::ActorConfig { image: protocol::Image { id: Uuid::nil(), @@ -101,10 +102,6 @@ pub async fn start_echo_actor( memory_max: 15 * 1024 * 1024, disk: 15, }, - owner: protocol::ActorOwner::DynamicServer { - server_id: actor_id, - workflow_id: Uuid::new_v4(), - }, metadata: protocol::Raw::new(&protocol::ActorMetadata { actor: protocol::ActorMetadataActor { actor_id, @@ -131,6 +128,7 @@ pub async fn start_echo_actor( build: protocol::ActorMetadataBuild { build_id: Uuid::nil(), }, + network: None, }) .unwrap(), }), @@ -145,6 +143,7 @@ pub async fn start_js_echo_actor( ) { let cmd = protocol::Command::StartActor { actor_id, + generation: 0, config: Box::new(protocol::ActorConfig { image: protocol::Image { id: Uuid::nil(), @@ -172,10 +171,6 @@ pub async fn start_js_echo_actor( memory_max: 15 * 1024 * 1024, disk: 15, }, - owner: protocol::ActorOwner::DynamicServer { - server_id: actor_id, - workflow_id: Uuid::new_v4(), - }, metadata: protocol::Raw::new(&protocol::ActorMetadata { actor: protocol::ActorMetadataActor { actor_id, @@ -202,6 +197,7 @@ pub async fn start_js_echo_actor( build: protocol::ActorMetadataBuild { build_id: Uuid::nil(), }, + network: None, }) .unwrap(), }), @@ -262,8 +258,7 @@ pub async fn init_client(gen_path: &Path, working_path: &Path) -> Config { data_dir: Some(working_path.to_path_buf()), cluster: Cluster { client_id: Uuid::new_v4(), - datacenter_id: Uuid::new_v4(), - pegboard_endpoint: Url::parse("ws://127.0.0.1:5030").unwrap(), + ws_addresses: Addresses::Static(vec!["ws://127.0.0.1:5030".to_string()]), // Not necessary for the test api_endpoint: Url::parse("http://127.0.0.1").unwrap(), }, @@ -328,11 +323,7 @@ pub async fn start_client( url.set_port(Some(port)).unwrap(); url.set_path(&format!("/v{PROTOCOL_VERSION}")); url.query_pairs_mut() - .append_pair("client_id", &config.client.cluster.client_id.to_string()) - .append_pair( - "datacenter_id", - &config.client.cluster.datacenter_id.to_string(), - ); + .append_pair("client_id", &config.client.cluster.client_id.to_string()); tracing::info!("connecting to ws: {url}"); @@ -375,7 +366,7 @@ pub async fn build_binaries(gen_path: &Path) { .arg("pegboard-echo-server") .arg("-f") .arg(pkg_path.join(format!("echo")).join("Dockerfile")) - .arg(pkg_path.join("..").join("..").join("..")) + .arg(pkg_path.join("..").join("..").join("..").join("..")) .status() .await .unwrap(); @@ -431,7 +422,7 @@ async fn build_runner(gen_path: &Path, variant: &str) { .join(format!("{variant}-runner")) .join("Dockerfile"), ) - .arg(pkg_path.join("..").join("..").join("..")) + .arg(pkg_path.join("..").join("..").join("..").join("..")) .status() .await .unwrap(); diff --git a/packages/edge/infra/client/manager/tests/container_lifecycle.rs b/packages/edge/infra/client/manager/tests/container_lifecycle.rs index 487a3f04c0..3975e92ab2 100644 --- a/packages/edge/infra/client/manager/tests/container_lifecycle.rs +++ b/packages/edge/infra/client/manager/tests/container_lifecycle.rs @@ -100,7 +100,7 @@ async fn handle_connection( // Verify client state let actors = ctx.actors().read().await; assert!( - actors.contains_key(&actor_id), + actors.contains_key(&(actor_id, 0)), "actor not in client memory" ); } @@ -116,7 +116,7 @@ async fn handle_connection( // Verify client state let actors = ctx.actors().read().await; assert!( - actors.contains_key(&actor_id), + actors.contains_key(&(actor_id, 0)), "actor not in client memory" ); @@ -147,9 +147,9 @@ async fn handle_connection( &mut tx, protocol::Command::SignalActor { actor_id, + generation: 0, signal: Signal::SIGKILL as i32, persist_storage: false, - ignore_future_state: false, }, ) .await; @@ -166,7 +166,7 @@ async fn handle_connection( // Verify client state let actors = ctx.actors().read().await; assert!( - actors.contains_key(&actor_id), + actors.contains_key(&(actor_id, 0)), "actor not in client memory" ); } @@ -184,7 +184,7 @@ async fn handle_connection( // Verify client state let actors = ctx.actors().read().await; assert!( - !actors.contains_key(&actor_id), + actors.contains_key(&(actor_id, 0)), "actor still in client memory" );