def test_3(self): cache_budget = 30 cache_nodes = 3 cacheplacement.optimal_median_cache_placement(self.topo, cache_budget, cache_nodes, 0.5) self.assertEqual(10, self.topo.node["c1"]['stack'][1]['cache_size']) self.assertEqual(10, self.topo.node["c2"]['stack'][1]['cache_size']) self.assertEqual(10, self.topo.node["c3"]['stack'][1]['cache_size']) self.assertDictEqual({'r1': 'c1', 'r2': 'c1', 'r3': 'c2', 'r4': 'c2', 'r5': 'c2', 'r6': 'c3'}, self.topo.graph['cache_assignment'])
def test_3(self): cache_budget = 30 cache_nodes = 3 cacheplacement.optimal_median_cache_placement(self.topo, cache_budget, cache_nodes, 0.5) self.assertEqual(10, self.topo.node["c1"]['stack'][1]['cache_size']) self.assertEqual(10, self.topo.node["c2"]['stack'][1]['cache_size']) self.assertEqual(10, self.topo.node["c3"]['stack'][1]['cache_size']) self.assertDictEqual({'r1': 'c1', 'r2': 'c1', 'r3': 'c2', 'r4': 'c2', 'r5': 'c2', 'r6': 'c3'}, self.topo.graph['cache_assignment'])
def test_2(self): cache_budget = 30 cache_nodes = 2 cacheplacement.optimal_median_cache_placement(self.topo, cache_budget, cache_nodes, 0.5) assert 15 == self.topo.node["c1"]['stack'][1]['cache_size'] assert 15 == self.topo.node["c2"]['stack'][1]['cache_size'] if 'cache_size' in self.topo.node["c3"]['stack'][1]: assert 0 == self.topo.node["c3"]['stack'][1]['cache_size'] assert {'r1': 'c1', 'r2': 'c1', 'r3': 'c2', 'r4': 'c2', 'r5': 'c2', 'r6': 'c2'} == \ self.topo.graph['cache_assignment']
def test_3(self): cache_budget = 30 cache_nodes = 3 cacheplacement.optimal_median_cache_placement( self.topo, cache_budget, cache_nodes, 0.5 ) assert self.topo.node["c1"]["stack"][1]["cache_size"] == 10 assert self.topo.node["c2"]["stack"][1]["cache_size"] == 10 assert self.topo.node["c3"]["stack"][1]["cache_size"] == 10 assert { "r1": "c1", "r2": "c1", "r3": "c2", "r4": "c2", "r5": "c2", "r6": "c3", } == self.topo.graph["cache_assignment"]
def test_1(self): cache_budget = 30 cache_nodes = 1 cacheplacement.optimal_median_cache_placement( self.topo, cache_budget, cache_nodes, 0.5 ) if "cache_size" in self.topo.node["c1"]["stack"][1]: assert 0 == self.topo.node["c1"]["stack"][1]["cache_size"] assert 30 == self.topo.node["c2"]["stack"][1]["cache_size"] if "cache_size" in self.topo.node["c3"]["stack"][1]: assert 0 == self.topo.node["c3"]["stack"][1]["cache_size"] assert { "r1": "c2", "r2": "c2", "r3": "c2", "r4": "c2", "r5": "c2", "r6": "c2", } == self.topo.graph["cache_assignment"]