Permalink
Browse files

new test added. all are passing now

  • Loading branch information...
1 parent 7a58d11 commit 5c513b6742928c868b1540e72a7116c97ae4e214 BuzzTroll committed Sep 9, 2010
@@ -39,7 +39,7 @@ def __init__(self, filename, json_header):
ep['port'] = d['port']
ep['id'] = rid
ep['filename'] = fname
- ep['emsg'] = None
+ ep['emsg'] = "Success was never reported, nor was a specific error"
self.dest[rid] = ep
self.md5er = hashlib.md5()
@@ -102,18 +102,17 @@ def main(argv=sys.argv[1:]):
port = a[0]
x = int(port)
filename = "/" + a[1].strip()
- rid = str(uuid.uuid1())
filenames = [filename,]
- json_dest = pylantorrent.create_endpoint_entry(host, filenames, data_size, port, block_size, degree, rid)
+ json_dest = pylantorrent.create_endpoint_entry(host, filenames, data_size, port, block_size, degree)
dests.append(json_dest)
l = sys.stdin.readline()
cnt = cnt + 1
# for the sake of code resuse this will just be piped into an
# lt daemon processor. /dev/null is used to supress a local write
- final = pylantorrent.create_endpoint_entry("localhost", ["/dev/null",])
+ final = pylantorrent.create_endpoint_entry("localhost", ["/dev/null",], data_size)
final['destinations'] = dests
c = LTClient(argv[0], final)
@@ -43,12 +43,14 @@ def do_it_live(con, rows):
last_host = None
last_port = None
json_dest = None
+ rids_all = []
for r in rows:
new_host = r[0]
new_port = int(r[1])
dst_filename = r[3]
src_filename = r[2]
rid = r[4]
+ rids_all.append(rid)
sz = os.path.getsize(src_filename)
# if it is the same host just tack on another dest file
if new_host == last_host and last_port == new_port:
@@ -69,7 +71,7 @@ def do_it_live(con, rows):
json_dest['block_size'] = 128*1024
json_dest['degree'] = 1
json_dest['length'] = sz
-
+
if json_dest != None:
dests.append(json_dest)
@@ -90,9 +92,6 @@ def do_it_live(con, rows):
v = LTServer(client, client)
v.store_and_forward()
- rids_all = []
- for r in rows:
- rids_all.append(r[4])
rc = 0
es = client.get_incomplete()
bad_rid = []
@@ -69,6 +69,6 @@ def get_printable(self):
for req in self.reqs:
s = self.get_json(rid=req['id'], filename=req['filename'])
s = json.dumps(s)
- str_out = s + os.linesep
+ str_out = str_out + s + os.linesep
- return s
+ return str_out
@@ -82,7 +82,7 @@ def read_header(self):
raise LTException(502, str(ex), traceback)
def print_results(self, s):
- pylantorrent.log(logging.DEBUG, "printing %s" % (s))
+ pylantorrent.log(logging.DEBUG, "printing\n--------- %s\n---------------" % (s))
# self.lock.acquire()
try:
self.outf.write(s)
@@ -167,7 +167,7 @@ def store_and_forward(self):
v_con.read_output()
v_con.close()
- pylantorrent.log(logging.DEBUG, "All data sent %s" % (md5str))
+ pylantorrent.log(logging.DEBUG, "All data sent %s %d" % (md5str, len(requests_a)))
# if we got to here it was successfully written to a file
# and we can call it success. Print out a success message for
# everyfile written
@@ -52,7 +52,7 @@ def test_request_many_block(self):
port = int(self.ports_a[0])
host = "localhost:%d" % (port)
- for i in range(0, 10):
+ for i in range(0, 7):
fname = self._get_temp_file()
rc = pylantorrent.request.main([self.src_file, fname, str(uuid.uuid1()), host])
self.assertEqual(rc, 0, "rc should be 0 but is %d" % (rc))
@@ -71,7 +71,7 @@ def get_rid(self, out_file):
return rid
- def test_request_many_nonblock(self):
+ def test_request_same_host_nonblock(self):
port = int(self.ports_a[0])
host = "localhost:%d" % (port)
@@ -88,6 +88,32 @@ def test_request_many_nonblock(self):
print "waiting on all the files"
for rid in rids:
+ print "waiting on %s" % (rid)
+ rc = pylantorrent.request.main(["-a", rid])
+ self.assertEqual(rc, 0, "rc should be 0 but is %d" % (rc))
+
+ print "checking all the files"
+ for f in self.files:
+ self._t_file_compare(f)
+
+ def test_request_many_host_nonblock(self):
+
+ print "requesting all the files"
+ rids = []
+ for i in range(0, len(self.ports_a) * 2):
+ port = int(self.ports_a[i%len(self.ports_a)])
+ host = "localhost:%d" % (port)
+ (osf, out_file) = tempfile.mkstemp()
+ os.close(osf)
+ fname = self._get_temp_file()
+ rc = pylantorrent.request.main(["-O", out_file, "-n", self.src_file, fname, str(uuid.uuid1()), host])
+ self.assertEqual(rc, 0, "rc should be 0 but is %d" % (rc))
+ rid = self.get_rid(out_file)
+ rids.append(rid)
+
+ print "waiting on all the files"
+ for rid in rids:
+ print "waiting on %s" % (rid)
rc = pylantorrent.request.main(["-a", rid])
self.assertEqual(rc, 0, "rc should be 0 but is %d" % (rc))

0 comments on commit 5c513b6

Please sign in to comment.