Skip to content

Commit

Permalink
chore(NODE-1399): Update test driver to use zst images (#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbattat authored Aug 1, 2024
1 parent c77043f commit 3909a2c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
3 changes: 1 addition & 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 rs/ic_os/launch-single-vm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn main() {
// Adjust VM configuration for nested setup
let (image_location, vm_type, vm_size) = if args.nested {
// Create an empty image, this will be used as the "main" drive
let empty_image_name = "empty.img.tar.gz";
let empty_image_name = "empty.img.tar.zst";
let tmp_dir = tempfile::tempdir().unwrap();
let empty_image = build_empty_image(tmp_dir.path(), empty_image_name).unwrap();
let empty_image_id = farm
Expand Down
2 changes: 1 addition & 1 deletion rs/tests/driver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ rust_library(
"@crate_index//:clap",
"@crate_index//:crossbeam-channel",
"@crate_index//:ed25519-dalek",
"@crate_index//:flate2",
"@crate_index//:futures",
"@crate_index//:hex",
"@crate_index//:http_0_2_12",
Expand Down Expand Up @@ -178,5 +177,6 @@ rust_library(
"@crate_index//:url",
"@crate_index//:walkdir",
"@crate_index//:wat",
"@crate_index//:zstd",
],
)
3 changes: 1 addition & 2 deletions rs/tests/driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dfn_candid = { path = "../../rust_canisters/dfn_candid" }
dfn_protobuf = { path = "../../rust_canisters/dfn_protobuf" }
dfn_core = { path = "../../rust_canisters/dfn_core" }
ed25519-dalek = { workspace = true }
flate2 = { workspace = true }
futures = { workspace = true }
humantime = "2.0"
humantime-serde = { workspace = true }
Expand Down Expand Up @@ -104,7 +103,6 @@ http = "0.2.12"
lazy_static = { workspace = true }
icp-ledger = { path = "../../rosetta-api/icp_ledger" }
leb128 = "0.2.5"
libflate = "1.3.0"
lifeline = { path = "../../nns/handlers/lifeline/impl" }
itertools = { workspace = true }
maplit = "1.0.2"
Expand Down Expand Up @@ -149,5 +147,6 @@ tracing-subscriber = { workspace = true }
tree-deserializer = { path = "../../tree_deserializer" }
url = { workspace = true }
wat = "1.0.52"
zstd = { workspace = true }
ic-agent = { workspace = true }
ic-utils = { workspace = true }
8 changes: 4 additions & 4 deletions rs/tests/driver/src/driver/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use crate::k8s::images::*;
use crate::k8s::tnet::{TNet, TNode};
use crate::util::block_on;
use anyhow::{bail, Result};
use flate2::{write::GzEncoder, Compression};
use ic_base_types::NodeId;
use ic_prep_lib::{
internet_computer::{IcConfig, InitializedIc, TopologyConfig},
Expand All @@ -44,6 +43,7 @@ use std::{
thread::{self, JoinHandle},
};
use url::Url;
use zstd::stream::write::Encoder;

pub type UnassignedNodes = BTreeMap<NodeIndex, NodeConfiguration>;
pub type NodeVms = BTreeMap<NodeId, AllocatedVm>;
Expand All @@ -54,7 +54,7 @@ const JAEGER_ADDR_PATH: &str = "jaeger_addr";
const SOCKS_PROXY_PATH: &str = "socks_proxy";

fn mk_compressed_img_path() -> std::string::String {
format!("{}.gz", CONF_IMG_FNAME)
format!("{}.zst", CONF_IMG_FNAME)
}

pub fn init_ic(
Expand Down Expand Up @@ -539,7 +539,7 @@ fn create_config_disk_image(
let mut img_file = File::open(img_path)?;
let compressed_img_path = PathBuf::from(&node.node_path).join(mk_compressed_img_path());
let compressed_img_file = File::create(compressed_img_path.clone())?;
let mut encoder = GzEncoder::new(compressed_img_file, Compression::default());
let mut encoder = Encoder::new(compressed_img_file, 0)?;
let _ = io::copy(&mut img_file, &mut encoder)?;
let mut write_stream = encoder.finish()?;
write_stream.flush()?;
Expand Down Expand Up @@ -669,7 +669,7 @@ fn configure_setupos_image(

let mut img_file = File::open(&uncompressed_image)?;
let configured_image_file = File::create(configured_image.clone())?;
let mut encoder = GzEncoder::new(configured_image_file, Compression::default());
let mut encoder = Encoder::new(configured_image_file, 0)?;
let _ = io::copy(&mut img_file, &mut encoder)?;
let mut write_stream = encoder.finish()?;
write_stream.flush()?;
Expand Down
6 changes: 3 additions & 3 deletions rs/tests/driver/src/driver/boundary_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ use crate::{

use anyhow::{bail, Result};
use async_trait::async_trait;
use flate2::{write::GzEncoder, Compression};
use ic_agent::{Agent, AgentError};
use kube::ResourceExt;
use reqwest::Url;
use serde::{Deserialize, Serialize};
use slog::info;
use ssh2::Session;
use zstd::stream::write::Encoder;

use crate::driver::{farm::PlaynetCertificate, test_env_api::HasIcDependencies};

Expand All @@ -58,7 +58,7 @@ const PLAYNET_PATH: &str = "playnet.json";
const BN_AAAA_RECORDS_CREATED_EVENT_NAME: &str = "bn_aaaa_records_created_event";

fn mk_compressed_img_path() -> std::string::String {
format!("{}.gz", CONF_IMG_FNAME)
format!("{}.zst", CONF_IMG_FNAME)
}

#[derive(Clone)]
Expand Down Expand Up @@ -675,7 +675,7 @@ fn create_config_disk_image(
let compressed_img_path = boundary_node_dir.join(mk_compressed_img_path());
let compressed_img_file = File::create(compressed_img_path.clone())?;

let mut encoder = GzEncoder::new(compressed_img_file, Compression::default());
let mut encoder = Encoder::new(compressed_img_file, 0)?;
let _ = io::copy(&mut img_file, &mut encoder)?;
let mut write_stream = encoder.finish()?;
write_stream.flush()?;
Expand Down
2 changes: 1 addition & 1 deletion rs/tests/driver/src/driver/nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use url::Url;

pub const NESTED_VMS_DIR: &str = "nested_vms";
pub const NESTED_VM_PATH: &str = "vm.json";
pub const NESTED_CONFIGURED_IMAGE_PATH: &str = "config.img.gz";
pub const NESTED_CONFIGURED_IMAGE_PATH: &str = "config.img.zst";
pub const NESTED_NETWORK_PATH: &str = "ips.json";

pub struct NestedNode {
Expand Down
6 changes: 3 additions & 3 deletions rs/tests/driver/src/driver/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::driver::ic::{AmountOfMemoryKiB, InternetComputer, Node, NrOfVCPUs};
use crate::driver::universal_vm::UniversalVm;
use crate::k8s::tnet::TNet;
use anyhow::{self, bail};
use flate2::{write::GzEncoder, Compression};
use kube::ResourceExt;
use serde::{Deserialize, Serialize};
use slog::{info, warn};
Expand All @@ -13,6 +12,7 @@ use std::net::{Ipv4Addr, Ipv6Addr};
use std::path::{Path, PathBuf};
use std::process::Command;
use url::Url;
use zstd::stream::write::Encoder;

use crate::driver::farm::FarmResult;
use crate::driver::farm::FileId;
Expand Down Expand Up @@ -215,7 +215,7 @@ pub fn get_resource_request_for_nested_nodes(

// Build and upload an empty image.
// TODO: This is temporary until farm can do this natively.
let empty_image_name = "empty.img.tar.gz";
let empty_image_name = "empty.img.tar.zst";
let tmp_dir = tempfile::tempdir().unwrap();
let empty_image = build_empty_image(tmp_dir.path(), empty_image_name)?;
let image_id = farm.upload_file(group_name, empty_image, empty_image_name)?;
Expand Down Expand Up @@ -481,7 +481,7 @@ pub fn build_empty_image(tmp_dir: &Path, out_file_name: &str) -> anyhow::Result<

let mut tar_file = File::open(tar_path)?;
let compressed_img_file = File::create(&compressed_img_path)?;
let mut encoder = GzEncoder::new(compressed_img_file, Compression::default());
let mut encoder = Encoder::new(compressed_img_file, 0)?;
let _ = io::copy(&mut tar_file, &mut encoder)?;
let mut write_stream = encoder.finish()?;
write_stream.flush()?;
Expand Down

0 comments on commit 3909a2c

Please sign in to comment.