Exemple #1
0
 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()
Exemple #2
0
 def test(self, _):
     server = SCIONDnsServer("srvid", "conf_dir")
     server.zk = create_mock(["retry", "party_setup"])
     server.addr = create_mock(["isd_as"])
     server.addr.isd_as = "30-10"
     server._parties = {}
     # Call
     server._setup_parties()
     # Tests
     for srv in server.SRV_TYPES:
         autojoin = False
         if srv == DNS_SERVICE:
             autojoin = True
         server.zk.retry.assert_any_call("Joining %s party" % srv,
                                         server.zk.party_setup,
                                         prefix="/30-10/%s" % srv,
                                         autojoin=autojoin)
     ntools.eq_(server.zk.retry.call_count, len(server.SRV_TYPES))