Esempio n. 1
0
def prepare():
    global POOL
    POOL = cluster.connect(CONN_PARAMS,
                           loop=io_loop,
                           retries=1,
                           delay=0,
                           timeout=100)
Esempio n. 2
0
def prepare():
    global POOL
    POOL = cluster.connect(CONN_PARAMS,
                           loop=io_loop,
                           retries=1,
                           delay=0,
                           timeout=100)
Esempio n. 3
0
 def test_connect(self):
     """test connect to the cluster"""
     connection_args = {"master": "localhost:3306#2,localhost#4", "slave": "localhost:3306#2", "database": "test"}
     connection = connect(connection_args, loop=self._context.loop)
     self.assertIsInstance(connection, Cluster)
     self.assertEqual(6, len(connection._cluster[1]._connection._upstream))
     self.assertEqual(2, len(connection._cluster[0]._connection._upstream))
     connection_args = {"slave": "localhost:3306#2", "database": "test"}
     self.assertIsInstance(connect(connection_args, loop=self._context.loop), Cluster)
     connection_args = {"master": "localhost:3306#2,localhost#4", "database": "test"}
     self.assertFalse(isinstance(connect(connection_args, loop=self._context.loop), Cluster))
     connection_args = {}
     self.assertFalse(isinstance(connect(connection_args, loop=self._context.loop), Cluster))
     connection_args = "master=localhost:3306#2,localhost#4;slave=localhost:3306#2;database=test;"
     connection = connect(connection_args, loop=self._context.loop)
     self.assertIsInstance(connection, Cluster)
     self.assertEqual(6, len(connection._cluster[1]._connection._upstream))
     self.assertEqual(2, len(connection._cluster[0]._connection._upstream))
     # test real connect
     connection_args = {"master": "%(host)s" % _wsql_context.Configuration.connect_kwargs}
     connection_args.update(_wsql_context.Configuration.connect_kwargs)
     connection = connect(connection_args, loop=self._context.loop)
     connection.execute(self.wrap_query(lambda x: None))
Esempio n. 4
0
 def test_connect(self):
     """test connect to the cluster"""
     connection_args = {
         "master": "localhost:3306#2,localhost#4",
         "slave": "localhost:3306#2",
         "database": "test"
     }
     connection = connect(connection_args, loop=self._context.loop)
     self.assertIsInstance(connection, Cluster)
     self.assertEqual(6, len(connection._cluster[1]._connection._upstream))
     self.assertEqual(2, len(connection._cluster[0]._connection._upstream))
     connection_args = {"slave": "localhost:3306#2", "database": "test"}
     self.assertIsInstance(
         connect(connection_args, loop=self._context.loop), Cluster)
     connection_args = {
         "master": "localhost:3306#2,localhost#4",
         "database": "test"
     }
     self.assertFalse(
         isinstance(connect(connection_args, loop=self._context.loop),
                    Cluster))
     connection_args = {}
     self.assertFalse(
         isinstance(connect(connection_args, loop=self._context.loop),
                    Cluster))
     connection_args = "master=localhost:3306#2,localhost#4;slave=localhost:3306#2;database=test;"
     connection = connect(connection_args, loop=self._context.loop)
     self.assertIsInstance(connection, Cluster)
     self.assertEqual(6, len(connection._cluster[1]._connection._upstream))
     self.assertEqual(2, len(connection._cluster[0]._connection._upstream))
     # test real connect
     connection_args = {
         "master": "%(host)s" % _wsql_context.Configuration.connect_kwargs
     }
     connection_args.update(_wsql_context.Configuration.connect_kwargs)
     connection = connect(connection_args, loop=self._context.loop)
     connection.execute(self.wrap_query(lambda x: None))