diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/pybind/mgr/mds_autoscaler/tests | |
parent | Initial commit. (diff) | |
download | ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.tar.xz ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/pybind/mgr/mds_autoscaler/tests/__init__.py | 0 | ||||
-rw-r--r-- | src/pybind/mgr/mds_autoscaler/tests/test_autoscaler.py | 88 |
2 files changed, 88 insertions, 0 deletions
diff --git a/src/pybind/mgr/mds_autoscaler/tests/__init__.py b/src/pybind/mgr/mds_autoscaler/tests/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/pybind/mgr/mds_autoscaler/tests/__init__.py diff --git a/src/pybind/mgr/mds_autoscaler/tests/test_autoscaler.py b/src/pybind/mgr/mds_autoscaler/tests/test_autoscaler.py new file mode 100644 index 000000000..2d6017d4a --- /dev/null +++ b/src/pybind/mgr/mds_autoscaler/tests/test_autoscaler.py @@ -0,0 +1,88 @@ +import pytest +from unittest import mock + +from ceph.deployment.service_spec import ServiceSpec, PlacementSpec +from orchestrator import DaemonDescription, OrchResult, ServiceDescription + +try: + from typing import Any, List +except ImportError: + pass + +from mds_autoscaler.module import MDSAutoscaler + + +@pytest.fixture() +def mds_autoscaler_module(): + + yield MDSAutoscaler('mds_autoscaler', 0, 0) + + +class TestCephadm(object): + + @mock.patch("mds_autoscaler.module.MDSAutoscaler.get") + @mock.patch("mds_autoscaler.module.MDSAutoscaler.list_daemons") + @mock.patch("mds_autoscaler.module.MDSAutoscaler.describe_service") + @mock.patch("mds_autoscaler.module.MDSAutoscaler.apply_mds") + def test_scale_up(self, _apply_mds, _describe_service, _list_daemons, _get, mds_autoscaler_module: MDSAutoscaler): + daemons = OrchResult(result=[ + DaemonDescription( + hostname='myhost', + daemon_type='mds', + daemon_id='fs_name.myhost.a' + ), + DaemonDescription( + hostname='myhost', + daemon_type='mds', + daemon_id='fs_name.myhost.b' + ), + ]) + _list_daemons.return_value = daemons + + services = OrchResult(result=[ + ServiceDescription( + spec=ServiceSpec( + service_type='mds', + service_id='fs_name', + placement=PlacementSpec( + count=2 + ) + ) + ) + ]) + _describe_service.return_value = services + + apply = OrchResult(result='') + _apply_mds.return_value = apply + + _get.return_value = { + 'filesystems': [ + { + 'mdsmap': { + 'fs_name': 'fs_name', + 'in': [ + { + 'name': 'mds.fs_name.myhost.a', + } + ], + 'standby_count_wanted': 2, + 'max_mds': 1 + } + } + ], + 'standbys': [ + { + 'name': 'mds.fs_name.myhost.b', + } + ], + + } + mds_autoscaler_module.notify('fs_map', None) + + _apply_mds.assert_called_with(ServiceSpec( + service_type='mds', + service_id='fs_name', + placement=PlacementSpec( + count=3 + ) + )) |