9639: Delete all cached discovery docs, but do not delete the cache directory.
authorTom Clegg <tom@curoverse.com>
Wed, 20 Jul 2016 21:14:47 +0000 (17:14 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 20 Jul 2016 21:14:47 +0000 (17:14 -0400)
refs #9639

sdk/python/tests/run_test_server.py

index 8f2d4406fe1c50cc4f4f3529367e970525300dcc..45cc3ca32b465ed96989e910189b6f0de9fb2f8d 100644 (file)
@@ -4,6 +4,7 @@ from __future__ import print_function
 import argparse
 import atexit
 import errno
+import glob
 import httplib2
 import os
 import pipes
@@ -12,8 +13,8 @@ import re
 import shutil
 import signal
 import socket
-import subprocess
 import string
+import subprocess
 import sys
 import tempfile
 import time
@@ -213,8 +214,14 @@ def run(leave_running_atexit=False):
     """
     global my_api_host
 
-    # Delete cached discovery document.
-    shutil.rmtree(arvados.http_cache('discovery'))
+    # Delete cached discovery documents.
+    #
+    # This will clear cached docs that belong to other processes (like
+    # concurrent test suites) even if they're still running. They should
+    # be able to tolerate that.
+    for fn in glob.glob(os.path.join(arvados.http_cache('discovery'),
+                                     '*,arvados,v1,rest,*')):
+        os.unlink(fn)
 
     pid_file = _pidfile('api')
     pid_file_ok = find_server_pid(pid_file, 0)