Skip to content

Commit

Permalink
Merge pull request #3093 from radical-cybertools/fix/service_cb
Browse files Browse the repository at this point in the history
fixed collecting service related data in registry
  • Loading branch information
mtitov authored Nov 27, 2023
2 parents 15900cf + 8905f11 commit 6dec056
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/radical/pilot/agent/agent_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ def _services_startup_cb(self, cb_data):
service_urls[idx] = url

if service_urls:
key = cb_data[tid]['name']
for idx, url in service_urls.items():
key = cb_data[tid]['name']
if idx:
key += '.%s' % idx
key += '.url'
Expand Down
34 changes: 34 additions & 0 deletions tests/unit_tests/test_agent_0/test_agent_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,40 @@ def test_ctrl_service_up(self, mocked_init):
self.assertTrue(agent_0._services_setup.is_set())


# --------------------------------------------------------------------------
#
@mock.patch.object(Agent_0, '__init__', return_value=None)
def test_services_startup_cb(self, mocked_init):

fd, startup_file = tempfile.mkstemp()
self._cleanup_files.append(startup_file)

uri_0 = 'ofi+verbs;ofi_rxm://10.41.0.103:35298'
uri_1 = 'ofi+verbs;ofi_rxm://10.41.0.104:38112'
with os.fdopen(fd, 'w') as f:
f.write('2\n0 %s\n1 %s' % (uri_0, uri_1))

reg = ru.zmq.Registry()
reg.start()

agent_0 = Agent_0()
agent_0._session = self._session
agent_0._session._reg = ru.zmq.RegistryClient(url=reg.addr)

agent_0.publish = mock.Mock()

cb_data = {'service.0000': {'name' : 'service.monit',
'startup_file': startup_file}}
agent_0._services_startup_cb(cb_data=cb_data)

self.assertEqual(agent_0._session._reg['service.monit.0.url'], uri_0)
self.assertEqual(agent_0._session._reg['service.monit.1.url'], uri_1)

agent_0._session._reg.close()
reg.stop()
reg.wait()


# ------------------------------------------------------------------------------
#
if __name__ == '__main__':
Expand Down

0 comments on commit 6dec056

Please sign in to comment.