Skip to content

Commit ae1406a

Browse files
fix(ingest/ci): fix integration test failures (#15284)
1 parent ac20d06 commit ae1406a

File tree

6 files changed

+100
-17
lines changed

6 files changed

+100
-17
lines changed
Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: '3'
21
services:
32
hex-mock-api:
43
image: python:3.9-alpine
@@ -8,12 +7,28 @@ services:
87
volumes:
98
- ./hex_projects_response.json:/app/hex_projects_response.json
109
- ./mock_hex_server.py:/app/mock_hex_server.py
11-
command: ["python", "/app/mock_hex_server.py"]
10+
command:
11+
- sh
12+
- -c
13+
- |
14+
apk add --no-cache wget
15+
python /app/mock_hex_server.py &
16+
SERVER_PID=$$!
17+
for i in $$(seq 1 30); do
18+
if wget --no-verbose --tries=1 --spider http://localhost:8000/health 2>/dev/null; then
19+
wait $$SERVER_PID
20+
exit 0
21+
fi
22+
sleep 1
23+
done
24+
kill $$SERVER_PID 2>/dev/null || true
25+
exit 1
1226
healthcheck:
13-
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000/health"]
27+
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8000/health || exit 1"]
1428
interval: 5s
15-
timeout: 5s
16-
retries: 3
29+
timeout: 10s
30+
retries: 60
31+
start_period: 30s
1732
datahub-mock-api:
1833
image: python:3.9-alpine
1934
container_name: datahub-mock-api
@@ -25,9 +40,25 @@ services:
2540
- ./datahub_get_urns_by_filter_page1.json:/app/datahub_get_urns_by_filter_page1.json
2641
- ./datahub_get_urns_by_filter_page2.json:/app/datahub_get_urns_by_filter_page2.json
2742
- ./mock_datahub_server.py:/app/mock_datahub_server.py
28-
command: ["python", "/app/mock_datahub_server.py"]
43+
command:
44+
- sh
45+
- -c
46+
- |
47+
apk add --no-cache wget
48+
python /app/mock_datahub_server.py &
49+
SERVER_PID=$$!
50+
for i in $$(seq 1 30); do
51+
if wget --no-verbose --tries=1 --spider http://localhost:8010/health 2>/dev/null; then
52+
wait $$SERVER_PID
53+
exit 0
54+
fi
55+
sleep 1
56+
done
57+
kill $$SERVER_PID 2>/dev/null || true
58+
exit 1
2959
healthcheck:
30-
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8010/health"]
60+
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8010/health || exit 1"]
3161
interval: 5s
32-
timeout: 5s
33-
retries: 3
62+
timeout: 10s
63+
retries: 60
64+
start_period: 30s

metadata-ingestion/tests/integration/hex/docker/mock_datahub_server.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,31 @@ def do_GET(self):
5959
self.end_headers()
6060
self.wfile.write(json.dumps({"error": "Not found", "path": self.path}).encode())
6161

62+
def do_HEAD(self):
63+
"""Handle HEAD requests (used by wget --spider for health checks)"""
64+
parsed_url = urlparse(self.path)
65+
path = parsed_url.path
66+
67+
# Health check endpoint
68+
if path == "/health":
69+
self.send_response(HTTPStatus.OK)
70+
self.send_header("Content-type", "text/plain")
71+
self.end_headers()
72+
return
73+
74+
# Mock DataHub API endpoints
75+
if path.startswith("/config"):
76+
self.send_response(HTTPStatus.OK)
77+
self.send_header("Content-type", "application/json")
78+
self.send_header("Access-Control-Allow-Origin", "*")
79+
self.end_headers()
80+
return
81+
82+
# Default 404 response
83+
self.send_response(HTTPStatus.NOT_FOUND)
84+
self.send_header("Content-type", "application/json")
85+
self.end_headers()
86+
6287
def do_POST(self):
6388
parsed_url = urlparse(self.path)
6489
path = parsed_url.path

metadata-ingestion/tests/integration/hex/docker/mock_hex_server.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,31 @@ def do_GET(self):
4545
self.end_headers()
4646
self.wfile.write(json.dumps({"error": "Not found", "path": self.path}).encode())
4747

48+
def do_HEAD(self):
49+
"""Handle HEAD requests (used by wget --spider for health checks)"""
50+
parsed_url = urlparse(self.path)
51+
path = parsed_url.path
52+
53+
# Health check endpoint
54+
if path == "/health":
55+
self.send_response(HTTPStatus.OK)
56+
self.send_header("Content-type", "text/plain")
57+
self.end_headers()
58+
return
59+
60+
# Mock Hex API endpoints
61+
if path.startswith("/api/v1/projects"):
62+
self.send_response(HTTPStatus.OK)
63+
self.send_header("Content-type", "application/json")
64+
self.send_header("Access-Control-Allow-Origin", "*")
65+
self.end_headers()
66+
return
67+
68+
# Default 404 response
69+
self.send_response(HTTPStatus.NOT_FOUND)
70+
self.send_header("Content-type", "application/json")
71+
self.end_headers()
72+
4873

4974
# Set up the server
5075
handler = MockHexAPIHandler

metadata-ingestion/tests/integration/hex/test_hex.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
FROZEN_TIME = "2025-03-25 12:00:00"
1010

11+
1112
pytestmark = pytest.mark.integration_batch_2
1213

1314

metadata-ingestion/tests/integration/iceberg/docker-compose.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ services:
6666
/usr/bin/mc rm -r --force minio/warehouse;
6767
/usr/bin/mc mb minio/warehouse;
6868
/usr/bin/mc anonymous set public minio/warehouse;
69-
exit 0;
69+
touch /tmp/mc_done;
70+
tail -f /dev/null;
7071
"
72+
healthcheck:
73+
test: ["CMD", "test", "-f", "/tmp/mc_done"]
74+
interval: 5s
75+
timeout: 5s
76+
retries: 5
77+
start_period: 10s
7178
networks:
7279
iceberg_net:

metadata-ingestion/tests/integration/kafka-connect/docker-compose.override.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,7 @@ services:
204204
environment:
205205
- initialBuckets=test-bucket
206206
ports:
207-
- "9090:9090"
208-
healthcheck:
209-
test: ["CMD-SHELL", "curl -s -f http://localhost:9090/ || exit 1"]
210-
interval: 5s
211-
timeout: 3s
212-
retries: 3
213-
start_period: 10s
207+
- "9090:9191"
214208
restart: on-failure:3
215209
deploy:
216210
resources:

0 commit comments

Comments
 (0)