Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new model_reuse_type to enable sync by peers and creation by leader #170

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions runner/src/scenario/ceramic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ pub enum ReuseType {
PerNode,
/// Reuse the same model or model instance document for all users
Shared,
/// Create a new model for lead worker (id - 0) and let other workers subscribe to that model
LeadWorkerSubscriber,
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
Expand Down
46 changes: 44 additions & 2 deletions runner/src/scenario/ceramic/model_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,15 @@ impl CeramicModelInstanceTestUser {
debug!(params=?config.params, "setting up scenario");
let (small_model_id, large_model_id) = match config.params.model_reuse {
super::ReuseType::PerUser => {
Self::generate_list_models(user, &config.admin_cli, &config.redis_cli, true, None)
.await?
Self::generate_list_models(
user,
&config.admin_cli,
&config.redis_cli,
true,
None,
false,
)
.await?
}
super::ReuseType::Shared => {
let (small, large) = Self::generate_list_models(
Expand All @@ -164,6 +171,7 @@ impl CeramicModelInstanceTestUser {
&config.redis_cli,
global_leader,
None,
false,
)
.await?;
// js ceramic subscribes to the meta model, so we'll get all models created synced to us. we just need to make sure they sync before starting
Expand All @@ -180,9 +188,24 @@ impl CeramicModelInstanceTestUser {
&config.redis_cli,
lead_user,
Some(goose::get_worker_id().to_string()),
false,
)
.await?
}
crate::scenario::ceramic::ReuseType::LeadWorkerSubscriber => {
let (small, large) = Self::generate_list_models(
user,
&config.admin_cli,
&config.redis_cli,
global_leader,
None,
true,
)
.await?;
Self::ensure_model_exists(user, &config.user_cli, &small).await?;
Self::ensure_model_exists(user, &config.user_cli, &large).await?;
(small, large)
}
};

if lead_user {
Copy link
Collaborator

@smrz2001 smrz2001 May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this if-block, one user per worker will call the model subscription API, which means each node will already be subscribed to the models. This means that we shouldn't need to pass the should_subscribe flag as you're doing below.

Expand Down Expand Up @@ -251,6 +274,20 @@ impl CeramicModelInstanceTestUser {
)
.await?
}
super::ReuseType::LeadWorkerSubscriber => {
// For model instance reuse type make it work the same way as shared
Self::generate_mids(
user,
&config.user_cli,
&config.redis_cli,
&small_model_id,
&large_model_id,
config.params.number_of_documents,
global_leader,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be true so that each worker creates MIDs instead of just the global leader.

Suggested change
global_leader,
true,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, we need the ReuseType::Shared code when creating models, but ReuseType::PerUser code when creating MIDs.

None,
)
.await?
}
};

let resp = Self {
Expand Down Expand Up @@ -293,6 +330,7 @@ impl CeramicModelInstanceTestUser {
redis_cli: &redis::Client,
should_create: bool,
redis_postfix: Option<String>,
should_subscribe: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be necessary - see my comment above. One user on each worker is already making sure that the corresponding node is subscribed to the models.

) -> Result<(StreamId, StreamId), TransactionError> {
let mut conn = redis_cli.get_async_connection().await.unwrap();
let (small_key, large_key) = if let Some(pf) = redis_postfix {
Expand Down Expand Up @@ -332,6 +370,10 @@ impl CeramicModelInstanceTestUser {
info!("waiting for shared model IDs to be set in redis");
let small = loop_until_key_value_set(&mut conn, &small_key).await;
let large = loop_until_key_value_set(&mut conn, &large_key).await;
if should_subscribe {
Self::subscribe_to_model(user, &small).await?;
Self::subscribe_to_model(user, &large).await?;
}
Ok((small, large))
}
}
Expand Down
5 changes: 2 additions & 3 deletions runner/src/simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ pub enum Scenario {
// but covering using js-ceramic rather than talking directly to the ipfs API.
CeramicAnchoringBenchmark,

// Scenario that creates model instance documents and verifies that they have been anchored at the desired rate.
// This is a benchmark scenario for e2e testing, simliar to the recon event sync scenario,
// but covering using js-ceramic rather than talking directly to the ipfs API.
// Scenario that creates anchor requests to Ceramic Anchor Service directly, there is no verification.
// Dashboards should be used to verify the rate of anchor requests and health of the service.
CASBenchmark,
}

Expand Down
Loading