Skip to content

Commit 7e64b2a

Browse files
authored
fix(router): use 503 instead of 500 when router is not ready (#512)
1 parent 8b9d9c8 commit 7e64b2a

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

bin/router/src/http_utils/probes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ pub async fn readiness_check_handler(
1414
if schema_state.is_ready() {
1515
web::HttpResponse::Ok()
1616
} else {
17-
web::HttpResponse::InternalServerError()
17+
web::HttpResponse::ServiceUnavailable()
1818
}
1919
}

e2e/src/hive_cdn_supergraph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ mod hive_cdn_supergraph_e2e_tests {
204204
source: hive
205205
endpoint: http://{host}/supergraph
206206
key: dummy_key
207-
poll_interval: 500ms
207+
poll_interval: 800ms
208208
"#,
209209
))
210210
.await
@@ -234,7 +234,7 @@ mod hive_cdn_supergraph_e2e_tests {
234234
assert_eq!(types_arr.len(), 14);
235235

236236
// Now wait for the schema to be reloaded and updated
237-
sleep(Duration::from_millis(600)).await;
237+
sleep(Duration::from_millis(900)).await;
238238
mock2.assert();
239239

240240
let resp = test::call_service(

e2e/src/supergraph.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[cfg(test)]
2-
mod jwt_e2e_tests {
2+
mod supergraph_e2e_tests {
33
use std::{sync::Arc, time::Duration};
44

55
use ntex::{time, web::test};
@@ -207,22 +207,15 @@ mod jwt_e2e_tests {
207207
mock1.assert();
208208

209209
let app_clone = test_app.app.clone();
210-
let resp_handle = ntex::rt::spawn(async move {
211-
let response = test::call_service(
212-
&app_clone.clone(),
213-
init_graphql_request("{ users { id name reviews { id body } } }", None)
214-
.to_request(),
215-
)
216-
.await;
217-
assert!(response.status().is_success(), "Expected 200 OK");
218-
let body = test::read_body(response).await;
219-
let json_body: Value = from_slice(&body).unwrap();
220-
221-
json_body
222-
});
210+
let response = test::call_service(
211+
&app_clone.clone(),
212+
init_graphql_request("{ users { id name reviews { id body } } }", None).to_request(),
213+
)
214+
.await;
215+
assert!(response.status().is_success(), "Expected 200 OK");
216+
let body = test::read_body(response).await;
217+
let resp: Value = from_slice(&body).unwrap();
223218

224-
ntex::time::sleep(Duration::from_millis(100)).await;
225-
let resp = resp_handle.await.unwrap();
226219
mock2.assert();
227220

228221
assert!(resp["data"].is_object());

0 commit comments

Comments
 (0)