From e9c2625d16126f3b551cf1178dcdb006e2075aa0 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Thu, 7 May 2026 13:34:57 +0000 Subject: [PATCH 01/12] chore: support allocating testnets to the local DC --- bazel/BUILD.bazel | 7 ++- bazel/defs.bzl | 10 ++++ bazel/workspace_status.sh | 3 ++ rs/tests/driver/src/driver/group.rs | 13 ++++- rs/tests/driver/src/driver/test_env_api.rs | 55 ++++++++++++++++++++-- rs/tests/nested/registration.rs | 1 + rs/tests/system_tests.bzl | 1 + 7 files changed, 84 insertions(+), 6 deletions(-) diff --git a/bazel/BUILD.bazel b/bazel/BUILD.bazel index c435675aceb8..fc3fadd4787e 100644 --- a/bazel/BUILD.bazel +++ b/bazel/BUILD.bazel @@ -1,6 +1,6 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") load("@buildifier_prebuilt//:rules.bzl", "buildifier") -load("//bazel:defs.bzl", "write_info_file_var") +load("//bazel:defs.bzl", "volatile_status", "write_info_file_var") bool_flag( name = "enable_malicious_code", @@ -72,6 +72,11 @@ write_info_file_var( visibility = ["//visibility:public"], ) +volatile_status( + name = "volatile-status.txt", + visibility = ["//visibility:public"], +) + exports_files( [ "prost_generator.sh", diff --git a/bazel/defs.bzl b/bazel/defs.bzl index f2135e0ed1c3..e15139b3441c 100644 --- a/bazel/defs.bzl +++ b/bazel/defs.bzl @@ -368,6 +368,16 @@ write_info_file_var = rule( }, ) +def _volatile_status_impl(ctx): + return [DefaultInfo( + files = depset([ctx.version_file]), + runfiles = ctx.runfiles(files = [ctx.version_file]), + )] + +volatile_status = rule( + implementation = _volatile_status_impl, +) + def file_size_check( name, file, diff --git a/bazel/workspace_status.sh b/bazel/workspace_status.sh index 83f98a02c2ff..f7393061b443 100755 --- a/bazel/workspace_status.sh +++ b/bazel/workspace_status.sh @@ -27,3 +27,6 @@ if [ -n "${CI_JOB_NAME:-}" ]; then STABLE_FARM_METADATA="$STABLE_FARM_METADATA;JOB_NAME=$CI_JOB_NAME" fi echo "STABLE_FARM_METADATA $STABLE_FARM_METADATA" + +# Used for allocating a Farm testnet to the local DC in CI (Search for allocate_testnet_to_local_dc) +echo "NODE_NAME ${NODE_NAME:-}" \ No newline at end of file diff --git a/rs/tests/driver/src/driver/group.rs b/rs/tests/driver/src/driver/group.rs index 3f6254bb971f..ae841378d2ae 100644 --- a/rs/tests/driver/src/driver/group.rs +++ b/rs/tests/driver/src/driver/group.rs @@ -648,6 +648,7 @@ impl SystemTestSubGroup { } pub struct SystemTestGroup { + allocate_testnet_to_local_dc: bool, setup: Option>, teardowns: Vec>, tests: Vec, @@ -692,6 +693,7 @@ impl TestEnvAttribute for CliArguments { impl SystemTestGroup { pub fn new() -> Self { Self { + allocate_testnet_to_local_dc: false, setup: Default::default(), teardowns: Default::default(), tests: Default::default(), @@ -744,6 +746,11 @@ impl SystemTestGroup { self } + pub fn allocate_testnet_to_local_dc(mut self) -> Self { + self.allocate_testnet_to_local_dc = true; + self + } + pub fn with_setup(mut self, setup: F) -> Self { self.setup = Some(Box::new(setup)); self @@ -1296,7 +1303,11 @@ impl SystemTestGroup { } InfraProvider::Farm.write_attribute(&root_env); if with_farm { - root_env.create_group_setup(group_ctx.group_base_name.clone(), args.no_group_ttl); + root_env.create_group_setup( + group_ctx.group_base_name.clone(), + self.allocate_testnet_to_local_dc, + args.no_group_ttl, + ); } debug!(group_ctx.log(), "Created group context: {:?}", group_ctx); } diff --git a/rs/tests/driver/src/driver/test_env_api.rs b/rs/tests/driver/src/driver/test_env_api.rs index 04ee2c6658b7..528cb21612b4 100644 --- a/rs/tests/driver/src/driver/test_env_api.rs +++ b/rs/tests/driver/src/driver/test_env_api.rs @@ -134,7 +134,7 @@ use super::{ config::NODES_INFO, driver_setup::SSH_AUTHORIZED_PRIV_KEYS_DIR, - farm::{DnsRecord, PlaynetCertificate}, + farm::{DnsRecord, HostFeature, PlaynetCertificate}, test_setup::{GroupSetup, InfraProvider}, }; use crate::{ @@ -1482,11 +1482,21 @@ pub fn get_build_setupos_config_image_tool() -> PathBuf { } pub trait HasGroupSetup { - fn create_group_setup(&self, group_base_name: String, no_group_ttl: bool); + fn create_group_setup( + &self, + group_base_name: String, + allocate_testnet_to_local_dc: bool, + no_group_ttl: bool, + ); } impl HasGroupSetup for TestEnv { - fn create_group_setup(&self, group_base_name: String, no_group_ttl: bool) { + fn create_group_setup( + &self, + group_base_name: String, + allocate_testnet_to_local_dc: bool, + no_group_ttl: bool, + ) { let log = self.logger(); if GroupSetup::attribute_exists(self) { let group_setup = GroupSetup::read_attribute(self); @@ -1501,11 +1511,33 @@ impl HasGroupSetup for TestEnv { let group_setup = GroupSetup::new(group_base_name.clone(), timeout); match InfraProvider::read_attribute(self) { InfraProvider::Farm => { + let required_host_features = if allocate_testnet_to_local_dc { + let node_name = read_var_from_volatile_status_file("NODE_NAME"); + if let Some(name) = node_name { + let dc = name + .split_once('-') + .expect("NODE_NAME doesn't contain '-'") + .0 + .to_string(); + vec![HostFeature::DC(dc.clone())] + } else { + vec![] + } + } else { + vec![] + }; + info!( + log, + "Creating group {} with required_host_features: {:?}", + group_setup.infra_group_name, + required_host_features + ); + let farm_base_url = FarmBaseUrl::read_attribute(self); let farm = Farm::new(farm_base_url.into(), self.logger()); let group_spec = GroupSpec { vm_allocation: None, - required_host_features: vec![], + required_host_features: required_host_features, preferred_network: None, metadata: None, }; @@ -1612,6 +1644,21 @@ pub fn read_dependency_from_env_to_string(v: &str) -> Result { read_dependency_to_string(path_from_env) } +pub fn read_var_from_volatile_status_file(var_name: &str) -> Option { + let volatile_status_path = get_dependency_path_from_env("VOLATILE_STATUS_FILE"); + let content = fs::read_to_string(&volatile_status_path).unwrap_or_else(|e| { + panic!("Couldn't read content of the {volatile_status_path:?} file: {e:?}") + }); + for line in content.lines() { + if let Some((name, value)) = line.split_once(' ') { + if name.trim() == var_name { + return Some(value.trim().to_string()); + } + } + } + None +} + pub fn load_wasm>(p: P) -> Vec { let mut wasm_bytes = std::fs::read(get_dependency_path(&p)) .unwrap_or_else(|e| panic!("Could not read WASM from {:?}: {e:?}", p.as_ref())); diff --git a/rs/tests/nested/registration.rs b/rs/tests/nested/registration.rs index cbc855d805b6..7eb8252c778a 100644 --- a/rs/tests/nested/registration.rs +++ b/rs/tests/nested/registration.rs @@ -4,6 +4,7 @@ use std::time::Duration; fn main() -> Result<()> { SystemTestGroup::new() + .allocate_testnet_to_local_dc() .with_setup(nested::setup) .add_test(systest!(nested::registration)) .with_timeout_per_test(Duration::from_secs(20 * 60)) diff --git a/rs/tests/system_tests.bzl b/rs/tests/system_tests.bzl index fcabef7da1da..4cb625d0a535 100644 --- a/rs/tests/system_tests.bzl +++ b/rs/tests/system_tests.bzl @@ -121,6 +121,7 @@ def system_test( _runtime_deps = dict(runtime_deps) _runtime_deps["TEST_BIN"] = test_driver_target + _runtime_deps["VOLATILE_STATUS_FILE"] = "//bazel:volatile-status.txt" env_var_files = {} icos_images = dict() From 843e0c968258249c73429fabeb0c8aab2fe05851 Mon Sep 17 00:00:00 2001 From: IDX GitHub Automation Date: Thu, 7 May 2026 13:41:47 +0000 Subject: [PATCH 02/12] Automatically fixing code for linting and formatting issues --- bazel/workspace_status.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazel/workspace_status.sh b/bazel/workspace_status.sh index f7393061b443..366d689d9fea 100755 --- a/bazel/workspace_status.sh +++ b/bazel/workspace_status.sh @@ -29,4 +29,4 @@ fi echo "STABLE_FARM_METADATA $STABLE_FARM_METADATA" # Used for allocating a Farm testnet to the local DC in CI (Search for allocate_testnet_to_local_dc) -echo "NODE_NAME ${NODE_NAME:-}" \ No newline at end of file +echo "NODE_NAME ${NODE_NAME:-}" From 9a878bafee0a5998201bfb466fbf0f2b6977fb54 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Thu, 7 May 2026 13:56:06 +0000 Subject: [PATCH 03/12] fix clippy --- rs/tests/driver/src/driver/test_env_api.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rs/tests/driver/src/driver/test_env_api.rs b/rs/tests/driver/src/driver/test_env_api.rs index 528cb21612b4..0fbeeb70cb7d 100644 --- a/rs/tests/driver/src/driver/test_env_api.rs +++ b/rs/tests/driver/src/driver/test_env_api.rs @@ -1528,7 +1528,7 @@ impl HasGroupSetup for TestEnv { }; info!( log, - "Creating group {} with required_host_features: {:?}", + "Creating group {} with required_host_features: {:?} ...", group_setup.infra_group_name, required_host_features ); @@ -1537,7 +1537,7 @@ impl HasGroupSetup for TestEnv { let farm = Farm::new(farm_base_url.into(), self.logger()); let group_spec = GroupSpec { vm_allocation: None, - required_host_features: required_host_features, + required_host_features, preferred_network: None, metadata: None, }; From a4157cf55217b97138abe67707fa26e0354a598b Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Thu, 7 May 2026 13:56:23 +0000 Subject: [PATCH 04/12] Use .allocate_testnet_to_local_dc() on all nested tests --- rs/tests/nested/guestos_upgrade.rs | 1 + rs/tests/nested/hostos_upgrade.rs | 1 + rs/tests/nested/nns_recovery/nr_all_broken_seq_np_actions.rs | 1 + rs/tests/nested/nns_recovery/nr_broken_dfinity_node.rs | 1 + rs/tests/nested/nns_recovery/nr_local.rs | 1 + rs/tests/nested/nns_recovery/nr_no_bless_fix_like_np.rs | 1 + 6 files changed, 6 insertions(+) diff --git a/rs/tests/nested/guestos_upgrade.rs b/rs/tests/nested/guestos_upgrade.rs index db89d6a48df8..34099983d48c 100644 --- a/rs/tests/nested/guestos_upgrade.rs +++ b/rs/tests/nested/guestos_upgrade.rs @@ -22,6 +22,7 @@ use nested::{ fn main() -> Result<()> { SystemTestGroup::new() + .allocate_testnet_to_local_dc() .with_setup(nested::setup) .add_test(systest!(upgrade_guestos)) .with_timeout_per_test(Duration::from_secs(30 * 60)) diff --git a/rs/tests/nested/hostos_upgrade.rs b/rs/tests/nested/hostos_upgrade.rs index fd7543ee21d7..c1d0fe107165 100644 --- a/rs/tests/nested/hostos_upgrade.rs +++ b/rs/tests/nested/hostos_upgrade.rs @@ -17,6 +17,7 @@ use nested::util::{ fn main() -> Result<()> { SystemTestGroup::new() + .allocate_testnet_to_local_dc() .with_setup(nested::setup) .add_test(systest!(upgrade_hostos)) .with_timeout_per_test(Duration::from_secs(30 * 60)) diff --git a/rs/tests/nested/nns_recovery/nr_all_broken_seq_np_actions.rs b/rs/tests/nested/nns_recovery/nr_all_broken_seq_np_actions.rs index 171019755890..0ccc3931b0e3 100644 --- a/rs/tests/nested/nns_recovery/nr_all_broken_seq_np_actions.rs +++ b/rs/tests/nested/nns_recovery/nr_all_broken_seq_np_actions.rs @@ -32,6 +32,7 @@ use std::time::Duration; fn main() -> Result<()> { SystemTestGroup::new() + .allocate_testnet_to_local_dc() .with_setup(|env| { setup( env, diff --git a/rs/tests/nested/nns_recovery/nr_broken_dfinity_node.rs b/rs/tests/nested/nns_recovery/nr_broken_dfinity_node.rs index 775795451757..f918248c7665 100644 --- a/rs/tests/nested/nns_recovery/nr_broken_dfinity_node.rs +++ b/rs/tests/nested/nns_recovery/nr_broken_dfinity_node.rs @@ -31,6 +31,7 @@ use std::time::Duration; fn main() -> Result<()> { SystemTestGroup::new() + .allocate_testnet_to_local_dc() .with_setup(|env| { setup( env, diff --git a/rs/tests/nested/nns_recovery/nr_local.rs b/rs/tests/nested/nns_recovery/nr_local.rs index 117d2fcdf203..2d0269f725e3 100644 --- a/rs/tests/nested/nns_recovery/nr_local.rs +++ b/rs/tests/nested/nns_recovery/nr_local.rs @@ -31,6 +31,7 @@ use std::time::Duration; fn main() -> Result<()> { SystemTestGroup::new() + .allocate_testnet_to_local_dc() .with_setup(|env| { setup( env, diff --git a/rs/tests/nested/nns_recovery/nr_no_bless_fix_like_np.rs b/rs/tests/nested/nns_recovery/nr_no_bless_fix_like_np.rs index efe94b94deb0..23102c3c2d12 100644 --- a/rs/tests/nested/nns_recovery/nr_no_bless_fix_like_np.rs +++ b/rs/tests/nested/nns_recovery/nr_no_bless_fix_like_np.rs @@ -32,6 +32,7 @@ use std::time::Duration; fn main() -> Result<()> { SystemTestGroup::new() + .allocate_testnet_to_local_dc() .with_setup(|env| { setup( env, From 47e971b0554e4b13af760df234b5e9e9d6804933 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Thu, 7 May 2026 14:35:51 +0000 Subject: [PATCH 05/12] fix clippy --- rs/tests/driver/src/driver/test_env_api.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rs/tests/driver/src/driver/test_env_api.rs b/rs/tests/driver/src/driver/test_env_api.rs index 0fbeeb70cb7d..997fe1782666 100644 --- a/rs/tests/driver/src/driver/test_env_api.rs +++ b/rs/tests/driver/src/driver/test_env_api.rs @@ -1650,10 +1650,10 @@ pub fn read_var_from_volatile_status_file(var_name: &str) -> Option { panic!("Couldn't read content of the {volatile_status_path:?} file: {e:?}") }); for line in content.lines() { - if let Some((name, value)) = line.split_once(' ') { - if name.trim() == var_name { - return Some(value.trim().to_string()); - } + if let Some((name, value)) = line.split_once(' ') + && name.trim() == var_name + { + return Some(value.trim().to_string()); } } None From b71a39f95913fa74adb6b42b69bb367f3a4d04e4 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Fri, 8 May 2026 09:10:51 +0000 Subject: [PATCH 06/12] just pass DC to volatile --- bazel/workspace_status.sh | 2 +- rs/tests/driver/src/driver/test_env_api.rs | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/bazel/workspace_status.sh b/bazel/workspace_status.sh index 366d689d9fea..daaf24519ad7 100755 --- a/bazel/workspace_status.sh +++ b/bazel/workspace_status.sh @@ -29,4 +29,4 @@ fi echo "STABLE_FARM_METADATA $STABLE_FARM_METADATA" # Used for allocating a Farm testnet to the local DC in CI (Search for allocate_testnet_to_local_dc) -echo "NODE_NAME ${NODE_NAME:-}" +echo "DC ${NODE_NAME%%-*}" \ No newline at end of file diff --git a/rs/tests/driver/src/driver/test_env_api.rs b/rs/tests/driver/src/driver/test_env_api.rs index 997fe1782666..f12f1334a654 100644 --- a/rs/tests/driver/src/driver/test_env_api.rs +++ b/rs/tests/driver/src/driver/test_env_api.rs @@ -1512,17 +1512,8 @@ impl HasGroupSetup for TestEnv { match InfraProvider::read_attribute(self) { InfraProvider::Farm => { let required_host_features = if allocate_testnet_to_local_dc { - let node_name = read_var_from_volatile_status_file("NODE_NAME"); - if let Some(name) = node_name { - let dc = name - .split_once('-') - .expect("NODE_NAME doesn't contain '-'") - .0 - .to_string(); - vec![HostFeature::DC(dc.clone())] - } else { - vec![] - } + read_var_from_volatile_status_file("DC") + .map_or_else(Vec::new, |dc| vec![HostFeature::DC(dc.clone())]) } else { vec![] }; From fb2094a393637707ec082bb932d639b42880429f Mon Sep 17 00:00:00 2001 From: IDX GitHub Automation Date: Fri, 8 May 2026 09:14:54 +0000 Subject: [PATCH 07/12] Automatically fixing code for linting and formatting issues --- bazel/workspace_status.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazel/workspace_status.sh b/bazel/workspace_status.sh index daaf24519ad7..5b8cf59df4a9 100755 --- a/bazel/workspace_status.sh +++ b/bazel/workspace_status.sh @@ -29,4 +29,4 @@ fi echo "STABLE_FARM_METADATA $STABLE_FARM_METADATA" # Used for allocating a Farm testnet to the local DC in CI (Search for allocate_testnet_to_local_dc) -echo "DC ${NODE_NAME%%-*}" \ No newline at end of file +echo "DC ${NODE_NAME%%-*}" From 3a630842b7520052c16eabda24bdb12ba7aa729a Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Fri, 8 May 2026 09:26:01 +0000 Subject: [PATCH 08/12] fix --- bazel/workspace_status.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bazel/workspace_status.sh b/bazel/workspace_status.sh index 5b8cf59df4a9..9664b11d757c 100755 --- a/bazel/workspace_status.sh +++ b/bazel/workspace_status.sh @@ -29,4 +29,5 @@ fi echo "STABLE_FARM_METADATA $STABLE_FARM_METADATA" # Used for allocating a Farm testnet to the local DC in CI (Search for allocate_testnet_to_local_dc) +NODE_NAME="${NODE_NAME:-}" echo "DC ${NODE_NAME%%-*}" From a415d64ccde11e1c215921792e1d27445f474ac0 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Fri, 8 May 2026 12:51:27 +0000 Subject: [PATCH 09/12] Use write_version_file_var --- bazel/BUILD.bazel | 7 +----- bazel/defs.bzl | 26 +++++++++++++++------- rs/tests/BUILD.bazel | 8 ++++++- rs/tests/driver/src/driver/test_env_api.rs | 23 +++++-------------- rs/tests/system_tests.bzl | 2 +- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/bazel/BUILD.bazel b/bazel/BUILD.bazel index fc3fadd4787e..c435675aceb8 100644 --- a/bazel/BUILD.bazel +++ b/bazel/BUILD.bazel @@ -1,6 +1,6 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") load("@buildifier_prebuilt//:rules.bzl", "buildifier") -load("//bazel:defs.bzl", "volatile_status", "write_info_file_var") +load("//bazel:defs.bzl", "write_info_file_var") bool_flag( name = "enable_malicious_code", @@ -72,11 +72,6 @@ write_info_file_var( visibility = ["//visibility:public"], ) -volatile_status( - name = "volatile-status.txt", - visibility = ["//visibility:public"], -) - exports_files( [ "prost_generator.sh", diff --git a/bazel/defs.bzl b/bazel/defs.bzl index e15139b3441c..bcaa410c99bc 100644 --- a/bazel/defs.bzl +++ b/bazel/defs.bzl @@ -368,14 +368,24 @@ write_info_file_var = rule( }, ) -def _volatile_status_impl(ctx): - return [DefaultInfo( - files = depset([ctx.version_file]), - runfiles = ctx.runfiles(files = [ctx.version_file]), - )] - -volatile_status = rule( - implementation = _volatile_status_impl, +def _write_version_file_var_impl(ctx): + """Helper rule that creates a file with the content of the provided var from the version file.""" + + output = ctx.actions.declare_file(ctx.label.name) + ctx.actions.run_shell( + command = """ + grep <{version_file} -e '{varname}' \\ + | cut -d' ' -f2 > {out}""".format(varname = ctx.attr.varname, version_file = ctx.version_file.path, out = output.path), + inputs = [ctx.version_file], + outputs = [output], + ) + return [DefaultInfo(files = depset([output]))] + +write_version_file_var = rule( + implementation = _write_version_file_var_impl, + attrs = { + "varname": attr.string(mandatory = True), + }, ) def file_size_check( diff --git a/rs/tests/BUILD.bazel b/rs/tests/BUILD.bazel index 6d5abb4d7bb3..bec4055eac3b 100644 --- a/rs/tests/BUILD.bazel +++ b/rs/tests/BUILD.bazel @@ -3,7 +3,7 @@ load("@rules_distroless//apt:defs.bzl", "dpkg_status") load("@rules_distroless//distroless:defs.bzl", "passwd") load("@rules_oci//oci:defs.bzl", "oci_image") load("@rules_shell//shell:sh_binary.bzl", "sh_binary") -load("//bazel:defs.bzl", "write_info_file_var") +load("//bazel:defs.bzl", "write_info_file_var", "write_version_file_var") load(":system_tests.bzl", "oci_tar", "uvm_config_image") package(default_visibility = ["//rs:system-tests-pkg"]) @@ -284,3 +284,9 @@ write_info_file_var( varname = "STABLE_FARM_METADATA", visibility = ["//visibility:public"], ) + +write_version_file_var( + name = "DC.txt", + varname = "DC", + visibility = ["//visibility:public"], +) diff --git a/rs/tests/driver/src/driver/test_env_api.rs b/rs/tests/driver/src/driver/test_env_api.rs index f12f1334a654..af64802f359b 100644 --- a/rs/tests/driver/src/driver/test_env_api.rs +++ b/rs/tests/driver/src/driver/test_env_api.rs @@ -1512,8 +1512,12 @@ impl HasGroupSetup for TestEnv { match InfraProvider::read_attribute(self) { InfraProvider::Farm => { let required_host_features = if allocate_testnet_to_local_dc { - read_var_from_volatile_status_file("DC") - .map_or_else(Vec::new, |dc| vec![HostFeature::DC(dc.clone())]) + let dc = std::env::var("DC").expect("Expected env var to DC be set"); + if dc.is_empty() { + vec![] + } else { + vec![HostFeature::DC(dc)] + } } else { vec![] }; @@ -1635,21 +1639,6 @@ pub fn read_dependency_from_env_to_string(v: &str) -> Result { read_dependency_to_string(path_from_env) } -pub fn read_var_from_volatile_status_file(var_name: &str) -> Option { - let volatile_status_path = get_dependency_path_from_env("VOLATILE_STATUS_FILE"); - let content = fs::read_to_string(&volatile_status_path).unwrap_or_else(|e| { - panic!("Couldn't read content of the {volatile_status_path:?} file: {e:?}") - }); - for line in content.lines() { - if let Some((name, value)) = line.split_once(' ') - && name.trim() == var_name - { - return Some(value.trim().to_string()); - } - } - None -} - pub fn load_wasm>(p: P) -> Vec { let mut wasm_bytes = std::fs::read(get_dependency_path(&p)) .unwrap_or_else(|e| panic!("Could not read WASM from {:?}: {e:?}", p.as_ref())); diff --git a/rs/tests/system_tests.bzl b/rs/tests/system_tests.bzl index 4cb625d0a535..e832c73641c2 100644 --- a/rs/tests/system_tests.bzl +++ b/rs/tests/system_tests.bzl @@ -121,7 +121,6 @@ def system_test( _runtime_deps = dict(runtime_deps) _runtime_deps["TEST_BIN"] = test_driver_target - _runtime_deps["VOLATILE_STATUS_FILE"] = "//bazel:volatile-status.txt" env_var_files = {} icos_images = dict() @@ -134,6 +133,7 @@ def system_test( icos_images |= icos_config.icos_images env_var_files["FARM_METADATA"] = "//rs/tests:farm_metadata.txt" + env_var_files["DC"] = "//rs/tests:DC.txt" extra_args_simple = [] extra_args_colocated = [] From 4e15a932a8a10058fdf81890b3c8308661f70b74 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Fri, 8 May 2026 12:58:51 +0000 Subject: [PATCH 10/12] doc --- rs/tests/driver/src/driver/test_env_api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rs/tests/driver/src/driver/test_env_api.rs b/rs/tests/driver/src/driver/test_env_api.rs index af64802f359b..0879cf7063bf 100644 --- a/rs/tests/driver/src/driver/test_env_api.rs +++ b/rs/tests/driver/src/driver/test_env_api.rs @@ -1512,7 +1512,7 @@ impl HasGroupSetup for TestEnv { match InfraProvider::read_attribute(self) { InfraProvider::Farm => { let required_host_features = if allocate_testnet_to_local_dc { - let dc = std::env::var("DC").expect("Expected env var to DC be set"); + let dc = std::env::var("DC").expect("Expected env var 'DC' to be set"); if dc.is_empty() { vec![] } else { From a896b764b52f3c4176352943d9c2b31e95c7613b Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Fri, 8 May 2026 13:01:45 +0000 Subject: [PATCH 11/12] refactor --- rs/tests/driver/src/driver/test_env_api.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rs/tests/driver/src/driver/test_env_api.rs b/rs/tests/driver/src/driver/test_env_api.rs index 0879cf7063bf..bb779c9781fd 100644 --- a/rs/tests/driver/src/driver/test_env_api.rs +++ b/rs/tests/driver/src/driver/test_env_api.rs @@ -1511,15 +1511,11 @@ impl HasGroupSetup for TestEnv { let group_setup = GroupSetup::new(group_base_name.clone(), timeout); match InfraProvider::read_attribute(self) { InfraProvider::Farm => { - let required_host_features = if allocate_testnet_to_local_dc { - let dc = std::env::var("DC").expect("Expected env var 'DC' to be set"); - if dc.is_empty() { - vec![] - } else { - vec![HostFeature::DC(dc)] - } - } else { - vec![] + let required_host_features = match allocate_testnet_to_local_dc + .then(|| std::env::var("DC").expect("Expected env var 'DC' to be set")) + { + Some(dc) if !dc.is_empty() => vec![HostFeature::DC(dc)], + _ => vec![], }; info!( log, From 57abc755ada914313936d07f12b2354586fa7bd9 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Fri, 8 May 2026 13:05:29 +0000 Subject: [PATCH 12/12] drop visibility for DC.txt, as it is only used in rs/tests/system_tests.bzl and not in bazel/BUILD.bazel anymore --- rs/tests/BUILD.bazel | 1 - 1 file changed, 1 deletion(-) diff --git a/rs/tests/BUILD.bazel b/rs/tests/BUILD.bazel index bec4055eac3b..134fc212c8a7 100644 --- a/rs/tests/BUILD.bazel +++ b/rs/tests/BUILD.bazel @@ -288,5 +288,4 @@ write_info_file_var( write_version_file_var( name = "DC.txt", varname = "DC", - visibility = ["//visibility:public"], )