Author: jbellis
Date: Tue Jul 28 02:45:28 2009
New Revision: 798366

URL: http://svn.apache.org/viewvc?rev=798366&view=rev
Log:
update stress.py for current thrift api

Modified:
    incubator/cassandra/trunk/test/system/__init__.py
    incubator/cassandra/trunk/test/system/stress.py

Modified: incubator/cassandra/trunk/test/system/__init__.py
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/system/__init__.py?rev=798366&r1=798365&r2=798366&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/system/__init__.py (original)
+++ incubator/cassandra/trunk/test/system/__init__.py Tue Jul 28 02:45:28 2009
@@ -30,8 +30,7 @@
 sys.path.append(os.path.join(_ipath, 'cassandra'))
 import Cassandra
 
-host, port = '127.0.0.1', 9170
-def get_client():
+def get_client(host='127.0.0.1', port=9170):
     socket = TSocket.TSocket(host, port)
     transport = TTransport.TBufferedTransport(socket)
     protocol = TBinaryProtocol.TBinaryProtocol(transport)
@@ -97,7 +96,10 @@
                     print "Stderr: %s" % (stderr_value)
                 sys.exit()
         else:
-            client.transport.open()
+            try:
+                client.transport.open()
+            except:
+                pass
 
     def tearDown(self):
         if self.runserver:

Modified: incubator/cassandra/trunk/test/system/stress.py
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/system/stress.py?rev=798366&r1=798365&r2=798366&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/system/stress.py (original)
+++ incubator/cassandra/trunk/test/system/stress.py Tue Jul 28 02:45:28 2009
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# nosetests --tests=test.stress:Stress.ten_million_inserts
+# PYTHONPATH=test nosetests --tests=system.stress:Stress.ten_million_inserts
 
 from hashlib import md5
 from threading import Thread
@@ -22,36 +22,39 @@
 import time
 
 from . import get_client, root, CassandraTester
+from ttypes import *
 
 class Inserter(Thread):
     def run(self):
         id = get_ident()
         self.count = 0
-        client = get_client()
+        client = get_client(port=9160)
         client.transport.open()
         for i in xrange(0, 1000):
             data = md5(str(i)).hexdigest()
             for j in xrange(0, 1000):
                 key = '%s.%s.%s' % (time.time(), id, j)
-                client.insert('Table1', key, 'Standard1:A', data, i)
-                client.insert('Table1', key, 'Standard1:B', data, i)
-            self.count += 1000
+                client.insert('Table1', key, ColumnPath('Standard1', 
column='A'), data, i, 1)
+                client.insert('Table1', key, ColumnPath('Standard1', 
column='B'), data, i, 1)
+                self.count += 1
 
 class Stress(CassandraTester):
     runserver = False
 
     def ten_million_inserts(self):
         threads = []
-        for i in xrange(0, 10):
+        for i in xrange(0, 50):
             th = Inserter()
             threads.append(th)
             th.start()
 
-        total = 0
+        total = old_total = 0
         while True:
-            time.sleep(1)
+            time.sleep(10)
+            old_total = total
             total = sum(th.count for th in threads)
-            file('/tmp/progress', 'w').write('%s\n' % str(total))
+            delta = total - old_total
+            file('/tmp/progress', 'w').write('%d at %d/s\n' % (total, delta / 
10))
             if not [th for th in threads if th.isAlive()]:
                 file('/tmp/progress', 'w').write('done -- %s\n' % str(total))
                 break


Reply via email to