]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados/thrash: add test for radosgw with snaps
authorSamuel Just <sjust@redhat.com>
Wed, 20 May 2015 22:09:18 +0000 (15:09 -0700)
committerSamuel Just <sjust@redhat.com>
Thu, 28 May 2015 22:36:39 +0000 (15:36 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
suites/rados/thrash/workloads/rgw_snaps.yaml [new file with mode: 0644]
tasks/ceph_manager.py
tasks/thrash_pool_snaps.py [new file with mode: 0644]

diff --git a/suites/rados/thrash/workloads/rgw_snaps.yaml b/suites/rados/thrash/workloads/rgw_snaps.yaml
new file mode 100644 (file)
index 0000000..8200cc3
--- /dev/null
@@ -0,0 +1,25 @@
+tasks:
+- rgw:
+    default_idle_timeout: 3600
+    client.0: null
+- thrash_pool_snaps:
+    pools:
+    - .rgw.buckets
+    - .rgw.root
+    - .rgw.control
+    - .rgw
+    - .users.uid
+    - .users.email
+    - .users
+- s3readwrite:
+    client.0:
+      rgw_server: client.0
+      readwrite:
+        bucket: rwtest
+        readers: 10
+        writers: 3
+        duration: 300
+        files:
+          num: 10
+          size: 2000
+          stddev: 500
index 5b62d10506298af07766f489a42fae53faf21a4f..dbaac4012bf1a3793fba488a0dc28dc3ed57128d 100644 (file)
@@ -1137,6 +1137,24 @@ class CephManager:
                                      pool_name, str(pg_num))
             self.pools[pool_name] = pg_num
 
+    def add_pool_snap(self, pool_name, snap_name):
+        """
+        Add pool snapshot
+        :param pool_name: name of pool to snapshot
+        :param snap_name: name of snapshot to take
+        """
+        self.raw_cluster_cmd('osd', 'pool', 'mksnap',
+                             str(pool_name), str(snap_name))
+
+    def remove_pool_snap(self, pool_name, snap_name):
+        """
+        Remove pool snapshot
+        :param pool_name: name of pool to snapshot
+        :param snap_name: name of snapshot to remove
+        """
+        self.raw_cluster_cmd('osd', 'pool', 'rmsnap',
+                             str(pool_name), str(snap_name))
+
     def remove_pool(self, pool_name):
         """
         Remove the indicated pool
diff --git a/tasks/thrash_pool_snaps.py b/tasks/thrash_pool_snaps.py
new file mode 100644 (file)
index 0000000..1c3f8f4
--- /dev/null
@@ -0,0 +1,60 @@
+"""
+Thrash -- Simulate random osd failures.
+"""
+import contextlib
+import logging
+import gevent
+import time
+import random
+
+
+log = logging.getLogger(__name__)
+
+@contextlib.contextmanager
+def task(ctx, config):
+    """
+    "Thrash" snap creation and removal on the listed pools
+
+    Example:
+
+    thrash_pool_snaps:
+      pools: [.rgw.buckets, .rgw.buckets.index]
+      max_snaps: 10
+      min_snaps: 5
+      period: 10
+    """
+    stopping = False
+    def do_thrash():
+        pools = config.get('pools', [])
+        max_snaps = config.get('max_snaps', 10)
+        min_snaps = config.get('min_snaps', 5)
+        period = config.get('period', 30)
+        snaps = []
+        def remove_snap():
+            assert len(snaps) > 0
+            snap = random.choice(snaps)
+            log.info("Removing snap %s" % (snap,))
+            for pool in pools:
+                ctx.manager.remove_pool_snap(pool, str(snap))
+            snaps.remove(snap)
+        def add_snap(snap):
+            log.info("Adding snap %s" % (snap,))
+            for pool in pools:
+                ctx.manager.add_pool_snap(pool, str(snap))
+            snaps.append(snap)
+        index = 0
+        while not stopping:
+            index += 1
+            time.sleep(period)
+            if len(snaps) <= min_snaps:
+                add_snap(index)
+            elif len(snaps) >= max_snaps:
+                remove_snap()
+            else:
+                random.choice([lambda: add_snap(index), remove_snap])()
+        log.info("Stopping")
+    thread = gevent.spawn(do_thrash)
+    yield
+    stopping = True
+    thread.join()
+