From a268d0e283625c26412d1320d855905cc5fba367 Mon Sep 17 00:00:00 2001 From: tamo Date: Tue, 16 Mar 2021 17:42:01 +0100 Subject: [PATCH] return a 200 on health check --- meilisearch-http/src/routes/health.rs | 3 ++- meilisearch-http/tests/stats/mod.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/meilisearch-http/src/routes/health.rs b/meilisearch-http/src/routes/health.rs index c57e4c7e9..053790d61 100644 --- a/meilisearch-http/src/routes/health.rs +++ b/meilisearch-http/src/routes/health.rs @@ -9,5 +9,6 @@ pub fn services(cfg: &mut web::ServiceConfig) { #[get("/health")] async fn get_health() -> Result { - Ok(HttpResponse::NoContent().finish()) + let payload = serde_json::json!({ "status": "available" }); + Ok(HttpResponse::Ok().body(payload.to_string())) } diff --git a/meilisearch-http/tests/stats/mod.rs b/meilisearch-http/tests/stats/mod.rs index 733e2ba79..5e3c9db45 100644 --- a/meilisearch-http/tests/stats/mod.rs +++ b/meilisearch-http/tests/stats/mod.rs @@ -10,3 +10,12 @@ async fn get_settings_unexisting_index() { assert!(version.get("buildDate").is_some()); assert!(version.get("pkgVersion").is_some()); } + +#[actix_rt::test] +async fn test_healthyness() { + let server = Server::new().await; + + let (response, status_code) = server.service.get("/health").await; + assert_eq!(status_code, 200); + assert_eq!(response["status"], "available"); + }