Skip to content

Commit

Permalink
post merge 0.18.7
Browse files Browse the repository at this point in the history
  • Loading branch information
julien6387 committed Jan 10, 2025
1 parent 570e8b2 commit c8ab97d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
The state `INITIALIZATION` has been renamed as `SYNCHRONIZATION` and a new state `ELECTION` has been added
to get more stability in the *Master* election.

* Fix the issue raised by the rejected [Pull Request #120](https://github.com/julien6387/supvisors/pull/120).
* Implement the enhancement requested by the [Pull Request #120](https://github.com/julien6387/supvisors/pull/120).
**Supvisors** uses the `ioctl` functions to get the relevant network data on all network interfaces and matches
the local instance on the whole information available.
During the handshake, the local network data is shared with the other **Supvisors** instances using the new XML-RPC
Expand Down
2 changes: 1 addition & 1 deletion supvisors/internal_com/supervisorproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def xml_rpc(self, fct_name: str, fct, args):
self.logger.warn(f'SupervisorProxy.xml_rpc: Supervisor={self.status.usage_identifier}'
f' {fct_name}{args} failed - {str(exc)}')
self.logger.debug(f'SupervisorProxy.xml_rpc: {traceback.format_exc()}')
return None
except (OSError, HTTPException) as exc:
# transport issue due to network or remote Supervisor failure (includes a bunch of exceptions, such as
# socket.gaierror, ConnectionResetError, ConnectionRefusedError, CannotSendRequest, IncompleteRead, etc.)
Expand All @@ -135,6 +134,7 @@ def xml_rpc(self, fct_name: str, fct, args):
# reset the proxy, same reason as above
self._proxy = None
raise SupervisorProxyException
return None

def send_remote_comm_event(self, event_type: str, event) -> None:
""" Send a user message to the remote Supervisor using the sendRemoteCommEvent XML-RPC. """
Expand Down
2 changes: 1 addition & 1 deletion supvisors/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_expand_faults():
assert SupvisorsFaults.DISABLED.value == Faults.DISABLED


def test_patch_logger(mocker, supvisors):
def test_patch_logger(mocker):
""" Test the patch_logger function. """
# check initial context
assert not hasattr(Handler, '_emit')
Expand Down
24 changes: 6 additions & 18 deletions supvisors/tests/test_supervisorproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,34 +64,22 @@ def test_proxy_creation(mocked_rpc, proxy, supvisors_instance):
""" Test the SupvisorsProxy creation. """
assert proxy.supvisors is supvisors_instance
assert proxy.status is supvisors_instance.context.instances['10.0.0.2:25000']
assert proxy.proxy is not None
assert proxy.supvisors is supvisors
assert proxy.status is supvisors.context.instances['10.0.0.1:25000']
assert proxy._proxy is None
assert 0.0 < proxy.last_used < time.monotonic()
assert proxy.logger is supvisors_instance.logger
assert proxy.local_identifier == supvisors_instance.mapper.local_identifier
assert mocked_rpc.call_args_list == [call({'SUPERVISOR_SERVER_URL': 'http://10.0.0.2:25000',
assert proxy.logger is supvisors.logger
assert proxy.local_identifier == supvisors.mapper.local_identifier



def test_proxy_proxy(mocked_rpc, supvisors, proxy):
def test_proxy_proxy(mocked_rpc, supvisors_instance, proxy):
""" Test the SupvisorsProxy proxy property. """
# test with non-local proxy
assert proxy._proxy is None
assert proxy.status.supvisors_id.identifier != proxy.local_identifier
assert proxy.proxy is not None
assert mocked_rpc.call_args_list == [call({'SUPERVISOR_SERVER_URL': 'http://10.0.0.1:25000',
assert mocked_rpc.call_args_list == [call({'SUPERVISOR_SERVER_URL': 'http://10.0.0.2:25000',
'SUPERVISOR_USERNAME': 'user',
'SUPERVISOR_PASSWORD': 'p@$$w0rd'})]


def test_proxy_proxy(supvisors_instance, proxy):
""" Test the SupvisorsProxy proxy property. """
# test with non-local proxy
assert proxy.status.supvisors_id.identifier != proxy.local_identifier
ref_proxy = proxy._proxy
ref_usage = proxy.last_used
mocked_rpc.reset_mock()
Expand Down Expand Up @@ -565,20 +553,20 @@ def test_proxy_run(mocker, supvisors_instance, proxy_thread):
proxy_thread.stop()
proxy_thread.join()
assert not proxy_thread.is_alive()
assert mocked_close.call_args_list == [call('10.0.0.1:25000')]
assert mocked_close.call_args_list == [call('10.0.0.2:25000')]


def test_proxy_handle_exception(mocker, supvisors_instance, proxy_thread):
""" Test the SupvisorsProxy thread run / stop with an exception on the local proxy. """
mocked_push = mocker.patch.object(supvisors_instance.rpc_handler.proxy_server, 'push_notification')
# test with non-local and non-active state
supvisors_instance.context.instances['10.0.0.1:25000']._state = SupvisorsInstanceStates.STOPPED
supvisors_instance.context.instances['10.0.0.2:25000']._state = SupvisorsInstanceStates.STOPPED
proxy_thread.handle_exception()
assert not mocked_push.called
# test with non-local and active state
supvisors_instance.context.instances['10.0.0.1:25000']._state = SupvisorsInstanceStates.RUNNING
supvisors_instance.context.instances['10.0.0.2:25000']._state = SupvisorsInstanceStates.RUNNING
proxy_thread.handle_exception()
assert mocked_push.call_args_list == [call((('10.0.0.1:25000', '10.0.0.1', ('10.0.0.1', 25000)),
assert mocked_push.call_args_list == [call((('10.0.0.2:25000', '10.0.0.2', ('10.0.0.2', 25000)),
(NotificationHeaders.INSTANCE_FAILURE.value, None)))]
mocked_push.reset_mock()
# test with local
Expand Down

0 comments on commit c8ab97d

Please sign in to comment.