[Zodb-checkins] CVS: ZODB3/ZEO/tests - testMonitor.py:1.3
Jeremy Hylton
jeremy@zope.com
Wed, 15 Jan 2003 16:23:20 -0500
Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv19784/ZEO/tests
Modified Files:
testMonitor.py
Log Message:
Extend the monitor test suite to actually parse the monitor output.
=== ZODB3/ZEO/tests/testMonitor.py 1.2 => 1.3 ===
--- ZODB3/ZEO/tests/testMonitor.py:1.2 Mon Jan 13 16:43:24 2003
+++ ZODB3/ZEO/tests/testMonitor.py Wed Jan 15 16:23:17 2003
@@ -21,6 +21,7 @@
import unittest
from ZEO.tests.ConnectionTests import CommonSetupTearDown
+from ZEO.monitor import StorageStats
class MonitorTests(CommonSetupTearDown):
@@ -39,6 +40,37 @@
s.close()
return "".join(L)
+ def parse(self, s):
+ # Return a list of StorageStats, one for each storage.
+ lines = s.split("\n")
+ self.assert_(lines[0].startswith("ZEO monitor server"))
+ # lines[1] is a date
+
+ # Break up rest of lines into sections starting with Storage:
+ # and ending with a blank line.
+ sections = []
+ cur = None
+ for line in lines[2:]:
+ if line.startswith("Storage:"):
+ cur = [line]
+ elif line:
+ cur.append(line)
+ else:
+ if cur is not None:
+ sections.append(cur)
+ cur = None
+ assert cur is None # bug in the test code if this fails
+
+ d = {}
+ for sect in sections:
+ hdr = sect[0]
+ key, value = hdr.split(":")
+ storage = int(value)
+ s = d[storage] = StorageStats()
+ s.parse("\n".join(sect[1:]))
+
+ return d
+
def getConfig(self, path, create, read_only):
return """\
<Storage>
@@ -53,7 +85,10 @@
s = self.get_monitor_output()
self.storage.close()
self.assert_(s.find("monitor") != -1)
-
+ d = self.parse(s)
+ stats = d[1]
+ self.assertEqual(stats.clients, 1)
+ self.assertEqual(stats.commits, 0)
def test_suite():
return unittest.makeSuite(MonitorTests)