Commit 85dbfd78 authored by Guido Trotter's avatar Guido Trotter
Browse files

TestMainloop: test scheduler priorities as well



By using enterabs we can schedule events at the same time, which will
then be sorted by priority.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 19ad29d2
......@@ -117,6 +117,20 @@ class TestMainloop(testutils.GanetiTestCase):
signal.SIGCHLD, signal.SIGCHLD, signal.SIGTERM])
self.assertEquals(self.onsignal_events, self.sendsig_events)
def testPriority(self):
# for events at the same time, the highest priority one executes first
now = time.time()
self.mainloop.scheduler.enterabs(now + 0.1, 2, self._SendSig,
[signal.SIGCHLD])
self.mainloop.scheduler.enterabs(now + 0.1, 1, self._SendSig,
[signal.SIGTERM])
self.mainloop.Run()
self.assertEquals(self.sendsig_events, [signal.SIGTERM])
self.mainloop.scheduler.enter(0.2, 1, self._SendSig, [signal.SIGTERM])
self.mainloop.Run()
self.assertEquals(self.sendsig_events,
[signal.SIGTERM, signal.SIGCHLD, signal.SIGTERM])
class _MyAsyncUDPSocket(daemon.AsyncUDPSocket):
......
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