Skip to content

Commit

Permalink
dist_test: work with latest 'isolate'
Browse files Browse the repository at this point in the history
The handling of paths in 'isolate' changed upstream so that all
paths must be expressed relative to the isolate file itself. We
were previously putting the isolate files in /tmp, and trying to
use relative paths from the repo directory. This no longer works
in a reasonable way.

Instead, we put the isolate files in build/isolate/ and then we
construct paths relative to this directory.

Tested against ca2862b9255f9cf4e293bd399145a818ce8f04b7 from the
luci-go repository.

Change-Id: I74a4fdf10650fd3dd0752ff321d7923d9accc454
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/6815
Tested-by: jenkins
Reviewed-by: Todd Lipcon <[email protected]>
  • Loading branch information
toddlipcon committed Jun 4, 2015
1 parent da8e042 commit c721cf8
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions build-support/dist_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
class StagingDir(object):
@staticmethod
def new():
dir = "/tmp/kudu-test-%d-%d" % (os.getpid(), time.time())
dir = rel_to_abs("build/isolate")
if os.path.isdir(dir):
shutil.rmtree(dir)
os.makedirs(dir)
return StagingDir(dir)

Expand All @@ -85,8 +87,8 @@ def rel_to_abs(rel_path):
return abs


def abs_to_rel(abs_path):
rel = os.path.relpath(abs_path, rel_to_abs("."))
def abs_to_rel(abs_path, staging):
rel = os.path.relpath(abs_path, staging.dir)
if abs_path.endswith('/') and not rel.endswith('/'):
rel += '/'
return rel
Expand Down Expand Up @@ -119,6 +121,11 @@ def is_lib_blacklisted(lib):
return False


def is_outside_of_tree(path):
repo_dir = rel_to_abs("./")
rel = os.path.relpath(path, repo_dir)
return rel.startswith("../")

def copy_system_library(lib):
"""
For most system libraries, we expect them to be installed on the test
Expand All @@ -135,7 +142,7 @@ def copy_system_library(lib):
if not os.path.exists(dst):
logging.info("Copying system library %s to %s...", lib, dst)
shutil.copy2(rel_to_abs(lib), dst)
return abs_to_rel(dst)
return dst


def ldd_deps(exe):
Expand Down Expand Up @@ -186,24 +193,24 @@ def create_archive_input(staging, argv,
print >>sys.stderr, "Unable to handle test: ", argv
return
test_name = os.path.basename(argv[1])
argv[1] = abs_to_rel(os.path.realpath(argv[1]))
test_exe = argv[1]
abs_test_exe = os.path.realpath(argv[1])
rel_test_exe = abs_to_rel(abs_test_exe, staging)
argv[1] = rel_test_exe
files = []
files.append(test_exe)
deps = ldd_deps(test_exe)
files.append(rel_test_exe)
deps = ldd_deps(abs_test_exe)
for d in DEPS_FOR_ALL:
d = os.path.realpath(d)
if os.path.isdir(d):
d += "/"
deps.append(d)
for d in deps:
rel = abs_to_rel(d)
if rel.startswith("../"):
# System libraries will end up being relative paths out
# of the build tree. We need to copy those into the build
# tree somewhere.
rel = copy_system_library(rel)
files.append(rel)
# System libraries will end up being relative paths out
# of the build tree. We need to copy those into the build
# tree somewhere.
if is_outside_of_tree(d):
d = copy_system_library(d)
files.append(abs_to_rel(d, staging))

if disable_sharding:
num_shards = 1
Expand All @@ -213,7 +220,7 @@ def create_archive_input(staging, argv,
out_archive = os.path.join(staging.dir, '%s.%d.gen.json' % (test_name, shard))
out_isolate = os.path.join(staging.dir, '%s.%d.isolate' % (test_name, shard))

command = ['build-support/run_dist_test.py',
command = ['../../build-support/run_dist_test.py',
'-e', 'GTEST_SHARD_INDEX=%d' % shard,
'-e', 'GTEST_TOTAL_SHARDS=%d' % num_shards,
'-e', 'KUDU_TEST_TIMEOUT=%d' % (TEST_TIMEOUT_SECS - 30),
Expand Down

0 comments on commit c721cf8

Please sign in to comment.