def _non_registered_slaves(self, registered_slaves, slaves_to_validate): """ Return list of slave hosts that have failed to register with the master service. :param slaves_to_validate: list of slave hostnames to check for :type slaves_to_validate: list[str] :return: list of slave hostnames that haven't registered with the master service yet :rtype: list[str] """ registered_host_ids = [ Network.get_host_id(slave) for slave in registered_slaves ] slaves_to_validate_host_id_pairs = { Network.get_host_id(slave): slave for slave in slaves_to_validate } non_registered_slave_hosts = [ slaves_to_validate_host_id_pairs[host_id] for host_id in slaves_to_validate_host_id_pairs if host_id not in registered_host_ids ] return non_registered_slave_hosts
def test_get_host_id_of_localhost(self): # todo: this is an integration test -- move it to integration dir local_host_name = socket.gethostname() self.assertEqual( Network.get_host_id('localhost'), Network.get_host_id(local_host_name), 'Host id of "localhost" is not the same as host id of "{}"'.format(local_host_name), )
def test_get_host_id_of_localhost(self): local_host_name = socket.gethostname() self.assertEqual( Network.get_host_id('localhost'), Network.get_host_id(local_host_name), 'Host id of "localhost" is not the same as host id of "{}"'.format(local_host_name), )
def all_slaves_registered(): registered_slave_uids = set( [Network.get_host_id(x) for x in self._registered_slave_hostnames(slave_api_url, network)] ) slaves_to_validate_uids = set( [Network.get_host_id(x) for x in slaves_to_validate] ) return registered_slave_uids == slaves_to_validate_uids
def test_get_host_id_of_localhost(self): local_host_name = socket.gethostname() self.assertEqual( Network.get_host_id('localhost'), Network.get_host_id(local_host_name), 'Host id of "localhost" is not the same as host id of "{}"'.format( local_host_name), )
def test_get_host_id_of_localhost( self ): # todo: this is an integration test -- move it to integration dir local_host_name = socket.gethostname() self.assertEqual( Network.get_host_id('localhost'), Network.get_host_id(local_host_name), 'Host id of "localhost" is not the same as host id of "{}"'.format( local_host_name), )
def _non_registered_slaves(self, registered_slaves, slaves_to_validate): """ Return list of slave hosts that have failed to register with the master service. :param slaves_to_validate: list of slave hostnames to check for :type slaves_to_validate: list[str] :return: list of slave hostnames that haven't registered with the master service yet :rtype: list[str] """ registered_host_ids = [Network.get_host_id(slave) for slave in registered_slaves] slaves_to_validate_host_id_pairs = { Network.get_host_id(slave): slave for slave in slaves_to_validate } non_registered_slave_hosts = [ slaves_to_validate_host_id_pairs[host_id] for host_id in slaves_to_validate_host_id_pairs if host_id not in registered_host_ids ] return non_registered_slave_hosts
def test_get_host_id_returns_ip_of_the_host(self): self._patch_socket_gethostbyname(side_effect=[self._ip]) self.assertEqual(Network.get_host_id(self._hostname), self._ip) self._mock_get_host_by_name.assert_called_once_with(self._hostname)
def test_get_host_id_returns_none_if_gaierror(self): self._patch_socket_gethostbyname(side_effect=socket.gaierror) self.assertIsNone(Network.get_host_id(self._hostname)) self._mock_get_host_by_name.assert_called_once_with(self._hostname)
def test_get_host_id_returns_ip_of_the_host(self): self._patch_socket_gethostbyname(side_effect=[self._ip]) self.assertEqual(Network.get_host_id(self._hostname), self._ip) self._mock_get_host_by_name.assert_called_once_with(self._hostname)
def test_get_host_id_returns_none_if_gaierror(self): self._patch_socket_gethostbyname(side_effect=socket.gaierror) self.assertIsNone(Network.get_host_id(self._hostname)) self._mock_get_host_by_name.assert_called_once_with(self._hostname)