Exemple #1
0
 def setUp(self):
     super().setUp()
     # Ensure there's an initial DNS publication. Outside of tests this is
     # guaranteed by a migration.
     DNSPublication(source="Initial").save()
     # Allow test-local changes to configuration.
     self.useFixture(RegionConfigurationFixture())
     # Immediately make DNS changes as they're needed.
     self.patch(dns_config_module, "DNS_DEFER_UPDATES", False)
     # Create a DNS server.
     self.bind = self.useFixture(BINDServer())
     # Use the dnspython resolver for at least some queries.
     self.resolver = dns.resolver.Resolver()
     self.resolver.nameservers = ["127.0.0.1"]
     self.resolver.port = self.bind.config.port
     patch_dns_config_path(self, self.bind.config.homedir)
     # Use a random port for rndc.
     patch_dns_rndc_port(self, allocate_ports("localhost")[0])
     # This simulates what should happen when the package is
     # installed:
     # Create MAAS-specific DNS configuration files.
     parser = ArgumentParser()
     setup_dns.add_arguments(parser)
     setup_dns.run(parser.parse_args([]))
     # Register MAAS-specific DNS configuration files with the
     # system's BIND instance.
     parser = ArgumentParser()
     get_named_conf.add_arguments(parser)
     get_named_conf.run(
         parser.parse_args(
             ["--edit", "--config-path", self.bind.config.conf_file]))
     # Reload BIND.
     self.bind.runner.rndc("reload")
Exemple #2
0
 def test_start_check_shutdown(self):
     # The fixture correctly starts and stops BIND.
     with BINDServer() as fixture:
         try:
             result = dig_call(fixture.config.port)
             self.assertIn("Got answer", result)
         except Exception:
             # self.useFixture() is not being used because we want to
             # handle the fixture's lifecycle, so we must also be
             # responsible for propagating fixture details.
             gather_details(fixture.getDetails(), self.getDetails())
             raise
     self.assertFalse(fixture.runner.is_running())
Exemple #3
0
 def test_config(self):
     # The configuration can be passed in.
     config = BINDServerResources()
     fixture = self.useFixture(BINDServer(config))
     self.assertIs(config, fixture.config)