Skip to content

Commit f670dce

Browse files
committed
cephadm/tests: Add tests for deb bundled dependencies
Add container definitions and test cases for building cephadm with Debian package dependencies. The new test_cephadm_build_from_debs function mirrors the existing RPM test structure, verifying that: - Build succeeds when required Debian packages are installed - Build fails when packages are missing - Bundled packages are correctly identified as sourced from 'deb' - All expected packages (Jinja2, MarkupSafe, PyYAML) are included - The zipapp contains expected package directories Test environments include Ubuntu 22.04 and 24.04 with and without the required python3-jinja2, python3-yaml, and python3-markupsafe packages. Signed-off-by: Kefu Chai <[email protected]>
1 parent 3ff9b0c commit f670dce

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

src/cephadm/tests/build/test_cephadm_build.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
'base_image': 'docker.io/library/ubuntu:24.04',
4848
'script': 'apt update && apt install -y python3-venv',
4949
},
50+
'ubuntu-22.04-plusdeps': {
51+
'name': 'cephadm-build-test:ubuntu-22-04-py3-deps',
52+
'base_image': 'docker.io/library/ubuntu:22.04',
53+
'script': 'apt update && apt install -y python3-jinja2 python3-yaml python3-markupsafe',
54+
},
55+
'ubuntu-24.04-plusdeps': {
56+
'name': 'cephadm-build-test:ubuntu-24-04-py3-deps',
57+
'base_image': 'docker.io/library/ubuntu:24.04',
58+
'script': 'apt update && apt install -y python3-jinja2 python3-yaml python3-markupsafe',
59+
},
5060
}
5161

5262
BUILD_PY = 'src/cephadm/build.py'
@@ -193,6 +203,57 @@ def test_cephadm_build_from_rpms(env, source_dir, tmp_path):
193203
assert any(e.startswith('_cephadmmeta') for e in zre)
194204

195205

206+
@pytest.mark.parametrize(
207+
'env',
208+
[
209+
'ubuntu-22.04-plusdeps',
210+
'ubuntu-24.04-plusdeps',
211+
'ubuntu-22.04',
212+
],
213+
)
214+
def test_cephadm_build_from_debs(env, source_dir, tmp_path):
215+
res = build_in(
216+
env,
217+
source_dir,
218+
tmp_path,
219+
['-Bdeb', '-SCEPH_GIT_VER=0', '-SCEPH_GIT_NICE_VER=foobar'],
220+
)
221+
if 'plusdeps' not in env:
222+
assert res.returncode != 0
223+
return
224+
binary = tmp_path / 'cephadm'
225+
assert binary.is_file()
226+
res = subprocess.run(
227+
[sys.executable, str(binary), 'version'],
228+
stdout=subprocess.PIPE,
229+
)
230+
out = res.stdout.decode('utf8')
231+
assert 'version' in out
232+
assert 'foobar' in out
233+
assert res.returncode == 0
234+
res = subprocess.run(
235+
[sys.executable, str(binary), 'version', '--verbose'],
236+
stdout=subprocess.PIPE,
237+
)
238+
data = json.loads(res.stdout)
239+
assert isinstance(data, dict)
240+
assert 'bundled_packages' in data
241+
assert all(v['package_source'] == 'deb' for v in data['bundled_packages'])
242+
assert all(
243+
v['name'] in ('Jinja2', 'MarkupSafe', 'PyYAML')
244+
for v in data['bundled_packages']
245+
)
246+
assert all('requirements_entry' in v for v in data['bundled_packages'])
247+
assert 'zip_root_entries' in data
248+
zre = data['zip_root_entries']
249+
assert any(_dist_info(e, 'Jinja2') for e in zre)
250+
assert any(_dist_info(e, 'MarkupSafe') for e in zre)
251+
assert any(e.startswith('jinja2') for e in zre)
252+
assert any(e.startswith('markupsafe') for e in zre)
253+
assert any(e.startswith('cephadmlib') for e in zre)
254+
assert any(e.startswith('_cephadmmeta') for e in zre)
255+
256+
196257
def _dist_info(entry, name):
197258
return (
198259
entry.startswith(name) or entry.startswith(name.lower())

0 commit comments

Comments
 (0)