in ftl/cached/cached.py [0:0]
def run_cached_tests(self):
logging.info('Beginning building {0} images'.format(self._runtime))
# For the binary
builder_path = 'ftl/{0}_builder.par'.format(self._runtime)
# For container builder
if not os.path.isfile(builder_path):
builder_path = 'bazel-bin/ftl/{0}_builder.par'.format(
self._runtime)
lyr_shas = []
random_suffix = randomword(32)
WORKDIR = "/workspace-cached"
for label, dir in zip(self._labels, self._dirs):
logging.info("label: %s", label)
logging.info("dir: %s", dir)
img_name = "%s:%s" % (self._name.split(":")[0], label)
ftl_util.run_command("copy-%s-to-%s" % (dir, WORKDIR),
["cp", "-r", dir, WORKDIR])
ftl_args = [
builder_path, '--base', self._base, '--name', img_name,
'--directory', WORKDIR,
'--destination', "/srv",
'--cache-repository',
'gcr.io/ftl-node-test/ftl-cache-repo-%s' % random_suffix
]
if label == "original":
ftl_args.extend(['--no-cache'])
out = ""
try:
out = ftl_util.run_command("cached-ftl-build-%s" % img_name,
ftl_args)
lyr_shas.append(self._fetch_lyr_shas(img_name))
except ftl_util.FTLException as e:
logging.error(e)
exit(1)
finally:
logging.info("cleaning up directories...")
self._cleanup(constants.VIRTUALENV_DIR)
ftl_util.run_command("cleanup-%s" % WORKDIR,
["rm", "-rf", WORKDIR])
if self._should_cache and label == "reupload":
if "[HIT]" not in out:
logging.error("Cache `[HIT]` not found on reupload: %s", out)
exit(1)
if len(lyr_shas) is not 2:
logging.error("Incorrect number of layers to compare")
exit(1)
self._compare_layers(lyr_shas[0], lyr_shas[1], self._offset)