|
1 | 1 | import base64
|
2 | 2 | import boto3
|
3 | 3 | import gzip
|
| 4 | +import logging |
4 | 5 | import os
|
5 | 6 | import pytest
|
6 | 7 | import requests
|
|
149 | 150 | }}
|
150 | 151 | """
|
151 | 152 |
|
| 153 | +logger = logging.getLogger("ami-tests") |
| 154 | +handler = logging.StreamHandler() |
| 155 | +formatter = logging.Formatter( |
| 156 | + '%(asctime)s %(name)-12s %(levelname)-8s %(message)s') |
| 157 | +handler.setFormatter(formatter) |
| 158 | +logger.addHandler(handler) |
| 159 | +logger.setLevel(logging.DEBUG) |
152 | 160 |
|
153 | 161 | # scope='session' uses the same container for all the tests;
|
154 | 162 | # scope='function' uses a new container per test function.
|
@@ -245,30 +253,37 @@ def gzip_then_base64_encode(s: str) -> str:
|
245 | 253 | def is_healthy(host) -> bool:
|
246 | 254 | cmd = host.run("pg_isready -U postgres")
|
247 | 255 | if cmd.failed is True:
|
| 256 | + logger.warn("pg not ready") |
248 | 257 | return False
|
249 | 258 |
|
250 |
| - cmd = host.run(f"curl http://localhost:8085/health -H 'apikey: {supabase_admin_key}'") |
| 259 | + cmd = host.run(f"curl -sf -k https://localhost:8085/health -H 'apikey: {supabase_admin_key}'") |
251 | 260 | if cmd.failed is True:
|
| 261 | + logger.warn("adminapi not ready") |
252 | 262 | return False
|
253 | 263 |
|
254 |
| - cmd = host.run("curl http://localhost:3001/ready") |
| 264 | + cmd = host.run("curl -sf http://localhost:3001/ready") |
255 | 265 | if cmd.failed is True:
|
| 266 | + logger.warn("postgrest not ready") |
256 | 267 | return False
|
257 | 268 |
|
258 |
| - cmd = host.run("curl http://localhost:8081/health") |
| 269 | + cmd = host.run("curl -sf http://localhost:8081/health") |
259 | 270 | if cmd.failed is True:
|
| 271 | + logger.warn("gotrue not ready") |
260 | 272 | return False
|
261 | 273 |
|
262 | 274 | cmd = host.run("sudo kong health")
|
263 | 275 | if cmd.failed is True:
|
| 276 | + logger.warn("kong not ready") |
264 | 277 | return False
|
265 | 278 |
|
266 | 279 | cmd = host.run("printf \\\\0 > '/dev/tcp/localhost/6543'")
|
267 | 280 | if cmd.failed is True:
|
| 281 | + logger.warn("pgbouncer not ready") |
268 | 282 | return False
|
269 | 283 |
|
270 | 284 | cmd = host.run("sudo fail2ban-client status")
|
271 | 285 | if cmd.failed is True:
|
| 286 | + logger.warn("fail2ban not ready") |
272 | 287 | return False
|
273 | 288 |
|
274 | 289 | return True
|
|
0 commit comments