]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add a unit test to check sidecar removal
authorJohn Mulligan <jmulligan@redhat.com>
Sun, 19 Nov 2023 20:39:52 +0000 (15:39 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 2 Jan 2024 14:30:21 +0000 (09:30 -0500)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/tests/test_deploy.py

index dadf3456fd5afa8bc43843b59e2a0856c310a3dd..cfde3fbce0aab80210f3fc8cd153dbf012edf55e 100644 (file)
@@ -488,3 +488,47 @@ def test_deploy_ceph_exporter_container(cephadm_fs, funkypatch):
         assert f.read() == 'XXXXXXX'
     with open(basedir / 'keyring') as f:
         assert f.read() == 'YYYYYY'
+
+
+def test_deploy_and_rm_iscsi(cephadm_fs, funkypatch):
+    # Test that the deploy and remove paths for iscsi (which has sidecar container)
+    # create and remove the correct unit files.
+    mocks = _common_patches(funkypatch)
+    _firewalld = mocks['Firewalld']
+    fsid = 'b01dbeef-701d-9abe-0000-e1e5a47004a7'
+    with with_cephadm_ctx([]) as ctx:
+        ctx.container_engine = mock_podman()
+        ctx.fsid = fsid
+        ctx.name = 'iscsi.wuzzy'
+        ctx.image = 'quay.io/ayeaye/iscsi:latest'
+        ctx.reconfig = False
+        ctx.config_blobs = {
+            'config': 'XXXXXXX',
+            'keyring': 'YYYYYY',
+            'files': {
+                'iscsi-gateway.cfg': 'portal',
+            },
+        }
+        _cephadm._common_deploy(ctx)
+
+    unit_dir = pathlib.Path('/etc/systemd/system')
+    assert unit_dir.is_dir()
+    assert (unit_dir / f'ceph-{fsid}@.service').exists()
+    drop_in = unit_dir / f'ceph-{fsid}@iscsi.wuzzy.service.d/99-cephadm.conf'
+    assert drop_in.parent.is_dir()
+    assert drop_in.exists()
+    assert 'tcmu' in drop_in.read_text()
+    tcmu_sidecar = unit_dir / f'ceph-{fsid}-sidecar@iscsi.wuzzy:tcmu.service'
+    assert tcmu_sidecar.exists()
+    assert 'sidecar-tcmu.run' in tcmu_sidecar.read_text()
+
+    with with_cephadm_ctx([]) as ctx:
+        ctx.container_engine = mock_podman()
+        ctx.fsid = fsid
+        ctx.name = 'iscsi.wuzzy'
+        ctx.image = 'quay.io/ayeaye/iscsi:latest'
+        _cephadm.command_rm_daemon(ctx)
+
+    assert not drop_in.exists()
+    assert not drop_in.parent.exists()
+    assert not tcmu_sidecar.exists()