Skip to content

Commit

Permalink
chore(deps): update for control-interface 2.2.0
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
  • Loading branch information
vados-cosmonic committed Oct 4, 2024
1 parent eb57ec9 commit 3079ddb
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 92 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ uuid = "1"
wadm = { version = "0.15.0", path = "./crates/wadm" }
wadm-client = { version = "0.5.0", path = "./crates/wadm-client" }
wadm-types = { version = "0.5.0", path = "./crates/wadm-types" }
wasmcloud-control-interface = { version = "2.0.0" }
wasmcloud-control-interface = { version = "2.2.0" }
wasmcloud-secrets-types = "0.2.0"
wit-bindgen-wrpc = { version = "0.3.7", default-features = false }

Expand Down
27 changes: 15 additions & 12 deletions crates/wadm/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::{
collections::{BTreeMap, HashMap},
error::Error,
hash::{Hash, Hasher},
};

Expand Down Expand Up @@ -235,18 +236,20 @@ pub struct PutLink {
pub model_name: String,
}

impl From<PutLink> for Link {
fn from(value: PutLink) -> Link {
Link {
source_id: value.source_id,
target: value.target,
name: value.name,
wit_namespace: value.wit_namespace,
wit_package: value.wit_package,
interfaces: value.interfaces,
source_config: value.source_config,
target_config: value.target_config,
}
impl TryFrom<PutLink> for Link {
type Error = Box<dyn Error + Send + Sync>;

fn try_from(value: PutLink) -> Result<Link, Self::Error> {
Link::builder()
.source_id(&value.source_id)
.target(&value.target)
.name(&value.name)
.wit_namespace(&value.wit_namespace)
.wit_package(&value.wit_package)
.interfaces(value.interfaces)
.source_config(value.source_config)
.target_config(value.target_config)
.build()
}
}

Expand Down
16 changes: 8 additions & 8 deletions crates/wadm/src/scaler/spreadscaler/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ where
self.reconcile().await
}
Event::LinkdefSet(LinkdefSet { linkdef })
if linkdef.source_id == self.config.source_id
&& linkdef.target == self.config.target
&& linkdef.name == self.config.name =>
if linkdef.source_id() == self.config.source_id
&& linkdef.target() == self.config.target
&& linkdef.name() == self.config.name =>
{
*self.status.write().await = StatusInfo::deployed("");
Ok(Vec::new())
Expand All @@ -141,21 +141,21 @@ where
let (exists, _config_different) = linkdefs
.into_iter()
.find(|linkdef| {
&linkdef.source_id == source_id
&& &linkdef.target == target
&& linkdef.name == self.config.name
linkdef.source_id() == source_id
&& linkdef.target() == target
&& linkdef.name() == self.config.name
})
.map(|linkdef| {
(
true,
// TODO(#88): reverse compare too
// Ensure all supplied configs (both source and target) are the same
linkdef
.source_config
.source_config()
.iter()
.eq(self.config.source_config.iter())
&& linkdef
.target_config
.target_config()
.iter()
.eq(self.config.target_config.iter()),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/wadm/src/workers/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Worker for CommandWorker {
trace!(command = ?ld, "Handling put linkdef command");
// TODO(thomastaylor312): We should probably change ScopedMessage to allow us `pub`
// access to the inner type so we don't have to clone, but no need to worry for now
self.client.put_link(ld.clone().into()).await
self.client.put_link(ld.clone().try_into()?).await
}
Command::DeleteLink(ld) => {
trace!(command = ?ld, "Handling delete linkdef command");
Expand Down
16 changes: 8 additions & 8 deletions tests/command_worker_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ async fn test_commands() {
inventory
.into_iter()
.find(|ld| {
ld.source_id == HTTP_SERVER_COMPONENT_ID
&& ld.target == HELLO_COMPONENT_ID
&& ld.wit_namespace == "wasi"
&& ld.wit_package == "http"
ld.source_id() == HTTP_SERVER_COMPONENT_ID
&& ld.target() == HELLO_COMPONENT_ID
&& ld.wit_namespace() == "wasi"
&& ld.wit_package() == "http"
})
.expect("Linkdef should exist");

Expand Down Expand Up @@ -249,10 +249,10 @@ async fn test_commands() {
// We could have more than one link due to local testing, so search for the proper link
assert!(
!inventory.into_iter().any(|ld| {
ld.target == HELLO_COMPONENT_ID
&& ld.source_id == HTTP_SERVER_COMPONENT_ID
&& ld.wit_namespace == "wasi"
&& ld.wit_package == "http"
ld.target() == HELLO_COMPONENT_ID
&& ld.source_id() == HTTP_SERVER_COMPONENT_ID
&& ld.wit_namespace() == "wasi"
&& ld.wit_package() == "http"
}),
"Linkdef should be deleted"
);
Expand Down
36 changes: 18 additions & 18 deletions tests/e2e_multiple_hosts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ async fn test_no_requirements(client_info: &ClientInfo) {
.context("Should have links")?;

if !links.iter().any(|ld| {
ld.source_id == HTTP_SERVER_COMPONENT_ID
&& ld.target == HELLO_COMPONENT_ID
&& ld.wit_namespace == "wasi"
&& ld.wit_package == "http"
&& ld.interfaces == vec!["incoming-handler"]
&& ld.name == "default"
ld.source_id() == HTTP_SERVER_COMPONENT_ID
&& ld.target() == HELLO_COMPONENT_ID
&& ld.wit_namespace() == "wasi"
&& ld.wit_package() == "http"
&& ld.name() == "default"
&& *ld.interfaces() == vec!["incoming-handler"]
}) {
anyhow::bail!(
"Link between http provider and hello component should exist: {:#?}",
Expand Down Expand Up @@ -366,12 +366,12 @@ async fn test_complex_app(client_info: &ClientInfo) {
.context("Should have links")?;

if !links.iter().any(|ld| {
ld.source_id == HTTP_SERVER_COMPONENT_ID
&& ld.target == BLOBBY_COMPONENT_ID
&& ld.wit_namespace == "wasi"
&& ld.wit_package == "http"
&& ld.interfaces == vec!["incoming-handler"]
&& ld.name == "default"
ld.source_id() == HTTP_SERVER_COMPONENT_ID
&& ld.target() == BLOBBY_COMPONENT_ID
&& ld.wit_namespace() == "wasi"
&& ld.wit_package() == "http"
&& ld.name() == "default"
&& *ld.interfaces() == vec!["incoming-handler"]
}) {
anyhow::bail!(
"Link between blobby component and http provider should exist: {:#?}",
Expand All @@ -380,12 +380,12 @@ async fn test_complex_app(client_info: &ClientInfo) {
}

if !links.iter().any(|ld| {
ld.source_id == BLOBBY_COMPONENT_ID
&& ld.target == BLOBSTORE_FS_PROVIDER_ID
&& ld.wit_namespace == "wasi"
&& ld.wit_package == "blobstore"
&& ld.interfaces == vec!["blobstore"]
&& ld.name == "default"
ld.source_id() == BLOBBY_COMPONENT_ID
&& ld.target() == BLOBSTORE_FS_PROVIDER_ID
&& ld.wit_namespace() == "wasi"
&& ld.wit_package() == "blobstore"
&& ld.name() == "default"
&& *ld.interfaces() == vec!["blobstore"]
}) {
anyhow::bail!(
"Link between blobby component and blobstore-fs provider should exist: {:#?}",
Expand Down
76 changes: 38 additions & 38 deletions tests/e2e_upgrades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ async fn test_upgrade(client_info: &ClientInfo) {
let http_link = links
.iter()
.find(|link| {
link.target == HELLO_COMPONENT_ID
&& link.source_id == HTTP_SERVER_COMPONENT_ID
&& link.wit_namespace == "wasi"
&& link.wit_package == "http"
link.target() == HELLO_COMPONENT_ID
&& link.source_id() == HTTP_SERVER_COMPONENT_ID
&& link.wit_namespace() == "wasi"
&& link.wit_package() == "http"
})
.context("Should have http link with hello")?;
if let Err(e) = check_config(
client_info.ctl_client("default"),
&http_link.source_config[0],
&http_link.source_config()[0],
&HashMap::from_iter([("address".to_string(), "0.0.0.0:8080".to_string())]),
)
.await
Expand All @@ -164,15 +164,15 @@ async fn test_upgrade(client_info: &ClientInfo) {
let dog_link = links
.iter()
.find(|link| {
link.target == generated_dogfetcher_id
&& link.source_id == HTTP_SERVER_COMPONENT_ID
&& link.wit_namespace == "wasi"
&& link.wit_package == "http"
link.target() == generated_dogfetcher_id
&& link.source_id() == HTTP_SERVER_COMPONENT_ID
&& link.wit_namespace() == "wasi"
&& link.wit_package() == "http"
})
.context("Should have http link with dog-fetcher")?;
if let Err(e) = check_config(
client_info.ctl_client("default"),
&dog_link.source_config[0],
&dog_link.source_config()[0],
&HashMap::from_iter([("address".to_string(), "0.0.0.0:8081".to_string())]),
)
.await
Expand All @@ -186,15 +186,15 @@ async fn test_upgrade(client_info: &ClientInfo) {
let kv_link = links
.iter()
.find(|link| {
link.source_id == generated_kvcounter_id
&& link.target == KEYVALUE_REDIS_COMPONENT_ID
&& link.wit_namespace == "wasi"
&& link.wit_package == "keyvalue"
link.source_id() == generated_kvcounter_id
&& link.target() == KEYVALUE_REDIS_COMPONENT_ID
&& link.wit_namespace() == "wasi"
&& link.wit_package() == "keyvalue"
})
.context("Should have redis link with kvcounter")?;
if let Err(e) = check_config(
client_info.ctl_client("default"),
&kv_link.target_config[0],
&kv_link.target_config()[0],
&HashMap::from_iter([("URL".to_string(), "redis://127.0.0.1:6379".to_string())]),
)
.await
Expand Down Expand Up @@ -311,16 +311,16 @@ async fn test_upgrade(client_info: &ClientInfo) {
let http_link = links
.iter()
.find(|link| {
link.target == HELLO_COMPONENT_ID
&& link.source_id == HTTP_SERVER_COMPONENT_ID
&& link.wit_namespace == "wasi"
&& link.wit_package == "http"
link.target() == HELLO_COMPONENT_ID
&& link.source_id() == HTTP_SERVER_COMPONENT_ID
&& link.wit_namespace() == "wasi"
&& link.wit_package() == "http"
})
.ok_or_else(|| anyhow::anyhow!("Should have http link with hello"))?;

if let Err(e) = check_config(
client_info.ctl_client("default"),
&http_link.source_config[0],
&http_link.source_config()[0],
&HashMap::from([("address".to_string(), "0.0.0.0:8082".to_string())]),
)
.await
Expand All @@ -332,10 +332,10 @@ async fn test_upgrade(client_info: &ClientInfo) {
}

if links.iter().any(|ld| {
ld.source_id == generated_kvcounter_id
&& ld.target == KEYVALUE_REDIS_COMPONENT_ID
&& ld.wit_namespace == "wasi"
&& ld.wit_package == "keyvalue"
ld.source_id() == generated_kvcounter_id
&& ld.target() == KEYVALUE_REDIS_COMPONENT_ID
&& ld.wit_namespace() == "wasi"
&& ld.wit_package() == "keyvalue"
}) {
anyhow::bail!(
"Link between kvcounter component and redis provider should not exist: {:#?}",
Expand Down Expand Up @@ -429,16 +429,16 @@ async fn test_upgrade(client_info: &ClientInfo) {
let http_link = links
.iter()
.find(|link| {
link.target == HELLO_COMPONENT_ID
&& link.source_id == HTTP_SERVER_COMPONENT_ID
&& link.wit_namespace == "wasi"
&& link.wit_package == "http"
link.target() == HELLO_COMPONENT_ID
&& link.source_id() == HTTP_SERVER_COMPONENT_ID
&& link.wit_namespace() == "wasi"
&& link.wit_package() == "http"
})
.ok_or_else(|| anyhow::anyhow!("Should have http link with hello"))?;

if let Err(e) = check_config(
client_info.ctl_client("default"),
&http_link.source_config[0],
&http_link.source_config()[0],
&HashMap::from([("address".to_string(), "0.0.0.0:8080".to_string())]),
)
.await
Expand All @@ -452,16 +452,16 @@ async fn test_upgrade(client_info: &ClientInfo) {
let dog_link = links
.iter()
.find(|link| {
link.target == generated_dogfetcher_id
&& link.source_id == HTTP_SERVER_COMPONENT_ID
&& link.wit_namespace == "wasi"
&& link.wit_package == "http"
link.target() == generated_dogfetcher_id
&& link.source_id() == HTTP_SERVER_COMPONENT_ID
&& link.wit_namespace() == "wasi"
&& link.wit_package() == "http"
})
.ok_or_else(|| anyhow::anyhow!("Should have dog link with hello"))?;

if let Err(e) = check_config(
client_info.ctl_client("default"),
&dog_link.source_config[0],
&dog_link.source_config()[0],
&HashMap::from([("address".to_string(), "0.0.0.0:8081".to_string())]),
)
.await
Expand All @@ -473,10 +473,10 @@ async fn test_upgrade(client_info: &ClientInfo) {
}

if links.iter().any(|ld| {
ld.source_id == generated_kvcounter_id
&& ld.target == KEYVALUE_REDIS_COMPONENT_ID
&& ld.wit_namespace == "wasi"
&& ld.wit_package == "keyvalue"
ld.source_id() == generated_kvcounter_id
&& ld.target() == KEYVALUE_REDIS_COMPONENT_ID
&& ld.wit_namespace() == "wasi"
&& ld.wit_package() == "keyvalue"
}) {
anyhow::bail!(
"Link between kvcounter component and redis provider should not exist: {:#?}",
Expand Down
8 changes: 4 additions & 4 deletions tests/event_consumer_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ async fn test_event_stream() -> Result<()> {
let mut evt = wait_for_event(&mut stream, LINK_OPERATION_TIMEOUT_DURATION).await;
if let Event::LinkdefSet(event) = evt.as_ref() {
assert_eq!(
event.linkdef.source_id, HELLO_COMPONENT_ID,
event.linkdef.source_id(), HELLO_COMPONENT_ID,
"Expected to get a linkdef event for the right component and provider, got component ID: {}",
event.linkdef.source_id,
event.linkdef.source_id(),
);
assert_eq!(
event.linkdef.target, HTTP_SERVER_COMPONENT_ID,
event.linkdef.target(), HTTP_SERVER_COMPONENT_ID,
"Expected to get a linkdef event for the right component and provider, got provider ID: {}",
event.linkdef.target,
event.linkdef.target(),
);
} else {
panic!("Event wasn't an link set event");
Expand Down

0 comments on commit 3079ddb

Please sign in to comment.