You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by md...@apache.org on 2022/04/21 17:42:39 UTC

[solr] branch branch_9x updated: SOLR-16133 Use tempfile module in smoketester (#806)

This is an automated email from the ASF dual-hosted git repository.

mdrob pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 1de3b049dc0 SOLR-16133 Use tempfile module in smoketester (#806)
1de3b049dc0 is described below

commit 1de3b049dc08af7e5e98afa3e9e3b5eafdd09c9a
Author: Mike Drob <md...@apache.org>
AuthorDate: Thu Apr 21 10:41:51 2022 -0700

    SOLR-16133 Use tempfile module in smoketester (#806)
---
 dev-tools/scripts/smokeTestRelease.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/dev-tools/scripts/smokeTestRelease.py b/dev-tools/scripts/smokeTestRelease.py
index 1a715c67f70..dc9b76dbf79 100755
--- a/dev-tools/scripts/smokeTestRelease.py
+++ b/dev-tools/scripts/smokeTestRelease.py
@@ -27,6 +27,7 @@ import re
 import shutil
 import subprocess
 import sys
+import tempfile
 import textwrap
 import traceback
 import urllib.error
@@ -1013,7 +1014,7 @@ def parse_config():
   parser = argparse.ArgumentParser(description=description, epilog=epilogue,
                                    formatter_class=argparse.RawDescriptionHelpFormatter)
   parser.add_argument('--tmp-dir', metavar='PATH',
-                      help='Temporary directory to test inside, defaults to /tmp/smoke_solr_$version_$revision')
+                      help='Temporary directory to test inside, defaults to $TMPDIR/smoke_solr_$version_$revision ')
   parser.add_argument('--not-signed', dest='is_signed', action='store_false', default=True,
                       help='Indicates the release is not signed')
   parser.add_argument('--local-keys', metavar='PATH',
@@ -1057,12 +1058,7 @@ def parse_config():
   if c.tmp_dir:
     c.tmp_dir = os.path.abspath(c.tmp_dir)
   else:
-    tmp = '/tmp/smoke_solr_%s_%s' % (c.version, c.revision)
-    c.tmp_dir = tmp
-    i = 1
-    while os.path.exists(c.tmp_dir):
-      c.tmp_dir = tmp + '_%d' % i
-      i += 1
+    c.tmp_dir = tempfile.mkdtemp(prefix = 'smoke_solr_%s_%s' % (c.version, c.revision))
 
   return c
 
@@ -1092,7 +1088,7 @@ def smokeTest(java, baseURL, gitRevision, version, tmpDir, isSigned, local_keys,
   testArgs = '-Dtests.nightly=false -Dtests.badapples=false %s' % testArgs
 
   if FORCE_CLEAN:
-    if os.path.exists(tmpDir):
+    if os.path.exists(tmpDir) and len(os.listdir(tmpDir)) > 0:
       raise RuntimeError('temp dir %s exists; please remove first' % tmpDir)
 
   if not os.path.exists(tmpDir):