File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,12 +7,34 @@ NODE_INDEX=${CIRCLE_NODE_INDEX:-0}
77
88set -e
99
10+ # Retry a command up to $1 times, with exponential backoff starting at $2 seconds.
11+ retry () {
12+ local attempts=$1 ; shift
13+ local delay=$1 ; shift
14+ local count=0
15+ until " $@ " ; do
16+ count=$(( count + 1 ))
17+ if [ " $count " -ge " $attempts " ]; then
18+ echo " Command failed after $attempts attempts: $* " >&2
19+ return 1
20+ fi
21+ echo " Attempt $count failed. Retrying in ${delay} s..." >&2
22+ sleep " $delay "
23+ delay=$(( delay * 2 ))
24+ done
25+ }
26+
27+ # Wrapper for apt-get install with automatic retry on transient network errors.
28+ apt_install () {
29+ retry 3 30 sudo apt-get -y install --fix-missing " $@ "
30+ }
31+
1032export NODE_ENV=test
1133
1234if [ " $NODE_INDEX " = " 1" ]; then
1335 echo " Running node $NODE_INDEX ..."
1436
15- sudo apt-get -y install cpanminus
37+ apt_install cpanminus
1638
1739 echo " Testing perl"
1840 (cd samples/client/petstore/perl && /bin/bash ./test.bash)
@@ -22,7 +44,7 @@ elif [ "$NODE_INDEX" = "2" ]; then
2244 echo " Running node $NODE_INDEX to test cpp-restsdk"
2345
2446 # install cpprestsdk
25- sudo apt-get install libcpprest-dev
47+ apt_install libcpprest-dev
2648 wget " https://github.com/aminya/setup-cpp/releases/download/v0.37.0/setup-cpp-x64-linux"
2749 chmod +x ./setup-cpp-x64-linux
2850 sudo ./setup-cpp-x64-linux --compiler llvm --cmake true --ninja true
You can’t perform that action at this time.
0 commit comments