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 /qa/tasks/immutable_object_cache_thrash.py | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.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 'qa/tasks/immutable_object_cache_thrash.py')
-rw-r--r-- | qa/tasks/immutable_object_cache_thrash.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/qa/tasks/immutable_object_cache_thrash.py b/qa/tasks/immutable_object_cache_thrash.py new file mode 100644 index 000000000..0bf3ad3a0 --- /dev/null +++ b/qa/tasks/immutable_object_cache_thrash.py @@ -0,0 +1,79 @@ +""" +immutable object cache thrash task +""" +import contextlib +import logging + +from teuthology import misc as teuthology +from teuthology import contextutil +from teuthology.orchestra import run + +DEFAULT_KILL_DAEMON_TIME = 2 +DEFAULT_DEAD_TIME = 30 +DEFAULT_LIVE_TIME = 120 + +log = logging.getLogger(__name__) + +@contextlib.contextmanager +def thrashes_immutable_object_cache_daemon(ctx, config): + """ + thrashes immutable object cache daemon. + It can test reconnection feature of RO cache when RO daemon crash + TODO : replace sleep with better method. + """ + log.info("thrashes immutable object cache daemon") + + # just thrash one rbd client. + client, client_config = list(config.items())[0] + (remote,) = ctx.cluster.only(client).remotes.keys() + client_config = client_config if client_config is not None else dict() + kill_daemon_time = client_config.get('kill_daemon_time', DEFAULT_KILL_DAEMON_TIME) + dead_time = client_config.get('dead_time', DEFAULT_DEAD_TIME) + live_time = client_config.get('live_time', DEFAULT_LIVE_TIME) + + for i in range(kill_daemon_time): + log.info("ceph-immutable-object-cache crash....") + remote.run( + args=[ + 'sudo', 'killall', '-s', '9', 'ceph-immutable-object-cache', run.Raw('||'), 'true', + ] + ) + # librbd shoud normally run when ceph-immutable-object-cache + remote.run( + args=[ + 'sleep', '{dead_time}'.format(dead_time=dead_time), + ] + ) + # librbd should reconnect daemon + log.info("startup ceph-immutable-object-cache") + remote.run( + args=[ + 'ceph-immutable-object-cache', '-b', + ] + ) + remote.run( + args=[ + 'sleep', '{live_time}'.format(live_time=live_time), + ] + ) + try: + yield + finally: + log.info("cleanup") + +@contextlib.contextmanager +def task(ctx, config): + """ + This is task for testing immutable_object_cache thrash. + """ + assert isinstance(config, dict), \ + "task immutable_object_cache_thrash only supports a dictionary for configuration" + + managers = [] + config = teuthology.replace_all_with_clients(ctx.cluster, config) + managers.append( + lambda: thrashes_immutable_object_cache_daemon(ctx=ctx, config=config) + ) + + with contextutil.nested(*managers): + yield |