Ejemplo n.º 1
0
    def test_limits_maxtasks(self):
        s = State(max_tasks_in_memory=1)
        s.event({
            'type': 'task-unknown-event-xxx',
            'foo': 'bar',
            'uuid': 'x',
            'hostname': 'y',
            'clock': 3,
            'timestamp': time(),
            'local_received': time(),
        })
        s.event({
            'type': 'task-unknown-event-xxx',
            'foo': 'bar',
            'uuid': 'y',
            'hostname': 'y',
            'clock': 4,
            'timestamp': time(),
            'local_received': time(),
        })
        s.event({
            'type': 'task-unknown-event-xxx',
            'foo': 'bar',
            'uuid': 'z',
            'hostname': 'y',
            'clock': 5,
            'timestamp': time(),
            'local_received': time(),
        })
        self.assertEqual(len(s._taskheap), 2)
        self.assertEqual(s._taskheap[0].clock, 4)
        self.assertEqual(s._taskheap[1].clock, 5)

        s._taskheap.append(s._taskheap[0])
        self.assertTrue(list(s.tasks_by_time()))
Ejemplo n.º 2
0
    def test_limits_maxtasks(self):
        s = State()
        s.max_tasks_in_memory = 1
        s.task_event('task-unknown-event-xxx', {
            'foo': 'bar',
            'uuid': 'x',
            'hostname': 'y',
            'clock': 3
        })
        s.task_event('task-unknown-event-xxx', {
            'foo': 'bar',
            'uuid': 'y',
            'hostname': 'y',
            'clock': 4
        })

        s.task_event('task-unknown-event-xxx', {
            'foo': 'bar',
            'uuid': 'z',
            'hostname': 'y',
            'clock': 5
        })
        self.assertEqual(len(s._taskheap), 2)
        self.assertEqual(s._taskheap[0].clock, 4)
        self.assertEqual(s._taskheap[1].clock, 5)

        s._taskheap.append(s._taskheap[0])
        self.assertTrue(list(s.tasks_by_time()))
Ejemplo n.º 3
0
 def test_task_descending_clock_ordering(self):
     state = State()
     r = ev_logical_clock_ordering(state)
     tA, tB, tC = r.uids
     r.play()
     now = list(state.tasks_by_time(reverse=False))
     assert now[0][0] == tA
     assert now[1][0] == tB
     assert now[2][0] == tC
     for _ in range(1000):
         shuffle(r.uids)
         tA, tB, tC = r.uids
         r.rewind_with_offset(r.current_clock + 1, r.uids)
         r.play()
     now = list(state.tasks_by_time(reverse=False))
     assert now[0][0] == tB
     assert now[1][0] == tC
     assert now[2][0] == tA
Ejemplo n.º 4
0
 def test_task_descending_clock_ordering(self):
     state = State()
     r = ev_logical_clock_ordering(state)
     tA, tB, tC = r.uids
     r.play()
     now = list(state.tasks_by_time(reverse=False))
     assert now[0][0] == tA
     assert now[1][0] == tB
     assert now[2][0] == tC
     for _ in range(1000):
         shuffle(r.uids)
         tA, tB, tC = r.uids
         r.rewind_with_offset(r.current_clock + 1, r.uids)
         r.play()
     now = list(state.tasks_by_time(reverse=False))
     assert now[0][0] == tB
     assert now[1][0] == tC
     assert now[2][0] == tA
Ejemplo n.º 5
0
 def test_task_logical_clock_ordering(self):
     state = State()
     r = ev_logical_clock_ordering(state)
     tA, tB, tC = r.uids
     r.play()
     now = list(state.tasks_by_time())
     self.assertEqual(now[0][0], tA)
     self.assertEqual(now[1][0], tC)
     self.assertEqual(now[2][0], tB)
     for _ in range(1000):
         shuffle(r.uids)
         tA, tB, tC = r.uids
         r.rewind_with_offset(r.current_clock + 1, r.uids)
         r.play()
     now = list(state.tasks_by_time())
     self.assertEqual(now[0][0], tA)
     self.assertEqual(now[1][0], tC)
     self.assertEqual(now[2][0], tB)
Ejemplo n.º 6
0
 def test_task_logical_clock_ordering(self):
     state = State()
     r = ev_logical_clock_ordering(state)
     tA, tB, tC = r.uids
     r.play()
     now = list(state.tasks_by_time())
     self.assertEqual(now[0][0], tA)
     self.assertEqual(now[1][0], tC)
     self.assertEqual(now[2][0], tB)
     for _ in range(1000):
         shuffle(r.uids)
         tA, tB, tC = r.uids
         r.rewind_with_offset(r.current_clock + 1, r.uids)
         r.play()
     now = list(state.tasks_by_time())
     self.assertEqual(now[0][0], tA)
     self.assertEqual(now[1][0], tC)
     self.assertEqual(now[2][0], tB)
Ejemplo n.º 7
0
 def test_task_descending_clock_ordering(self):
     raise SkipTest('not working')
     state = State()
     r = ev_logical_clock_ordering(state)
     tA, tB, tC = r.uids
     r.play()
     now = list(state.tasks_by_time(reverse=False))
     self.assertEqual(now[0][0], tA)
     self.assertEqual(now[1][0], tB)
     self.assertEqual(now[2][0], tC)
     for _ in range(1000):
         shuffle(r.uids)
         tA, tB, tC = r.uids
         r.rewind_with_offset(r.current_clock + 1, r.uids)
         r.play()
     now = list(state.tasks_by_time(reverse=False))
     self.assertEqual(now[0][0], tB)
     self.assertEqual(now[1][0], tC)
     self.assertEqual(now[2][0], tA)
Ejemplo n.º 8
0
 def test_task_descending_clock_ordering(self):
     raise SkipTest('not working')
     state = State()
     r = ev_logical_clock_ordering(state)
     tA, tB, tC = r.uids
     r.play()
     now = list(state.tasks_by_time(reverse=False))
     self.assertEqual(now[0][0], tA)
     self.assertEqual(now[1][0], tB)
     self.assertEqual(now[2][0], tC)
     for _ in range(1000):
         shuffle(r.uids)
         tA, tB, tC = r.uids
         r.rewind_with_offset(r.current_clock + 1, r.uids)
         r.play()
     now = list(state.tasks_by_time(reverse=False))
     self.assertEqual(now[0][0], tB)
     self.assertEqual(now[1][0], tC)
     self.assertEqual(now[2][0], tA)
Ejemplo n.º 9
0
    def test_limits_maxtasks(self):
        s = State()
        s.max_tasks_in_memory = 1
        s.task_event("task-unknown-event-xxx", {"foo": "bar", "uuid": "x", "hostname": "y", "clock": 3})
        s.task_event("task-unknown-event-xxx", {"foo": "bar", "uuid": "y", "hostname": "y", "clock": 4})

        s.task_event("task-unknown-event-xxx", {"foo": "bar", "uuid": "z", "hostname": "y", "clock": 5})
        self.assertEqual(len(s._taskheap), 2)
        self.assertEqual(s._taskheap[0].clock, 4)
        self.assertEqual(s._taskheap[1].clock, 5)

        s._taskheap.append(s._taskheap[0])
        self.assertTrue(list(s.tasks_by_time()))
Ejemplo n.º 10
0
    def test_limits_maxtasks(self):
        s = State(max_tasks_in_memory=1)
        s.heap_multiplier = 2
        s.event(
            {
                "type": "task-unknown-event-xxx",
                "foo": "bar",
                "uuid": "x",
                "hostname": "y",
                "clock": 3,
                "timestamp": time(),
                "local_received": time(),
            }
        )
        s.event(
            {
                "type": "task-unknown-event-xxx",
                "foo": "bar",
                "uuid": "y",
                "hostname": "y",
                "clock": 4,
                "timestamp": time(),
                "local_received": time(),
            }
        )
        s.event(
            {
                "type": "task-unknown-event-xxx",
                "foo": "bar",
                "uuid": "z",
                "hostname": "y",
                "clock": 5,
                "timestamp": time(),
                "local_received": time(),
            }
        )
        self.assertEqual(len(s._taskheap), 2)
        self.assertEqual(s._taskheap[0].clock, 4)
        self.assertEqual(s._taskheap[1].clock, 5)

        s._taskheap.append(s._taskheap[0])
        self.assertTrue(list(s.tasks_by_time()))
Ejemplo n.º 11
0
    def test_limits_maxtasks(self):
        s = State()
        s.max_tasks_in_memory = 1
        s.task_event('task-unknown-event-xxx', {'foo': 'bar',
                                                'uuid': 'x',
                                                'hostname': 'y',
                                                'clock': 3})
        s.task_event('task-unknown-event-xxx', {'foo': 'bar',
                                                'uuid': 'y',
                                                'hostname': 'y',
                                                'clock': 4})

        s.task_event('task-unknown-event-xxx', {'foo': 'bar',
                                                'uuid': 'z',
                                                'hostname': 'y',
                                                'clock': 5})
        self.assertEqual(len(s._taskheap), 2)
        self.assertEqual(s._taskheap[0].clock, 4)
        self.assertEqual(s._taskheap[1].clock, 5)

        s._taskheap.append(s._taskheap[0])
        self.assertTrue(list(s.tasks_by_time()))
Ejemplo n.º 12
0
    def test_limits_maxtasks(self):
        s = State(max_tasks_in_memory=1)
        s.heap_multiplier = 2
        s.event({
            'type': 'task-unknown-event-xxx',
            'foo': 'bar',
            'uuid': 'x',
            'hostname': 'y',
            'clock': 3,
            'timestamp': time(),
            'local_received': time(),
        })
        s.event({
            'type': 'task-unknown-event-xxx',
            'foo': 'bar',
            'uuid': 'y',
            'hostname': 'y',
            'clock': 4,
            'timestamp': time(),
            'local_received': time(),
        })
        s.event({
            'type': 'task-unknown-event-xxx',
            'foo': 'bar',
            'uuid': 'z',
            'hostname': 'y',
            'clock': 5,
            'timestamp': time(),
            'local_received': time(),
        })
        assert len(s._taskheap) == 2
        assert s._taskheap[0].clock == 4
        assert s._taskheap[1].clock == 5

        s._taskheap.append(s._taskheap[0])
        assert list(s.tasks_by_time())
Ejemplo n.º 13
0
    def test_limits_maxtasks(self):
        s = State(max_tasks_in_memory=1)
        s.heap_multiplier = 2
        s.event({
            'type': 'task-unknown-event-xxx',
            'foo': 'bar',
            'uuid': 'x',
            'hostname': 'y',
            'clock': 3,
            'timestamp': time(),
            'local_received': time(),
        })
        s.event({
            'type': 'task-unknown-event-xxx',
            'foo': 'bar',
            'uuid': 'y',
            'hostname': 'y',
            'clock': 4,
            'timestamp': time(),
            'local_received': time(),
        })
        s.event({
            'type': 'task-unknown-event-xxx',
            'foo': 'bar',
            'uuid': 'z',
            'hostname': 'y',
            'clock': 5,
            'timestamp': time(),
            'local_received': time(),
        })
        assert len(s._taskheap) == 2
        assert s._taskheap[0].clock == 4
        assert s._taskheap[1].clock == 5

        s._taskheap.append(s._taskheap[0])
        assert list(s.tasks_by_time())