Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding a request test

  • Loading branch information...
commit f0bea60555c0fff22a30f2b1368487a9da0127c8 1 parent a91e29d
BuzzTroll authored
View
5 lantorrent/bin/test.sh
@@ -18,6 +18,9 @@ $LANTORRENT_HOME/bin/make_lt_server.sh 4 $pidfile
xinet_pid=`cat $pidfile`
echo "xinet on $xinet_pid"
-trap "kill $xinet_pid; sleep 10; kill -9 $xinet_pid" EXIT
+$dir/lt-daemon &
+ltd_pid=$!
+
+trap "kill $xinet_pid $ltd_pid; sleep 10; kill -9 $xinet_pid $ltd_pid" EXIT
source $LANTORRENT_HOME/tests/ports_env.sh
nosetests tests/*_test.py
View
3  lantorrent/etc/lt.sql
@@ -3,8 +3,7 @@ create table requests(
rid varchar(36) UNIQUE NOT NULL,
src_filename varchar(1024) NOT NULL,
dst_filename varchar(1024) NOT NULL,
- group_id varchar(64) NOT NULL,
- group_count INTEGER NOT NULL,
+ xfer_id varchar(64),
hostname varchar(1024) NOT NULL,
port INTEGER NOT NULL DEFAULT 2893,
state INTEGER DEFAULT 0,
View
8 lantorrent/pylantorrent/request.py
@@ -12,11 +12,11 @@
import time
import datetime
-def wait_until_sent(con, host, port, group_id):
+def wait_until_sent(con, rid):
done = False
while not done:
- s = "select state,messsage from requests where group_id = ? and hostname = ? and port = ?"
- data = (group_id,host,port,)
+ s = "select state,messsage from requests where rid = ?"
+ data = (rid,)
c = con.cursor()
c.execute(s, data)
rs = c.fetchone()
@@ -81,7 +81,7 @@ def main(argv=sys.argv[1:]):
con.commit()
cnt = int(rs[0])
- (rc, message) = wait_until_sent(con, host, port, group_id)
+ (rc, message) = wait_until_sent(con, rid)
if rc == 0:
print "Success"
else:
View
2  lantorrent/tests/many_xfer_test.py
@@ -26,7 +26,7 @@ def setUp(self):
def tearDown(self):
while len(self.files) > 0:
f = self.files.pop(0)
- ## os.remove(f)
+ os.remove(f)
def _t_new_dest(self, host, port, sz=128*1024):
(osf, fname) = tempfile.mkstemp()
View
47 lantorrent/tests/request_test.py
@@ -0,0 +1,47 @@
+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 *
+from pylantorrent.request import *
+
+
+
+class TestRequestXfer(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_file_compare(self, f):
+ rc = filecmp.cmp(self.src_file, f)
+ self.assertTrue(rc)
+
+ def test_request_one(self):
+ port = int(self.ports_a[0])
+ host = "localhost:%d" % (port)
+ (osf, fname) = tempfile.mkstemp()
+ os.close(osf)
+
+ rc = pylantorrent.request.main([self.src_file, fname, str(uuid.uuid1()), host])
+ self.assertEqual(rc, 0, "rc should be 0 but is %d" % (rc))
+ self._t_file_compare(fname)
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.