On Wed, 03/07 14:17, Paolo Bonzini wrote:
On 07/03/2018 09:46, Fam Zheng wrote:
With "testing.ready" property, we immediately mark series as "ready to
test" when git apply is done, eliminating the need to do a relatively
heavy search query.
Signed-off-by: Fam Zheng <famz@xxxxxxxxxx>
---
mods/testing.py | 22 +++++++++++++++++-----
tests/test_testing.py | 1 +
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/mods/testing.py b/mods/testing.py
index 47933e2..80a22a5 100644
--- a/mods/testing.py
+++ b/mods/testing.py
@@ -23,7 +23,7 @@ import math
from api.views import APILoginRequiredView
from api.models import Message, Project, MessageProperty
from api.search import SearchEngine
-from event import emit_event, declare_event
+from event import emit_event, declare_event, register_handler
from patchew.logviewer import LogView
from schema import *
@@ -112,6 +112,16 @@ class TestingModule(PatchewModule):
test="test name",
log="test log",
is_timeout="whether the test has timeout")
+ register_handler("SetProperty", self.on_set_property)
+
+ def on_set_property(self, evt, obj, name, value, old_value):
+ if ((isinstance(obj, Message) and obj.is_series_head) \
+ or isinstance(obj, Project)) \
+ and name in ("git.tag", "git.repo") \
+ and old_value is None \
+ and obj.get_property("git.tag") and
obj.get_property("git.repo"):
+ self.remove_testing_properties(obj)
+ obj.set_property("testing.ready", 1)
I wonder if we should already move this event towards the "result" model
that is used by the REST API. In this case, the event could be
something like OnResultUpdate, with a name of "git" and a status of
"success".
Otherwise, this makes sense.