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 (
@@ -226,6 +235,7 @@ def test_integer_types(self, connection):
226235
227236
228237class TestWithClause (TablesTest ):
238+ __backend__ = True
229239 run_create_tables = "each"
230240
231241 @staticmethod
@@ -238,10 +248,7 @@ def _create_table_and_get_desc(connection, metadata, **kwargs):
238248 )
239249 table .create (connection )
240250
241- session : ydb .Session = connection .connection .driver_connection .session_pool .acquire ()
242- table_description = session .describe_table ("/local/" + table .name )
243- connection .connection .driver_connection .session_pool .release (session )
244- return table_description
251+ return connection .connection .driver_connection .describe (table .name )
245252
246253 @pytest .mark .parametrize (
247254 "auto_partitioning_by_size,res" ,
@@ -389,6 +396,8 @@ def test_several_keys(self, connection, metadata):
389396
390397
391398class TestTransaction (TablesTest ):
399+ __backend__ = True
400+
392401 @classmethod
393402 def define_tables (cls , metadata : sa .MetaData ):
394403 Table (
@@ -477,6 +486,8 @@ def test_not_interactive_transaction(
477486
478487
479488class TestTransactionIsolationLevel (TestBase ):
489+ __backend__ = True
490+
480491 class IsolationSettings (NamedTuple ):
481492 ydb_mode : ydb .AbstractTransactionModeBuilder
482493 interactive : bool
@@ -508,7 +519,10 @@ def test_connection_set(self, connection_no_trans: sa.Connection):
508519
509520
510521class TestEngine (TestBase ):
511- @pytest .fixture (scope = "module" )
522+ __backend__ = True
523+ __only_on__ = "yql+ydb"
524+
525+ @pytest .fixture (scope = "class" )
512526 def ydb_driver (self ):
513527 url = config .db_url
514528 driver = ydb .Driver (endpoint = f"grpc://{ url .host } :{ url .port } " , database = url .database )
@@ -520,13 +534,14 @@ def ydb_driver(self):
520534
521535 driver .stop ()
522536
523- @pytest .fixture (scope = "module " )
537+ @pytest .fixture (scope = "class " )
524538 def ydb_pool (self , ydb_driver ):
525539 session_pool = ydb .SessionPool (ydb_driver , size = 5 , workers_threads_count = 1 )
526540
527- yield session_pool
528-
529- session_pool .stop ()
541+ try :
542+ yield session_pool
543+ finally :
544+ session_pool .stop ()
530545
531546 def test_sa_queue_pool_with_ydb_shared_session_pool (self , ydb_driver , ydb_pool ):
532547 engine1 = sa .create_engine (config .db_url , poolclass = sa .QueuePool , connect_args = {"ydb_session_pool" : ydb_pool })
@@ -559,7 +574,36 @@ def test_sa_null_pool_with_ydb_shared_session_pool(self, ydb_driver, ydb_pool):
559574 assert not ydb_driver ._stopped
560575
561576
577+ class TestAsyncEngine (TestEngine ):
578+ __only_on__ = "yql+ydb_async"
579+
580+ @pytest .fixture (scope = "class" )
581+ def ydb_driver (self ):
582+ loop = asyncio .get_event_loop ()
583+ url = config .db_url
584+ driver = ydb .aio .Driver (endpoint = f"grpc://{ url .host } :{ url .port } " , database = url .database )
585+ try :
586+ loop .run_until_complete (driver .wait (timeout = 5 , fail_fast = True ))
587+ yield driver
588+ finally :
589+ loop .run_until_complete (driver .stop ())
590+
591+ loop .run_until_complete (driver .stop ())
592+
593+ @pytest .fixture (scope = "class" )
594+ def ydb_pool (self , ydb_driver ):
595+ session_pool = ydb .aio .SessionPool (ydb_driver , size = 5 )
596+
597+ try :
598+ yield session_pool
599+ finally :
600+ loop = asyncio .get_event_loop ()
601+ loop .run_until_complete (session_pool .stop ())
602+
603+
562604class TestUpsert (TablesTest ):
605+ __backend__ = True
606+
563607 @classmethod
564608 def define_tables (cls , metadata ):
565609 Table (
@@ -659,6 +703,8 @@ def test_upsert_from_select(self, connection, metadata):
659703
660704
661705class TestUpsertDoesNotReplaceInsert (TablesTest ):
706+ __backend__ = True
707+
662708 @classmethod
663709 def define_tables (cls , metadata ):
664710 Table (
0 commit comments