You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2017/10/24 08:05:18 UTC

[GitHub] garrensmith closed pull request #1005: Retry docker:up a few times in case of failure

garrensmith closed pull request #1005: Retry docker:up a few times in case of failure
URL: https://github.com/apache/couchdb-fauxton/pull/1005
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.travis.yml b/.travis.yml
index 7eccf52bd..16e203d91 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,18 +8,14 @@ git:
   depth: 1
 
 before_script:
-  - npm run docker:up
+  - travis_retry ./bin/docker-up-and-check.sh
   - npm install
-  - docker logs couchdb
-  - docker logs selenium
   - curl http://127.0.0.1:5984
   - npm run stylecheck
   - npm test
   - grunt debugDev
   - DIST=./dist/debug ./bin/fauxton &
   - sleep 30
-  - docker logs couchdb
-  - curl http://127.0.0.1:5984
 script:
   - travis_retry ./node_modules/.bin/grunt nightwatch
 after_script:
diff --git a/bin/docker-up-and-check.sh b/bin/docker-up-and-check.sh
new file mode 100755
index 000000000..7d6985926
--- /dev/null
+++ b/bin/docker-up-and-check.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+## Sometimes the couchdb docker container won't start correctly, which causes
+## the Travis build to fail and forces users to resubmit their PRs.
+## This script tries to minimize the issue by retrying to start the containers
+## in case of failure.
+
+
+start_containters_and_check() {
+  npm run docker:up
+  if [[ $? != 0 ]]; then exit $?; fi
+
+  # Uses docker logs to check if couchdb server has started
+  NUM_CHECKS=10
+  for ((check=1; check<=$NUM_CHECKS; check++));
+  do
+    echo "Checking if couchdb container has started ($check of $NUM_CHECKS)"
+    logs=$(docker logs couchdb)
+    if [[ $logs == *"Errno socket error"* ]]; then
+      echo "Failed to start couchdb container"
+      echo "=============================="
+      docker logs couchdb
+      echo "=============================="
+      return 1
+    fi
+    if [[ $logs == *"Developers cluster is set up"* ]]; then
+      echo "Docker containers are up"
+      echo "========================"
+      docker logs couchdb
+      echo "========================"
+      return 0
+    fi
+    sleep 6
+  done
+}
+
+stop_containters() {
+  npm run docker:down
+  sleep 2
+}
+
+
+if start_containters_and_check 
+then
+  exit 0
+fi
+
+stop_containters
+exit 2
\ No newline at end of file


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services