|
8 | 8 | import testinfra
|
9 | 9 | from ec2instanceconnectcli.EC2InstanceConnectLogger import EC2InstanceConnectLogger
|
10 | 10 | from ec2instanceconnectcli.EC2InstanceConnectKey import EC2InstanceConnectKey
|
| 11 | +from paramiko.ssh_exception import NoValidConnectionsError |
11 | 12 | from time import sleep
|
12 | 13 |
|
13 |
| -RUN_ID = os.environ["GITHUB_RUN_ID"] if os.environ["GITHUB_RUN_ID"] else "unknown-ci-run" |
| 14 | +RUN_ID = os.environ.get("GITHUB_RUN_ID", "unknown-ci-run") |
14 | 15 |
|
15 | 16 | postgresql_schema_sql_content = """
|
16 | 17 | ALTER DATABASE postgres SET "app.settings.jwt_secret" TO 'my_jwt_secret_which_is_not_so_secret';
|
@@ -251,39 +252,43 @@ def gzip_then_base64_encode(s: str) -> str:
|
251 | 252 | )
|
252 | 253 |
|
253 | 254 | def is_healthy(host) -> bool:
|
254 |
| - cmd = host.run("pg_isready -U postgres") |
255 |
| - if cmd.failed is True: |
256 |
| - logger.warn("pg not ready") |
257 |
| - return False |
| 255 | + try: |
| 256 | + cmd = host.run("pg_isready -U postgres") |
| 257 | + if cmd.failed is True: |
| 258 | + logger.warn("pg not ready") |
| 259 | + return False |
258 | 260 |
|
259 |
| - cmd = host.run(f"curl -sf -k https://localhost:8085/health -H 'apikey: {supabase_admin_key}'") |
260 |
| - if cmd.failed is True: |
261 |
| - logger.warn("adminapi not ready") |
262 |
| - return False |
| 261 | + cmd = host.run(f"curl -sf -k https://localhost:8085/health -H 'apikey: {supabase_admin_key}'") |
| 262 | + if cmd.failed is True: |
| 263 | + logger.warn("adminapi not ready") |
| 264 | + return False |
263 | 265 |
|
264 |
| - cmd = host.run("curl -sf http://localhost:3001/ready") |
265 |
| - if cmd.failed is True: |
266 |
| - logger.warn("postgrest not ready") |
267 |
| - return False |
| 266 | + cmd = host.run("curl -sf http://localhost:3001/ready") |
| 267 | + if cmd.failed is True: |
| 268 | + logger.warn("postgrest not ready") |
| 269 | + return False |
268 | 270 |
|
269 |
| - cmd = host.run("curl -sf http://localhost:8081/health") |
270 |
| - if cmd.failed is True: |
271 |
| - logger.warn("gotrue not ready") |
272 |
| - return False |
| 271 | + cmd = host.run("curl -sf http://localhost:8081/health") |
| 272 | + if cmd.failed is True: |
| 273 | + logger.warn("gotrue not ready") |
| 274 | + return False |
273 | 275 |
|
274 |
| - cmd = host.run("sudo kong health") |
275 |
| - if cmd.failed is True: |
276 |
| - logger.warn("kong not ready") |
277 |
| - return False |
| 276 | + cmd = host.run("sudo kong health") |
| 277 | + if cmd.failed is True: |
| 278 | + logger.warn("kong not ready") |
| 279 | + return False |
278 | 280 |
|
279 |
| - cmd = host.run("printf \\\\0 > '/dev/tcp/localhost/6543'") |
280 |
| - if cmd.failed is True: |
281 |
| - logger.warn("pgbouncer not ready") |
282 |
| - return False |
| 281 | + cmd = host.run("printf \\\\0 > '/dev/tcp/localhost/6543'") |
| 282 | + if cmd.failed is True: |
| 283 | + logger.warn("pgbouncer not ready") |
| 284 | + return False |
283 | 285 |
|
284 |
| - cmd = host.run("sudo fail2ban-client status") |
285 |
| - if cmd.failed is True: |
286 |
| - logger.warn("fail2ban not ready") |
| 286 | + cmd = host.run("sudo fail2ban-client status") |
| 287 | + if cmd.failed is True: |
| 288 | + logger.warn("fail2ban not ready") |
| 289 | + return False |
| 290 | + except NoValidConnectionsError: |
| 291 | + logger.warn("unable to connect via ssh") |
287 | 292 | return False
|
288 | 293 |
|
289 | 294 | return True
|
|
0 commit comments