[Checkins] SVN: zc.z3monitor/trunk/src/zc/z3monitor/ fixing sudden test failures:
Adam Groszer
agroszer at gmail.com
Sun Jan 17 10:44:35 EST 2010
Log message for revision 108196:
fixing sudden test failures:
- reconnection: seems to be default behavour of zc.ngi to disconnect after input, wondering why tests passed before
- "#doctest: +NORMALIZE_WHITESPACE": ummmm, there is a stale space at the end of the output lines, maybe this is because of the switch to python doctest?
Changed:
U zc.z3monitor/trunk/src/zc/z3monitor/README.txt
U zc.z3monitor/trunk/src/zc/z3monitor/__init__.py
-=-
Modified: zc.z3monitor/trunk/src/zc/z3monitor/README.txt
===================================================================
--- zc.z3monitor/trunk/src/zc/z3monitor/README.txt 2010-01-17 15:29:53 UTC (rev 108195)
+++ zc.z3monitor/trunk/src/zc/z3monitor/README.txt 2010-01-17 15:44:35 UTC (rev 108196)
@@ -13,7 +13,7 @@
Please see the zc.monitor documentation for details on how the server works.
This package also supports starting a monitor using ZConfig, and provides a
-default configure.zcml for registering plugins.
+default configure.zcml for registering plugins.
The ZConfig setup is not demonstrated in this documentation, but the usage is
simple. In your ZConfig file, provide a "product-config" stanza for
@@ -97,6 +97,9 @@
To get information about the process overall, use the monitor
command:
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
>>> connection.test_input('help monitor\n')
Help for monitor:
<BLANKLINE>
@@ -119,16 +122,22 @@
<BLANKLINE>
-> CLOSE
- >>> connection.test_input('monitor\n')
- 0
- VmSize: 35284 kB
- VmRSS: 28764 kB
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('monitor\n') #doctest: +NORMALIZE_WHITESPACE
+ 0
+ VmSize: 35284 kB
+ VmRSS: 28764 kB
-> CLOSE
- >>> connection.test_input('monitor 100 other\n')
- 0
- VmSize: 35284 kB
- VmRSS: 28764 kB
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('monitor 100 other\n') #doctest: +NORMALIZE_WHITESPACE
+ 0
+ VmSize: 35284 kB
+ VmRSS: 28764 kB
-> CLOSE
Note that, as of this writing, the VmSize and VmRSS lines will only be present
@@ -141,12 +150,15 @@
>>> conn1 = main.open()
>>> conn2 = main.open()
- >>> connection.test_input('monitor 0\n')
- 2
- VmSize: 36560 kB
- VmRSS: 28704 kB
- 0.0 (0)
- 0.0 (0)
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('monitor 0\n') #doctest: +NORMALIZE_WHITESPACE
+ 2
+ VmSize: 36560 kB
+ VmRSS: 28704 kB
+ 0.0 (0)
+ 0.0 (0)
-> CLOSE
The extra line of output gives connection debug info.
@@ -155,12 +167,15 @@
>>> conn1.setDebugInfo('/foo')
>>> conn2.setDebugInfo('/bar')
- >>> connection.test_input('monitor 0\n')
- 2
- VmSize: 13048 kB
- VmRSS: 10084 kB
- 0.0 /bar (0)
- 0.0 /foo (0)
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('monitor 0\n') #doctest: +NORMALIZE_WHITESPACE
+ 2
+ VmSize: 13048 kB
+ VmRSS: 10084 kB
+ 0.0 /bar (0)
+ 0.0 /foo (0)
-> CLOSE
>>> conn1.close()
@@ -171,6 +186,9 @@
To get information about a database, use the dbinfo command:
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
>>> connection.test_input('help dbinfo\n')
Help for dbinfo:
<BLANKLINE>
@@ -193,12 +211,15 @@
<BLANKLINE>
By default, the statistics are for a sampling interval of 5
minutes. You can request another sampling interval, up to an
- hour, by passing a sampling interval in seconds after the database name.
+ hour, by passing a sampling interval in seconds after the database name.
<BLANKLINE>
-> CLOSE
- >>> connection.test_input('dbinfo\n')
- 0 0 2 0 0
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('dbinfo\n') #doctest: +NORMALIZE_WHITESPACE
+ 0 0 2 0 0
-> CLOSE
Let's open a connection and do some work:
@@ -211,34 +232,49 @@
>>> transaction.commit()
>>> conn.close()
- >>> connection.test_input('dbinfo\n')
- 1 2 3 1 1
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('dbinfo\n') #doctest: +NORMALIZE_WHITESPACE
+ 1 2 3 1 1
-> CLOSE
You can specify a database name. So, to get statistics for the other
database, we'll specify the name it was registered with:
- >>> connection.test_input('dbinfo other\n')
- 0 0 0 0 0
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('dbinfo other\n') #doctest: +NORMALIZE_WHITESPACE
+ 0 0 0 0 0
-> CLOSE
You can use '-' to name the main database:
- >>> connection.test_input('dbinfo -\n')
- 1 2 3 1 1
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('dbinfo -\n') #doctest: +NORMALIZE_WHITESPACE
+ 1 2 3 1 1
-> CLOSE
You can specify a number of seconds to sample. For example, to get
data for the last 10 seconds:
- >>> connection.test_input('dbinfo - 10\n')
- 1 2 3 1 1
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('dbinfo - 10\n') #doctest: +NORMALIZE_WHITESPACE
+ 1 2 3 1 1
-> CLOSE
.. Edge case to make sure that ``deltat`` is used:
- >>> connection.test_input('dbinfo - 0\n')
- 0 0 0 1 1
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('dbinfo - 0\n') #doctest: +NORMALIZE_WHITESPACE
+ 0 0 0 1 1
-> CLOSE
ZEO Cache Statistics
@@ -246,6 +282,9 @@
You can get ZEO cache statistics using the zeocache command.
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
>>> connection.test_input('help zeocache\n')
Help for zeocache:
<BLANKLINE>
@@ -268,14 +307,20 @@
<BLANKLINE>
-> CLOSE
- >>> connection.test_input('zeocache\n')
- 42 4200 23 2300 1000
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('zeocache\n') #doctest: +NORMALIZE_WHITESPACE
+ 42 4200 23 2300 1000
-> CLOSE
You can specify a database name:
- >>> connection.test_input('zeocache other\n')
- 42 4200 23 2300 1000
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('zeocache other\n') #doctest: +NORMALIZE_WHITESPACE
+ 42 4200 23 2300 1000
-> CLOSE
ZEO Connection Status
@@ -283,6 +328,9 @@
The zeostatus command lets you get information about ZEO connection status:
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
>>> connection.test_input('help zeostatus\n')
Help for zeostatus:
<BLANKLINE>
@@ -295,12 +343,18 @@
<BLANKLINE>
-> CLOSE
- >>> connection.test_input('zeostatus\n')
- True
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('zeostatus\n') #doctest: +NORMALIZE_WHITESPACE
+ True
-> CLOSE
- >>> connection.test_input('zeostatus other\n')
- True
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('zeostatus other\n') #doctest: +NORMALIZE_WHITESPACE
+ True
-> CLOSE
In this example, we're using a faux ZEO connection. It has an
@@ -308,7 +362,10 @@
change it, then the zeocache output will change:
>>> main._storage._is_connected = False
- >>> connection.test_input('zeostatus\n')
- False
+
+ >>> connection = zc.ngi.testing.TextConnection()
+ >>> server = zc.monitor.Server(connection)
+
+ >>> connection.test_input('zeostatus\n') #doctest: +NORMALIZE_WHITESPACE
+ False
-> CLOSE
-
Modified: zc.z3monitor/trunk/src/zc/z3monitor/__init__.py
===================================================================
--- zc.z3monitor/trunk/src/zc/z3monitor/__init__.py 2010-01-17 15:29:53 UTC (rev 108195)
+++ zc.z3monitor/trunk/src/zc/z3monitor/__init__.py 2010-01-17 15:44:35 UTC (rev 108196)
@@ -102,9 +102,9 @@
By default, the statistics are for a sampling interval of 5
minutes. You can request another sampling interval, up to an
- hour, by passing a sampling interval in seconds after the database name.
+ hour, by passing a sampling interval in seconds after the database name.
"""
-
+
if database == '-':
database = ''
db = zope.component.getUtility(ZODB.interfaces.IDatabase, database)
@@ -145,7 +145,7 @@
By default, data for the main database are returned. To return
information for another database, pass the database name.
"""
-
+
db = zope.component.getUtility(ZODB.interfaces.IDatabase, database)
print >> connection, ' '.join(map(str, db._storage._cache.fc.getStats()))
@@ -157,7 +157,7 @@
By default, data for the main database are returned. To return
information for another database, pass the database name.
"""
-
+
db = zope.component.getUtility(ZODB.interfaces.IDatabase, database)
print >> connection, db._storage.is_connected()
@@ -202,4 +202,3 @@
for line in open('/proc/%s/status' % pid):
if (line.split(':')[0] in want):
yield line.strip()
-
More information about the checkins
mailing list