Skip to content

Commit

Permalink
rebase main
Browse files Browse the repository at this point in the history
Created using spr 1.3.6-beta.1
  • Loading branch information
papertigers committed Dec 3, 2024
2 parents d38bf65 + 24b59fc commit 27e18dd
Show file tree
Hide file tree
Showing 20 changed files with 272 additions and 5,846 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.

12 changes: 12 additions & 0 deletions dev-tools/omdb/tests/test_all_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use dropshot::Method;
use expectorate::assert_contents;
use http::StatusCode;
use nexus_test_utils::wait_for_producer;
use nexus_test_utils::{OXIMETER_UUID, PRODUCER_UUID};
use nexus_test_utils_macros::nexus_test;
use nexus_types::deployment::Blueprint;
Expand All @@ -23,6 +24,7 @@ use std::fmt::Write;
use std::net::IpAddr;
use std::path::Path;
use subprocess::Exec;
use uuid::Uuid;

/// name of the "omdb" executable
const CMD_OMDB: &str = env!("CARGO_BIN_EXE_omdb");
Expand Down Expand Up @@ -274,6 +276,11 @@ async fn test_omdb_success_cases(cptestctx: &ControlPlaneTestContext) {
let mut ox_output = String::new();
let ox = ox_url.clone();

wait_for_producer(
&cptestctx.oximeter,
PRODUCER_UUID.parse::<Uuid>().unwrap(),
)
.await;
do_run_no_redactions(
&mut ox_output,
move |exec| exec.env("OMDB_OXIMETER_URL", &ox),
Expand Down Expand Up @@ -423,6 +430,11 @@ async fn test_omdb_env_settings(cptestctx: &ControlPlaneTestContext) {
// Case 2: is covered by the success tests above.
let ox_args1 = &["oximeter", "--oximeter-url", &ox_url, "list-producers"];
let mut ox_output1 = String::new();
wait_for_producer(
&cptestctx.oximeter,
PRODUCER_UUID.parse::<Uuid>().unwrap(),
)
.await;
do_run_no_redactions(
&mut ox_output1,
move |exec| exec,
Expand Down
38 changes: 38 additions & 0 deletions nexus/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ use omicron_common::disk::CompressionAlgorithm;
use omicron_common::zpool_name::ZpoolName;
use omicron_sled_agent::sim;
use omicron_test_utils::dev;
use omicron_test_utils::dev::poll::{wait_for_condition, CondCheckError};
use omicron_uuid_kinds::DatasetUuid;
use omicron_uuid_kinds::ExternalIpUuid;
use omicron_uuid_kinds::GenericUuid;
Expand Down Expand Up @@ -1716,3 +1717,40 @@ pub async fn start_dns_server(

Ok((dns_server, http_server, resolver))
}

/// Wait until a producer is registered with Oximeter.
///
/// This blocks until the producer is registered, for up to 60s. It panics if
/// the retry loop hits a permanent error.
pub async fn wait_for_producer<G: GenericUuid>(
oximeter: &oximeter_collector::Oximeter,
producer_id: G,
) {
wait_for_producer_impl(oximeter, producer_id.into_untyped_uuid()).await;
}

// This function is outlined from wait_for_producer to avoid unnecessary
// monomorphization.
async fn wait_for_producer_impl(
oximeter: &oximeter_collector::Oximeter,
producer_id: Uuid,
) {
wait_for_condition(
|| async {
if oximeter
.list_producers(None, usize::MAX)
.await
.iter()
.any(|p| p.id == producer_id)
{
Ok(())
} else {
Err(CondCheckError::<()>::NotYet)
}
},
&Duration::from_secs(1),
&Duration::from_secs(60),
)
.await
.expect("Failed to find producer within time limit");
}
3 changes: 1 addition & 2 deletions nexus/tests/integration_tests/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

//! Tests basic disk support in the API
use crate::integration_tests::metrics::wait_for_producer;

use super::instances::instance_wait_for_state;
use super::metrics::{get_latest_silo_metric, query_for_metrics};
use chrono::Utc;
Expand All @@ -32,6 +30,7 @@ use nexus_test_utils::resource_helpers::create_instance;
use nexus_test_utils::resource_helpers::create_instance_with;
use nexus_test_utils::resource_helpers::create_project;
use nexus_test_utils::resource_helpers::objects_list_page_authz;
use nexus_test_utils::wait_for_producer;
use nexus_test_utils::SLED_AGENT_UUID;
use nexus_test_utils_macros::nexus_test;
use nexus_types::external_api::params;
Expand Down
3 changes: 1 addition & 2 deletions nexus/tests/integration_tests/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

//! Tests basic instance support in the API
use crate::integration_tests::metrics::wait_for_producer;

use super::external_ips::floating_ip_get;
use super::external_ips::get_floating_ip_by_id_url;
use super::metrics::{get_latest_silo_metric, get_latest_system_metric};
Expand Down Expand Up @@ -39,6 +37,7 @@ use nexus_test_utils::resource_helpers::object_put;
use nexus_test_utils::resource_helpers::objects_list_page_authz;
use nexus_test_utils::resource_helpers::DiskTest;
use nexus_test_utils::start_sled_agent;
use nexus_test_utils::wait_for_producer;
use nexus_types::external_api::params::SshKeyCreate;
use nexus_types::external_api::shared::IpKind;
use nexus_types::external_api::shared::IpRange;
Expand Down
38 changes: 1 addition & 37 deletions nexus/tests/integration_tests/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use nexus_test_utils::resource_helpers::{
create_default_ip_pool, create_disk, create_instance, create_project,
objects_list_page_authz, DiskTest,
};
use nexus_test_utils::wait_for_producer;
use nexus_test_utils::ControlPlaneTestContext;
use nexus_test_utils_macros::nexus_test;
use nexus_types::external_api::views::OxqlQueryResult;
Expand Down Expand Up @@ -790,40 +791,3 @@ async fn test_mgs_metrics(
// this test, we are responsible for removing its logs.
mgs.logctx.cleanup_successful();
}

/// Wait until a producer is registered with Oximeter.
///
/// This blocks until the producer is registered, for up to 60s. It panics if
/// the retry loop hits a permanent error.
pub async fn wait_for_producer<G: GenericUuid>(
oximeter: &oximeter_collector::Oximeter,
producer_id: G,
) {
wait_for_producer_impl(oximeter, producer_id.into_untyped_uuid()).await;
}

// This function is outlined from wait_for_producer to avoid unnecessary
// monomorphization.
async fn wait_for_producer_impl(
oximeter: &oximeter_collector::Oximeter,
producer_id: Uuid,
) {
wait_for_condition(
|| async {
if oximeter
.list_producers(None, usize::MAX)
.await
.iter()
.any(|p| p.id == producer_id)
{
Ok(())
} else {
Err(CondCheckError::<()>::NotYet)
}
},
&Duration::from_secs(1),
&Duration::from_secs(60),
)
.await
.expect("Failed to find producer within time limit");
}
2 changes: 1 addition & 1 deletion nexus/tests/integration_tests/oximeter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

//! Integration tests for oximeter collectors and producers.
use crate::integration_tests::metrics::wait_for_producer;
use nexus_test_interface::NexusServer;
use nexus_test_utils::wait_for_producer;
use nexus_test_utils_macros::nexus_test;
use omicron_test_utils::dev::poll::{wait_for_condition, CondCheckError};
use oximeter_db::DbWrite;
Expand Down
1 change: 1 addition & 0 deletions oximeter/collector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ semver.workspace = true
serde.workspace = true
slog.workspace = true
slog-async.workspace = true
slog-error-chain.workspace = true
slog-dtrace.workspace = true
slog-term.workspace = true
strum.workspace = true
Expand Down
Loading

0 comments on commit 27e18dd

Please sign in to comment.