Bug 1523562 [wpt PR 15073] - Add a retry to the initial git checkout, a=testonly
authorJames Graham <james@hoppipolla.co.uk>
Fri, 01 Feb 2019 11:40:39 +0000
changeset 458176 48e765f7795c13b8cdd36ba27d6995eb3efd2762
parent 458175 92a780f5eca95537b4274b17bbe063643858394c
child 458177 410068244807bc4f7b392d1dc94d2ed27a07c02e
push id35518
push useropoprus@mozilla.com
push dateFri, 08 Feb 2019 09:55:14 +0000
treeherdermozilla-central@3a3e393396f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1523562, 15073
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1523562 [wpt PR 15073] - Add a retry to the initial git checkout, a=testonly Automatic update from web-platform-tests Add a retry to the initial git checkout -- Update docker image -- wpt-commits: aa94ec995bdf6de55dca6dc51fc83dc0a66c31e9, 68f47dfce55536c861d4e28220de4d296a5472c7 wpt-pr: 15073
testing/web-platform/tests/.taskcluster.yml
testing/web-platform/tests/tools/docker/Dockerfile
testing/web-platform/tests/tools/docker/retry.py
testing/web-platform/tests/tools/docker/start.sh
--- a/testing/web-platform/tests/.taskcluster.yml
+++ b/testing/web-platform/tests/.taskcluster.yml
@@ -56,17 +56,17 @@ tasks:
               name: wpt-${browser.name}-${browser.channel}-${chunk[0]}-${chunk[1]}
               description: >-
                 A subset of WPT's "${chunk[0]}" tests (chunk number ${chunk[1]}
                 of ${chunk[2]}), run in the ${browser.channel} release of
                 ${browser.name}.
               owner: ${event.pusher.email}
               source: ${event.repository.url}
             payload:
-              image: harjgam/web-platform-tests:0.26
+              image: harjgam/web-platform-tests:0.29
               maxRunTime: 7200
               artifacts:
                 public/results:
                   path: /home/test/artifacts
                   type: directory
               command:
                 - /bin/bash
                 - --login
@@ -131,17 +131,17 @@ tasks:
                 else:
                   github-worker
               metadata:
                 name: ${operation.name}
                 description: ${operation.description}
                 owner: ${event.pull_request.user.login}@users.noreply.github.com
                 source: ${event.repository.url}
               payload:
-                image: harjgam/web-platform-tests:0.26
+                image: harjgam/web-platform-tests:0.29
                 maxRunTime: 7200
                 artifacts:
                   public/results:
                     path: /home/test/artifacts
                     type: directory
                 # Fetch the GitHub-provided merge commit (rather than the pull
                 # request branch) so that the tasks simulate the behavior of the
                 # submitted patch after it is merged. Using the merge commit also
--- a/testing/web-platform/tests/tools/docker/Dockerfile
+++ b/testing/web-platform/tests/tools/docker/Dockerfile
@@ -61,14 +61,18 @@ ENV DISPLAY :99.0
 USER test
 
 WORKDIR /home/test
 
 # Remove information on how to use sudo on login
 RUN sudo echo ""
 
 RUN mkdir -p /home/test/artifacts
+RUN mkdir -p /home/test/bin
+
+ENV PATH="/home/test/bin:${PATH}"
 
 WORKDIR /home/test/
 
 COPY .bashrc /home/test/.bashrc
 
 COPY start.sh /home/test/start.sh
+COPY retry.py /home/test/bin/retry
new file mode 100755
--- /dev/null
+++ b/testing/web-platform/tests/tools/docker/retry.py
@@ -0,0 +1,58 @@
+#! /usr/bin/env python
+import argparse
+import subprocess
+import time
+import sys
+
+
+def get_args():
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--delay", action="store", type=float, default=3, help="Initial delay before retry, in seconds")
+    parser.add_argument("--count", action="store", type=int, default=5, help="Total number of tries")
+    parser.add_argument("--factor", action="store", type=float, default=2, help="Exponential backoff factor")
+    parser.add_argument("cmd", nargs=argparse.REMAINDER)
+    return parser
+
+
+def iter_range(n):
+    i = 0
+    while i < n:
+        yield i
+        i += 1
+
+
+def main():
+    args = get_args().parse_args()
+
+    if not args.cmd:
+        print("No command supplied")
+        sys.exit(1)
+
+    retcode = None
+
+    for n in iter_range(args.count):
+        try:
+            print("Running %s [try %d/%d]" % (" ".join(args.cmd), (n+1), args.count))
+            subprocess.check_call(args.cmd)
+        except subprocess.CalledProcessError as e:
+            retcode = e.returncode
+        else:
+            print("Command succeeded")
+            retcode = 0
+            break
+
+        if args.factor == 0:
+            wait_time = (n+1) * args.delay
+        else:
+            wait_time = args.factor**n * args.delay
+        if n < args.count - 1:
+            print("Command failed, waiting %s seconds to retry" % wait_time)
+            time.sleep(wait_time)
+        else:
+            print("Command failed, out of retries")
+
+    sys.exit(retcode)
+
+
+if __name__ == "__main__":
+    main()
--- a/testing/web-platform/tests/tools/docker/start.sh
+++ b/testing/web-platform/tests/tools/docker/start.sh
@@ -21,20 +21,20 @@ cd ~
 
 mkdir web-platform-tests
 cd web-platform-tests
 
 git init
 git remote add origin ${REMOTE}
 
 # Initially we just fetch 50 commits in order to save several minutes of fetching
-git fetch --quiet --depth=50 --tags origin ${REF}
+retry git fetch --quiet --depth=50 --tags origin ${REF}
 
 if [[ ! `git rev-parse --verify -q ${REVISION}` ]];
 then
     # But if for some reason the commit under test isn't in that range, we give in and
     # fetch everything
-    git fetch -q --unshallow ${REMOTE}
+    retry git fetch -q --unshallow ${REMOTE}
     git rev-parse --verify ${REVISION}
 fi
 git checkout -b build ${REVISION}
 
 source tools/ci/start.sh