From: John Mulligan Date: Thu, 2 Nov 2023 22:04:42 +0000 (-0400) Subject: cephadm: add cephadm build tests for bundled sourced from rpms X-Git-Tag: v19.0.0~80^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8da38f303eec26385fc5131d23709986f5aa6edd;p=ceph.git cephadm: add cephadm build tests for bundled sourced from rpms 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 11c85f1f3250..7cf51961ffca 100644 --- a/src/cephadm/tests/build/test_cephadm_build.py +++ b/src/cephadm/tests/build/test_cephadm_build.py @@ -22,6 +22,16 @@ CONTAINERS = { 'base_image': 'quay.io/centos/centos:stream9', 'script': 'dnf install -y python3', }, + 'centos-8-plusdeps': { + 'name': 'cephadm-build-test:centos8-py36-deps', + 'base_image': 'quay.io/centos/centos:stream8', + 'script': 'dnf install -y python36 python3-jinja2', + }, + 'centos-9-plusdeps': { + 'name': 'cephadm-build-test:centos9-py3-deps', + 'base_image': 'quay.io/centos/centos:stream9', + 'script': 'dnf install -y python3 python3-jinja2', + }, 'ubuntu-20.04': { 'name': 'cephadm-build-test:ubuntu-20-04-py3', 'base_image': 'docker.io/library/ubuntu:20.04', @@ -74,7 +84,7 @@ def build_in(alias, ceph_dir, out_dir, args): ctr = CONTAINERS[alias] build_container(ctr['base_image'], ctr['name'], ctr['script'], out_dir) cmd = ['/ceph/' + BUILD_PY] + list(args or []) + ['/out/cephadm'] - run_container_cmd(ctr['name'], cmd, ceph_dir, out_dir) + return run_container_cmd(ctr['name'], cmd, ceph_dir, out_dir) @pytest.fixture @@ -124,3 +134,59 @@ def test_cephadm_build(env, source_dir, tmp_path): 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) + + +@pytest.mark.parametrize( + 'env', + [ + 'centos-8-plusdeps', + 'centos-9-plusdeps', + 'centos-9', + ], +) +def test_cephadm_build_from_rpms(env, source_dir, tmp_path): + res = build_in( + env, + source_dir, + tmp_path, + ['-Brpm', '-SCEPH_GIT_VER=0', '-SCEPH_GIT_NICE_VER=foobar'], + ) + if 'plusdeps' not in env: + assert res.returncode != 0 + return + binary = tmp_path / 'cephadm' + if 'centos-8' in env and sys.version_info[:2] >= (3, 10): + # The version of markupsafe in centos 8 is incompatible with + # python>=3.10 due to changes in the stdlib therefore we can't execute + # the cephadm binary, so we quit the test early. + return + 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 'foobar' 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'] == 'rpm' 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)