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 <ncutler@suse.com>
'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:
'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