Commit 083d5998 authored by Alain Takoudjou's avatar Alain Takoudjou

grid.promise: do no write execution timestamp if running testless or anomalyless promise

parent d75813e0
......@@ -146,7 +146,6 @@ class PromiseProcess(Process):
"""
try:
os.chdir(self.partition_folder)
self.setPromiseStartTimestamp()
if self.uid and self.gid:
dropPrivileges(self.uid, self.gid, logger=self.logger)
......@@ -157,6 +156,10 @@ class PromiseProcess(Process):
promise_module = self._loadPromiseModule()
promise_instance = promise_module.RunPromise(self.argument_dict)
if (promise_instance.isAnomalyDetected() and self.check_anomaly) or \
(promise_instance.isTested() and not self.check_anomaly):
# if the promise will run, we save execution timestamp
self.setPromiseStartTimestamp()
promise_instance.run(self.check_anomaly, self.allow_bang)
except Exception:
self.logger.error(traceback.format_exc())
......
......@@ -1148,6 +1148,50 @@ exit 1
# promise result is saved
self.assertTrue(self.called)
def test_runpromise_not_tested_will_not_change_periodicity(self):
promise_name = 'my_promise.py'
def test_method(result):
self.called = True
self.called = False
self.configureLauncher(save_method=test_method, timeout=5, enable_anomaly=False)
self.generatePromiseScript(promise_name, success=True, periodicity=5,
is_tested=False,)
# will not run the promise in test mode
self.launcher.run()
self.assertFalse(self.called)
self.configureLauncher(save_method=test_method, timeout=5, enable_anomaly=True)
# will not run immediately anomaly
self.launcher.run()
# no result returned by the promise
self.assertTrue(self.called)
def test_runpromise_without_anomaly_no_change_periodicity(self):
promise_name = 'my_promise.py'
def test_method(result):
self.called = True
self.called = False
self.configureLauncher(save_method=test_method, timeout=5, enable_anomaly=True)
self.generatePromiseScript(promise_name, success=True, periodicity=5,
with_anomaly=False,)
# will not run the promise in anomaly mode
self.launcher.run()
self.assertFalse(self.called)
self.configureLauncher(save_method=test_method, timeout=5, enable_anomaly=False)
# will not run immediately anomaly (periodicity didn't change)
self.launcher.run()
# no result returned by the promise
self.assertTrue(self.called)
def test_runpromise_not_tested_without_anomaly_fail(self):
promise_name = 'my_promise.py'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment