From: John Mulligan Date: Wed, 14 Jun 2023 14:22:07 +0000 (-0400) Subject: cephadm: move custom container tests to a dedicated file X-Git-Tag: v19.0.0~711^2~27 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6c2f22b7fabec06ddb3f93ad132328d9d0683039;p=ceph.git cephadm: move custom container tests to a dedicated file Signed-off-by: John Mulligan --- diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index 39af53f0a9a2f..015e7db33b5ea 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -1032,90 +1032,6 @@ ff792c06d8544b983.scope not found.: OCI runtime error""" ) -class TestCustomContainer(unittest.TestCase): - cc: _cephadm.CustomContainer - - def setUp(self): - self.cc = _cephadm.CustomContainer( - 'e863154d-33c7-4350-bca5-921e0467e55b', - 'container', - config_json={ - 'entrypoint': 'bash', - 'gid': 1000, - 'args': [ - '--no-healthcheck', - '-p 6800:6800' - ], - 'envs': ['SECRET=password'], - 'ports': [8080, 8443], - 'volume_mounts': { - '/CONFIG_DIR': '/foo/conf', - 'bar/config': '/bar:ro' - }, - 'bind_mounts': [ - [ - 'type=bind', - 'source=/CONFIG_DIR', - 'destination=/foo/conf', - '' - ], - [ - 'type=bind', - 'source=bar/config', - 'destination=/bar:ro', - 'ro=true' - ] - ] - }, - image='docker.io/library/hello-world:latest' - ) - - def test_entrypoint(self): - self.assertEqual(self.cc.entrypoint, 'bash') - - def test_uid_gid(self): - self.assertEqual(self.cc.uid, 65534) - self.assertEqual(self.cc.gid, 1000) - - def test_ports(self): - self.assertEqual(self.cc.ports, [8080, 8443]) - - def test_get_container_args(self): - result = self.cc.get_container_args() - self.assertEqual(result, [ - '--no-healthcheck', - '-p 6800:6800' - ]) - - def test_get_container_envs(self): - result = self.cc.get_container_envs() - self.assertEqual(result, ['SECRET=password']) - - def test_get_container_mounts(self): - result = self.cc.get_container_mounts('/xyz') - self.assertDictEqual(result, { - '/CONFIG_DIR': '/foo/conf', - '/xyz/bar/config': '/bar:ro' - }) - - def test_get_container_binds(self): - result = self.cc.get_container_binds('/xyz') - self.assertEqual(result, [ - [ - 'type=bind', - 'source=/CONFIG_DIR', - 'destination=/foo/conf', - '' - ], - [ - 'type=bind', - 'source=/xyz/bar/config', - 'destination=/bar:ro', - 'ro=true' - ] - ]) - - class TestMaintenance: systemd_target = "ceph.00000000-0000-0000-0000-000000c0ffee.target" fsid = '0ea8cdd0-1bbf-11ec-a9c7-5254002763fa' diff --git a/src/cephadm/tests/test_custom_container.py b/src/cephadm/tests/test_custom_container.py new file mode 100644 index 0000000000000..e3b419b4d1908 --- /dev/null +++ b/src/cephadm/tests/test_custom_container.py @@ -0,0 +1,90 @@ +import unittest + +from .fixtures import import_cephadm + + +_cephadm = import_cephadm() + + +class TestCustomContainer(unittest.TestCase): + cc: _cephadm.CustomContainer + + def setUp(self): + self.cc = _cephadm.CustomContainer( + 'e863154d-33c7-4350-bca5-921e0467e55b', + 'container', + config_json={ + 'entrypoint': 'bash', + 'gid': 1000, + 'args': [ + '--no-healthcheck', + '-p 6800:6800' + ], + 'envs': ['SECRET=password'], + 'ports': [8080, 8443], + 'volume_mounts': { + '/CONFIG_DIR': '/foo/conf', + 'bar/config': '/bar:ro' + }, + 'bind_mounts': [ + [ + 'type=bind', + 'source=/CONFIG_DIR', + 'destination=/foo/conf', + '' + ], + [ + 'type=bind', + 'source=bar/config', + 'destination=/bar:ro', + 'ro=true' + ] + ] + }, + image='docker.io/library/hello-world:latest' + ) + + def test_entrypoint(self): + self.assertEqual(self.cc.entrypoint, 'bash') + + def test_uid_gid(self): + self.assertEqual(self.cc.uid, 65534) + self.assertEqual(self.cc.gid, 1000) + + def test_ports(self): + self.assertEqual(self.cc.ports, [8080, 8443]) + + def test_get_container_args(self): + result = self.cc.get_container_args() + self.assertEqual(result, [ + '--no-healthcheck', + '-p 6800:6800' + ]) + + def test_get_container_envs(self): + result = self.cc.get_container_envs() + self.assertEqual(result, ['SECRET=password']) + + def test_get_container_mounts(self): + result = self.cc.get_container_mounts('/xyz') + self.assertDictEqual(result, { + '/CONFIG_DIR': '/foo/conf', + '/xyz/bar/config': '/bar:ro' + }) + + def test_get_container_binds(self): + result = self.cc.get_container_binds('/xyz') + self.assertEqual(result, [ + [ + 'type=bind', + 'source=/CONFIG_DIR', + 'destination=/foo/conf', + '' + ], + [ + 'type=bind', + 'source=/xyz/bar/config', + 'destination=/bar:ro', + 'ro=true' + ] + ])