Skip to content

Commit d967870

Browse files
committed
fix(pegboard): fix manager tests
1 parent c0a769d commit d967870

File tree

5 files changed

+27
-25
lines changed

5 files changed

+27
-25
lines changed

Cargo.lock

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/edge/infra/client/echo/Dockerfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ COPY . .
55
RUN \
66
--mount=type=cache,target=/root/.cargo/git \
77
--mount=type=cache,target=/root/.cargo/registry \
8-
--mount=type=cache,target=/app/packages/infra/client/target \
9-
cd packages/infra/client && \
8+
--mount=type=cache,target=/app/target \
109
RUSTFLAGS="--cfg tokio_unstable" cargo build --release --bin pegboard-echo-server && \
1110
mkdir -p /app/dist && \
1211
mv /app/target/x86_64-unknown-linux-musl/release/pegboard-echo-server /app/dist/pegboard-echo-server

packages/edge/infra/client/manager/src/ctx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ impl Ctx {
846846
// Test bindings
847847
#[cfg(feature = "test")]
848848
impl Ctx {
849-
pub fn actors(&self) -> &RwLock<HashMap<Uuid, Arc<Actor>>> {
849+
pub fn actors(&self) -> &RwLock<HashMap<(Uuid, u32), Arc<Actor>>> {
850850
&self.actors
851851
}
852852
}

packages/edge/infra/client/manager/tests/common.rs

+8-17
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub async fn start_echo_actor(
7272
) {
7373
let cmd = protocol::Command::StartActor {
7474
actor_id,
75+
generation: 0,
7576
config: Box::new(protocol::ActorConfig {
7677
image: protocol::Image {
7778
id: Uuid::nil(),
@@ -101,10 +102,6 @@ pub async fn start_echo_actor(
101102
memory_max: 15 * 1024 * 1024,
102103
disk: 15,
103104
},
104-
owner: protocol::ActorOwner::DynamicServer {
105-
server_id: actor_id,
106-
workflow_id: Uuid::new_v4(),
107-
},
108105
metadata: protocol::Raw::new(&protocol::ActorMetadata {
109106
actor: protocol::ActorMetadataActor {
110107
actor_id,
@@ -131,6 +128,7 @@ pub async fn start_echo_actor(
131128
build: protocol::ActorMetadataBuild {
132129
build_id: Uuid::nil(),
133130
},
131+
network: None,
134132
})
135133
.unwrap(),
136134
}),
@@ -145,6 +143,7 @@ pub async fn start_js_echo_actor(
145143
) {
146144
let cmd = protocol::Command::StartActor {
147145
actor_id,
146+
generation: 0,
148147
config: Box::new(protocol::ActorConfig {
149148
image: protocol::Image {
150149
id: Uuid::nil(),
@@ -172,10 +171,6 @@ pub async fn start_js_echo_actor(
172171
memory_max: 15 * 1024 * 1024,
173172
disk: 15,
174173
},
175-
owner: protocol::ActorOwner::DynamicServer {
176-
server_id: actor_id,
177-
workflow_id: Uuid::new_v4(),
178-
},
179174
metadata: protocol::Raw::new(&protocol::ActorMetadata {
180175
actor: protocol::ActorMetadataActor {
181176
actor_id,
@@ -202,6 +197,7 @@ pub async fn start_js_echo_actor(
202197
build: protocol::ActorMetadataBuild {
203198
build_id: Uuid::nil(),
204199
},
200+
network: None,
205201
})
206202
.unwrap(),
207203
}),
@@ -262,8 +258,7 @@ pub async fn init_client(gen_path: &Path, working_path: &Path) -> Config {
262258
data_dir: Some(working_path.to_path_buf()),
263259
cluster: Cluster {
264260
client_id: Uuid::new_v4(),
265-
datacenter_id: Uuid::new_v4(),
266-
pegboard_endpoint: Url::parse("ws://127.0.0.1:5030").unwrap(),
261+
ws_addresses: Addresses::Static(vec!["ws://127.0.0.1:5030".to_string()]),
267262
// Not necessary for the test
268263
api_endpoint: Url::parse("http://127.0.0.1").unwrap(),
269264
},
@@ -328,11 +323,7 @@ pub async fn start_client(
328323
url.set_port(Some(port)).unwrap();
329324
url.set_path(&format!("/v{PROTOCOL_VERSION}"));
330325
url.query_pairs_mut()
331-
.append_pair("client_id", &config.client.cluster.client_id.to_string())
332-
.append_pair(
333-
"datacenter_id",
334-
&config.client.cluster.datacenter_id.to_string(),
335-
);
326+
.append_pair("client_id", &config.client.cluster.client_id.to_string());
336327

337328
tracing::info!("connecting to ws: {url}");
338329

@@ -375,7 +366,7 @@ pub async fn build_binaries(gen_path: &Path) {
375366
.arg("pegboard-echo-server")
376367
.arg("-f")
377368
.arg(pkg_path.join(format!("echo")).join("Dockerfile"))
378-
.arg(pkg_path.join("..").join("..").join(".."))
369+
.arg(pkg_path.join("..").join("..").join("..").join(".."))
379370
.status()
380371
.await
381372
.unwrap();
@@ -431,7 +422,7 @@ async fn build_runner(gen_path: &Path, variant: &str) {
431422
.join(format!("{variant}-runner"))
432423
.join("Dockerfile"),
433424
)
434-
.arg(pkg_path.join("..").join("..").join(".."))
425+
.arg(pkg_path.join("..").join("..").join("..").join(".."))
435426
.status()
436427
.await
437428
.unwrap();

packages/edge/infra/client/manager/tests/container_lifecycle.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async fn handle_connection(
100100
// Verify client state
101101
let actors = ctx.actors().read().await;
102102
assert!(
103-
actors.contains_key(&actor_id),
103+
actors.contains_key(&(actor_id, 0)),
104104
"actor not in client memory"
105105
);
106106
}
@@ -116,7 +116,7 @@ async fn handle_connection(
116116
// Verify client state
117117
let actors = ctx.actors().read().await;
118118
assert!(
119-
actors.contains_key(&actor_id),
119+
actors.contains_key(&(actor_id, 0)),
120120
"actor not in client memory"
121121
);
122122

@@ -147,9 +147,9 @@ async fn handle_connection(
147147
&mut tx,
148148
protocol::Command::SignalActor {
149149
actor_id,
150+
generation: 0,
150151
signal: Signal::SIGKILL as i32,
151152
persist_storage: false,
152-
ignore_future_state: false,
153153
},
154154
)
155155
.await;
@@ -166,7 +166,7 @@ async fn handle_connection(
166166
// Verify client state
167167
let actors = ctx.actors().read().await;
168168
assert!(
169-
actors.contains_key(&actor_id),
169+
actors.contains_key(&(actor_id, 0)),
170170
"actor not in client memory"
171171
);
172172
}
@@ -184,7 +184,7 @@ async fn handle_connection(
184184
// Verify client state
185185
let actors = ctx.actors().read().await;
186186
assert!(
187-
!actors.contains_key(&actor_id),
187+
actors.contains_key(&(actor_id, 0)),
188188
"actor still in client memory"
189189
);
190190

0 commit comments

Comments
 (0)