[TASK] bamboo: db dependency loop needs break condition 67/59567/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 25 Jan 2019 11:00:46 +0000 (12:00 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 25 Jan 2019 13:21:11 +0000 (14:21 +0100)
Functional and acceptance tests need a db up and running.
The according container is started as dependency and a
loop delays further execution until the database connected
to its network port. This sometimes goes wrong, for
instance mssql in rare conditions does not come up. This
leads to the loop running "forever", consuming the
executing bamboo agent and the job never finishs.
The patch adds an additional break condition: If db did
not connect to the port after a minute, the job now fails.

Resolves: #87549
Releases: master, 9.5, 8.7
Change-Id: Idc45f57d9cfd2d390cea6bd5319adaf4158340df
Reviewed-on: https://review.typo3.org/59567
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Build/testing-docker/bamboo/docker-compose.yml

index b54052a..47ff171 100644 (file)
@@ -61,12 +61,17 @@ services:
       - test
     command: >
       /bin/sh -c "
-        echo Waiting for db start...;
-        while ! nc -z mariadb10 3306;
-        do
-          sleep 1;
-        done;
-        echo Connected!;
+        echo Waiting for database start
+        COUNT=0
+        while ! nc -z mariadb10 3306; do
+          if [ "$${COUNT}" -ge "60" ]; then
+            echo Database did not come up
+            exit 1
+          fi
+          let "COUNT++"
+          sleep 1
+        done
+        echo Database is up
       "
 
   start_dependencies_acceptance_install_postgres10:
@@ -79,12 +84,17 @@ services:
       - test
     command: >
       /bin/sh -c "
-        echo Waiting for db start...;
-        while ! nc -z postgres10 5432;
-        do
-          sleep 1;
-        done;
-        echo Connected!;
+        echo Waiting for database start
+        COUNT=0
+        while ! nc -z postgres10 5432; do
+          if [ "$${COUNT}" -ge "60" ]; then
+            echo Database did not come up
+            exit 1
+          fi
+          let "COUNT++"
+          sleep 1
+        done
+        echo Database is up
       "
 
   start_dependencies_acceptance_install_sqlite:
@@ -107,12 +117,17 @@ services:
       - test
     command: >
       /bin/sh -c "
-        echo Waiting for db start...;
-        while ! nc -z mariadb10 3306;
-        do
-          sleep 1;
-        done;
-        echo Connected!;
+        echo Waiting for database start
+        COUNT=0
+        while ! nc -z mariadb10 3306; do
+          if [ "$${COUNT}" -ge "60" ]; then
+            echo Database did not come up
+            exit 1
+          fi
+          let "COUNT++"
+          sleep 1
+        done
+        echo Database is up
       "
 
   start_dependencies_functional_mariadb10:
@@ -125,12 +140,17 @@ services:
       - test
     command: >
       /bin/sh -c "
-        echo Waiting for db start...;
-        while ! nc -z mariadb10 3306;
-        do
-          sleep 1;
-        done;
-        echo Connected!;
+        echo Waiting for database start
+        COUNT=0
+        while ! nc -z mariadb10 3306; do
+          if [ "$${COUNT}" -ge "60" ]; then
+            echo Database did not come up
+            exit 1
+          fi
+          let "COUNT++"
+          sleep 1
+        done
+        echo Database is up
       "
 
   start_dependencies_functional_mssql:
@@ -143,12 +163,17 @@ services:
       - test
     command: >
       /bin/sh -c "
-        echo Waiting for db start...;
-        while ! nc -z mssql2017cu9 1433;
-        do
-          sleep 1;
-        done;
-        echo Connected!;
+        echo Waiting for database start
+        COUNT=0
+        while ! nc -z mssql2017cu9 1433; do
+          if [ "$${COUNT}" -ge "60" ]; then
+            echo Database did not come up
+            exit 1
+          fi
+          let "COUNT++"
+          sleep 1
+        done
+        echo Database is up
       "
 
   start_dependencies_functional_postgres10:
@@ -161,12 +186,17 @@ services:
       - test
     command: >
       /bin/sh -c "
-        echo Waiting for db start...;
-        while ! nc -z postgres10 5432;
-        do
-          sleep 1;
-        done;
-        echo Connected!;
+        echo Waiting for database start
+        COUNT=0
+        while ! nc -z postgres10 5432; do
+          if [ "$${COUNT}" -ge "60" ]; then
+            echo Database did not come up
+            exit 1
+          fi
+          let "COUNT++"
+          sleep 1
+        done
+        echo Database is up
       "
   start_dependencies_functional_sqlite:
     image: alpine:3.8