Skip to content
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ jobs:
AGENTOS_SIDECAR_BIN: ${{ github.workspace }}/target/debug/agentos-native-sidecar
run: |
cargo test -p agentos-client \
--features service-internals \
--lib \
--test scaffold \
--test e2e_smoke \
Expand All @@ -163,6 +164,7 @@ jobs:
--test sidecar_pool_e2e \
--test cron_e2e \
--test cron_grammar_e2e \
--test vm_config_compare_e2e \
-- --test-threads=1
- name: Stage stripped sidecar artifacts
run: |
Expand Down
45 changes: 45 additions & 0 deletions crates/client/tests/vm_config_compare_e2e.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//! Config comparison against a running VM through a real `agentos-native-sidecar`.
#![cfg(feature = "service-internals")]
Comment thread
eersnington marked this conversation as resolved.

mod common;

use std::collections::BTreeMap;

use agentos_client::config::AgentOsConfig;
use agentos_client::service_internals::vm_config_equivalent;
use agentos_client::AgentOs;

fn config(environment: Option<BTreeMap<String, String>>) -> AgentOsConfig {
AgentOsConfig {
environment,
..Default::default()
}
}

#[tokio::test]
async fn running_vm_compares_configs_through_the_sidecar() {
if !common::require_sidecar("running_vm_compares_configs_through_the_sidecar") {
return;
}
let vm = AgentOs::create(config(None))
.await
.expect("create VM against real sidecar");

let same = vm_config_equivalent(&vm, &config(None), &config(None), Vec::new(), Vec::new())
.await
.expect("compare an unchanged config");
let changed_environment = Some(BTreeMap::from([(String::from("DEBUG"), String::from("1"))]));
let changed = vm_config_equivalent(
&vm,
&config(None),
&config(changed_environment),
Vec::new(),
Vec::new(),
)
.await
.expect("compare a config with a changed environment");
vm.shutdown().await.expect("shutdown VM");

assert!(same);
assert!(!changed);
}
11 changes: 8 additions & 3 deletions crates/native-sidecar/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2607,6 +2607,7 @@ where
| RequestRoute::GetZombieTimerCount(_)
| RequestRoute::ProvidedCommands(_)
| RequestRoute::ListMounts(_)
| RequestRoute::CompareVmConfig(_)
| RequestRoute::GuestFilesystemCall(_)
| RequestRoute::GuestKernelCall(_)
| RequestRoute::BootstrapRootFilesystem(_)
Expand Down Expand Up @@ -2801,6 +2802,12 @@ where
let future = self.list_mounts(&request, payload);
Ok(Some(PreparedRequest::from_vm_command(request, future)))
}
RequestRoute::CompareVmConfig(payload) => {
let result = self.compare_vm_config(&request, payload);
Ok(Some(PreparedRequest::from_future(request, async move {
result
})))
}
RequestRoute::BootstrapRootFilesystem(payload) => {
let future = self.bootstrap_root_filesystem(&request, payload.entries);
Ok(Some(PreparedRequest::from_vm_command(request, future)))
Expand Down Expand Up @@ -3032,9 +3039,7 @@ where
})
})))
}
RequestRoute::CreateVm(_)
| RequestRoute::CompareVmConfig(_)
| RequestRoute::DisposeVm(_) => {
RequestRoute::CreateVm(_) | RequestRoute::DisposeVm(_) => {
unreachable!("VM creation and disposal use dedicated prepared routes")
}
}
Expand Down