Skip to content

Commit 1840de0

Browse files
authored
chore: add backoff to retry function used in e2e test (#120)
* chore: add backoff to retry function used in e2e test * address comments
1 parent d658ae3 commit 1840de0

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

system-test/system_test.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ trap "echo '** AT LEAST ONE OF TESTS FAILED **'" ERR
66
# Fail on any error, show commands run.
77
set -eox pipefail
88

9-
retry() {
10-
"${@}" || "${@}" || "${@}" || exit $?
11-
}
9+
. $(dirname $0)/../tools/retry.sh
1210

1311
cd $(dirname $0)
1412

system-test/test.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
trap "echo '** TEST FAILED **'" ERR
44

5-
retry() {
6-
"${@}" || "${@}" || "${@}" || return 1
7-
}
5+
. $(dirname $0)/../tools/retry.sh
86

97
function timeout_after() {
108
# timeout on Node 11 alpine image requires -t to specify time.

tools/build/linux_build_and_test.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
retry() {
18-
"${@}" || "${@}" || "${@}" || exit $?
19-
}
17+
. $(dirname $0)/../retry.sh
2018

2119
# Fail on any error.
2220
set -e pipefail

tools/publish.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
retry() {
17-
for i in {1..3}; do
18-
"${@}" && return 0
19-
done
20-
return 1
21-
}
16+
17+
. $(dirname $0)/retry.sh
2218

2319
set -eo pipefail
2420

tools/retry.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Copyright 2020 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
retry() {
17+
for attempt in {1..3}; do
18+
[ $attempt == 1 ] || sleep 10 # Backing off after a failed attempt.
19+
"${@}" && return 0
20+
done
21+
return 1
22+
}

0 commit comments

Comments
 (0)