Skip to content

Commit 97c4632

Browse files
authored
Merge pull request #17 from zhanghaitao3/master
fix: disable UNLISTEN for GaussDB and unskip related tests
2 parents d05f8a2 + e04088e commit 97c4632

File tree

5 files changed

+22
-41
lines changed

5 files changed

+22
-41
lines changed

‎async_gaussdb/_version.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
importtyping
1616

17-
__version__: typing.Final='0.30.1'
17+
__version__: typing.Final='0.30.2'

‎async_gaussdb/connection.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2674,8 +2674,17 @@ def _detect_server_capabilities(server_version, connection_settings):
26742674
sql_close_all=False
26752675
jit=False
26762676
sql_copy_from_where=False
2677+
elifhasattr(connection_settings, 'sql_mode') orhasattr(connection_settings, 'session_respool'):
2678+
# Standard GaussDBSQL serve
2679+
advisory_locks=True
2680+
notifications=False
2681+
plpgsql=True
2682+
sql_reset=True
2683+
sql_close_all=True
2684+
jit=False
2685+
sql_copy_from_where=False
26772686
else:
2678-
# Standard GaussDBSQL server assumed.
2687+
# Standard Postgresql server assumed.
26792688
advisory_locks=True
26802689
notifications=True
26812690
plpgsql=True

‎tests/test_cache_invalidation.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
importasync_gaussdb
99
fromasync_gaussdbimport_testbaseastb
10-
importunittest
1110
ERRNUM='unexpected number of attributes of composite type'
1211
ERRTYP='unexpected data type of composite type'
1312

@@ -75,10 +74,8 @@ async def test_prepare_cache_invalidation_in_transaction(self):
7574
finally:
7675
awaitself.con.execute('DROP TABLE tab1')
7776

78-
@unittest.skip('UNLISTEN statement is not yet supported.')
7977
asyncdeftest_prepare_cache_invalidation_in_pool(self):
80-
pool=awaitself.create_pool(database='postgres',
81-
min_size=2, max_size=2)
78+
pool=awaitself.create_pool(min_size=2, max_size=2)
8279

8380
awaitself.con.execute('CREATE TABLE tab1(a int, b int)')
8481

@@ -307,11 +304,13 @@ async def test_type_cache_invalidation_on_change_attr(self):
307304
awaitself.con.execute('DROP TABLE tab1')
308305
awaitself.con.execute('DROP TYPE typ1')
309306

310-
@unittest.skip('UNLISTEN statement is not yet supported.')
311307
asyncdeftest_type_cache_invalidation_in_pool(self):
308+
try:
309+
awaitself.con.execute('DROP DATABASE IF EXISTS testdb')
310+
exceptException:
311+
pass
312312
awaitself.con.execute('CREATE DATABASE testdb')
313-
pool=awaitself.create_pool(database='postgres',
314-
min_size=2, max_size=2)
313+
pool=awaitself.create_pool(min_size=2, max_size=2)
315314

316315
pool_chk=awaitself.create_pool(database='testdb',
317316
min_size=2, max_size=2)

‎tests/test_pool.py‎

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ async def _cancel(self, waiter):
4343

4444
classTestPool(tb.ConnectedTestCase):
4545

46-
@unittest.skip("UNLISTEN statement is not yet supported.")
4746
asyncdeftest_pool_01(self):
4847
fornin{1, 5, 10, 20, 100}:
4948
withself.subTest(tasksnum=n):
@@ -59,7 +58,6 @@ async def worker():
5958
awaitasyncio.gather(*tasks)
6059
awaitpool.close()
6160

62-
@unittest.skip("UNLISTEN statement is not yet supported.")
6361
asyncdeftest_pool_02(self):
6462
fornin{1, 3, 5, 10, 20, 100}:
6563
withself.subTest(tasksnum=n):
@@ -108,7 +106,6 @@ async def test_pool_04(self):
108106

109107
pool.terminate()
110108

111-
@unittest.skip("UNLISTEN statement is not yet supported.")
112109
asyncdeftest_pool_05(self):
113110
fornin{1, 3, 5, 10, 20, 100}:
114111
withself.subTest(tasksnum=n):
@@ -123,7 +120,6 @@ async def worker():
123120
awaitasyncio.gather(*tasks)
124121
awaitpool.close()
125122

126-
@unittest.skip("UNLISTEN statement is not yet supported.")
127123
asyncdeftest_pool_06(self):
128124
fut=asyncio.Future()
129125

@@ -206,7 +202,6 @@ async def test_pool_08(self):
206202
withself.assertRaisesRegex(async_gaussdb.InterfaceError, 'is not a member'):
207203
awaitpool.release(con._con)
208204

209-
@unittest.skip("UNLISTEN statement is not yet supported.")
210205
asyncdeftest_pool_09(self):
211206
pool1=awaitself.create_pool(database='postgres',
212207
min_size=1, max_size=1)
@@ -225,7 +220,6 @@ async def test_pool_09(self):
225220
awaitpool1.close()
226221
awaitpool2.close()
227222

228-
@unittest.skip("UNLISTEN statement is not yet supported.")
229223
asyncdeftest_pool_10(self):
230224
pool=awaitself.create_pool(database='postgres',
231225
min_size=1, max_size=1)
@@ -236,7 +230,6 @@ async def test_pool_10(self):
236230

237231
awaitpool.close()
238232

239-
@unittest.skip("UNLISTEN statement is not yet supported.")
240233
asyncdeftest_pool_11(self):
241234
pool=awaitself.create_pool(database='postgres',
242235
min_size=1, max_size=1)
@@ -294,7 +287,6 @@ async def test_pool_11(self):
294287

295288
awaitpool.close()
296289

297-
@unittest.skip("UNLISTEN statement is not yet supported.")
298290
asyncdeftest_pool_12(self):
299291
pool=awaitself.create_pool(database='postgres',
300292
min_size=1, max_size=1)
@@ -305,7 +297,6 @@ async def test_pool_12(self):
305297

306298
awaitpool.close()
307299

308-
@unittest.skip("UNLISTEN statement is not yet supported.")
309300
asyncdeftest_pool_13(self):
310301
pool=awaitself.create_pool(database='postgres',
311302
min_size=1, max_size=1)
@@ -325,7 +316,6 @@ def test_pool_init_run_until_complete(self):
325316
pool=self.loop.run_until_complete(pool_init)
326317
self.assertIsInstance(pool, async_gaussdb.pool.Pool)
327318

328-
@unittest.skip("UNLISTEN statement is not yet supported.")
329319
asyncdeftest_pool_exception_in_setup_and_init(self):
330320
classError(Exception):
331321
pass
@@ -419,7 +409,6 @@ async def worker():
419409
self.cluster.trust_local_connections()
420410
self.cluster.reload()
421411

422-
@unittest.skip("UNLISTEN statement is not yet supported.")
423412
asyncdeftest_pool_handles_task_cancel_in_acquire_with_timeout(self):
424413
# See https://github.com/MagicStack/async_gaussdb/issues/547
425414
pool=awaitself.create_pool(database='postgres',
@@ -440,7 +429,6 @@ async def worker():
440429
# Check that the connection has been returned to the pool.
441430
self.assertEqual(pool._queue.qsize(), 1)
442431

443-
@unittest.skip("UNLISTEN statement is not yet supported.")
444432
asyncdeftest_pool_handles_task_cancel_in_release(self):
445433
# Use SlowResetConnectionPool to simulate
446434
# the Task.cancel() and __aexit__ race.
@@ -462,7 +450,6 @@ async def worker():
462450
# Check that the connection has been returned to the pool.
463451
self.assertEqual(pool._queue.qsize(), 1)
464452

465-
@unittest.skip("UNLISTEN statement is not yet supported.")
466453
asyncdeftest_pool_handles_query_cancel_in_release(self):
467454
# Use SlowResetConnectionPool to simulate
468455
# the Task.cancel() and __aexit__ race.
@@ -528,7 +515,6 @@ async def test(pool):
528515

529516
self.assertEqual(len(cons), N)
530517

531-
@unittest.skip("UNLISTEN statement is not yet supported.")
532518
asyncdeftest_pool_release_in_xact(self):
533519
"""Test that Connection.reset() closes any open transaction."""
534520
asyncwithself.create_pool(database='postgres',
@@ -558,7 +544,6 @@ async def get_xact_id(con):
558544
id3=awaitget_xact_id(con)
559545
self.assertNotEqual(id2, id3)
560546

561-
@unittest.skip("UNLISTEN statement is not yet supported.")
562547
asyncdeftest_pool_connection_methods(self):
563548
asyncdeftest_fetch(pool):
564549
i=random.randint(0, 20)
@@ -610,7 +595,6 @@ async def run(N, meth):
610595
withself.subTest(method=method.__name__):
611596
awaitrun(200, method)
612597

613-
@unittest.skip("UNLISTEN statement is not yet supported.")
614598
asyncdeftest_pool_connection_execute_many(self):
615599
asyncdefworker(pool):
616600
awaitasyncio.sleep(random.random() /100)
@@ -639,7 +623,6 @@ async def worker(pool):
639623
finally:
640624
awaitpool.execute('DROP TABLE exmany')
641625

642-
@unittest.skip("UNLISTEN statement is not yet supported.")
643626
asyncdeftest_pool_max_inactive_time_01(self):
644627
asyncwithself.create_pool(
645628
database='postgres', min_size=1, max_size=1,
@@ -659,7 +642,6 @@ async def test_pool_max_inactive_time_01(self):
659642
'SELECT 1')
660643
self.assertIs(pool._holders[0]._con, con)
661644

662-
@unittest.skip("UNLISTEN statement is not yet supported.")
663645
asyncdeftest_pool_max_inactive_time_02(self):
664646
asyncwithself.create_pool(
665647
database='postgres', min_size=1, max_size=1,
@@ -683,7 +665,6 @@ async def test_pool_max_inactive_time_02(self):
683665
'SELECT 1')
684666
self.assertIsNot(pool._holders[0]._con, con)
685667

686-
@unittest.skip("UNLISTEN statement is not yet supported.")
687668
asyncdeftest_pool_max_inactive_time_03(self):
688669
asyncwithself.create_pool(
689670
database='postgres', min_size=1, max_size=1,
@@ -704,7 +685,6 @@ async def test_pool_max_inactive_time_03(self):
704685
'SELECT 1')
705686
self.assertIs(pool._holders[0]._con, con)
706687

707-
@unittest.skip("UNLISTEN statement is not yet supported.")
708688
asyncdeftest_pool_max_inactive_time_04(self):
709689
# Chaos test for max_inactive_connection_lifetime.
710690
DURATION=2.0
@@ -736,14 +716,14 @@ async def worker(pool):
736716

737717
self.assertGreaterEqual(N, 50)
738718

739-
@unittest.skip("UNLISTEN statement is not yet supported.")
740719
asyncdeftest_pool_max_inactive_time_05(self):
741720
# Test that idle never-acquired connections abide by
742721
# the max inactive lifetime.
743722
asyncwithself.create_pool(
744723
database='postgres', min_size=2, max_size=2,
745-
max_inactive_connection_lifetime=0.2) aspool:
724+
max_inactive_connection_lifetime=0.3) aspool:
746725

726+
awaitasyncio.sleep(0.02)
747727
self.assertIsNotNone(pool._holders[0]._con)
748728
self.assertIsNotNone(pool._holders[1]._con)
749729

@@ -755,7 +735,6 @@ async def test_pool_max_inactive_time_05(self):
755735
# but should be closed nonetheless.
756736
self.assertIs(pool._holders[1]._con, None)
757737

758-
@unittest.skip("UNLISTEN statement is not yet supported.")
759738
asyncdeftest_pool_handles_inactive_connection_errors(self):
760739
pool=awaitself.create_pool(database='postgres',
761740
min_size=1, max_size=1)
@@ -776,7 +755,6 @@ async def test_pool_handles_inactive_connection_errors(self):
776755

777756
awaitpool.close()
778757

779-
@unittest.skip("UNLISTEN statement is not yet supported.")
780758
asyncdeftest_pool_size_and_capacity(self):
781759
asyncwithself.create_pool(
782760
database='postgres',
@@ -809,7 +787,6 @@ async def test_pool_closing(self):
809787
pool.terminate()
810788
self.assertTrue(pool.is_closing())
811789

812-
@unittest.skip("UNLISTEN statement is not yet supported.")
813790
asyncdeftest_pool_handles_transaction_exit_in_asyncgen_1(self):
814791
pool=awaitself.create_pool(database='postgres',
815792
min_size=1, max_size=1)
@@ -831,7 +808,6 @@ class MyException(Exception):
831808
asyncfor_initerate(con): # noqa
832809
raiseMyException()
833810

834-
@unittest.skip("UNLISTEN statement is not yet supported.")
835811
asyncdeftest_pool_handles_transaction_exit_in_asyncgen_2(self):
836812
pool=awaitself.create_pool(database='postgres',
837813
min_size=1, max_size=1)
@@ -856,7 +832,6 @@ class MyException(Exception):
856832

857833
deliterator
858834

859-
@unittest.skip("UNLISTEN statement is not yet supported.")
860835
asyncdeftest_pool_handles_asyncgen_finalization(self):
861836
pool=awaitself.create_pool(database='postgres',
862837
min_size=1, max_size=1)
@@ -878,7 +853,6 @@ class MyException(Exception):
878853
asyncfor_initerate(con): # noqa
879854
raiseMyException()
880855

881-
@unittest.skip("UNLISTEN statement is not yet supported.")
882856
asyncdeftest_pool_close_waits_for_release(self):
883857
pool=awaitself.create_pool(database='postgres',
884858
min_size=1, max_size=1)
@@ -934,7 +908,6 @@ async def test_pool_expire_connections(self):
934908
self.assertIsNone(pool._holders[0]._con)
935909
awaitpool.close()
936910

937-
@unittest.skip("UNLISTEN statement is not yet supported.")
938911
asyncdeftest_pool_set_connection_args(self):
939912
pool=awaitself.create_pool(database='postgres',
940913
min_size=1, max_size=1)
@@ -1007,7 +980,6 @@ async def test_pool_init_and_use_race(self):
1007980
awaitpool_task
1008981
awaitpool.close()
1009982

1010-
@unittest.skip("UNLISTEN statement is not yet supported.")
1011983
asyncdeftest_pool_remote_close(self):
1012984
pool=awaitself.create_pool(min_size=1, max_size=1)
1013985
backend_pid_fut=self.loop.create_future()

‎tests/test_transaction.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ async def test_transaction_interface_errors(self):
160160
asyncwithtr:
161161
pass
162162

163-
@unittest.skip("openGauss doesn't support UNLISTEN statement")
164163
asyncdeftest_transaction_within_manual_transaction(self):
165164
self.assertIsNone(self.con._top_xact)
166165
self.assertFalse(self.con.is_in_transaction())
@@ -182,7 +181,9 @@ async def test_transaction_within_manual_transaction(self):
182181
self.assertIsNone(self.con._top_xact)
183182
self.assertFalse(self.con.is_in_transaction())
184183

185-
@unittest.skip("openGauss doesn't support UNLISTEN statement")
184+
@unittest.skip("""GaussDB handles nested transaction
185+
isolation levels differently from GaussDBSQL;
186+
cannot assert unified behavior.""")
186187
asyncdeftest_isolation_level(self):
187188
awaitself.con.reset()
188189
default_isolation=awaitself.con.fetchval(

0 commit comments

Comments
(0)