From: Nathan Cutler Date: Thu, 20 Feb 2020 11:12:56 +0000 (+0100) Subject: qa/cephadm.py: better check for cephadm download success X-Git-Tag: v15.1.1~348^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a0dd01bc5ecc72c4e480a0fc6cd246728866b004;p=ceph.git qa/cephadm.py: better check for cephadm download success When the URL passed to "curl --silent ..." does not exist, the resulting file will be populated with the string: 404: Not Found If that (or something similar) happens, the file size will be suspiciously low, like < 1000 bytes. Fail the test immediately in this case. Signed-off-by: Nathan Cutler --- diff --git a/qa/tasks/cephadm.py b/qa/tasks/cephadm.py index 1dd666752644..f2499733165e 100644 --- a/qa/tasks/cephadm.py +++ b/qa/tasks/cephadm.py @@ -100,12 +100,6 @@ def download_cephadm(ctx, config, ref): 'https://raw.githubusercontent.com/' + rest + '/' + ref + '/src/cephadm/cephadm', run.Raw('>'), ctx.cephadm, - run.Raw('&&'), - 'test', '-s', - ctx.cephadm, - run.Raw('&&'), - 'chmod', '+x', - ctx.cephadm, ], ) else: @@ -119,14 +113,19 @@ def download_cephadm(ctx, config, ref): 'tar', '-xO', 'src/cephadm/cephadm', run.Raw('>'), ctx.cephadm, - run.Raw('&&'), - 'test', '-s', - ctx.cephadm, - run.Raw('&&'), - 'chmod', '+x', - ctx.cephadm, ], ) + # sanity-check the resulting file and set executable bit + cephadm_file_size = '$(stat -c%s {})'.format(ctx.cephadm) + ctx.cluster.run( + args=[ + 'test', '-s', ctx.cephadm, + run.Raw('&&'), + 'test', run.Raw(cephadm_file_size), "-gt", run.Raw('1000'), + run.Raw('&&'), + 'chmod', '+x', ctx.cephadm, + ], + ) try: yield