Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit ed8a74b

Browse files
authored
Support running the end-to-end test repeatedly. (#2053)
This will aid in reproducing and fixing flaky test failures. In particular, this is being added to help test fixes for #2051.
1 parent a33ff75 commit ed8a74b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tools/cli/tests/end-to-end.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# of the bundled CLI tool. This requires a GCP project in which the
1919
# test will create, connect to, and delete Datalab instances.
2020

21+
import argparse
2122
import random
2223
import socket
2324
import subprocess
@@ -232,4 +233,18 @@ def run_connection_test(self):
232233

233234

234235
if __name__ == '__main__':
235-
unittest.main()
236+
parser = argparse.ArgumentParser()
237+
parser.add_argument('--runs', type=int, default=1, choices=range(1, 100),
238+
metavar='COUNT', dest='runs',
239+
help='Number of times to run the test suite')
240+
args = parser.parse_args()
241+
242+
failed_count, run_count = 0, 0
243+
for _ in range(0, args.runs):
244+
suite = unittest.TestLoader().loadTestsFromTestCase(TestEndToEnd)
245+
result = unittest.TextTestRunner(buffer=True).run(suite)
246+
run_count += 1
247+
if not result.wasSuccessful():
248+
failed_count += 1
249+
250+
print('Ran {} test runs with {} failing'.format(run_count, failed_count))

0 commit comments

Comments
 (0)