소스 검색

fix(api): wait for dbapi during missing migration test

Peter Thomassen 2 년 전
부모
커밋
60cedae694
5개의 변경된 파일13개의 추가작업 그리고 9개의 파일을 삭제
  1. 1 1
      .github/workflows/main.yml
  2. 2 1
      api/entrypoint-tests.sh
  3. 2 1
      api/entrypoint.sh
  4. 8 0
      api/wait-dbapi
  5. 0 6
      api/wait-ns

+ 1 - 1
.github/workflows/main.yml

@@ -53,7 +53,7 @@ jobs:
 
     - name: Check for missing migrations
       run: |
-        docker-compose -f docker-compose.yml run -T api python manage.py makemigrations --check
+        docker-compose -f docker-compose.yml run -T api sh -c "./wait-dbapi && python manage.py makemigrations --check"
         docker-compose -f docker-compose.yml down -v
 
     - name: Run e2e2 Tests

+ 2 - 1
api/entrypoint-tests.sh

@@ -2,7 +2,8 @@
 
 # wait for dependencies
 echo "waiting for dependencies ..."
-./wait
+./wait-dbapi
+./wait-ns
 
 # start cron
 /root/cronhook/start-cron.sh &

+ 2 - 1
api/entrypoint.sh

@@ -2,7 +2,8 @@
 
 # wait for dependencies
 echo "waiting for dependencies ..."
-./wait
+./wait-dbapi
+./wait-ns
 
 # set permissions for Django metrics (docker-compose.yml setting does not work, see #333)
 chmod 1777 /var/local/django_metrics

+ 8 - 0
api/wait-dbapi

@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+set -e
+
+# wait for api database to come up
+until PGPASSWORD=$DESECSTACK_DBAPI_PASSWORD_desec psql -h dbapi -U desec -c '\q'; do
+  >&2 echo "Postgres is unavailable - sleeping"
+  sleep 1
+done

+ 0 - 6
api/wait → api/wait-ns

@@ -1,12 +1,6 @@
 #!/usr/bin/env bash
 set -e
 
-# wait for api database to come up
-until PGPASSWORD=$DESECSTACK_DBAPI_PASSWORD_desec psql -h dbapi -U desec -c '\q'; do
-  >&2 echo "Postgres is unavailable - sleeping"
-  sleep 1
-done
-
 # wait for pdns api to come up
 host=nslord; port=8081; n=120; i=0; while ! (echo > /dev/tcp/$host/$port) 2> /dev/null; do [[ $i -eq $n ]] && >&2 echo "$host:$port not up after $n seconds, exiting" && exit 1; echo "waiting for $host:$port to come up"; sleep 1; i=$((i+1)); done
 host=nsmaster; port=8081; n=120; i=0; while ! (echo > /dev/tcp/$host/$port) 2> /dev/null; do [[ $i -eq $n ]] && >&2 echo "$host:$port not up after $n seconds, exiting" && exit 1; echo "waiting for $host:$port to come up"; sleep 1; i=$((i+1)); done