def _validate_with_port(self, address, host, port):
        primaries, secondaries = AddressHelper.get_possible_addresses(address)
        self.assertEqual(1, len(primaries))
        self.assertEqual(0, len(secondaries))

        address = primaries[0]
        self.assertEqual(host, address.host)
        self.assertEqual(port, address.port)
    def _validate_without_port(self, address, host):
        primaries, secondaries = AddressHelper.get_possible_addresses(address)
        self.assertEqual(1, len(primaries))
        self.assertEqual(self.default_port_count - 1, len(secondaries))

        for i in range(self.default_port_count):
            if i == 0:
                address = primaries[i]
            else:
                address = secondaries[i - 1]
            self.assertEqual(host, address.host)
            self.assertEqual(self.default_port + i, address.port)
Ejemplo n.º 3
0
    def load_addresses(self):
        """Returns the possible primary and secondary member addresses to connect to."""
        configured_addresses = self._addresses

        if not configured_addresses:
            configured_addresses = ["127.0.0.1"]

        primaries = []
        secondaries = []
        for address in configured_addresses:
            p, s = AddressHelper.get_possible_addresses(address)
            primaries.extend(p)
            secondaries.extend(s)

        return primaries, secondaries