From 336c21eb454ff64facf3215178bf409f59fe8d9d Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Tue, 6 Jun 2017 15:23:10 -0700
Subject: [PATCH] Use bigquery data to inform flakiness

---
 tools/run_tests/run_tests.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index a4aae489f8..8462b618fc 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -157,6 +157,9 @@ class Config(object):
     actual_environ = self.environ.copy()
     for k, v in environ.items():
       actual_environ[k] = v
+    if not flaky and shortname and shortname in flaky_tests:
+      print('Setting %s to flaky' % shortname)
+      flaky = True
     return jobset.JobSpec(cmdline=self.tool_prefix + cmdline,
                           shortname=shortname,
                           environ=actual_environ,
@@ -1251,9 +1254,15 @@ argp.add_argument('--bq_result_table',
                   nargs='?',
                   help='Upload test results to a specified BQ table.')
 # XXX Remove the following line. Only used for proof-of-concept-ing
-argp.add_argument('--show_flakes', default=False, type=bool);
+argp.add_argument('--show_flakes', default=False, action='store_const', const=True);
 args = argp.parse_args()
 
+try:
+  flaky_tests = set(get_flaky_tests())
+except:
+  print("Unexpected error getting flaky tests:", sys.exc_info()[0])
+  flaky_tests = set()
+
 if args.show_flakes:
   import pprint
   pprint.pprint (get_flaky_tests())
-- 
GitLab