From 348274947efd1ef96f9b4c15044e3c7f20d4bc85 Mon Sep 17 00:00:00 2001 From: Ivo De Decker Date: Tue, 25 Dec 2018 22:12:33 +0000 Subject: [PATCH] Add option fake_runtime to override runtime in britney.conf This is useful to run tests with the data files from a specific point in time, without changes due to ageing when the test runs later. Signed-off-by: Ivo De Decker --- britney2/policies/policy.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py index bd4b14d..98258c5 100644 --- a/britney2/policies/policy.py +++ b/britney2/policies/policy.py @@ -182,7 +182,12 @@ class AgePolicy(BasePolicy): self._min_days_default = None # initialised later # britney's "day" begins at 7pm (we want aging to occur in the 22:00Z run and we run Britney 2-4 times a day) # NB: _date_now is used in tests - self._date_now = int(((time.time() / (60*60)) - 19) / 24) + time_now = time.time() + if hasattr(self.options, 'fake_runtime'): + time_now = int(self.options.fake_runtime) + self.logger.info("overriding runtime with fake_runtime %d"%time_now) + + self._date_now = int(((time_now / (60*60)) - 19) / 24) self._dates = {} self._urgencies = {} self._default_urgency = self.options.default_urgency