[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Rewrite pinger to use pysqlite instead of having to kee...



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv1928/lib/mixminion

Modified Files:
	test.py 
Log Message:
Rewrite pinger to use pysqlite instead of having to keep everything in memory or rescan disk over and over. eventually, we can move to supporting multiple DBs

Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -d -r1.203 -r1.204
--- test.py	24 Aug 2004 22:16:08 -0000	1.203
+++ test.py	2 Dec 2004 06:47:06 -0000	1.204
@@ -64,6 +64,7 @@
 import mixminion._minionlib as _ml
 import mixminion.server.MMTPServer
 import mixminion.server.Modules
+import mixminion.server.Pinger
 import mixminion.server.ServerConfig
 import mixminion.server.ServerKeys
 import mixminion.server.ServerMain
@@ -7725,6 +7726,39 @@
 
 #----------------------------------------------------------------------
 
+class PingerTests(TestCase):
+    def testPinglogMemory(self):
+        #XXXX We need way better tests here. 'now' needs to be an arg to
+        #all the new log functions.
+        P = mixminion.server.Pinger
+        if not P.canRunPinger():
+            print "[Skipping ping tests; old python or missing pysqlite]",
+
+        d = mix_mktemp()
+        os.mkdir(d)
+        loc = os.path.join(d, "db")
+        log = P.openPingLog(loc)
+        log.startup()
+        log.heartbeat()
+        log.heartbeat()
+        log.heartbeat()
+        log.connected("Foobar")
+        log.connectFailed("Foobarbaz")
+        log.queuedPing("BZ"*10, "Foobar")
+        log.queuedPing("BN"*10, "Foobarbazzy")
+        log.gotPing("BZ"*10)
+        log.gotPing("BN"*10)
+        log.gotPing("BL"*10) #Never sent.
+        log.shutdown()
+        log.rotate()
+        log.calculateUptimes(time.time()-1000, time.time())
+        #log.calculateDailyResults( ) #XXXX TEST
+        log.close()
+        log = P.openPingLog(loc)
+        log.close()
+
+#----------------------------------------------------------------------
+
 def initializeGlobals():
     init_crypto()
 
@@ -7758,8 +7792,7 @@
     tc = loader.loadTestsFromTestCase
 
     if 0:
-        suite.addTest(tc(ServerKeysTests))
-        suite.addTest(tc(ServerInfoTests))
+        suite.addTest(tc(PingerTests))
         return suite
     testClasses = [MiscTests,
                    MinionlibCryptoTests,
@@ -7785,6 +7818,7 @@
                    ClientMainTests,
                    ServerKeysTests,
                    ServerMainTests,
+                   PingerTests,
 
                    # These tests are slowest, so we do them last.
                    ModuleManagerTests,