Skip to content

Commit

Permalink
fixed tools gotest and cache
Browse files Browse the repository at this point in the history
  • Loading branch information
godfryd committed Jan 23, 2021
1 parent 7003fcb commit 7fcc1c5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions agent/kraken/agent/kraken_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ def _save_to_cache(mc, cache_key, minio_bucket, dest_folder, paths):
size = 5 * 1024 * 1024

for pth in paths:
pth = os.path.expandvars(pth)
pth = os.path.expanduser(pth)
if not os.path.exists(pth):
log.error("path '%s' does not exists", pth)
return 1, "path '%s' does not exists" % pth
pumper = Pumper(pth)
tar_name = '%s.tar.gz' % pth.strip('/').replace('/', '_')
tar = tarfile.open(tar_name, 'w|gz', pumper, bufsize=size)
Expand Down
9 changes: 8 additions & 1 deletion agent/kraken/agent/kraken_gotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def _process_output(q, text):
try:
data = json.loads(l)
except:
log.error('failed parsing: %s', l)
log.exception('IGNORED EXCEPTION')
continue

Expand Down Expand Up @@ -78,6 +79,7 @@ def run_tests(step, report_result=None):
cwd = step.get('cwd', None)
go_exe = step.get('go_exe', 'go')
params = step.get('params', '')
timeout = int(step.get('timeout', 60))

cmd = '%s test -json %s' % (go_exe, params)

Expand All @@ -88,16 +90,21 @@ def run_tests(step, report_result=None):

_process_output2 = partial(_process_output, q)

ret = utils.execute(cmd, cwd=cwd, output_handler=_process_output2, tracing=False)
ret = utils.execute(cmd, cwd=cwd, output_handler=_process_output2, tracing=False, timeout=timeout)

q.join()
finished.set()
uploader.join()

if ret != 0:
log.error('go test exited with non-zero retcode: %s', ret)
return ret, 'go test exited with non-zero retcode'

return 0, ''


def main():
logging.basicConfig(level=logging.INFO)
step = dict(cwd='/tmp/hgo/hugo',
go_exe='/usr/bin/go',
params='-p 1 ./...')
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
poetry
shiv
wheel
fabric
4 changes: 4 additions & 0 deletions server/kraken/server/schemaval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,10 @@
"tool": {
"const": "gotest"
},
"timeout": {
"type": "integer",
"minimum": 30
},
"gotest_exe": {
"type": "string"
},
Expand Down

0 comments on commit 7fcc1c5

Please sign in to comment.