From: Noah Watkins Date: Thu, 16 Aug 2018 18:23:29 +0000 (-0700) Subject: mgr/selftest: set insights now offset X-Git-Tag: v14.0.1~336^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=bc13558c4ad29634eb53f1fd7b8df3e87a33cc34;p=ceph.git mgr/selftest: set insights now offset 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 --- diff --git a/src/pybind/mgr/selftest/module.py b/src/pybind/mgr/selftest/module.py index 2c0577ef2dc31..3f48ad180eb83 100644 --- a/src/pybind/mgr/selftest/module.py +++ b/src/pybind/mgr/selftest/module.py @@ -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...")