From: John Mulligan Date: Thu, 22 Jun 2023 18:12:24 +0000 (-0400) Subject: pybind/mgr/cephadm/tests: add test_deploy_custom_container_with_init_ctrs X-Git-Tag: v19.0.0~711^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5a024b034555d0b1fbbc6f0b23bfc9c424f142fc;p=ceph.git pybind/mgr/cephadm/tests: add test_deploy_custom_container_with_init_ctrs This adds a test case to explicitly check custom containers with init containers. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/cephadm/tests/test_services.py b/src/pybind/mgr/cephadm/tests/test_services.py index b0f9743ce6cc..292634fd364a 100644 --- a/src/pybind/mgr/cephadm/tests/test_services.py +++ b/src/pybind/mgr/cephadm/tests/test_services.py @@ -2557,3 +2557,89 @@ class TestCustomContainer: } ), ) + + @patch("cephadm.serve.CephadmServe._run_cephadm") + def test_deploy_custom_container_with_init_ctrs( + self, _run_cephadm, cephadm_module: CephadmOrchestrator + ): + _run_cephadm.side_effect = async_side_effect(('{}', '', 0)) + + spec = CustomContainerSpec( + service_id='tsettinu', + image='quay.io/foobar/barbaz:latest', + entrypoint='/usr/local/bin/blat.sh', + ports=[9090], + init_containers=[ + {'entrypoint': '/usr/local/bin/prepare.sh'}, + { + 'entrypoint': '/usr/local/bin/optimize.sh', + 'entrypoint_args': [ + '--timeout=5m', + '--cores=8', + {'argument': '--title=Alpha One'}, + ], + }, + ], + ) + + expected = { + 'fsid': 'fsid', + 'name': 'container.tsettinu.test', + 'image': 'quay.io/foobar/barbaz:latest', + 'deploy_arguments': [], + 'params': { + 'tcp_ports': [9090], + 'init_containers': [ + {'entrypoint': '/usr/local/bin/prepare.sh'}, + { + 'entrypoint': '/usr/local/bin/optimize.sh', + 'entrypoint_args': [ + '--timeout=5m', + '--cores=8', + '--title=Alpha One', + ], + }, + ], + }, + 'meta': { + 'service_name': 'container.tsettinu', + 'ports': [], + 'ip': None, + 'deployed_by': [], + 'rank': None, + 'rank_generation': None, + 'extra_container_args': None, + 'extra_entrypoint_args': None, + 'init_containers': [ + {'entrypoint': '/usr/local/bin/prepare.sh'}, + { + 'entrypoint': '/usr/local/bin/optimize.sh', + 'entrypoint_args': [ + '--timeout=5m', + '--cores=8', + {'argument': '--title=Alpha One', 'split': False}, + ], + }, + ], + }, + 'config_blobs': { + 'image': 'quay.io/foobar/barbaz:latest', + 'entrypoint': '/usr/local/bin/blat.sh', + 'args': [], + 'envs': [], + 'volume_mounts': {}, + 'privileged': False, + 'ports': [9090], + 'dirs': [], + 'files': {}, + }, + } + with with_host(cephadm_module, 'test'): + with with_service(cephadm_module, spec): + _run_cephadm.assert_called_with( + 'test', + 'container.tsettinu.test', + ['_orch', 'deploy'], + [], + stdin=json.dumps(expected), + )