From: John Mulligan Date: Thu, 2 Nov 2023 21:19:34 +0000 (-0400) Subject: cephadm: extend the cephadm build test to cover version --verbose X-Git-Tag: v19.0.0~80^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=957b8bd443b7891114c4fc2ed0fe0574eb924c66;p=ceph.git cephadm: extend the cephadm build test to cover version --verbose Signed-off-by: John Mulligan --- diff --git a/src/cephadm/tests/build/test_cephadm_build.py b/src/cephadm/tests/build/test_cephadm_build.py index b6fea0e8a9ea..11c85f1f3250 100644 --- a/src/cephadm/tests/build/test_cephadm_build.py +++ b/src/cephadm/tests/build/test_cephadm_build.py @@ -3,6 +3,7 @@ # these should not be run automatically as they require the use of podman, # which should not be assumed to exist on a typical test node +import json import os import pathlib import pytest @@ -92,5 +93,34 @@ def source_dir(): ) def test_cephadm_build(env, source_dir, tmp_path): build_in(env, source_dir, tmp_path, []) - assert (tmp_path / 'cephadm').is_file() - # TODO: verify contents of zip + binary = tmp_path / 'cephadm' + assert binary.is_file() + res = subprocess.run( + [sys.executable, str(binary), 'version'], + stdout=subprocess.PIPE, + ) + out = res.stdout.decode('utf8') + assert 'version' in out + assert 'UNKNOWN' in out + assert res.returncode != 0 + res = subprocess.run( + [sys.executable, str(binary), 'version', '--verbose'], + stdout=subprocess.PIPE, + ) + data = json.loads(res.stdout) + assert isinstance(data, dict) + assert 'bundled_packages' in data + assert all(v['package_source'] == 'pip' for v in data['bundled_packages']) + assert all( + v['name'] in ('Jinja2', 'MarkupSafe') + for v in data['bundled_packages'] + ) + assert all('requirements_entry' in v for v in data['bundled_packages']) + assert 'zip_root_entries' in data + zre = data['zip_root_entries'] + assert any(e.startswith('Jinja2') for e in zre) + assert any(e.startswith('MarkupSafe') for e in zre) + assert any(e.startswith('jinja2') for e in zre) + assert any(e.startswith('markupsafe') for e in zre) + assert any(e.startswith('cephadmlib') for e in zre) + assert any(e.startswith('_cephadmmeta') for e in zre)