def test_remote_closing(self): pool = ConnectionPool( max_connections=int(os.getenv("MYSQL_POOL", "5")), idle_seconds=7200, **self.PARAMS ) try: self.proxy.stop() yield pool.Connection() except OperationalError: pass else: raise AssertionError("Unexpected normal situation") finally: pool.close()
def setUp(self): super(BaseTestCase, self).setUp() self.pool = ConnectionPool( max_connections=int(os.getenv("MYSQL_POOL", 5)), idle_seconds=7200, **self.PARAMS )
def test_pool_closing(self): pool = ConnectionPool( max_connections=int(os.getenv("MYSQL_POOL", "5")), idle_seconds=7200, **self.PARAMS ) try: with (yield pool.Connection()) as connect: with connect.cursor() as cursor: self._close_proxy_sessions() yield cursor.execute("SELECT 1 as test") except (OperationalError, ConnectionNotFoundError) as e: pass else: raise AssertionError("Unexpected normal situation") finally: pool.close()
class BaseTestCase(AsyncTestCase): PARAMS = dict( host=os.getenv("MYSQL_HOST", "127.0.0.1"), port=int(os.getenv("MYSQL_PORT", "3306")), user=os.getenv("MYSQL_USER", "root"), passwd=os.getenv("MYSQL_PASSWD", ""), db=os.getenv("MYSQL_DB", "test"), charset=os.getenv("MYSQL_CHARSET", "utf8"), no_delay=True, sql_mode="REAL_AS_FLOAT", init_command="SET max_join_size=DEFAULT" ) def setUp(self): super(BaseTestCase, self).setUp() self.pool = ConnectionPool( max_connections=int(os.getenv("MYSQL_POOL", 5)), idle_seconds=7200, **self.PARAMS ) def tearDown(self): super(BaseTestCase, self).tearDown() self.pool.close()