Skip to content
Open
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: 0 additions & 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/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ follows the hierarchical structure of the tests. For example:
├── api_test <<== POT name
│ ├── setup <<== data related to the setup of this pot
│ │ ├── ic_prep
│ │ │ ├── blessed_replica_versions.pb
│ │ │ ├── elected_replica_versions.pb
│ │ │ <... etc. etc. ...>
│ │ └── test.log <<== logs produced during the setup
│ └── tests
Expand Down
7 changes: 4 additions & 3 deletions rs/tests/consensus/backup/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use ic_backup::{
config::{ColdStorage, Config, SubnetConfig},
};
use ic_base_types::SubnetId;
use ic_consensus_system_test_utils::upgrade::bless_replica_version;
use ic_consensus_system_test_utils::upgrade::elect_replica_version;
use ic_consensus_system_test_utils::{
rw_message::install_nns_and_check_progress,
ssh_access::{
Expand Down Expand Up @@ -103,12 +103,13 @@ pub fn test(env: TestEnv) {
let binary_version = get_ic_build_version();
let target_version = get_guestos_update_img_version();

// Bless target version
// Elect target version
let sha256 = get_guestos_update_img_sha256();
let upgrade_url = get_guestos_update_img_url();
let guest_launch_measurements = get_guestos_update_launch_measurements();
block_on(bless_replica_version(
block_on(elect_replica_version(
&nns_node,
&env.topology_snapshot(),
&target_version,
&log,
sha256,
Expand Down
5 changes: 3 additions & 2 deletions rs/tests/consensus/orchestrator/unstuck_subnet_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end::catalog[] */
use anyhow::Result;
use anyhow::bail;
use ic_consensus_system_test_utils::upgrade::{
bless_replica_version, deploy_guestos_to_all_subnet_nodes, get_assigned_replica_version,
deploy_guestos_to_all_subnet_nodes, elect_replica_version, get_assigned_replica_version,
};
use ic_consensus_system_test_utils::{
rw_message::{
Expand Down Expand Up @@ -72,8 +72,9 @@ fn test(test_env: TestEnv) {
let upgrade_url = get_guestos_initial_update_img_url();
let expected_sha256 = get_guestos_update_img_sha256();
let guest_launch_measurements = get_guestos_update_launch_measurements();
block_on(bless_replica_version(
block_on(elect_replica_version(
&nns_node,
&test_env.topology_snapshot(),
&target_version,
&logger,
expected_sha256.clone(),
Expand Down
4 changes: 2 additions & 2 deletions rs/tests/consensus/subnet_recovery/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ pub mod local {
};
let upgrade_image_launch_measurements_path_cli =
opt_cli_arg!(upgrade_image_launch_measurements_path);
let add_and_bless_upgrade_version_cli = opt_cli_arg!(add_and_bless_upgrade_version);
let add_upgrade_version_cli = opt_cli_arg!(add_and_bless_upgrade_version);
let replay_until_height_cli = opt_cli_arg!(replay_until_height);
let download_pool_node_cli = opt_cli_arg!(download_pool_node);
// We are doing a local recovery, so we override the admin access location to "local"
Expand Down Expand Up @@ -608,7 +608,7 @@ pub mod local {
{upgrade_image_url_cli} \
{upgrade_image_hash_cli} \
{upgrade_image_launch_measurements_path_cli} \
{add_and_bless_upgrade_version_cli} \
{add_upgrade_version_cli} \
{replay_until_height_cli} \
{download_pool_node_cli} \
{admin_access_location_cli} \
Expand Down
11 changes: 6 additions & 5 deletions rs/tests/consensus/upgrade/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use ic_consensus_system_test_utils::rw_message::{
};
use ic_consensus_system_test_utils::subnet::enable_chain_key_signing_on_subnet;
use ic_consensus_system_test_utils::upgrade::{
assert_assigned_replica_version, bless_replica_version, deploy_guestos_to_all_subnet_nodes,
assert_assigned_replica_version, deploy_guestos_to_all_subnet_nodes, elect_replica_version,
};
use ic_consensus_threshold_sig_system_test_utils::{
get_public_key_with_retries, run_chain_key_signature_test,
Expand All @@ -44,24 +44,25 @@ const ALLOWED_FAILURES: usize = 1;
pub const UP_DOWNGRADE_OVERALL_TIMEOUT: Duration = Duration::from_secs(25 * 60);
pub const UP_DOWNGRADE_PER_TEST_TIMEOUT: Duration = Duration::from_secs(20 * 60);

pub fn bless_target_version(env: &TestEnv, nns_node: &IcNodeSnapshot) -> ReplicaVersion {
pub fn elect_target_version(env: &TestEnv, nns_node: &IcNodeSnapshot) -> ReplicaVersion {
let logger = env.logger();

let target_version = get_guestos_update_img_version();

// Bless target version
// Elect target version
let sha256 = get_guestos_update_img_sha256();
let upgrade_url = get_guestos_update_img_url();
let guest_launch_measurements = get_guestos_update_launch_measurements();
block_on(bless_replica_version(
block_on(elect_replica_version(
nns_node,
&env.topology_snapshot(),
&target_version,
&logger,
sha256,
Some(guest_launch_measurements),
vec![upgrade_url.to_string()],
));
info!(&logger, "Blessed target version");
info!(&logger, "Elected target version");

target_version
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use slog::Logger;
use tokio::runtime::{Builder, Runtime};

use ic_consensus_system_test_upgrade_common::{
bless_target_version, get_chain_key_canister_and_public_key, upgrade,
elect_target_version, get_chain_key_canister_and_public_key, upgrade,
};
use ic_consensus_system_test_utils::rw_message::{
can_read_msg_with_retries, install_nns_and_check_progress,
Expand Down Expand Up @@ -74,7 +74,7 @@ fn setup(env: TestEnv) {
// Tests an upgrade of the app subnet to the target version and a downgrade back to the initial version
fn upgrade_downgrade_app_subnet(env: TestEnv) {
let nns_node = env.get_first_healthy_system_node_snapshot();
let target_version = bless_target_version(&env, &nns_node);
let target_version = elect_target_version(&env, &nns_node);
let agent = nns_node.with_default_agent(|agent| async move { agent });
let key_ids = make_key_ids_for_all_schemes();
let ecdsa_state = get_chain_key_canister_and_public_key(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::time::Duration;

use anyhow::Result;

use ic_consensus_system_test_upgrade_common::{bless_target_version, upgrade};
use ic_consensus_system_test_upgrade_common::{elect_target_version, upgrade};
use ic_consensus_system_test_utils::rw_message::{
can_read_msg_with_retries, install_nns_and_check_progress,
};
Expand Down Expand Up @@ -42,7 +42,7 @@ fn upgrade_downgrade_nns_subnet(env: TestEnv) {
let log = env.logger();
let nns_node = env.get_first_healthy_system_node_snapshot();

let target_version = bless_target_version(&env, &nns_node);
let target_version = elect_target_version(&env, &nns_node);
info!(log, "Upgrading NNS subnet to {} ...", target_version);
let (faulty_node, can_id, msg) =
upgrade(&env, &nns_node, &target_version, SubnetType::System, None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end::catalog[] */

use anyhow::Result;
use anyhow::bail;
use ic_consensus_system_test_upgrade_common::bless_target_version;
use ic_consensus_system_test_upgrade_common::elect_target_version;
use ic_consensus_system_test_utils::{
rw_message::install_nns_and_check_progress,
upgrade::{deploy_guestos_to_all_unassigned_nodes, fetch_unassigned_node_version},
Expand Down Expand Up @@ -83,7 +83,7 @@ fn upgrade_downgrade_unassigned_nodes(env: TestEnv) {
let nns_node = env.get_first_healthy_system_node_snapshot();
let unassigned_node = env.topology_snapshot().unassigned_nodes().next().unwrap();

let target_version = bless_target_version(&env, &nns_node);
let target_version = elect_target_version(&env, &nns_node);
info!(log, "Upgrading unassigned nodes to {} ...", target_version);
upgrade_unassigned_nodes(&log, &nns_node, &unassigned_node, &target_version);
let initial_version = get_guestos_img_version();
Expand Down
17 changes: 9 additions & 8 deletions rs/tests/consensus/upgrade/upgrade_with_alternative_urls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Goal:: Orchestrator can download the release package, even when the replica vers
contains many faulty and only one valid URLs download URLs.

Description::
We deploy a fast single node subnet. Then, we make a proposal and bless a replica version
We deploy a fast single node subnet. Then, we make a proposal and elect a replica version
with one valid and multiple invalid download URLs. Then, we propose to upgrade the replica
version of that subnet to the newly blessed version. We expect that the orchestrator can
version of that subnet to the newly elected version. We expect that the orchestrator can
download the release image via the valid URL.

Runbook::
. Deploy an IC with a single-node root subnet.
. Bless the test replica version with multiple URLs, among which only one is correct.
. Upgrade the replica version of the subnet to the newly blessed replica version.
. Elect the test replica version with multiple URLs, among which only one is correct.
. Upgrade the replica version of the subnet to the newly elected replica version.

Success::
. The replica restarts, which is a sign of the node having downloaded and verified the new
Expand All @@ -25,8 +25,8 @@ end::catalog[] */
use anyhow::Result;
use ic_consensus_system_test_utils::rw_message::install_nns_and_check_progress;
use ic_consensus_system_test_utils::upgrade::{
assert_assigned_replica_version, bless_replica_version_with_urls,
deploy_guestos_to_all_subnet_nodes, get_assigned_replica_version,
assert_assigned_replica_version, deploy_guestos_to_all_subnet_nodes,
elect_replica_version_with_urls, get_assigned_replica_version,
};
use ic_registry_subnet_type::SubnetType;
use ic_system_test_driver::driver::group::SystemTestGroup;
Expand Down Expand Up @@ -80,10 +80,11 @@ fn test(env: TestEnv) {

info!(
logger,
"Blessing the test replica version with multiple URLs: {:?}", release_package_urls
"Electing the test replica version with multiple URLs: {:?}", release_package_urls
);
block_on(bless_replica_version_with_urls(
block_on(elect_replica_version_with_urls(
&nns_node,
&env.topology_snapshot(),
&target_version,
release_package_urls,
get_guestos_update_img_sha256(),
Expand Down
1 change: 0 additions & 1 deletion rs/tests/consensus/utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ rust_library(
"//rs/protobuf",
"//rs/registry/canister",
"//rs/registry/keys",
"//rs/registry/nns_data_provider",
"//rs/registry/subnet_type",
"//rs/rust_canisters/canister_test",
"//rs/tests/consensus/tecdsa/utils",
Expand Down
1 change: 0 additions & 1 deletion rs/tests/consensus/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ ic-nns-constants = { path = "../../../nns/constants" }
ic-nns-governance-api = { path = "../../../nns/governance/api" }
ic-protobuf = { path = "../../../protobuf" }
ic-registry-keys = { path = "../../../registry/keys" }
ic-registry-nns-data-provider = { path = "../../../registry/nns_data_provider" }
ic-registry-subnet-type = { path = "../../../registry/subnet_type" }
ic-system-test-driver = { path = "../../driver" }
ic-types = { path = "../../../types/types" }
Expand Down
43 changes: 19 additions & 24 deletions rs/tests/consensus/utils/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use anyhow::{Result, bail};
use ic_canister_client::Sender;
use ic_nervous_system_common_test_keys::{TEST_NEURON_1_ID, TEST_NEURON_1_OWNER_KEYPAIR};
use ic_nns_common::types::NeuronId;
use ic_protobuf::registry::replica_version::v1::{BlessedReplicaVersions, GuestLaunchMeasurements};
use ic_registry_keys::make_blessed_replica_versions_key;
use ic_registry_nns_data_provider::registry::RegistryCanister;
use ic_protobuf::registry::replica_version::v1::GuestLaunchMeasurements;
use ic_system_test_driver::{
driver::{group::assert_no_critical_errors, test_env_api::*},
nns::{
Expand All @@ -15,21 +13,16 @@ use ic_system_test_driver::{
util::runtime_from_url,
};
use ic_types::{ReplicaVersion, SubnetId, messages::ReplicaHealthStatus};
use prost::Message;
use slog::{Logger, info};
use std::{convert::TryFrom, io::Read, path::Path};

pub async fn get_blessed_replica_versions(
registry_canister: &RegistryCanister,
) -> BlessedReplicaVersions {
let blessed_vers_result = registry_canister
.get_value(
make_blessed_replica_versions_key().as_bytes().to_vec(),
None,
)
.await
.unwrap();
BlessedReplicaVersions::decode(&*blessed_vers_result.0).unwrap()
pub async fn get_elected_replica_versions(topology: &TopologySnapshot) -> Vec<String> {
topology
.replica_version_records()
.unwrap()
.into_iter()
.map(|(k, _)| k)
.collect()
}

/// Reads the replica version from an unassigned node.
Expand Down Expand Up @@ -136,16 +129,18 @@ pub fn get_assigned_replica_version(node: &IcNodeSnapshot) -> Result<ReplicaVers
ReplicaVersion::try_from(version).map_err(|_| "Invalid replica version".to_string())
}

pub async fn bless_replica_version(
pub async fn elect_replica_version(
nns_node: &IcNodeSnapshot,
topology: &TopologySnapshot,
target_version: &ReplicaVersion,
logger: &Logger,
sha256: String,
guest_launch_measurements: Option<GuestLaunchMeasurements>,
upgrade_url: Vec<String>,
) {
bless_replica_version_with_urls(
elect_replica_version_with_urls(
nns_node,
topology,
target_version,
upgrade_url,
sha256,
Expand All @@ -155,8 +150,9 @@ pub async fn bless_replica_version(
.await;
}

pub async fn bless_replica_version_with_urls(
pub async fn elect_replica_version_with_urls(
nns_node: &IcNodeSnapshot,
topology: &TopologySnapshot,
target_version: &ReplicaVersion,
release_package_urls: Vec<String>,
sha256: String,
Expand All @@ -165,15 +161,14 @@ pub async fn bless_replica_version_with_urls(
) {
let nns = runtime_from_url(nns_node.get_public_url(), nns_node.effective_canister_id());
let governance_canister = get_governance_canister(&nns);
let registry_canister = RegistryCanister::new(vec![nns_node.get_public_url()]);
let test_neuron_id = NeuronId(TEST_NEURON_1_ID);
let proposal_sender = Sender::from_keypair(&TEST_NEURON_1_OWNER_KEYPAIR);
let blessed_versions = get_blessed_replica_versions(&registry_canister).await;
info!(logger, "Initial: {:?}", blessed_versions);
let replica_versions = get_elected_replica_versions(topology).await;
info!(logger, "Initial: {:?}", replica_versions);

info!(
logger,
"Blessing replica version {} with sha256 {}", target_version, sha256
"Adding replica version {} with sha256 {}", target_version, sha256
);

let proposal_id = submit_update_elected_replica_versions_proposal(
Expand All @@ -188,8 +183,8 @@ pub async fn bless_replica_version_with_urls(
)
.await;
vote_execute_proposal_assert_executed(&governance_canister, proposal_id).await;
let blessed_versions = get_blessed_replica_versions(&registry_canister).await;
info!(logger, "Updated: {:?}", blessed_versions);
let replica_versions = get_elected_replica_versions(topology).await;
info!(logger, "Updated: {:?}", replica_versions);
}

pub async fn deploy_guestos_to_all_subnet_nodes(
Expand Down
6 changes: 3 additions & 3 deletions rs/tests/dre/guest_os_qualification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn main() -> anyhow::Result<()> {
.build()
.expect("Should be able to build runtime"),
vec![
// Ensure that the initial version is blessed
// Ensure that the initial version is elected
// Since we are using our config this should
// always be the case.
Box::new(EnsureElectedVersion {
Expand Down Expand Up @@ -135,7 +135,7 @@ pub fn main() -> anyhow::Result<()> {
Box::new(UpdateApiBoundaryNodes {
version: initial_version.clone(),
}),
// Ensure that the new version is blessed
// Ensure that the new version is elected
Box::new(EnsureElectedVersion {
version: target_version.clone(),
url: get_guestos_update_img_url(),
Expand Down Expand Up @@ -190,7 +190,7 @@ pub fn main() -> anyhow::Result<()> {
Box::new(RetireElectedVersions {
versions: vec![initial_version.clone()],
}),
// Ensure that the old version is blessed
// Ensure that the old version is elected
// if it was retired previously
Box::new(EnsureElectedVersion {
version: initial_version.clone(),
Expand Down
Loading
Loading