Commit d75813e0 authored by Alain Takoudjou's avatar Alain Takoudjou

grid.promise: send EmptyResult if promise is test less or anomaly less

There is now `EmptyResult` object which is an empty promise result. This result is send if the promise test or anomaly was skiped (if disabled).
To prevent raise because `EmptyResult` is unknonwn on old slapos-node with `slapos.core < 1.4.17` we will send an empty TestResult instead.
parent 3a9b84c1
......@@ -49,6 +49,7 @@ from slapos.grid.promise.generic import (GenericPromise, PromiseQueueResult,
from slapos.grid.promise.wrapper import WrapPromise
from slapos.version import version
class PromiseError(Exception):
......@@ -492,7 +493,7 @@ class PromiseLauncher(object):
message="Error: No output returned by the promise",
elif queue_item.item is None:
elif queue_item.item.type() == "Empty Result":
# no result collected (sense skipped)
skipped_method = "Anomaly" if self.check_anomaly else "Test"
self.logger.debug("Skipped, %s is disabled in promise %r." % (
......@@ -530,6 +531,7 @@ class PromiseLauncher(object):
'partition-id': self.partition_id,
'computer-id': self.computer_id,
'queue': self.queue_result,
'slapgrid-version': version,
if os.path.exists(self.promise_folder) and os.path.isdir(self.promise_folder):
......@@ -92,6 +92,15 @@ class AnomalyResult(BaseResult):
def type():
return "Anomaly Result"
class EmptyResult(BaseResult):
def __init__(self):
BaseResult.__init__(self, False, None, None)
def type():
return "Empty Result"
class PromiseQueueResult(object):
def __init__(self, path=None, name=None, title=None,
......@@ -101,6 +110,9 @@ class PromiseQueueResult(object):
self.item = item
self.title = title
self.execution_time = execution_time
if self.item is None:
# if no result set, then set EmptyResult
self.item = EmptyResult()
def serialize(self):
return {
......@@ -245,7 +257,7 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
self.__is_anomaly_detected = False
def isAnomalyLess(self):
def isAnomalyDetected(self):
return self.__is_anomaly_detected
def __bang(self, message):
......@@ -487,7 +499,11 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
elif (not self.__is_tested and not check_anomaly) or \
(not self.__is_anomaly_detected and check_anomaly):
# Anomaly or Test is disabled on this promise, send empty result
if self.getConfig('slapgrid-version', '') <= '1.4.17':
# old version cannot send EmptyResult
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