Skip to content

Commit

Permalink
Fixes and tests for oplog enumeration (#1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
vigoo authored Oct 14, 2024
1 parent 15a0616 commit 2f245d0
Show file tree
Hide file tree
Showing 9 changed files with 459 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ futures-core = "0.3.29"
futures-util = "0.3.29"
git-version = "0.3.9"
golem-wasm-ast = "1.0.1"
golem-wasm-rpc = { version = "1.0.5", default-features = false, features = [
golem-wasm-rpc = { version = "1.0.6", default-features = false, features = [
"host",
] }

Expand Down
2 changes: 1 addition & 1 deletion golem-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ futures-util = { workspace = true }
golem-examples = "1.0.6"
golem-wasm-ast = { workspace = true }
golem-wasm-rpc = { workspace = true }
golem-wasm-rpc-stubgen = { version = "1.0.5", optional = true }
golem-wasm-rpc-stubgen = { version = "1.0.6", optional = true }
h2 = "0.3.24"
http = { workspace = true }
humansize = { workspace = true }
Expand Down
34 changes: 33 additions & 1 deletion golem-cli/tests/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use crate::{RefKind, Tracing};
use anyhow::anyhow;
use assert2::assert;
use golem_cli::model::component::ComponentView;
use golem_cli::model::text::fmt::TextFormat;
use golem_cli::model::text::worker::WorkerGetView;
use golem_cli::model::{Format, IdempotencyKey, WorkersMetadataResponseView};
use golem_client::model::{PublicOplogEntry, UpdateRecord};
use golem_common::model::TargetWorkerId;
Expand All @@ -29,8 +31,10 @@ use indoc::formatdoc;
use serde_json::{json, Value};
use std::io::{BufRead, BufReader};
use std::sync::Arc;
use std::thread::sleep;
use std::time::Duration;
use test_r::core::{DynamicTestRegistration, TestType};
use tracing::debug;

inherit_test_dep!(EnvBasedTestDependencies);
inherit_test_dep!(Tracing);
Expand Down Expand Up @@ -1037,6 +1041,25 @@ fn worker_update(
UpdateRecord::FailedUpdate(_) => panic!("Update failed"),
};

loop {
let mut cli_args = vec!["worker".to_owned(), "get".to_owned()];
cli_args.append(&mut worker_ref(cfg, ref_kind, &component, &worker_name));
let result: WorkerGetView = cli.run(&cli_args)?;

if result.0.component_version == target_version {
break;
} else {
debug!("Waiting for worker to update...");
sleep(Duration::from_secs(2));
}
}

let mut cli_args = vec!["worker".to_owned(), "oplog".to_owned()];
cli_args.append(&mut worker_ref(cfg, ref_kind, &component, &worker_name));
let result: Vec<(u64, PublicOplogEntry)> = cli.run(&cli_args)?;
result.print();

assert_eq!(result.len(), 3); // create, enqueue update, successful update
assert_eq!(original_updates, 0);
assert_eq!(target_version, 1);
Ok(())
Expand Down Expand Up @@ -1106,6 +1129,11 @@ fn worker_invoke_indexed_resource(
json!({"typ":{"items":[{"type":"U64"}],"type":"Tuple"},"value":[3]})
);

let mut cli_args = vec!["worker".to_owned(), "oplog".to_owned()];
cli_args.append(&mut worker_ref(cfg, ref_kind, &component, &worker_name));
let result: Vec<(u64, PublicOplogEntry)> = cli.run(&cli_args)?;
result.print();

Ok(())
}

Expand Down Expand Up @@ -1231,7 +1259,11 @@ fn worker_get_oplog(
let result: Vec<(u64, PublicOplogEntry)> =
cli.run(&["worker", "oplog", &cfg.arg('W', "worker"), &url.to_string()])?;

assert_eq!(result.len(), 14);
result.print();

// Whether there is an "enqueued invocation" entry or just directly started invocation
// depends on timing
assert!(result.len() >= 12 && result.len() <= 14);

Ok(())
}
5 changes: 4 additions & 1 deletion golem-common/src/model/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ pub fn find_resource_site(
resource: resource_name.to_string(),
},
);
if functions.iter().any(|f| f.name == constructor.to_string()) {
if functions
.iter()
.any(|f| f.name == constructor.function().function_name())
{
Some(site)
} else {
None
Expand Down
Loading

0 comments on commit 2f245d0

Please sign in to comment.