Fix race-condition while making dirs in cli tests
Change-Id: I40a46ad513e6389767337b93402a3f81fe102541
This commit is contained in:
parent
2364d17b67
commit
d6565521ac
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import errno
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@ -118,6 +119,15 @@ class Rally(object):
|
|||||||
def __del__(self):
|
def __del__(self):
|
||||||
shutil.rmtree(self.tmp_dir)
|
shutil.rmtree(self.tmp_dir)
|
||||||
|
|
||||||
|
def _safe_make_dirs(self, dirs):
|
||||||
|
try:
|
||||||
|
os.makedirs(dirs)
|
||||||
|
except OSError as exc:
|
||||||
|
if exc.errno == errno.EEXIST and os.path.isdir(dirs):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
def gen_report_path(self, suffix=None, extension=None, keep_old=False):
|
def gen_report_path(self, suffix=None, extension=None, keep_old=False):
|
||||||
"""Report file path/name modifier
|
"""Report file path/name modifier
|
||||||
|
|
||||||
@ -137,8 +147,7 @@ class Rally(object):
|
|||||||
test_object = caller_frame.f_locals["self"]
|
test_object = caller_frame.f_locals["self"]
|
||||||
class_name = test_object.__class__.__name__
|
class_name = test_object.__class__.__name__
|
||||||
|
|
||||||
if not os.path.exists("%s/%s" % (self.reports_root, class_name)):
|
self._safe_make_dirs("%s/%s" % (self.reports_root, class_name))
|
||||||
os.makedirs("%s/%s" % (self.reports_root, class_name))
|
|
||||||
|
|
||||||
suff = suffix or ""
|
suff = suffix or ""
|
||||||
ext = extension or "txt"
|
ext = extension or "txt"
|
||||||
|
Loading…
Reference in New Issue
Block a user