Fix agent extending
Change-Id: I29c92a6d99b5aa01a7431e55997996700bf904ee
This commit is contained in:
parent
025bd164f0
commit
aa9716f3e0
@ -112,12 +112,16 @@ def read_scenario():
|
|||||||
return scenario
|
return scenario
|
||||||
|
|
||||||
|
|
||||||
def _extend_agents(agents):
|
def _extend_agents(agents_map):
|
||||||
for agent in agents.values():
|
extended_agents = {}
|
||||||
|
for agent in agents_map.values():
|
||||||
|
extended = copy.deepcopy(agent)
|
||||||
if agent.get('slave_id'):
|
if agent.get('slave_id'):
|
||||||
agent['slave'] = copy.deepcopy(agents[agent['slave_id']])
|
extended['slave'] = copy.deepcopy(agents_map[agent['slave_id']])
|
||||||
if agent.get('master_id'):
|
if agent.get('master_id'):
|
||||||
agent['master'] = copy.deepcopy(agents[agent['master_id']])
|
extended['master'] = copy.deepcopy(agents_map[agent['master_id']])
|
||||||
|
extended_agents[agent['id']] = extended
|
||||||
|
return extended_agents
|
||||||
|
|
||||||
|
|
||||||
def _pick_agents(agents, size):
|
def _pick_agents(agents, size):
|
||||||
@ -141,7 +145,7 @@ def _pick_agents(agents, size):
|
|||||||
|
|
||||||
|
|
||||||
def execute(quorum, execution, agents):
|
def execute(quorum, execution, agents):
|
||||||
_extend_agents(agents)
|
agents = _extend_agents(agents)
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from shaker.engine import server
|
|||||||
class TestServer(testtools.TestCase):
|
class TestServer(testtools.TestCase):
|
||||||
|
|
||||||
def test_extend_agents(self):
|
def test_extend_agents(self):
|
||||||
agents = {
|
agents_map = {
|
||||||
'UU1D_master_0': {
|
'UU1D_master_0': {
|
||||||
'id': 'UU1D_master_0',
|
'id': 'UU1D_master_0',
|
||||||
'mode': 'master',
|
'mode': 'master',
|
||||||
@ -33,7 +33,7 @@ class TestServer(testtools.TestCase):
|
|||||||
'mode': 'slave',
|
'mode': 'slave',
|
||||||
'node': 'dos'},
|
'node': 'dos'},
|
||||||
}
|
}
|
||||||
server._extend_agents(agents)
|
agents = server._extend_agents(agents_map)
|
||||||
self.assertDictContainsSubset(agents['UU1D_master_0']['slave'],
|
self.assertDictContainsSubset(agents['UU1D_master_0']['slave'],
|
||||||
agents['UU1D_slave_0'])
|
agents['UU1D_slave_0'])
|
||||||
self.assertDictContainsSubset(agents['UU1D_slave_0']['master'],
|
self.assertDictContainsSubset(agents['UU1D_slave_0']['master'],
|
||||||
|
Loading…
Reference in New Issue
Block a user