Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16133 Use tempfile module in smoketester (#806)

Mike Drobc31576b47051
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):