diff --git a/Cargo.lock b/Cargo.lock index f6e7e4c4..c3c9a6e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2190,6 +2190,20 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper 0.14.28", + "rustls 0.21.12", + "tokio", + "tokio-rustls", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -2518,7 +2532,7 @@ dependencies = [ "parking_lot 0.12.2", "paste", "rmp-serde 1.1.2", - "rustls", + "rustls 0.20.9", "serde", "serde_bytes", "serde_json", @@ -3621,6 +3635,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.28", + "hyper-rustls", "hyper-tls 0.5.0", "ipnet", "js-sys", @@ -3630,6 +3645,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls 0.21.12", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -3638,11 +3654,13 @@ dependencies = [ "system-configuration", "tokio", "tokio-native-tls", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots", "winreg 0.50.0", ] @@ -3890,6 +3908,18 @@ dependencies = [ "webpki", ] +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring 0.17.8", + "rustls-webpki", + "sct", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -3915,6 +3945,16 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring 0.17.8", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.17" @@ -4819,6 +4859,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls 0.21.12", + "tokio", +] + [[package]] name = "tokio-tungstenite" version = "0.21.0" @@ -5065,6 +5115,9 @@ dependencies = [ "lazy_static", "regex", "reqwest 0.11.27", + "serde", + "serde_derive", + "serde_json", "thiserror", ] @@ -5562,6 +5615,12 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + [[package]] name = "which" version = "6.0.1" @@ -5910,6 +5969,16 @@ version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" +[[package]] +name = "write_query" +version = "0.1.0" +dependencies = [ + "anyhow", + "happ_builder", + "holochain_types", + "holochain_wind_tunnel_runner", +] + [[package]] name = "write_read" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 87226a17..e4e32c98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ members = [ "scenarios/zome_call_single_value", "scenarios/first_call", "scenarios/write_read", + "scenarios/write_query", "zomes/return_single_value/coordinator", "zomes/crud/coordinator", @@ -61,8 +62,7 @@ url = "2.5.0" tabled = "0.15.0" indicatif = "0.17.8" # TODO waiting for 0.7.3+ relase to use the new reqwest-client-native-tls-vendored feature -# TODO waiting for Holochain 0.3 to add the feature `serde` back here, conflicts at 0.2 -influxdb = { version = "0.7.3-beta.1", package = "ts_influxdb", default-features = false, features = ["reqwest-client-native-tls-vendored"] } +influxdb = { version = "0.7.3-beta.1", package = "ts_influxdb", features = ["reqwest-client-native-tls-vendored"] } influxive-core = "0.0.2-alpha.1" nanoid = "0.4.0" which = "6.0.1" diff --git a/framework/instruments/Cargo.toml b/framework/instruments/Cargo.toml index fce479ff..afbc33dd 100644 --- a/framework/instruments/Cargo.toml +++ b/framework/instruments/Cargo.toml @@ -14,7 +14,7 @@ anyhow = { workspace = true } opentelemetry_api = { workspace = true } parking_lot = { workspace = true } tabled = { workspace = true } -influxdb = { workspace = true, default-features = false } +influxdb = { workspace = true } tokio = { workspace = true } log = { workspace = true } influxive-core = { workspace = true } diff --git a/scenarios/first_call/README.md b/scenarios/first_call/README.md index 9994a231..48e117de 100644 --- a/scenarios/first_call/README.md +++ b/scenarios/first_call/README.md @@ -1,4 +1,4 @@ -## app_install +## first_call ### Description diff --git a/scenarios/write_query/Cargo.toml b/scenarios/write_query/Cargo.toml new file mode 100644 index 00000000..85485abb --- /dev/null +++ b/scenarios/write_query/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "write_query" +version = "0.1.0" +edition = "2021" +build = "../scenario_build.rs" + +[dependencies] +anyhow = { workspace = true } +holochain_types = { workspace = true } +holochain_wind_tunnel_runner = { workspace = true } + +[build-dependencies] +happ_builder = { workspace = true } + +[lints] +workspace = true + +[package.metadata.required-dna] +name = "crud" +zomes = ["crud"] + +[package.metadata.required-happ] +name = "crud" +dnas = ["crud"] diff --git a/scenarios/write_query/README.md b/scenarios/write_query/README.md new file mode 100644 index 00000000..dcd26878 --- /dev/null +++ b/scenarios/write_query/README.md @@ -0,0 +1,11 @@ +## write_query + +### Description + +Creates an entry, then queries the source chain and performs a simple operation on the entries, then repeat. + +### Suggested command + +```bash +RUST_LOG=info cargo run --package write_query -- --connection-string ws://localhost:8888 --duration 300 +``` diff --git a/scenarios/write_query/src/main.rs b/scenarios/write_query/src/main.rs new file mode 100644 index 00000000..2ff07e40 --- /dev/null +++ b/scenarios/write_query/src/main.rs @@ -0,0 +1,66 @@ +use holochain_types::prelude::ActionHash; +use holochain_wind_tunnel_runner::prelude::*; +use holochain_wind_tunnel_runner::scenario_happ_path; +use std::path::Path; + +#[derive(Debug, Default)] +struct ScenarioValues { + call_count: u32, +} + +impl UserValuesConstraint for ScenarioValues {} + + +fn setup(ctx: &mut RunnerContext) -> HookResult { + configure_app_ws_url(ctx)?; + Ok(()) +} + +fn agent_setup( + ctx: &mut AgentContext>, +) -> HookResult { + install_app(ctx, scenario_happ_path!("crud"), &"crud".to_string())?; + + Ok(()) +} + +fn agent_behaviour( + ctx: &mut AgentContext>, +) -> HookResult { + let _: ActionHash = call_zome( + ctx, + "crud", + "create_sample_entry", + "this is a test entry value", + )?; + + let response: u32 = call_zome(ctx, "crud", "chain_query_count_len", ())?; + + let values = &mut ctx.get_mut().scenario_values; + values.call_count += 1; + + // Minimal check that we're querying the right content and getting the expected result from the + // calculation in this zome function. + assert_eq!(values.call_count * 26, response, "Expected call count to match response"); + + Ok(()) +} + +fn main() -> WindTunnelResult<()> { + let builder = + ScenarioDefinitionBuilder::>::new_with_init( + env!("CARGO_PKG_NAME"), + ) + .with_default_duration_s(60) + .use_setup(setup) + .use_agent_setup(agent_setup) + .use_agent_behaviour(agent_behaviour) + .use_agent_teardown(|ctx| { + uninstall_app(ctx, None).ok(); + Ok(()) + }); + + run(builder)?; + + Ok(()) +} diff --git a/scenarios/write_read/README.md b/scenarios/write_read/README.md index 0932b3b3..be55a365 100644 --- a/scenarios/write_read/README.md +++ b/scenarios/write_read/README.md @@ -1,4 +1,4 @@ -## single_write_many_read +## write_read ### Description diff --git a/zomes/crud/coordinator/src/lib.rs b/zomes/crud/coordinator/src/lib.rs index b7bd9fcf..66dd9945 100644 --- a/zomes/crud/coordinator/src/lib.rs +++ b/zomes/crud/coordinator/src/lib.rs @@ -1,4 +1,4 @@ -use crud_integrity::{EntryTypes, SampleEntry}; +use crud_integrity::{EntryTypes, UnitEntryTypes, SampleEntry}; use hdk::prelude::*; #[hdk_extern] @@ -24,3 +24,18 @@ fn create_sample_entry(value: String) -> ExternResult { fn get_sample_entry(hash: ActionHash) -> ExternResult> { get(hash, GetOptions::local()) } + +#[hdk_extern] +fn chain_query_count_len() -> ExternResult { + let q = ChainQueryFilter::new() + .include_entries(true) + .entry_type(UnitEntryTypes::SampleEntry.try_into()?); + let results = query(q)?; + + let sum = results.into_iter().filter_map(|r| { + let se: SampleEntry = r.entry.into_option().unwrap().try_into().ok()?; + Some(se) + }).map(|se| se.value.len()).fold(0, |acc, len| acc + len); + + Ok(sum as u32) +}