Skip to content

Commit

Permalink
Stop using just command to run launcher in integration tests
Browse files Browse the repository at this point in the history
As we switch to bazel, we'll want to work directly with the binaries
provided via data dependencies; adding a just command into the mix wil
only complicate things.

Fixed: b/377240486
Change-Id: Ic47646a758eb1cb6fa5e8bd45074672cb41cb976
  • Loading branch information
jblebrun committed Nov 7, 2024
1 parent 640f71b commit 2c8a737
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions oak_functions_test_utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ rust_library(
},
deps = [
"//oak_client",
"//oak_file_utils",
"//oak_functions_abi",
"//oak_functions_client:lib",
"//oak_proto_rust",
Expand Down
4 changes: 4 additions & 0 deletions oak_functions_test_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ authors = ["Razieh Behjati <[email protected]>"]
edition = "2021"
license = "Apache-2.0"

[features]
bazel = []

[dependencies]
anyhow = "*"
command-group = "*"
Expand All @@ -13,6 +16,7 @@ http = "*"
hyper = { version = "*", features = ["client", "http1", "runtime", "server"] }
nix = { version = "*", features = ["process", "signal"] }
oak_client = { workspace = true }
oak_file_utils = { workspace = true }
oak_functions_abi = { workspace = true }
oak_functions_client = { workspace = true }
oak_proto_rust = { workspace = true }
Expand Down
37 changes: 29 additions & 8 deletions oak_functions_test_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

//! Test utilities to help with unit testing of Oak Functions code.

use oak_file_utils::data_path;

#[cfg(feature = "bazel")]
pub static MOCK_LOOKUP_DATA_PATH: Lazy<PathBuf> = Lazy::new(|| {
PathBuf::from(env::var("TEST_SRCDIR").unwrap())
Expand Down Expand Up @@ -250,14 +252,33 @@ pub fn run_oak_functions_containers_example_in_background(
let port = portpicker::pick_unused_port().expect("failed to pick a port");
eprintln!("using port {}", port);

let child = std::process::Command::new("just")
let launch_bin = data_path("artifacts/oak_functions_containers_launcher");
let qemu = which::which("qemu-system-x86_64").unwrap();
let stage0_bin = data_path("artifacts/stage0_bin");
let kernel = data_path("bazel-out/k8-fastbuild/bin/oak_containers/kernel/bzImage");
let initrd = data_path("artifacts/stage1.cpio");
let system_image = data_path("artifacts/oak_containers_system_image.tar.xz");
let container_bundle =
data_path("bazel-out/k8-fastbuild/bin/oak_functions_containers_app/bundle.tar");
let ramdrive_size = 1000000;
let memory_size = "2G";
let virtio_guest_cid = nix::unistd::gettid();

let child = std::process::Command::new(launch_bin)
.args(vec![
"run_oak_functions_containers_launcher",
wasm_path,
&format!("{}", port),
lookup_data_path,
communication_channel,
&format!("{}", nix::unistd::gettid()),
format!("--vmm-binary={}", qemu.display()),
format!("--stage0-binary={}", stage0_bin.display()),
format!("--kernel={}", kernel.display()),
format!("--initrd={}", initrd.display()),
format!("--system-image={}", system_image.display()),
format!("--container-bundle={}", container_bundle.display()),
format!("--ramdrive-size={ramdrive_size}"),
format!("--memory-size={memory_size}"),
format!("--wasm={wasm_path}"),
format!("--port={port}"),
format!("--lookup-data={lookup_data_path}"),
format!("--virtio-guest-cid={virtio_guest_cid}"),
format!("--communication-channel={communication_channel}"),
])
.group_spawn()
.expect("didn't start oak functions containers launcher");
Expand Down Expand Up @@ -316,7 +337,7 @@ pub fn run_oak_functions_example_in_background(
])
.group_spawn()
}
.expect("didn't start oak functions containers launcher");
.expect("didn't start oak functions launcher");

(BackgroundHandle(child), port)
}
Expand Down

0 comments on commit 2c8a737

Please sign in to comment.