[Zodb-checkins] CVS: Zope/lib/python/zdaemon/tests - testzdrun.py:1.5.16.4

Fred Drake cvs-admin at zope.org
Fri Oct 24 17:33:08 EDT 2003


Update of /cvs-repository/Zope/lib/python/zdaemon/tests
In directory cvs.zope.org:/tmp/cvs-serv22928/lib/python/zdaemon/tests

Modified Files:
      Tag: Zope-2_7-branch
	testzdrun.py 
Log Message:
Change the ZEO control process and configuration schema so that a single
configuration file can be used for both the runzeo and zeoctl scripts.
This makes it easier to keep all the configuration needed to support the
ZEO server process in a single file.
For more explanation of the changes, see
http://zope.org/Members/fdrake/WikiBlog/ZEOServerConfiguration


=== Zope/lib/python/zdaemon/tests/testzdrun.py 1.5.16.3 => 1.5.16.4 ===
--- Zope/lib/python/zdaemon/tests/testzdrun.py:1.5.16.3	Fri Sep 19 17:03:08 2003
+++ Zope/lib/python/zdaemon/tests/testzdrun.py	Fri Oct 24 17:33:03 2003
@@ -7,9 +7,38 @@
 import tempfile
 import unittest
 import socket
+
 from StringIO import StringIO
+
+import ZConfig
+
 from zdaemon import zdrun, zdctl
 
+
+class ConfiguredOptions:
+    """Options class that loads configuration from a specified string.
+
+    This always loads from the string, regardless of any -C option
+    that may be given.
+    """
+
+    def set_configuration(self, configuration):
+        self.__configuration = configuration
+        self.configfile = "<preloaded string>"
+
+    def load_configfile(self):
+        sio = StringIO(self.__configuration)
+        cfg = ZConfig.loadConfigFile(self.schema, sio, self.zconfig_options)
+        self.configroot, self.confighandlers = cfg
+
+
+class ConfiguredZDRunOptions(ConfiguredOptions, zdrun.ZDRunOptions):
+
+    def __init__(self, configuration):
+        zdrun.ZDRunOptions.__init__(self)
+        self.set_configuration(configuration)
+
+
 class ZDaemonTests(unittest.TestCase):
 
     python = os.path.abspath(sys.executable)
@@ -145,6 +174,37 @@
         self.assertEqual(os.WTERMSIG(wsts), signal.SIGTERM)
         proc.setstatus(wsts)
         self.assertEqual(proc.pid, 0)
+
+    def testEventlogOverride(self):
+        # Make sure runner.eventlog is used if it exists
+        options = ConfiguredZDRunOptions("""\
+            <runner>
+              program /bin/true
+              <eventlog>
+                level 42
+              </eventlog>
+            </runner>
+
+            <eventlog>
+              level 35
+            </eventlog>
+            """)
+        options.realize(["/bin/true"])
+        self.assertEqual(options.config_logger.level, 42)
+
+    def testEventlogWithoutOverride(self):
+        # Make sure eventlog is used if runner.eventlog doesn't exist
+        options = ConfiguredZDRunOptions("""\
+            <runner>
+              program /bin/true
+            </runner>
+
+            <eventlog>
+              level 35
+            </eventlog>
+            """)
+        options.realize(["/bin/true"])
+        self.assertEqual(options.config_logger.level, 35)
 
     def testRunIgnoresParentSignals(self):
         # Spawn a process which will in turn spawn a zdrun process.




More information about the Zodb-checkins mailing list