http://git-wip-us.apache.org/repos/asf/cassandra-dtest/blob/49b2dda4/thrift_hsha_test.py
----------------------------------------------------------------------
diff --git a/thrift_hsha_test.py b/thrift_hsha_test.py
index 1aa8030..9e7dbf1 100644
--- a/thrift_hsha_test.py
+++ b/thrift_hsha_test.py
@@ -4,15 +4,15 @@ import shlex
 import subprocess
 import time
 import unittest
+import pytest
+import logging
 
-import pycassa
-
-from dtest import DEFAULT_DIR, Tester, debug, create_ks
-from tools.jmxutils import (JolokiaAgent, make_mbean,
-                            remove_perf_disable_shared_mem)
-
-from tools.decorators import since
+from dtest import DEFAULT_DIR, Tester, create_ks
+from thrift_test import get_thrift_client
+from tools.jmxutils import JolokiaAgent, make_mbean, 
remove_perf_disable_shared_mem
 
+since = pytest.mark.since
+logger = logging.getLogger(__name__)
 
 JNA_PATH = '/usr/share/java/jna.jar'
 ATTACK_JAR = 'lib/cassandra-attack.jar'
@@ -20,7 +20,7 @@ ATTACK_JAR = 'lib/cassandra-attack.jar'
 # Use jna.jar in {CASSANDRA_DIR,DEFAULT_DIR}/lib/, since >=2.1 needs correct 
version
 try:
     if glob.glob('%s/lib/jna-*.jar' % os.environ['CASSANDRA_DIR']):
-        debug('Using jna.jar in CASSANDRA_DIR/lib..')
+        logger.debug('Using jna.jar in CASSANDRA_DIR/lib..')
         JNA_IN_LIB = glob.glob('%s/lib/jna-*.jar' % 
os.environ['CASSANDRA_DIR'])
         JNA_PATH = JNA_IN_LIB[0]
 except KeyError:
@@ -31,7 +31,7 @@ except KeyError:
 
 
 @since('2.0', max_version='4')
-class ThriftHSHATest(Tester):
+class TestThriftHSHA(Tester):
 
     def test_closing_connections(self):
         """
@@ -56,26 +56,27 @@ class ThriftHSHATest(Tester):
         session.execute("CREATE TABLE \"CF\" (key text PRIMARY KEY, val text) 
WITH COMPACT STORAGE;")
 
         def make_connection():
-            pool = pycassa.ConnectionPool('test', timeout=None)
-            cf = pycassa.ColumnFamily(pool, 'CF')
-            return pool
+            host, port = node1.network_interfaces['thrift']
+            client = get_thrift_client(host, port)
+            client.transport.open()
+            return client
 
         pools = []
         connected_thrift_clients = make_mbean('metrics', type='Client', 
name='connectedThriftClients')
-        for i in xrange(10):
-            debug("Creating connection pools..")
-            for x in xrange(3):
+        for i in range(10):
+            logger.debug("Creating connection pools..")
+            for x in range(3):
                 pools.append(make_connection())
-            debug("Disabling/Enabling thrift iteration #{i}".format(i=i))
+            logger.debug("Disabling/Enabling thrift iteration 
#{i}".format(i=i))
             node1.nodetool('disablethrift')
             node1.nodetool('enablethrift')
-            debug("Closing connections from the client side..")
-            for pool in pools:
-                pool.dispose()
+            logger.debug("Closing connections from the client side..")
+            for client in pools:
+                client.transport.close()
 
             with JolokiaAgent(node1) as jmx:
                 num_clients = jmx.read_attribute(connected_thrift_clients, 
"Value")
-                self.assertEqual(int(num_clients), 0, "There are still open 
Thrift connections after stopping service")
+                assert int(num_clients), 0 == "There are still open Thrift 
connections after stopping service"
 
     @unittest.skipIf(not os.path.exists(ATTACK_JAR), "No attack jar found")
     @unittest.skipIf(not os.path.exists(JNA_PATH), "No JNA jar found")
@@ -104,7 +105,7 @@ class ThriftHSHATest(Tester):
         cluster.populate(2)
         nodes = (node1, node2) = cluster.nodelist()
         [n.start(use_jna=True) for n in nodes]
-        debug("Cluster started.")
+        logger.debug("Cluster started.")
 
         session = self.patient_cql_connection(node1)
         create_ks(session, 'tmp', 2)
@@ -117,13 +118,13 @@ class ThriftHSHATest(Tester):
 ) WITH COMPACT STORAGE;
 """)
 
-        debug("running attack jar...")
+        logger.debug("running attack jar...")
         p = subprocess.Popen(shlex.split("java -jar 
{attack_jar}".format(attack_jar=ATTACK_JAR)))
         p.communicate()
 
-        debug("Stopping cluster..")
+        logger.debug("Stopping cluster..")
         cluster.stop()
-        debug("Starting cluster..")
+        logger.debug("Starting cluster..")
         cluster.start(no_wait=True)
-        debug("Waiting 10 seconds before we're done..")
+        logger.debug("Waiting 10 seconds before we're done..")
         time.sleep(10)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to