diff --git a/nexus/src/external_api/http_entrypoints.rs b/nexus/src/external_api/http_entrypoints.rs index 670bac84a2d..bf080d4d4cb 100644 --- a/nexus/src/external_api/http_entrypoints.rs +++ b/nexus/src/external_api/http_entrypoints.rs @@ -366,17 +366,6 @@ pub fn external_api() -> NexusApiDescription { // clients. Client generators use operationId to name API methods, so changing // a function name is a breaking change from a client perspective. -#[derive(Clone, Debug, Eq, PartialEq, Serialize, JsonSchema)] -#[serde(rename_all = "snake_case")] -enum SystemHealthStatus { - Ok, -} - -#[derive(Clone, Debug, Eq, PartialEq, Serialize, JsonSchema)] -struct SystemHealth { - status: SystemHealthStatus, -} - /// Get API status /// /// Always tries to return Ok. If the API is down, it will either 500 or time out. @@ -387,8 +376,10 @@ struct SystemHealth { }] async fn system_health( _rqctx: RequestContext>, -) -> Result, HttpError> { - Ok(HttpResponseOk(SystemHealth { status: SystemHealthStatus::Ok })) +) -> Result, HttpError> { + Ok(HttpResponseOk(views::SystemHealth { + status: views::SystemHealthStatus::Ok, + })) } /// Fetch the top-level IAM policy diff --git a/nexus/tests/integration_tests/basic.rs b/nexus/tests/integration_tests/basic.rs index 65f724e380a..7bb04e8e269 100644 --- a/nexus/tests/integration_tests/basic.rs +++ b/nexus/tests/integration_tests/basic.rs @@ -13,7 +13,8 @@ use http::StatusCode; use omicron_common::api::external::IdentityMetadataCreateParams; use omicron_common::api::external::IdentityMetadataUpdateParams; use omicron_common::api::external::Name; -use omicron_nexus::external_api::{params, views::Project}; +use omicron_nexus::external_api::params; +use omicron_nexus::external_api::views::{self, Project}; use serde::Serialize; use uuid::Uuid; @@ -546,3 +547,13 @@ async fn test_projects_list(cptestctx: &ControlPlaneTestContext) { .collect::>() ); } + +#[nexus_test] +async fn test_system_health(cptestctx: &ControlPlaneTestContext) { + let client = &cptestctx.external_client; + + let health = NexusRequest::object_get(client, "/v1/system/health") + .execute_and_parse_unwrap::() + .await; + assert_eq!(health.status, views::SystemHealthStatus::Ok); +} diff --git a/nexus/tests/integration_tests/endpoints.rs b/nexus/tests/integration_tests/endpoints.rs index e140ce36208..5e3dd374267 100644 --- a/nexus/tests/integration_tests/endpoints.rs +++ b/nexus/tests/integration_tests/endpoints.rs @@ -1874,6 +1874,5 @@ lazy_static! { AllowedMethod::GetNonexistent ], }, - ]; } diff --git a/nexus/tests/output/uncovered-authz-endpoints.txt b/nexus/tests/output/uncovered-authz-endpoints.txt index 0e53222a8a6..376f611c370 100644 --- a/nexus/tests/output/uncovered-authz-endpoints.txt +++ b/nexus/tests/output/uncovered-authz-endpoints.txt @@ -1,4 +1,5 @@ API endpoints with no coverage in authz tests: +system_health (get "/v1/system/health") device_auth_request (post "/device/auth") device_auth_confirm (post "/device/confirm") device_access_token (post "/device/token") diff --git a/nexus/types/src/external_api/views.rs b/nexus/types/src/external_api/views.rs index 4b30b0be1c3..23da3582d33 100644 --- a/nexus/types/src/external_api/views.rs +++ b/nexus/types/src/external_api/views.rs @@ -522,3 +522,16 @@ pub struct UpdateDeployment { pub version: SemverVersion, pub status: UpdateStatus, } + +// SYSTEM HEALTH + +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum SystemHealthStatus { + Ok, +} + +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)] +pub struct SystemHealth { + pub status: SystemHealthStatus, +}