def test_null_pool_failover(self): listener = _TestListener() pool = NullPool(keyspace='Keyspace1', credentials=_credentials, listeners=[listener], use_threadlocal=False, server_list=['localhost:9160', 'localhost:9160']) conn = pool.get() cf = ColumnFamily(conn, 'Standard1') for i in range(1,5): setattr(cf.client._connection.client, 'batch_mutate', _timeout) # The first insert attempt should fail, but failover should occur # and the insert should succeed cf.insert('key', {'col': 'val'}) assert_equal(listener.failure_count, i) cf.get('key') pool.dispose() listener.reset() pool = NullPool(keyspace='Keyspace1', credentials=_credentials, listeners=[listener], use_threadlocal=False, server_list=['localhost:9160', 'localhost:9160']) threads = [] args = (pool, 'key', {'col':'val'}) for i in range(0, 5): threads.append(threading.Thread(target=_five_fails, args=args)) threads[-1].start() for thread in threads: thread.join() assert_equal(listener.failure_count, 25) pool.dispose()
def test_null_pool(self): listener = _TestListener() pool = NullPool(keyspace='Keyspace1', credentials=_credentials, listeners=[listener]) conn = pool.get() pool.return_conn(conn) assert_equal(listener.checkout_count, 1) assert_equal(listener.checkin_count, 1)