Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e9c2625
chore: support allocating testnets to the local DC
basvandijk May 7, 2026
843e0c9
Automatically fixing code for linting and formatting issues
May 7, 2026
9a878ba
fix clippy
basvandijk May 7, 2026
a4157cf
Use .allocate_testnet_to_local_dc() on all nested tests
basvandijk May 7, 2026
47e971b
fix clippy
basvandijk May 7, 2026
b71a39f
just pass DC to volatile
basvandijk May 8, 2026
fb2094a
Automatically fixing code for linting and formatting issues
May 8, 2026
3a63084
fix
basvandijk May 8, 2026
a415d64
Use write_version_file_var
basvandijk May 8, 2026
4e15a93
doc
basvandijk May 8, 2026
a896b76
refactor
basvandijk May 8, 2026
57abc75
drop visibility for DC.txt, as it is only used in rs/tests/system_tes…
basvandijk May 8, 2026
2751444
Revert "drop visibility for DC.txt, as it is only used in rs/tests/sy…
basvandijk May 11, 2026
afe5159
Revert "refactor"
basvandijk May 11, 2026
65896d0
Revert "doc"
basvandijk May 11, 2026
700dedd
Revert "Use write_version_file_var"
basvandijk May 11, 2026
22dc1c3
doc
basvandijk May 11, 2026
f4ce2ab
Use DC unknown by default
basvandijk May 11, 2026
4fbfba9
Make Farm metadata volatile
basvandijk May 12, 2026
4f02028
Merge branch 'master' into basvandijk/allocate_testnet_to_local_dc
basvandijk May 12, 2026
a483af3
Merge remote-tracking branch 'origin/master' into basvandijk/allocate…
basvandijk May 13, 2026
f6fdff5
use consistent naming for stable and volatile status
basvandijk May 13, 2026
2b33326
address code review comments
basvandijk May 13, 2026
1ad47e6
rm read_var_from_volatile_status_file
basvandijk May 13, 2026
1fa9ace
rename
basvandijk May 13, 2026
788836d
spelling
basvandijk May 13, 2026
ebafe4c
rename write_stable_file_var to write_stable_status_file_var
basvandijk May 13, 2026
ee3a0ec
doc
basvandijk May 13, 2026
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
20 changes: 20 additions & 0 deletions bazel/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,26 @@ write_info_file_var = rule(
},
)

def _write_version_file_var_impl(ctx):
"""Helper rule that creates a file with the content of the provided var from the version file."""
Comment thread
basvandijk marked this conversation as resolved.
Outdated

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(
name,
file,
Expand Down
4 changes: 4 additions & 0 deletions bazel/workspace_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ 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)
NODE_NAME="${NODE_NAME:-}"
Comment thread
basvandijk marked this conversation as resolved.
Outdated
echo "DC ${NODE_NAME%%-*}"
7 changes: 6 additions & 1 deletion rs/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down Expand Up @@ -284,3 +284,8 @@ write_info_file_var(
varname = "STABLE_FARM_METADATA",
visibility = ["//visibility:public"],
)

write_version_file_var(
name = "DC.txt",
varname = "DC",
)
13 changes: 12 additions & 1 deletion rs/tests/driver/src/driver/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ impl SystemTestSubGroup {
}

pub struct SystemTestGroup {
allocate_testnet_to_local_dc: bool,
setup: Option<Box<dyn PotSetupFn>>,
teardowns: Vec<Box<dyn PotSetupFn>>,
tests: Vec<SystemTestSubGroup>,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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<F: PotSetupFn>(mut self, setup: F) -> Self {
self.setup = Some(Box::new(setup));
self
Expand Down Expand Up @@ -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);
}
Expand Down
31 changes: 27 additions & 4 deletions rs/tests/driver/src/driver/test_env_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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);
Expand All @@ -1501,11 +1511,24 @@ 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 = 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,
"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,
preferred_network: None,
metadata: None,
};
Expand Down
1 change: 1 addition & 0 deletions rs/tests/nested/guestos_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions rs/tests/nested/hostos_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use std::time::Duration;

fn main() -> Result<()> {
SystemTestGroup::new()
.allocate_testnet_to_local_dc()
.with_setup(|env| {
setup(
env,
Expand Down
1 change: 1 addition & 0 deletions rs/tests/nested/nns_recovery/nr_broken_dfinity_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use std::time::Duration;

fn main() -> Result<()> {
SystemTestGroup::new()
.allocate_testnet_to_local_dc()
.with_setup(|env| {
setup(
env,
Expand Down
1 change: 1 addition & 0 deletions rs/tests/nested/nns_recovery/nr_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use std::time::Duration;

fn main() -> Result<()> {
SystemTestGroup::new()
.allocate_testnet_to_local_dc()
.with_setup(|env| {
setup(
env,
Expand Down
1 change: 1 addition & 0 deletions rs/tests/nested/nns_recovery/nr_no_bless_fix_like_np.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use std::time::Duration;

fn main() -> Result<()> {
SystemTestGroup::new()
.allocate_testnet_to_local_dc()
.with_setup(|env| {
setup(
env,
Expand Down
1 change: 1 addition & 0 deletions rs/tests/nested/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions rs/tests/system_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -133,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"
Comment thread
basvandijk marked this conversation as resolved.
Outdated

extra_args_simple = []
extra_args_colocated = []
Expand Down
Loading