Exemplo n.º 1
0
 def test_lce(self):
     hr = strategy.NearestReplicaRouting(self.view,
                                         self.controller,
                                         metacaching='LCE')
     # receiver 0 requests 2, expect miss
     hr.process_event(1, 0, 2, True)
     loc = self.view.content_locations(2)
     self.assertEqual(3, len(loc))
     self.assertIn(2, loc)
     self.assertIn(4, loc)
     self.assertIn(6, loc)
     self.assertNotIn(3, loc)
     self.assertNotIn(5, loc)
     summary = self.collector.session_summary()
     exp_req_hops = [(0, 2), (2, 4), (4, 6)]
     exp_cont_hops = [(6, 4), (4, 2), (2, 0)]
     self.assertSetEqual(set(exp_req_hops), set(summary['request_hops']))
     self.assertSetEqual(set(exp_cont_hops), set(summary['content_hops']))
     self.assertEqual(6, summary['serving_node'])
     # receiver 0 requests 2, expect hit
     hr.process_event(1, 1, 2, True)
     loc = self.view.content_locations(2)
     self.assertEqual(4, len(loc))
     self.assertIn(2, loc)
     self.assertIn(4, loc)
     self.assertIn(6, loc)
     self.assertIn(3, loc)
     self.assertNotIn(5, loc)
     summary = self.collector.session_summary()
     exp_req_hops = [(1, 3), (3, 2)]
     exp_cont_hops = [(2, 3), (3, 1)]
     self.assertSetEqual(set(exp_req_hops), set(summary['request_hops']))
     self.assertSetEqual(set(exp_cont_hops), set(summary['content_hops']))
     self.assertEqual(2, summary['serving_node'])
     hr.process_event(1, 1, 2, True)
     loc = self.view.content_locations(2)
     self.assertEqual(4, len(loc))
     self.assertIn(2, loc)
     self.assertIn(4, loc)
     self.assertIn(6, loc)
     self.assertIn(3, loc)
     self.assertNotIn(5, loc)
     summary = self.collector.session_summary()
     exp_req_hops = [(1, 3)]
     exp_cont_hops = [(3, 1)]
     self.assertSetEqual(set(exp_req_hops), set(summary['request_hops']))
     self.assertSetEqual(set(exp_cont_hops), set(summary['content_hops']))
     self.assertEqual(3, summary['serving_node'])
Exemplo n.º 2
0
 def test_lce(self):
     hr = strategy.NearestReplicaRouting(self.view,
                                         self.controller,
                                         metacaching="LCE")
     # receiver 0 requests 2, expect miss
     hr.process_event(1, 0, 2, True)
     loc = self.view.content_locations(2)
     assert 3 == len(loc)
     assert 2 in loc
     assert 4 in loc
     assert "s" in loc
     assert 3 not in loc
     assert 5 not in loc
     summary = self.collector.session_summary()
     exp_req_hops = [(0, 2), (2, 4), (4, "s")]
     exp_cont_hops = [("s", 4), (4, 2), (2, 0)]
     assert set(exp_req_hops) == set(summary["request_hops"])
     assert set(exp_cont_hops) == set(summary["content_hops"])
     assert "s" == summary["serving_node"]
     hr.process_event(1, 1, 2, True)
     loc = self.view.content_locations(2)
     assert 4 == len(loc)
     assert 2 in loc
     assert 4 in loc
     assert "s" in loc
     assert 3 in loc
     assert 5 not in loc
     summary = self.collector.session_summary()
     exp_req_hops = [(1, 3), (3, 2)]
     exp_cont_hops = [(2, 3), (3, 1)]
     assert set(exp_req_hops) == set(summary["request_hops"])
     assert set(exp_cont_hops) == set(summary["content_hops"])
     assert 2 == summary["serving_node"]
     hr.process_event(1, 1, 2, True)
     loc = self.view.content_locations(2)
     assert 4 == len(loc)
     assert 2 in loc
     assert 4 in loc
     assert "s" in loc
     assert 3 in loc
     assert 5 not in loc
     summary = self.collector.session_summary()
     exp_req_hops = [(1, 3)]
     exp_cont_hops = [(3, 1)]
     assert set(exp_req_hops) == set(summary["request_hops"])
     assert set(exp_cont_hops) == set(summary["content_hops"])
     assert 3 == summary["serving_node"]