Пример #1
0
 def test_lce_same_content(self):
     hr = strategy.LeaveCopyEverywhere(self.view, self.controller)
     # receiver 0 requests 2, expect miss
     hr.process_event(1, 0, 2, True)
     loc = self.view.content_locations(2)
     assert len(loc) == 4
     assert 1 in loc
     assert 2 in loc
     assert 3 in loc
     assert 4 in loc
     summary = self.collector.session_summary()
     exp_req_hops = [(0, 1), (1, 2), (2, 3), (3, 4)]
     exp_cont_hops = [(4, 3), (3, 2), (2, 1), (1, 0)]
     req_hops = summary['request_hops']
     cont_hops = summary['content_hops']
     assert set(exp_req_hops) == set(req_hops)
     assert set(exp_cont_hops) == set(cont_hops)
     # receiver 0 requests 2, expect hit
     hr.process_event(1, 5, 2, True)
     loc = self.view.content_locations(2)
     assert len(loc) == 4
     assert 1 in loc
     assert 2 in loc
     assert 3 in loc
     assert 4 in loc
     summary = self.collector.session_summary()
     exp_req_hops = set(((5, 2), ))
     exp_cont_hops = set(((2, 5), ))
     req_hops = summary['request_hops']
     cont_hops = summary['content_hops']
     assert exp_req_hops == set(req_hops)
     assert exp_cont_hops == set(cont_hops)
Пример #2
0
 def test_lce_same_content(self):
     hr = strategy.LeaveCopyEverywhere(self.view, self.controller)
     # receiver 0 requests 2, expect miss
     hr.process_event(1, 0, 2, True)
     loc = self.view.content_locations(2)
     self.assertEqual(len(loc), 4)
     self.assertIn(1, loc)
     self.assertIn(2, loc)
     self.assertIn(3, loc)
     self.assertIn(4, loc)
     summary = self.collector.session_summary()
     exp_req_hops = [(0, 1), (1, 2), (2, 3), (3, 4)]
     exp_cont_hops = [(4, 3), (3, 2), (2, 1), (1, 0)]
     req_hops = summary['request_hops']
     cont_hops = summary['content_hops']
     self.assertSetEqual(set(exp_req_hops), set(req_hops))
     self.assertSetEqual(set(exp_cont_hops), set(cont_hops))
     # receiver 0 requests 2, expect hit
     hr.process_event(1, 5, 2, True)
     loc = self.view.content_locations(2)
     self.assertEqual(len(loc), 4)
     self.assertIn(1, loc)
     self.assertIn(2, loc)
     self.assertIn(3, loc)
     self.assertIn(4, loc)
     summary = self.collector.session_summary()
     exp_req_hops = set(((5, 2), ))
     exp_cont_hops = set(((2, 5), ))
     req_hops = summary['request_hops']
     cont_hops = summary['content_hops']
     self.assertSetEqual(exp_req_hops, set(req_hops))
     self.assertSetEqual(exp_cont_hops, set(cont_hops))
Пример #3
0
 def test_lce_different_content(self):
     hr = strategy.LeaveCopyEverywhere(self.view, self.controller)
     # receiver 0 requests 2, expect miss
     hr.process_event(1, 0, 2, True)
     loc = self.view.content_locations(2)
     self.assertEquals(len(loc), 4)
     self.assertIn(1, loc)
     self.assertIn(2, loc)
     self.assertIn(3, loc)
     self.assertIn(4, loc)
     summary = self.collector.session_summary()
     exp_req_hops = set(((0, 1), (1, 2), (2, 3), (3, 4)))
     exp_cont_hops = set(((4, 3), (3, 2), (2, 1), (1, 0)))
     req_hops = summary['request_hops']
     cont_hops = summary['content_hops']
     self.assertSetEqual(exp_req_hops, set(req_hops))
     self.assertSetEqual(exp_cont_hops, set(cont_hops))
     # request content 3 from 5
     hr.process_event(1, 5, 3, True)
     loc = self.view.content_locations(3)
     self.assertEquals(len(loc), 3)
     self.assertIn(2, loc)
     self.assertIn(3, loc)
     self.assertIn(4, loc)
     loc = self.view.content_locations(2)
     self.assertEquals(len(loc), 2)
     self.assertIn(1, loc)
     self.assertIn(4, loc)
     summary = self.collector.session_summary()
     exp_req_hops = set(((5, 2), (2, 3), (3, 4)))
     exp_cont_hops = set(((4, 3), (3, 2), (2, 5)))
     req_hops = summary['request_hops']
     cont_hops = summary['content_hops']
     self.assertSetEqual(exp_req_hops, set(req_hops))
     self.assertSetEqual(exp_cont_hops, set(cont_hops))
     # request content 3 from , hit in 2
     hr.process_event(1, 0, 3, True)
     loc = self.view.content_locations(3)
     self.assertEquals(len(loc), 4)
     self.assertIn(1, loc)
     self.assertIn(2, loc)
     self.assertIn(3, loc)
     self.assertIn(4, loc)
     loc = self.view.content_locations(2)
     self.assertEquals(len(loc), 1)
     self.assertIn(4, loc)
     summary = self.collector.session_summary()
     exp_req_hops = set(((0, 1), (1, 2)))
     exp_cont_hops = set(((2, 1), (1, 0)))
     req_hops = summary['request_hops']
     cont_hops = summary['content_hops']
     self.assertSetEqual(exp_req_hops, set(req_hops))
     self.assertSetEqual(exp_cont_hops, set(cont_hops))