)
-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'
--- /dev/null
+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'
+ ]
+ ])