summaryrefslogtreecommitdiffstats
path: root/src/cephadm/tests/test_container_engine.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/cephadm/tests/test_container_engine.py
parentInitial commit. (diff)
downloadceph-b26c4052f3542036551aa9dec9caa4226e456195.tar.xz
ceph-b26c4052f3542036551aa9dec9caa4226e456195.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cephadm/tests/test_container_engine.py')
-rw-r--r--src/cephadm/tests/test_container_engine.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/cephadm/tests/test_container_engine.py b/src/cephadm/tests/test_container_engine.py
new file mode 100644
index 000000000..433f01270
--- /dev/null
+++ b/src/cephadm/tests/test_container_engine.py
@@ -0,0 +1,54 @@
+from unittest import mock
+
+import pytest
+
+from tests.fixtures import with_cephadm_ctx, import_cephadm
+
+_cephadm = import_cephadm()
+
+
+def test_container_engine():
+ with pytest.raises(NotImplementedError):
+ _cephadm.ContainerEngine()
+
+ class PhonyContainerEngine(_cephadm.ContainerEngine):
+ EXE = "true"
+
+ with mock.patch("cephadm.find_program") as find_program:
+ find_program.return_value = "/usr/bin/true"
+ pce = PhonyContainerEngine()
+ assert str(pce) == "true (/usr/bin/true)"
+
+
+def test_podman():
+ with mock.patch("cephadm.find_program") as find_program:
+ find_program.return_value = "/usr/bin/podman"
+ pm = _cephadm.Podman()
+ find_program.assert_called()
+ with pytest.raises(RuntimeError):
+ pm.version
+ with mock.patch("cephadm.call_throws") as call_throws:
+ call_throws.return_value = ("4.9.9", None, None)
+ with with_cephadm_ctx([]) as ctx:
+ pm.get_version(ctx)
+ assert pm.version == (4, 9, 9)
+ assert str(pm) == "podman (/usr/bin/podman) version 4.9.9"
+
+
+def test_podman_badversion():
+ with mock.patch("cephadm.find_program") as find_program:
+ find_program.return_value = "/usr/bin/podman"
+ pm = _cephadm.Podman()
+ find_program.assert_called()
+ with mock.patch("cephadm.call_throws") as call_throws:
+ call_throws.return_value = ("4.10.beta2", None, None)
+ with with_cephadm_ctx([]) as ctx:
+ with pytest.raises(ValueError):
+ pm.get_version(ctx)
+
+
+def test_docker():
+ with mock.patch("cephadm.find_program") as find_program:
+ find_program.return_value = "/usr/bin/docker"
+ docker = _cephadm.Docker()
+ assert str(docker) == "docker (/usr/bin/docker)"