BIND 10 trac213, updated. e81b86767a740bcb1c4d1a0408ad9a70690df0a6 [213] Skeleton for configurator tests
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Oct 5 14:58:16 UTC 2011
The branch, trac213 has been updated
via e81b86767a740bcb1c4d1a0408ad9a70690df0a6 (commit)
via 5222b98f4e2021eb543f836d5e6876eb28eab716 (commit)
via 0d1e50106720fd7c4ec58e88e381ce7cff071648 (commit)
via 8d139f70ee129787af631531e4ea825293007a58 (commit)
from 26841bf1f0c0f0066e17b53bea2261e759bfbdbe (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e81b86767a740bcb1c4d1a0408ad9a70690df0a6
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Oct 5 16:57:15 2011 +0200
[213] Skeleton for configurator tests
A testing component and a logging mechanism.
commit 5222b98f4e2021eb543f836d5e6876eb28eab716
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Oct 5 16:43:27 2011 +0200
[213] Fix teardown
It was in a wrong function
commit 0d1e50106720fd7c4ec58e88e381ce7cff071648
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Oct 5 16:34:33 2011 +0200
[213] Special evaluated component dict
commit 8d139f70ee129787af631531e4ea825293007a58
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Oct 5 16:32:32 2011 +0200
[213] Interface of the component configurator
-----------------------------------------------------------------------
Summary of changes:
src/lib/python/isc/bind10/component.py | 41 +++++++++++
src/lib/python/isc/bind10/tests/component_test.py | 74 +++++++++++++++++++-
2 files changed, 111 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/bind10/component.py b/src/lib/python/isc/bind10/component.py
index 6bef31b..37d948f 100644
--- a/src/lib/python/isc/bind10/component.py
+++ b/src/lib/python/isc/bind10/component.py
@@ -151,3 +151,44 @@ class Component:
time in between actual failure and the call.
"""
return self.__running
+
+specials = {}
+"""
+List of specially started components. Each one should be the class than can
+be created for that component.
+"""
+
+class Configurator:
+ """
+ This thing keeps track of configuration changes and starts and stops
+ components as it goes. It also handles the inital startup and final
+ shutdown.
+ """
+ def __init__(self, boss):
+ """
+ Initializes the configurator, but nothing is started yet.
+
+ The boss parameter is the boss object used to start and stop processes.
+ """
+ pass
+
+ def startup(self, configuration):
+ """
+ Starts the first set of processes. This configuration is expected
+ to be hardcoded from the boss itself to start the configuration
+ manager and other similar things.
+ """
+ pass
+
+ def shutdown(self):
+ """
+ Shuts everything down.
+ """
+ pass
+
+ def reconfigure(configuration):
+ """
+ Changes configuration from the current one to the provided. It
+ starts and stops all the components as needed.
+ """
+ pass
diff --git a/src/lib/python/isc/bind10/tests/component_test.py b/src/lib/python/isc/bind10/tests/component_test.py
index 33263b3..ee93c67 100644
--- a/src/lib/python/isc/bind10/tests/component_test.py
+++ b/src/lib/python/isc/bind10/tests/component_test.py
@@ -20,7 +20,7 @@ Tests for the bind10.component module
import unittest
import isc.log
import time
-from isc.bind10.component import Component
+from isc.bind10.component import Component, Configurator, specials
class TestError(Exception):
"""
@@ -34,7 +34,7 @@ class ComponentTests(unittest.TestCase):
"""
def setUp(self):
"""
- Pretend a newly started system
+ Pretend a newly started system.
"""
self.__shutdown = False
self.__exitcode = None
@@ -44,14 +44,19 @@ class ComponentTests(unittest.TestCase):
# Back up the time function, we may want to replace it with something
self.__orig_time = isc.bind10.component.time.time
+ def tearDown(self):
+ """
+ Clean up after tests.
+ """
+ # Return the original time function
+ isc.bind10.component.time.time = self.__orig_time
+
def shutdown(self, exitcode=0):
"""
Mock function to shut down. We just note we were asked to do so.
"""
self.__shutdown = True
self.__exitcode = None
- # Return the original time function
- isc.bind10.component.time.time = self.__orig_time
def __timeskip(self):
"""
@@ -348,6 +353,67 @@ class ComponentTests(unittest.TestCase):
for kind in ['Core', 'CORE', 'nonsense', 'need ed', 'required']:
self.assertRaises(ValueError, Component, 'No process', self, kind)
+class TestComponent(Component):
+ """
+ A test component. It does not start any processes or so, it just logs
+ information about what happens.
+ """
+ def __init__(self, owner, name, kind):
+ """
+ Initializes the component. The owner is the test that started the
+ component. The logging will happen into it.
+
+ The process is used as a name for the logging.
+ """
+ Component.__init__(self, name, owner, kind)
+ self.__owner = owner
+ self.__name = name
+ self.log('init')
+
+ def log(self, event):
+ """
+ Log an event into the owner. The owner can then check the correct
+ order of events that happened.
+ """
+ self.__owner.log.append((self.__name, event))
+
+ def start_internal(self):
+ self.log('start')
+
+ def stop_internal(self):
+ self.log('stop')
+
+ def failed_internal(self):
+ self.log('failed')
+
+class ConfiguratorTest(unittest.TestCase):
+ """
+ Tests for the configurator.
+ """
+ def setUp(self):
+ """
+ Insert the special evaluated test components we use and prepare the
+ log.
+ """
+ # We put our functions inside instead of class constructors,
+ # so we can look into what is happening more easily
+ self.__orig_specials = copy(specials)
+ specials['test'] = self.__component_test
+ log = []
+
+ def tearDown(self):
+ """
+ Clean up the special evaluated test components.
+ """
+ specials = self.__orig_specials
+
+ def __component_test(self, process, boss, kind):
+ """
+ Create a test component. It will log events to us.
+ """
+ self.assertEqual(self, boss)
+ return TestComponent(self, process, kind)
+
if __name__ == '__main__':
isc.log.init("bind10") # FIXME Should this be needed?
isc.log.resetUnitTestRootLogger()
More information about the bind10-changes
mailing list