Skip to content

Commit e4e1b13

Browse files
authored
feat(cat-gateway): Add health integration tests with proxy to nightly (#3707)
1 parent e28ce81 commit e4e1b13

File tree

4 files changed

+59
-36
lines changed

4 files changed

+59
-36
lines changed

.github/workflows/gateway-tests.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,6 @@ jobs:
106106
run: |
107107
docker compose -f catalyst-gateway/tests/docker-compose.yml up api-tests-runner --exit-code-from api-tests-runner
108108
109-
# Skip for now as it adds ~10mins to CI execution time, will try to incorporate this in nightly instead
110-
- name: Integration health thru proxy tests
111-
if: false
112-
env:
113-
API_TEST_MARKS: "health_with_proxy_endpoint"
114-
EVENT_DB_URL: "haproxy:18080"
115-
INDEX_DB_URL: "haproxy:18090"
116-
run: |
117-
docker stop cat-gateway || true
118-
docker compose -f catalyst-gateway/tests/docker-compose.yml up haproxy --detach
119-
docker compose -f catalyst-gateway/tests/docker-compose.yml up api-tests-runner --exit-code-from api-tests-runner
120-
121109
- name: Collect and upload test reports
122110
uses: actions/upload-artifact@v4
123111
if: success() || failure()

.github/workflows/nightly-ci.yml

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,65 @@ jobs:
6969
id: gateway-healthy
7070
if: ${{ steps.gateway-started.conclusion == 'success' }}
7171
run: |
72-
echo "Waiting for container to be healthy..."
73-
for i in {1..500}; do
74-
STATUS=$(docker inspect --format='{{.State.Health.Status}}' cat-gateway)
75-
echo "Health status: $STATUS"
76-
if [ "$STATUS" == "healthy" ]; then
77-
echo "Container is healthy!"
78-
break
79-
fi
80-
if [ "$STATUS" == "unhealthy" ]; then
81-
echo "Container became unhealthy."
82-
exit 1
83-
fi
84-
sleep 5
85-
done
72+
echo "Waiting for container to be healthy..."
73+
for i in {1..500}; do
74+
STATUS=$(docker inspect --format='{{.State.Health.Status}}' cat-gateway)
75+
echo "Health status: $STATUS"
76+
if [ "$STATUS" == "healthy" ]; then
77+
echo "Container is healthy!"
78+
break
79+
fi
80+
if [ "$STATUS" == "unhealthy" ]; then
81+
echo "Container became unhealthy."
82+
exit 1
83+
fi
84+
sleep 5
85+
done
8686
8787
- name: Schemathesis tests
88+
id: schemathesis-tests
8889
if: ${{ steps.gateway-healthy.conclusion == 'success' }}
8990
run: |
9091
export HYPOTHESIS_MAX_EXAMPLES=5000
9192
export MAX_RESPONSE_TIME=25000
9293
docker compose -f catalyst-gateway/tests/docker-compose.yml up schemathesis-runner --exit-code-from schemathesis-runner
9394
95+
- name: Spin up catalyst-gateway with haproxy
96+
id: gateway-with-proxy-started
97+
env:
98+
EVENT_DB_URL: "haproxy:18080"
99+
INDEX_DB_URL: "haproxy:18090"
100+
run: |
101+
docker stop cat-gateway || true
102+
docker compose -f catalyst-gateway/tests/docker-compose.yml up haproxy --detach
103+
docker compose -f catalyst-gateway/tests/docker-compose.yml up cat-gateway --detach
104+
105+
- name: Wait for cat-gateway to become healthy
106+
id: gateway-with-proxy-healthy
107+
if: ${{ steps.gateway-with-proxy-started.conclusion == 'success' }}
108+
run: |
109+
echo "Waiting for container to be healthy..."
110+
for i in {1..500}; do
111+
STATUS=$(docker inspect --format='{{.State.Health.Status}}' cat-gateway)
112+
echo "Health status: $STATUS"
113+
if [ "$STATUS" == "healthy" ]; then
114+
echo "Container is healthy!"
115+
break
116+
fi
117+
if [ "$STATUS" == "unhealthy" ]; then
118+
echo "Container became unhealthy."
119+
exit 1
120+
fi
121+
sleep 5
122+
done
123+
124+
- name: Integration health thru proxy tests
125+
if: ${{ steps.gateway-with-proxy-healthy.conclusion == 'success' }}
126+
env:
127+
API_TEST_MARKS: "health_with_proxy_endpoint"
128+
run: |
129+
docker compose -f catalyst-gateway/tests/docker-compose.yml up api-tests-runner --exit-code-from api-tests-runner
130+
94131
slack:
95132
name: slack notification
96133
needs: tests

catalyst-gateway/tests/api_tests/integration/test_health_thru_proxy.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44

55
from api.v1 import rbac
6-
from api.v1 import document
6+
from api.v2 import document
77
from utils import health
88
from utils.rbac_chain import rbac_chain_factory, Chain
99
from utils import ProxyHelper
@@ -39,7 +39,7 @@ def test_ready_endpoint_with_event_db_outage(event_db_proxy, rbac_chain_factory)
3939
event_db_proxy.disable()
4040
health.is_ready() #assertion
4141
# event-db threshold to start returning 503
42-
sleep(35)
42+
sleep(120)
4343
resp = document.post(filter={},limit=10,page=0)
4444
assert(resp.status_code == 503), f"Expected document index to fail: {resp.status_code} - {resp.text}"
4545
health.is_not_ready(5) #assertion
@@ -84,19 +84,20 @@ def test_ready_endpoint_with_index_db_outage(index_db_proxy, rbac_chain_factory)
8484
index_db_proxy.disable()
8585
health.is_ready() #assertion
8686
# index-db threshold to start returning 503
87-
sleep(180)
88-
# Index DB testing
89-
resp = rbac.get(lookup=stake_address_not_registered, token=auth_token)
90-
assert(resp.status_code == 503), f"Expected RBAC lookup to fail: {resp.status_code} - {resp.text}"
87+
health.is_not_ready(380) #assertion
9188
# Event DB testing
9289
resp = document.post(filter={},limit=10,page=0)
9390
assert(resp.status_code == 503), f"Expected document index to fail: {resp.status_code} - {resp.text}"
91+
# Index DB testing
92+
resp = rbac.get(lookup=stake_address_not_registered, token=auth_token)
93+
assert(resp.status_code == 503), f"Expected RBAC lookup to fail: {resp.status_code} - {resp.text}"
9494

9595
# resume index db comms
9696
index_db_proxy.enable()
9797
# wait for cat-gateway API to recover
9898
health.is_ready() #assertion
99-
99+
# sleep needs to stay until bug is fixed https://github.com/input-output-hk/catalyst-voices/issues/3705
100+
sleep(20)
100101
# Index DB testing
101102
resp = rbac.get(lookup=stake_address_not_registered, token=auth_token)
102103
assert(resp.status_code == 404), f"Expected not registered stake address: {resp.status_code} - {resp.text}"

catalyst-gateway/tests/docker-compose.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ services:
159159
- SERVICE_LIVE_TIMEOUT_INTERVAL=30
160160
command: >
161161
poetry run pytest -m "${API_TEST_MARKS}" -s --junitxml junit-report.xml --cov integration --cov-report lcov
162-
depends_on:
163-
cat-gateway:
164-
condition: service_healthy
165162
166163
schemathesis-runner:
167164
image: schemathesis-runner:latest

0 commit comments

Comments
 (0)