Parcourir la source

[trac565] Nothing started by config before startup

Michal 'vorner' Vaner il y a 14 ans
Parent
commit
5266058997
2 fichiers modifiés avec 21 ajouts et 0 suppressions
  1. 3 0
      src/bin/bind10/bind10.py.in
  2. 18 0
      src/bin/bind10/tests/bind10_test.py

+ 3 - 0
src/bin/bind10/bind10.py.in

@@ -228,6 +228,9 @@ class BoB:
         self.verbose = verbose
 
     def config_handler(self, new_config):
+        # This is initial update, don't do anything by it, leave it to startup
+        if not self.runnable:
+            return
         if self.verbose:
             sys.stdout.write("[bind10] Handling new configuration: " +
                 str(new_config) + "\n")

+ 18 - 0
src/bin/bind10/tests/bind10_test.py

@@ -381,6 +381,7 @@ class TestStartStopProcessesBob(unittest.TestCase):
         bob.cfg_start_resolver = False
 
         bob.start_all_processes()
+        bob.runnable = True
         self.check_started_none(bob)
 
         # Enable both at once
@@ -444,6 +445,7 @@ class TestStartStopProcessesBob(unittest.TestCase):
         bob.cfg_start_resolver = True
 
         bob.start_all_processes()
+        bob.runnable = True
         self.check_started_both(bob)
 
         bob.start_auth = lambda: self.fail("Started auth again")
@@ -456,5 +458,21 @@ class TestStartStopProcessesBob(unittest.TestCase):
         bob.config_handler({'start_auth': True})
         bob.config_handler({'start_resolver': True})
 
+    def test_config_not_started_early(self):
+        """
+        Test that processes are not started by the config handler before
+        startup.
+        """
+        bob = StartAllProcessesBob()
+        self.check_preconditions(bob)
+
+        bob.start_auth = lambda: self.fail("Started auth again")
+        bob.start_xfrout = lambda: self.fail("Started xfrout again")
+        bob.start_xfrin = lambda: self.fail("Started xfrin again")
+        bob.start_zonemgr = lambda: self.fail("Started zonemgr again")
+        bob.start_resolver = lambda: self.fail("Started resolver again")
+
+        bob.config_handler({'start_auth': True, 'start_resolver': True})
+
 if __name__ == '__main__':
     unittest.main()