Permalink
Browse files

many files tests added and passing

  • Loading branch information...
1 parent f434b5c commit 73011e23d88dfc320674e80ac9927227d29e8696 BuzzTroll committed Sep 8, 2010
Showing with 79 additions and 2 deletions.
  1. +5 −1 lantorrent/pylantorrent/daemon.py
  2. +1 −1 lantorrent/pylantorrent/server.py
  3. +73 −0 lantorrent/tests/many_files_test.py
@@ -22,8 +22,12 @@ def getrows(con):
if r == None or len(r) < 1:
return None
src_file = r[0]
+ # do a commit here. THe assumption is that jsut one daemon is pulling
+ # from the db. better to grab any that came in since the initial
+ # select
+ con.commit()
- s = "select hostname,port,src_filename,dst_filename,rid from requests where src_filename = ? and state = 0"
+ s = "select hostname,port,src_filename,dst_filename,rid from requests where src_filename = ? and state = 0 order by hostname,port"
data = (src_file, )
c.execute(s, data)
rows = c.fetchall()
@@ -179,7 +179,7 @@ def store_and_forward(self):
pylantorrent.log(logging.DEBUG, "All data sent %s" % (md5str))
# if we got to here it was successfully written to a file
# and we can call it success
- vex = LTException(0, filename, header['host'], int(header['port']), header['files'], header['id'], md5sum=md5str)
+ vex = LTException(0, "Success", header['host'], int(header['port']), header['files'], header['id'], md5sum=md5str)
j = vex.get_json()
s = json.dumps(j)
self.print_results(s)
@@ -0,0 +1,73 @@
+import string
+import random
+import os
+import sys
+import nose.tools
+import sys
+import time
+import unittest
+import tempfile
+import filecmp
+import uuid
+import traceback
+from pylantorrent.client import *
+from pylantorrent.server import *
+
+
+
+class TestManyFiels(unittest.TestCase):
+
+ def setUp(self):
+ self.src_file = "/etc/group"
+ self.src_size = os.path.getsize(self.src_file)
+ self.ports_a = os.environ['LANTORRENT_TEST_PORTS'].split(",")
+ self.files = []
+
+ def tearDown(self):
+ while len(self.files) > 0:
+ f = self.files.pop(0)
+ os.remove(f)
+
+ def _t_new_dest_file(self):
+ (osf, fname) = tempfile.mkstemp()
+ self.files.append(fname)
+ os.close(osf)
+ return fname
+
+ def _t_file_compare(self, f):
+ rc = filecmp.cmp(self.src_file, f)
+ self.assertTrue(rc)
+
+ def _t_build_list(self):
+ new_files = []
+ dests = []
+ for port in self.ports_a:
+ fnames_a = []
+ for i in range(0, 4):
+ fname = self._t_new_dest_file()
+ new_files.append(fname)
+ fnames_a.append(fname)
+
+ ent = pylantorrent.create_endpoint_entry("localhost", fnames_a, self.src_size, port=int(port))
+ dests.append(ent)
+ new_files.append(fname)
+ print "sending to %s" % (str(fnames_a))
+
+ top = dests.pop(0)
+ top['destinations'] = dests
+ print top
+
+ return (top, new_files)
+
+
+ def send_to_all_test(self):
+ (top, new_files) = self._t_build_list()
+
+ c = LTClient(self.src_file, top)
+ v = LTServer(c, c)
+ v.store_and_forward()
+
+ for f in new_files:
+ self._t_file_compare(f)
+ print f
+

0 comments on commit 73011e2

Please sign in to comment.