Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
423 changes: 135 additions & 288 deletions engine/packages/engine/tests/envoy/actors_alarm.rs

Large diffs are not rendered by default.

136 changes: 65 additions & 71 deletions engine/packages/engine/tests/envoy/actors_kv_crud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ fn basic_kv_put_and_get() {
&namespace,
"kv-put-get",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

Expand Down Expand Up @@ -485,7 +485,7 @@ fn kv_get_nonexistent_key() {
&namespace,
"kv-get-nonexistent",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

Expand Down Expand Up @@ -525,7 +525,7 @@ fn kv_put_overwrite_existing() {
&namespace,
"kv-overwrite",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

Expand Down Expand Up @@ -565,7 +565,7 @@ fn kv_delete_existing_key() {
&namespace,
"kv-delete",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

Expand All @@ -587,45 +587,42 @@ fn kv_delete_existing_key() {

#[test]
fn kv_delete_nonexistent_key() {
common::run(
common::TestOpts::new(1).with_timeout(30),
|ctx| async move {
let (namespace, _) = common::setup_test_namespace(ctx.leader_dc()).await;

let (notify_tx, notify_rx) = tokio::sync::oneshot::channel();
let notify_tx = Arc::new(Mutex::new(Some(notify_tx)));

let runner = common::setup_envoy(ctx.leader_dc(), &namespace, |builder| {
builder.with_actor_behavior("kv-delete-nonexistent", move |_| {
Box::new(DeleteNonexistentKeyActor::new(notify_tx.clone()))
})
common::run(common::TestOpts::new(1).with_timeout(30), |ctx| async move {
let (namespace, _) = common::setup_test_namespace(ctx.leader_dc()).await;

let (notify_tx, notify_rx) = tokio::sync::oneshot::channel();
let notify_tx = Arc::new(Mutex::new(Some(notify_tx)));

let runner = common::setup_envoy(ctx.leader_dc(), &namespace, |builder| {
builder.with_actor_behavior("kv-delete-nonexistent", move |_| {
Box::new(DeleteNonexistentKeyActor::new(notify_tx.clone()))
})
.await;
})
.await;

let res = common::create_actor(
ctx.leader_dc().guard_port(),
&namespace,
"kv-delete-nonexistent",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
)
.await;
let res = common::create_actor(
ctx.leader_dc().guard_port(),
&namespace,
"kv-delete-nonexistent",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

let actor_id = res.actor.actor_id.to_string();
let actor_id = res.actor.actor_id.to_string();

// Wait for actor to complete KV operations
let result = notify_rx.await.expect("actor should send test result");
// Wait for actor to complete KV operations
let result = notify_rx.await.expect("actor should send test result");

match result {
KvTestResult::Success => {
tracing::info!(?actor_id, "delete nonexistent key test succeeded");
}
KvTestResult::Failure(msg) => {
panic!("delete nonexistent key test failed: {}", msg);
}
match result {
KvTestResult::Success => {
tracing::info!(?actor_id, "delete nonexistent key test succeeded");
}
KvTestResult::Failure(msg) => {
panic!("delete nonexistent key test failed: {}", msg);
}
},
);
}
});
}
// MARK: Batch Operations Tests

Expand Down Expand Up @@ -883,44 +880,41 @@ impl Actor for BatchDeleteActor {

#[test]
fn kv_put_multiple_keys() {
common::run(
common::TestOpts::new(1).with_timeout(30),
|ctx| async move {
let (namespace, _) = common::setup_test_namespace(ctx.leader_dc()).await;

let (notify_tx, notify_rx) = tokio::sync::oneshot::channel();
let notify_tx = Arc::new(Mutex::new(Some(notify_tx)));

let runner = common::setup_envoy(ctx.leader_dc(), &namespace, |builder| {
builder.with_actor_behavior("kv-batch-put", move |_| {
Box::new(BatchPutActor::new(notify_tx.clone()))
})
common::run(common::TestOpts::new(1).with_timeout(30), |ctx| async move {
let (namespace, _) = common::setup_test_namespace(ctx.leader_dc()).await;

let (notify_tx, notify_rx) = tokio::sync::oneshot::channel();
let notify_tx = Arc::new(Mutex::new(Some(notify_tx)));

let runner = common::setup_envoy(ctx.leader_dc(), &namespace, |builder| {
builder.with_actor_behavior("kv-batch-put", move |_| {
Box::new(BatchPutActor::new(notify_tx.clone()))
})
.await;
})
.await;

let res = common::create_actor(
ctx.leader_dc().guard_port(),
&namespace,
"kv-batch-put",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
)
.await;
let res = common::create_actor(
ctx.leader_dc().guard_port(),
&namespace,
"kv-batch-put",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

let actor_id = res.actor.actor_id.to_string();
let actor_id = res.actor.actor_id.to_string();

let result = notify_rx.await.expect("actor should send test result");
let result = notify_rx.await.expect("actor should send test result");

match result {
KvTestResult::Success => {
tracing::info!(?actor_id, "batch put test succeeded");
}
KvTestResult::Failure(msg) => {
panic!("batch put test failed: {}", msg);
}
match result {
KvTestResult::Success => {
tracing::info!(?actor_id, "batch put test succeeded");
}
KvTestResult::Failure(msg) => {
panic!("batch put test failed: {}", msg);
}
},
);
}
});
}

#[test]
Expand All @@ -943,7 +937,7 @@ fn kv_get_multiple_keys() {
&namespace,
"kv-batch-get",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

Expand Down Expand Up @@ -982,7 +976,7 @@ fn kv_delete_multiple_keys() {
&namespace,
"kv-batch-delete",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

Expand Down
55 changes: 26 additions & 29 deletions engine/packages/engine/tests/envoy/actors_kv_delete_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,34 +96,31 @@ impl TestActor for DeleteRangeActor {

#[test]
fn kv_delete_range_removes_half_open_range() {
common::run(
common::TestOpts::new(1).with_timeout(30),
|ctx| async move {
let (namespace, _) = common::setup_test_namespace(ctx.leader_dc()).await;

let (notify_tx, notify_rx) = tokio::sync::oneshot::channel();
let notify_tx = Arc::new(Mutex::new(Some(notify_tx)));

let runner = common::setup_envoy(ctx.leader_dc(), &namespace, |builder| {
builder.with_actor_behavior("kv-delete-range", move |_| {
Box::new(DeleteRangeActor::new(notify_tx.clone()))
})
common::run(common::TestOpts::new(1).with_timeout(30), |ctx| async move {
let (namespace, _) = common::setup_test_namespace(ctx.leader_dc()).await;

let (notify_tx, notify_rx) = tokio::sync::oneshot::channel();
let notify_tx = Arc::new(Mutex::new(Some(notify_tx)));

let runner = common::setup_envoy(ctx.leader_dc(), &namespace, |builder| {
builder.with_actor_behavior("kv-delete-range", move |_| {
Box::new(DeleteRangeActor::new(notify_tx.clone()))
})
.await;

common::create_actor(
ctx.leader_dc().guard_port(),
&namespace,
"kv-delete-range",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
)
.await;

match notify_rx.await.expect("actor should send test result") {
KvTestResult::Success => {}
KvTestResult::Failure(msg) => panic!("kv delete range test failed: {}", msg),
}
},
);
})
.await;

common::create_actor(
ctx.leader_dc().guard_port(),
&namespace,
"kv-delete-range",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

match notify_rx.await.expect("actor should send test result") {
KvTestResult::Success => {}
KvTestResult::Failure(msg) => panic!("kv delete range test failed: {}", msg),
}
});
}
4 changes: 2 additions & 2 deletions engine/packages/engine/tests/envoy/actors_kv_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ fn kv_drop_clears_all_data() {
&namespace,
"kv-drop-clears",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

Expand Down Expand Up @@ -235,7 +235,7 @@ fn kv_drop_empty_store() {
&namespace,
"kv-drop-empty",
runner.pool_name(),
rivet_types::actors::CrashPolicy::Destroy,
rivet_types::actors::CrashPolicy::Sleep,
)
.await;

Expand Down
Loading
Loading