[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Improve logging, speed up tests, bulletproof queues.
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv15090/lib/mixminion
Modified Files:
Common.py benchmark.py test.py
Log Message:
Improve logging, speed up tests, bulletproof queues.
Also add a better linecounter (that's been sitting in my ~/bin for a
long time).
Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- Common.py 23 May 2003 22:49:30 -0000 1.77
+++ Common.py 26 May 2003 20:04:16 -0000 1.78
@@ -23,6 +23,7 @@
import cPickle
import errno
import fcntl
+import grp
import gzip
import os
import re
@@ -352,8 +353,9 @@
if (mode & 020) and not (mode & stat.S_ISVTX):
# FFFF We may want to give an even stronger error here.
if not _WARNED_DIRECTORIES.has_key(d):
- LOG.warn("Iffy mode %o on directory %s (Writable by gid %s)",
- mode, d, st[stat.ST_GID])
+ group = grp.getgrgid(st[stat.ST_GID])[0]
+ LOG.warn("Directory %s is writable by group %s (mode %o)",
+ d, group, mode&0777)
_WARNED_DIRECTORIES[d] = 1
#----------------------------------------------------------------------
Index: benchmark.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/benchmark.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- benchmark.py 17 May 2003 00:08:43 -0000 1.34
+++ benchmark.py 26 May 2003 20:04:19 -0000 1.35
@@ -903,6 +903,10 @@
#----------------------------------------------------------------------
def timeAll(name, args):
+ if 1:
+ serverQueueTiming()
+ return
+
cryptoTiming()
rsaTiming()
buildMessageTiming()
Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- test.py 25 May 2003 23:11:43 -0000 1.107
+++ test.py 26 May 2003 20:04:22 -0000 1.108
@@ -2393,6 +2393,10 @@
self.d2 = mix_mktemp("q2")
self.d3 = mix_mktemp("q3")
+ def unlink(self, fns):
+ for f in fns:
+ os.unlink(f)
+
def testCreateQueue(self):
# Nonexistent dir.
self.failUnlessRaises(MixFatalError, Queue, self.d1)
@@ -2422,7 +2426,7 @@
queue.removeMessage(h2)
self.assertEquals(1, queue.count())
- queue.removeAll()
+ queue.removeAll(self.unlink)
def testQueueOps(self):
queue1 = Queue(self.d2, create=1)
@@ -2513,10 +2517,10 @@
self.assertEquals(obj, cPickle.loads(queue1.messageContents(h1)))
# Scrub both queues.
- queue1.removeAll()
- queue2.removeAll()
- queue1.cleanQueue()
- queue2.cleanQueue()
+ queue1.removeAll(self.unlink)
+ queue2.removeAll(self.unlink)
+ queue1.cleanQueue(self.unlink)
+ queue2.cleanQueue(self.unlink)
def testDeliveryQueues(self):
d_d = mix_mktemp("qd")
@@ -2559,7 +2563,7 @@
queue.deliveryFailed(h3, retriable=0, now=now+4)
allHandles = queue.getAllMessages()
h4 = allHandles[0]
- queue.cleanQueue()
+ queue.cleanQueue(self.unlink)
files = os.listdir(d_d)
files.sort()
self.assertEquals(files, ["meta_"+h4, "msg_"+h4])
@@ -2604,8 +2608,8 @@
# Now Message 2 is timed out.
self.assertEquals([], queue.getAllMessages())
- queue.removeAll()
- queue.cleanQueue()
+ queue.removeAll(self.unlink)
+ queue.cleanQueue(self.unlink)
# Make sure old-style messages get nuked.
writePickled(os.path.join(d_d, "msg_ABCDEFGH"),
@@ -2662,6 +2666,7 @@
for x in xrange(10):
self.assertEquals(30, len(cmq.getBatch()))
+
# Binomial Cottrell pool
bcmq = BinomialCottrellMixPool(d_m, 600, 6, sendRate=.3)
# (Just make sure that we don't always return the same number of
@@ -2676,8 +2681,8 @@
self.assert_(messageLens[0] <= 30)
self.assert_(messageLens[-1] >= 30)
- bcmq.removeAll()
- bcmq.cleanQueue()
+ bcmq.removeAll(self.unlink)
+ bcmq.cleanQueue(self.unlink)
#---------------------------------------------------------------------
# LOGGING
@@ -3321,6 +3326,7 @@
class ConfigFileTests(unittest.TestCase):
def testValidFiles(self):
+
TCF = TestConfigFile
# Try a minimal file.
shorterString = """[Sec1]\nFoo a\n"""
@@ -4765,7 +4771,7 @@
queue.sendReadyMessages()
finally:
m = resumeLog()
- self.assert_(m.endswith("[ERROR] Unable to deliver message\n"))
+ self.assert_(stringContains(m,"[ERROR] Unable to deliver message"))
# After delivery: 91 and 92 go through, 93 stays, and 94 gets dropped.
self.assertEquals(1, queue.count())
self.assertEquals(5, len(os.listdir(dir)))
@@ -5720,7 +5726,7 @@
tc = loader.loadTestsFromTestCase
if 0:
- suite.addTest(tc(ClientMainTests))
+ suite.addTest(tc(QueueTests))
return suite
suite.addTest(tc(MiscTests))