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()