Skip to content

Commit

Permalink
mgr/cephadm: add some tests for the new smb service
Browse files Browse the repository at this point in the history
Signed-off-by: John Mulligan <jmulligan@redhat.com>
  • Loading branch information
phlogistonjohn committed Jan 29, 2024
1 parent 364bf9e commit 1660627
Showing 1 changed file with 120 additions and 0 deletions.
120 changes: 120 additions & 0 deletions src/pybind/mgr/cephadm/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from cephadm.services.osd import OSDService
from cephadm.services.monitoring import GrafanaService, AlertmanagerService, PrometheusService, \
NodeExporterService, LokiService, PromtailService
from cephadm.services.smb import SMBSpec
from cephadm.module import CephadmOrchestrator
from ceph.deployment.service_spec import (
AlertManagerSpec,
Expand Down Expand Up @@ -2882,3 +2883,122 @@ def test_deploy_custom_container_with_init_ctrs(
[],
stdin=json.dumps(expected),
)


class TestSMB:
@patch("cephadm.module.CephadmOrchestrator.get_unique_name")
@patch("cephadm.serve.CephadmServe._run_cephadm")
def test_deploy_smb(
self, _run_cephadm, _get_uname, cephadm_module: CephadmOrchestrator
):
_run_cephadm.side_effect = async_side_effect(('{}', '', 0))
_get_uname.return_value = 'tango.briskly'

spec = SMBSpec(
cluster_id='foxtrot',
config_uri='rados://.smb/foxtrot/config.json',
)

expected = {
'fsid': 'fsid',
'name': 'smb.tango.briskly',
'image': '',
'deploy_arguments': [],
'params': {},
'meta': {
'service_name': 'smb',
'ports': [],
'ip': None,
'deployed_by': [],
'rank': None,
'rank_generation': None,
'extra_container_args': None,
'extra_entrypoint_args': None,
},
'config_blobs': {
'cluster_id': 'foxtrot',
'features': [],
'config_uri': 'rados://.smb/foxtrot/config.json',
'config': '',
'keyring': '[client.smb.config.tango.briskly]\nkey = None\n',
'config_auth_entity': 'client.smb.config.tango.briskly',
},
}
with with_host(cephadm_module, 'hostx'):
with with_service(cephadm_module, spec):
_run_cephadm.assert_called_with(
'hostx',
'smb.tango.briskly',
['_orch', 'deploy'],
[],
stdin=json.dumps(expected),
)

@patch("cephadm.module.CephadmOrchestrator.get_unique_name")
@patch("cephadm.serve.CephadmServe._run_cephadm")
def test_deploy_smb_join_dns(
self, _run_cephadm, _get_uname, cephadm_module: CephadmOrchestrator
):
_run_cephadm.side_effect = async_side_effect(('{}', '', 0))
_get_uname.return_value = 'tango.briskly'

spec = SMBSpec(
cluster_id='foxtrot',
features=['domain'],
config_uri='rados://.smb/foxtrot/config2.json',
join_sources=[
'rados://.smb/foxtrot/join1.json',
'rados:mon-config-key:smb/config/foxtrot/join2.json',
],
custom_dns=['10.8.88.103'],
include_ceph_users=[
'client.smb.fs.cephfs.share1',
'client.smb.fs.cephfs.share2',
'client.smb.fs.fs2.share3',
],
)

expected = {
'fsid': 'fsid',
'name': 'smb.tango.briskly',
'image': '',
'deploy_arguments': [],
'params': {},
'meta': {
'service_name': 'smb',
'ports': [],
'ip': None,
'deployed_by': [],
'rank': None,
'rank_generation': None,
'extra_container_args': None,
'extra_entrypoint_args': None,
},
'config_blobs': {
'cluster_id': 'foxtrot',
'features': ['domain'],
'config_uri': 'rados://.smb/foxtrot/config2.json',
'join_sources': [
'rados://.smb/foxtrot/join1.json',
'rados:mon-config-key:smb/config/foxtrot/join2.json',
],
'custom_dns': ['10.8.88.103'],
'config': '',
'keyring': (
'[client.smb.config.tango.briskly]\nkey = None\n\n'
'[client.smb.fs.cephfs.share1]\nkey = None\n\n'
'[client.smb.fs.cephfs.share2]\nkey = None\n\n'
'[client.smb.fs.fs2.share3]\nkey = None\n'
),
'config_auth_entity': 'client.smb.config.tango.briskly',
},
}
with with_host(cephadm_module, 'hostx'):
with with_service(cephadm_module, spec):
_run_cephadm.assert_called_with(
'hostx',
'smb.tango.briskly',
['_orch', 'deploy'],
[],
stdin=json.dumps(expected),
)

0 comments on commit 1660627

Please sign in to comment.