]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: move custom container tests to a dedicated file
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 14 Jun 2023 14:22:07 +0000 (10:22 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 9 Aug 2023 17:48:07 +0000 (13:48 -0400)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/tests/test_cephadm.py
src/cephadm/tests/test_custom_container.py [new file with mode: 0644]

index 39af53f0a9a2f8dc379bf3602c726901c3c9dae9..015e7db33b5ea3c97b6a715ac01b82c519de4415 100644 (file)
@@ -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 (file)
index 0000000..e3b419b
--- /dev/null
@@ -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'
+            ]
+        ])