def test(self, init, zone_resolver, dns_server, udp_server, tcp_server, dns_logger, zookeeper): # Setup server = SCIONDnsServer("srvid", "conf_dir") server.lock = "lock" server.domain = "domain" server.addr = create_mock(["host"]) server.addr.host = "127.0.0.1" server.id = "srvid" server.topology = create_mock(["isd_as", "zookeepers"]) server.topology.isd_as = "isd as" server.topology.zookeepers = ["zk0", "zk1"] server._setup_parties = create_mock() # Call server.setup() # Tests zone_resolver.assert_called_once_with("lock", "domain") dns_server.assert_any_call(zone_resolver.return_value, port=SCION_DNS_PORT, address="127.0.0.1", server=udp_server, logger=dns_logger.return_value) dns_server.assert_any_call(zone_resolver.return_value, port=SCION_DNS_PORT, address="127.0.0.1", server=tcp_server, logger=dns_logger.return_value) ntools.eq_(dns_server.call_count, 2) zookeeper.assert_called_once_with( "isd as", DNS_SERVICE, "srvid\0%d\000127.0.0.1" % SCION_DNS_PORT, ["zk0", "zk1"]) ntools.eq_(server._parties, {}) server._setup_parties.assert_called_once_with()
def test_success(self, init): # Setup services = { BEACON_SERVICE: ["bs1", "bs2", "bs3"], CERTIFICATE_SERVICE: ["cs1"], DNS_SERVICE: ["ds1", "ds2"], PATH_SERVICE: [], SIBRA_SERVICE: ["sb1"], } server = SCIONDnsServer("srvid", "conf_dir") server.zk = create_mock(['wait_connected']) server.domain = self.DOMAIN server._parties = {} for i in SCIONDnsServer.SRV_TYPES: party = create_mock(["list"]) party.list.return_value = services[i] server._parties[i] = party server._parse_srv_inst = create_mock() server.lock = create_mock(['__enter__', '__exit__']) server.resolver = create_mock(["services"]) domain_set = set( [self.DOMAIN.add(srv) for srv in SCIONDnsServer.SRV_TYPES]) # Call server._sync_zk_state() # Tests server.zk.wait_connected.assert_called_once_with(timeout=10.0) ntools.eq_(domain_set, set(server.services)) for type_, insts in services.items(): for inst in insts: server._parse_srv_inst.assert_any_call(inst, self.DOMAIN.add(type_)) ntools.ok_(server.lock.mock_calls) ntools.eq_(server.resolver.services, server.services)