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

chore(deps): update for control-interface 2.2.0 #439

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
17 changes: 12 additions & 5 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
fail-fast: false
matrix:
# TODO: Re-enable the multitenant and upgrades tests in followup to #247
# e2e_test: [e2e_multiple_hosts, e2e_multitenant, e2e_upgrades]
e2e_test: [e2e_multiple_hosts, e2e_upgrades]
# test: [e2e_multiple_hosts, e2e_multitenant, e2e_upgrades]
test: [e2e_multiple_hosts, e2e_upgrades]

steps:
- uses: actions/checkout@v4
Expand All @@ -30,19 +30,26 @@ jobs:
with:
key: 'ubuntu-22.04-rust-cache'

# If the test uses a docker compose file, pre-emptively pull images used in docker compose
- name: Pull images for test ${{ matrix.test }}
shell: bash
run: |
export DOCKER_COMPOSE_FILE=tests/docker-compose-${{ matrix.test }}.yaml;
[[ -f "$DOCKER_COMPOSE_FILE" ]] && docker compose -f $DOCKER_COMPOSE_FILE pull;

# Run e2e tests in a matrix for efficiency
- name: Run tests ${{ matrix.e2e_test }}
- name: Run tests ${{ matrix.test }}
id: test
env:
WADM_E2E_TEST: ${{ matrix.e2e_test }}
WADM_E2E_TEST: ${{ matrix.test }}
run: make test-individual-e2e

# if the previous step fails, upload logs
- name: Upload logs for debugging
uses: actions/upload-artifact@v4
if: ${{ failure() && steps.test.outcome == 'failure' }}
with:
name: e2e-logs-${{ matrix.e2e_test }}
name: e2e-logs-${{ matrix.test }}
path: ./tests/e2e_log/*
# Be nice and only retain the logs for 7 days
retention-days: 7
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
65 changes: 31 additions & 34 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 Expand Up @@ -430,26 +430,25 @@ mod test {
let provider_ref = "provider_ref".to_string();
let provider_id = "provider".to_string();

let linkdef = Link {
source_id: component_id.to_string(),
target: provider_id.to_string(),
wit_namespace: "namespace".to_string(),
wit_package: "package".to_string(),
interfaces: vec!["interface".to_string()],
name: "default".to_string(),
source_config: vec![],
target_config: vec![],
};
let linkdef = Link::builder()
.source_id(&component_id)
.target(&provider_id)
.wit_namespace("namespace")
.wit_package("package")
.interfaces(vec!["interface".to_string()])
.name("default")
.build()
.unwrap();

let scaler = LinkScaler::new(
create_store(&lattice_id, &component_ref, &provider_ref).await,
LinkScalerConfig {
source_id: linkdef.source_id.clone(),
target: linkdef.target.clone(),
wit_namespace: linkdef.wit_namespace.clone(),
wit_package: linkdef.wit_package.clone(),
wit_interfaces: linkdef.interfaces.clone(),
name: linkdef.name.clone(),
source_id: linkdef.source_id().to_string(),
target: linkdef.target().to_string(),
wit_namespace: linkdef.wit_namespace().to_string(),
wit_package: linkdef.wit_package().to_string(),
wit_interfaces: linkdef.interfaces().clone(),
name: linkdef.name().to_string(),
source_config: vec![],
target_config: vec![],
lattice_id: lattice_id.clone(),
Expand Down Expand Up @@ -583,17 +582,15 @@ mod test {

let commands = link_scaler
.handle_event(&Event::LinkdefSet(LinkdefSet {
linkdef: Link {
linkdef: Link::builder()
// NOTE: contract, link, and provider id matches but the component is different
source_id: "nm0001772".to_string(),
target: "VASDASD".to_string(),
wit_namespace: "wasmcloud".to_string(),
wit_package: "httpserver".to_string(),
interfaces: vec![],
name: "default".to_string(),
source_config: vec![],
target_config: vec![],
},
.source_id("nm0001772")
.target("VASDASD")
.wit_namespace("wasmcloud")
.wit_package("httpserver")
.name("default")
.build()
.unwrap(),
}))
.await
.expect("");
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
14 changes: 11 additions & 3 deletions tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,18 @@ impl ClientInfo {
.kill_on_drop(true)
.spawn()
.expect("Unable to watch docker logs");

// Connect to NATS
let client = async_nats::connect("127.0.0.1:4222")
.await
.expect("Unable to connect to nats");
let client = tokio::time::timeout(Duration::from_secs(3), async {
loop {
if let Ok(client) = async_nats::connect("127.0.0.1:4222").await {
return client;
}
tokio::time::sleep(Duration::from_millis(250)).await;
}
})
.await
.expect("timed out while creating NATS client");

ClientInfo {
client,
Expand Down
38 changes: 19 additions & 19 deletions tests/e2e_multiple_hosts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
};

const MANIFESTS_PATH: &str = "tests/fixtures/manifests";
const DOCKER_COMPOSE_FILE: &str = "tests/docker-compose-e2e.yaml";
const DOCKER_COMPOSE_FILE: &str = "tests/docker-compose-e2e_multiple_hosts.yaml";
const BLOBSTORE_FS_IMAGE_REF: &str = "ghcr.io/wasmcloud/blobstore-fs:0.6.0";
const BLOBSTORE_FS_PROVIDER_ID: &str = "fileserver";
const BLOBBY_IMAGE_REF: &str = "ghcr.io/wasmcloud/components/blobby-rust:0.4.0";
Expand Down 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
2 changes: 1 addition & 1 deletion tests/e2e_multitenant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// use crate::e2e::check_status;

// const MANIFESTS_PATH: &str = "tests/fixtures/manifests";
// const DOCKER_COMPOSE_FILE: &str = "tests/docker-compose-e2e-multitenant.yaml";
// const DOCKER_COMPOSE_FILE: &str = "tests/docker-compose-e2e_multitenant.yaml";

// const MESSAGE_PUB_ACTOR_ID: &str = "MC3QONHYH3FY4KYFCOSVJWIDJG4WA2PVD6FHKR7FFT457GVUTZJYR2TJ";
// const NATS_PROVIDER_ID: &str = "VADNMSIML2XGO2X4TPIONTIC55R2UUQGPPDZPAVSC2QD7E76CR77SPW7";
Expand Down
Loading