Exemple #1
0
 def test_process_doesnt_proxy_update_config_when_nothing_to_process(self):
     service = RegionControllerService(sentinel.listener)
     service.needsProxyUpdate = False
     mock_proxy_update_config = self.patch(region_controller,
                                           "proxy_update_config")
     service.startProcessing()
     yield service.processingDefer
     self.assertThat(mock_proxy_update_config, MockNotCalled())
Exemple #2
0
 def test_process_updates_proxy_logs_failure(self):
     service = RegionControllerService(sentinel.listener)
     service.needsProxyUpdate = True
     mock_proxy_update_config = self.patch(region_controller,
                                           "proxy_update_config")
     mock_proxy_update_config.return_value = fail(factory.make_exception())
     mock_err = self.patch(region_controller.log, "err")
     service.startProcessing()
     yield service.processingDefer
     self.assertThat(mock_proxy_update_config,
                     MockCalledOnceWith(reload_proxy=True))
     self.assertThat(mock_err,
                     MockCalledOnceWith(ANY, "Failed configuring proxy."))
Exemple #3
0
 def test_process_updates_proxy(self):
     service = RegionControllerService(sentinel.listener)
     service.needsProxyUpdate = True
     mock_proxy_update_config = self.patch(region_controller,
                                           "proxy_update_config")
     mock_proxy_update_config.return_value = succeed(None)
     mock_msg = self.patch(region_controller.log, "msg")
     service.startProcessing()
     yield service.processingDefer
     self.assertThat(mock_proxy_update_config,
                     MockCalledOnceWith(reload_proxy=True))
     self.assertThat(mock_msg,
                     MockCalledOnceWith("Successfully configured proxy."))
Exemple #4
0
 def test_process_updates_bind_and_proxy(self):
     service = RegionControllerService(sentinel.listener)
     service.needsDNSUpdate = True
     service.needsProxyUpdate = True
     mock_dns_update_all_zones = self.patch(
         region_controller, "dns_update_all_zones")
     mock_proxy_update_config = self.patch(
         region_controller, "proxy_update_config")
     mock_proxy_update_config.return_value = succeed(None)
     service.startProcessing()
     yield service.processingDefer
     self.assertThat(
         mock_dns_update_all_zones, MockCalledOnceWith())
     self.assertThat(
         mock_proxy_update_config, MockCalledOnceWith(reload_proxy=True))
Exemple #5
0
 def test_process_updates_bind_and_proxy(self):
     service = RegionControllerService(sentinel.listener)
     service.needsDNSUpdate = True
     service.needsProxyUpdate = True
     dns_result = (random.randint(1, 1000),
                   [factory.make_name('domain') for _ in range(3)])
     mock_dns_update_all_zones = self.patch(region_controller,
                                            "dns_update_all_zones")
     mock_dns_update_all_zones.return_value = dns_result
     mock_check_serial = self.patch(service, "_checkSerial")
     mock_check_serial.return_value = succeed(dns_result)
     mock_proxy_update_config = self.patch(region_controller,
                                           "proxy_update_config")
     mock_proxy_update_config.return_value = succeed(None)
     service.startProcessing()
     yield service.processingDefer
     self.assertThat(mock_dns_update_all_zones, MockCalledOnceWith())
     self.assertThat(mock_check_serial, MockCalledOnceWith(dns_result))
     self.assertThat(mock_proxy_update_config,
                     MockCalledOnceWith(reload_proxy=True))