]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/selftest: set insights now offset
authorNoah Watkins <nwatkins@redhat.com>
Thu, 16 Aug 2018 18:23:29 +0000 (11:23 -0700)
committerNoah Watkins <nwatkins@redhat.com>
Thu, 16 Aug 2018 22:29:46 +0000 (15:29 -0700)
provides a testing interface for setting an offset value applied to the
current wall clock time to help make testing the insights health
collection easier.

Signed-off-by: Noah Watkins <nwatkins@redhat.com>
src/pybind/mgr/selftest/module.py

index 2c0577ef2dc31b100a506ae90682d23ba8cd0ccc..3f48ad180eb8338ee83576edd6bf7bd2c168ef2d 100644 (file)
@@ -81,6 +81,11 @@ class Module(MgrModule):
                 "desc": "Clear health checks by name. If no names provided, clear all.",
                 "perm": "rw"
             },
+            {
+                "cmd": "mgr self-test insights_set_now_offset name=hours,type=CephString",
+                "desc": "Set the now time for the insights module.",
+                "perm": "rw"
+            },
             ]
 
     def __init__(self, *args, **kwargs):
@@ -129,6 +134,8 @@ class Module(MgrModule):
             return self._health_set(inbuf, command)
         elif command['prefix'] == 'mgr self-test health clear':
             return self._health_clear(inbuf, command)
+        elif command['prefix'] == 'mgr self-test insights_set_now_offset':
+            return self._insights_set_now_offset(inbuf, command)
         else:
             return (-errno.EINVAL, '',
                     "Command not found '{0}'".format(command['prefix']))
@@ -163,6 +170,15 @@ class Module(MgrModule):
         self.set_health_checks(self._health)
         return 0, "", ""
 
+    def _insights_set_now_offset(self, inbuf, command):
+        try:
+            hours = long(command["hours"])
+        except Exception as e:
+            return -1, "", "Timestamp must be numeric: {}".format(e.message)
+
+        self.remote("insights", "testing_set_now_time_offset", hours)
+        return 0, "", ""
+
     def _self_test(self):
         self.log.info("Running self-test procedure...")