Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy committed May 15, 2024
1 parent abc8e12 commit 46b1fa4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions catalyst-gateway/bin/src/service/api/health/live_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub(crate) fn set_live(flag: bool) {
IS_LIVE.store(flag, Ordering::Relaxed);
}
/// Get the started flag
#[allow(dead_code)]
fn is_live() -> bool {
IS_LIVE.load(Ordering::Relaxed)
}
Expand All @@ -28,7 +27,6 @@ pub(crate) enum Responses {
NoContent,
/// Service is possibly not running reliably.
#[oai(status = 503)]
#[allow(dead_code)]
ServiceUnavailable,
}

Expand All @@ -46,5 +44,9 @@ pub(crate) type AllResponses = WithErrorResponses<Responses>;
/// by an endpoint in a short window.
#[allow(clippy::unused_async)]
pub(crate) async fn endpoint() -> AllResponses {
Responses::NoContent.into()
if is_live() {
Responses::NoContent.into()
} else {
Responses::ServiceUnavailable.into()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from loguru import logger
import asyncio
import asyncpg
import time

from api_tests import DB_URL, check_is_live, check_is_ready, check_is_not_ready

Expand Down Expand Up @@ -38,6 +39,7 @@ async def change_schema_version():


def test_schema_version_mismatch_changes_cat_gateway_behavior():
time.sleep(3)
# Check that the `live` endpoint is OK
check_is_live()

Expand Down
2 changes: 2 additions & 0 deletions catalyst-gateway/tests/api_tests/api_tests/test_slot_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
get_date_time_to_slot_number,
)
from datetime import datetime, timezone
import time


def test_date_time_to_slot_number_endpoint():
time.sleep(3)
check_is_live()
check_is_ready()

Expand Down
2 changes: 2 additions & 0 deletions catalyst-gateway/tests/api_tests/api_tests/test_utxo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import time
from loguru import logger
from api_tests import (
check_is_live,
Expand All @@ -10,6 +11,7 @@


def test_staked_ada_endpoint():
time.sleep(3)
check_is_live()
check_is_ready()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import time
from loguru import logger
from api_tests import (
check_is_live,
Expand Down Expand Up @@ -26,6 +27,7 @@ def check_delegations(provided, expected):


def test_voter_registration_endpoint():
time.sleep(3)
check_is_live()
check_is_ready()

Expand Down

0 comments on commit 46b1fa4

Please sign in to comment.