1+ import asyncio
12from datetime import date , datetime
23from decimal import Decimal
34from typing import NamedTuple
@@ -21,6 +22,8 @@ def clear_sql(stm):
2122
2223
2324class TestText (TestBase ):
25+ __backend__ = True
26+
2427 def test_sa_text (self , connection ):
2528 rs = connection .execute (sa .text ("SELECT 1 AS value" ))
2629 assert rs .fetchone () == (1 ,)
@@ -38,6 +41,8 @@ def test_sa_text(self, connection):
3841
3942
4043class TestCrud (TablesTest ):
44+ __backend__ = True
45+
4146 @classmethod
4247 def define_tables (cls , metadata ):
4348 Table (
@@ -82,6 +87,8 @@ def test_sa_crud(self, connection):
8287
8388
8489class TestSimpleSelect (TablesTest ):
90+ __backend__ = True
91+
8592 @classmethod
8693 def define_tables (cls , metadata ):
8794 Table (
@@ -174,6 +181,8 @@ def test_sa_select_simple(self, connection):
174181
175182
176183class TestTypes (TablesTest ):
184+ __backend__ = True
185+
177186 @classmethod
178187 def define_tables (cls , metadata ):
179188 Table (
@@ -211,6 +220,7 @@ def test_select_types(self, connection):
211220
212221
213222class TestWithClause (TablesTest ):
223+ __backend__ = True
214224 run_create_tables = "each"
215225
216226 @staticmethod
@@ -223,10 +233,7 @@ def _create_table_and_get_desc(connection, metadata, **kwargs):
223233 )
224234 table .create (connection )
225235
226- session : ydb .Session = connection .connection .driver_connection .session_pool .acquire ()
227- table_description = session .describe_table ("/local/" + table .name )
228- connection .connection .driver_connection .session_pool .release (session )
229- return table_description
236+ return connection .connection .driver_connection .describe (table .name )
230237
231238 @pytest .mark .parametrize (
232239 "auto_partitioning_by_size,res" ,
@@ -374,6 +381,8 @@ def test_several_keys(self, connection, metadata):
374381
375382
376383class TestTransaction (TablesTest ):
384+ __backend__ = True
385+
377386 @classmethod
378387 def define_tables (cls , metadata : sa .MetaData ):
379388 Table (
@@ -462,6 +471,8 @@ def test_not_interactive_transaction(
462471
463472
464473class TestTransactionIsolationLevel (TestBase ):
474+ __backend__ = True
475+
465476 class IsolationSettings (NamedTuple ):
466477 ydb_mode : ydb .AbstractTransactionModeBuilder
467478 interactive : bool
@@ -493,7 +504,10 @@ def test_connection_set(self, connection_no_trans: sa.Connection):
493504
494505
495506class TestEngine (TestBase ):
496- @pytest .fixture (scope = "module" )
507+ __backend__ = True
508+ __only_on__ = "yql+ydb"
509+
510+ @pytest .fixture (scope = "class" )
497511 def ydb_driver (self ):
498512 url = config .db_url
499513 driver = ydb .Driver (endpoint = f"grpc://{ url .host } :{ url .port } " , database = url .database )
@@ -505,13 +519,14 @@ def ydb_driver(self):
505519
506520 driver .stop ()
507521
508- @pytest .fixture (scope = "module " )
522+ @pytest .fixture (scope = "class " )
509523 def ydb_pool (self , ydb_driver ):
510524 session_pool = ydb .SessionPool (ydb_driver , size = 5 , workers_threads_count = 1 )
511525
512- yield session_pool
513-
514- session_pool .stop ()
526+ try :
527+ yield session_pool
528+ finally :
529+ session_pool .stop ()
515530
516531 def test_sa_queue_pool_with_ydb_shared_session_pool (self , ydb_driver , ydb_pool ):
517532 engine1 = sa .create_engine (config .db_url , poolclass = sa .QueuePool , connect_args = {"ydb_session_pool" : ydb_pool })
@@ -544,7 +559,36 @@ def test_sa_null_pool_with_ydb_shared_session_pool(self, ydb_driver, ydb_pool):
544559 assert not ydb_driver ._stopped
545560
546561
562+ class TestAsyncEngine (TestEngine ):
563+ __only_on__ = "yql+ydb_async"
564+
565+ @pytest .fixture (scope = "class" )
566+ def ydb_driver (self ):
567+ loop = asyncio .get_event_loop ()
568+ url = config .db_url
569+ driver = ydb .aio .Driver (endpoint = f"grpc://{ url .host } :{ url .port } " , database = url .database )
570+ try :
571+ loop .run_until_complete (driver .wait (timeout = 5 , fail_fast = True ))
572+ yield driver
573+ finally :
574+ loop .run_until_complete (driver .stop ())
575+
576+ loop .run_until_complete (driver .stop ())
577+
578+ @pytest .fixture (scope = "class" )
579+ def ydb_pool (self , ydb_driver ):
580+ session_pool = ydb .aio .SessionPool (ydb_driver , size = 5 )
581+
582+ try :
583+ yield session_pool
584+ finally :
585+ loop = asyncio .get_event_loop ()
586+ loop .run_until_complete (session_pool .stop ())
587+
588+
547589class TestUpsert (TablesTest ):
590+ __backend__ = True
591+
548592 @classmethod
549593 def define_tables (cls , metadata ):
550594 Table (
@@ -644,6 +688,8 @@ def test_upsert_from_select(self, connection, metadata):
644688
645689
646690class TestUpsertDoesNotReplaceInsert (TablesTest ):
691+ __backend__ = True
692+
647693 @classmethod
648694 def define_tables (cls , metadata ):
649695 Table (
0 commit comments