]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: extend the cephadm build test to cover version --verbose
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 2 Nov 2023 21:19:34 +0000 (17:19 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 6 Nov 2023 18:38:31 +0000 (13:38 -0500)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/tests/build/test_cephadm_build.py

index b6fea0e8a9ea45139fc77d0f27127d824f630474..11c85f1f3250596ba6557e7dd3a72985261ecfdf 100644 (file)
@@ -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)