summaryrefslogtreecommitdiffstats
path: root/qa/tasks/immutable_object_cache.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /qa/tasks/immutable_object_cache.py
parentInitial commit. (diff)
downloadceph-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 'qa/tasks/immutable_object_cache.py')
-rw-r--r--qa/tasks/immutable_object_cache.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/qa/tasks/immutable_object_cache.py b/qa/tasks/immutable_object_cache.py
new file mode 100644
index 000000000..b8034de47
--- /dev/null
+++ b/qa/tasks/immutable_object_cache.py
@@ -0,0 +1,72 @@
+"""
+immutable object cache task
+"""
+import contextlib
+import logging
+
+from teuthology import misc as teuthology
+from teuthology import contextutil
+from teuthology.orchestra import run
+
+log = logging.getLogger(__name__)
+
+@contextlib.contextmanager
+def immutable_object_cache(ctx, config):
+ """
+ setup and cleanup immutable object cache
+ """
+ log.info("start immutable object cache daemon")
+ for client, client_config in config.items():
+ (remote,) = ctx.cluster.only(client).remotes.keys()
+ # make sure that there is one immutable object cache daemon on the same node.
+ remote.run(
+ args=[
+ 'sudo', 'killall', '-s', '9', 'ceph-immutable-object-cache', run.Raw('||'), 'true',
+ ]
+ )
+ remote.run(
+ args=[
+ 'ceph-immutable-object-cache', '-b',
+ ]
+ )
+ try:
+ yield
+ finally:
+ log.info("check and cleanup immutable object cache")
+ for client, client_config in config.items():
+ client_config = client_config if client_config is not None else dict()
+ (remote,) = ctx.cluster.only(client).remotes.keys()
+ cache_path = client_config.get('immutable object cache path', '/tmp/ceph-immutable-object-cache')
+ ls_command = '"$(ls {} )"'.format(cache_path)
+ remote.run(
+ args=[
+ 'test', '-n', run.Raw(ls_command),
+ ]
+ )
+ remote.run(
+ args=[
+ 'sudo', 'killall', '-s', '9', 'ceph-immutable-object-cache', run.Raw('||'), 'true',
+ ]
+ )
+ remote.run(
+ args=[
+ 'sudo', 'rm', '-rf', cache_path, run.Raw('||'), 'true',
+ ]
+ )
+
+@contextlib.contextmanager
+def task(ctx, config):
+ """
+ This is task for start immutable_object_cache.
+ """
+ assert isinstance(config, dict), \
+ "task immutable_object_cache only supports a dictionary for configuration"
+
+ managers = []
+ config = teuthology.replace_all_with_clients(ctx.cluster, config)
+ managers.append(
+ lambda: immutable_object_cache(ctx=ctx, config=config)
+ )
+
+ with contextutil.nested(*managers):
+ yield