mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-18 10:00:31 +03:00
Skip connection tests which cannot pass on CockroachDB
Features not supported seem: - isolation level (always serializable) - client encodings - notices (maybe there is a way to generate them) - 2 phase commit - reset (because of the lack of transaction deferrable) - backend pid
This commit is contained in:
parent
bca72937d8
commit
e154cbe5aa
|
@ -44,7 +44,8 @@ from psycopg2 import extensions as ext
|
||||||
from .testutils import (
|
from .testutils import (
|
||||||
PY2, unittest, skip_if_no_superuser, skip_before_postgres,
|
PY2, unittest, skip_if_no_superuser, skip_before_postgres,
|
||||||
skip_after_postgres, skip_before_libpq, skip_after_libpq,
|
skip_after_postgres, skip_before_libpq, skip_after_libpq,
|
||||||
ConnectingTestCase, skip_if_tpc_disabled, skip_if_windows, slow)
|
ConnectingTestCase, skip_if_tpc_disabled, skip_if_windows, slow,
|
||||||
|
skip_if_crdb, crdb_version)
|
||||||
|
|
||||||
from .testconfig import dbhost, dsn, dbname
|
from .testconfig import dbhost, dsn, dbname
|
||||||
|
|
||||||
|
@ -74,6 +75,7 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
conn.close()
|
conn.close()
|
||||||
self.assertEqual(curs.closed, True)
|
self.assertEqual(curs.closed, True)
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
@skip_before_postgres(8, 4)
|
@skip_before_postgres(8, 4)
|
||||||
@skip_if_no_superuser
|
@skip_if_no_superuser
|
||||||
@skip_if_windows
|
@skip_if_windows
|
||||||
|
@ -88,6 +90,7 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
conn.close()
|
conn.close()
|
||||||
self.assertEqual(conn.closed, 1)
|
self.assertEqual(conn.closed, 1)
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_reset(self):
|
def test_reset(self):
|
||||||
conn = self.conn
|
conn = self.conn
|
||||||
# switch session characteristics
|
# switch session characteristics
|
||||||
|
@ -111,6 +114,7 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
if self.conn.info.server_version >= 90100:
|
if self.conn.info.server_version >= 90100:
|
||||||
self.assert_(conn.deferrable is None)
|
self.assert_(conn.deferrable is None)
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_notices(self):
|
def test_notices(self):
|
||||||
conn = self.conn
|
conn = self.conn
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
@ -120,6 +124,7 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
self.assertEqual("CREATE TABLE", cur.statusmessage)
|
self.assertEqual("CREATE TABLE", cur.statusmessage)
|
||||||
self.assert_(conn.notices)
|
self.assert_(conn.notices)
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_notices_consistent_order(self):
|
def test_notices_consistent_order(self):
|
||||||
conn = self.conn
|
conn = self.conn
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
@ -140,6 +145,7 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
self.assert_('table4' in conn.notices[3])
|
self.assert_('table4' in conn.notices[3])
|
||||||
|
|
||||||
@slow
|
@slow
|
||||||
|
@skip_if_crdb
|
||||||
def test_notices_limited(self):
|
def test_notices_limited(self):
|
||||||
conn = self.conn
|
conn = self.conn
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
@ -154,6 +160,7 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
self.assert_('table99' in conn.notices[-1], conn.notices[-1])
|
self.assert_('table99' in conn.notices[-1], conn.notices[-1])
|
||||||
|
|
||||||
@slow
|
@slow
|
||||||
|
@skip_if_crdb
|
||||||
def test_notices_deque(self):
|
def test_notices_deque(self):
|
||||||
conn = self.conn
|
conn = self.conn
|
||||||
self.conn.notices = deque()
|
self.conn.notices = deque()
|
||||||
|
@ -184,6 +191,7 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
self.assertEqual(len([n for n in conn.notices if 'CREATE TABLE' in n]),
|
self.assertEqual(len([n for n in conn.notices if 'CREATE TABLE' in n]),
|
||||||
100)
|
100)
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_notices_noappend(self):
|
def test_notices_noappend(self):
|
||||||
conn = self.conn
|
conn = self.conn
|
||||||
self.conn.notices = None # will make an error swallowes ok
|
self.conn.notices = None # will make an error swallowes ok
|
||||||
|
@ -230,6 +238,7 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
self.assert_(time.time() - t0 < 7,
|
self.assert_(time.time() - t0 < 7,
|
||||||
"something broken in concurrency")
|
"something broken in concurrency")
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_encoding_name(self):
|
def test_encoding_name(self):
|
||||||
self.conn.set_client_encoding("EUC_JP")
|
self.conn.set_client_encoding("EUC_JP")
|
||||||
# conn.encoding is 'EUCJP' now.
|
# conn.encoding is 'EUCJP' now.
|
||||||
|
@ -329,6 +338,7 @@ class ConnectionTests(ConnectingTestCase):
|
||||||
cur = conn.cursor(cursor_factory=None)
|
cur = conn.cursor(cursor_factory=None)
|
||||||
self.assertEqual(type(cur), psycopg2.extras.DictCursor)
|
self.assertEqual(type(cur), psycopg2.extras.DictCursor)
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_failed_init_status(self):
|
def test_failed_init_status(self):
|
||||||
class SubConnection(ext.connection):
|
class SubConnection(ext.connection):
|
||||||
def __init__(self, dsn):
|
def __init__(self, dsn):
|
||||||
|
@ -563,6 +573,12 @@ class IsolationLevelsTestCase(ConnectingTestCase):
|
||||||
|
|
||||||
conn = self.connect()
|
conn = self.connect()
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
if crdb_version(conn) is not None:
|
||||||
|
cur.execute("create table if not exists isolevel (id integer)")
|
||||||
|
cur.execute("truncate isolevel")
|
||||||
|
conn.commit()
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cur.execute("drop table isolevel;")
|
cur.execute("drop table isolevel;")
|
||||||
except psycopg2.ProgrammingError:
|
except psycopg2.ProgrammingError:
|
||||||
|
@ -583,6 +599,7 @@ class IsolationLevelsTestCase(ConnectingTestCase):
|
||||||
conn = self.connect()
|
conn = self.connect()
|
||||||
self.assert_(conn.encoding in ext.encodings)
|
self.assert_(conn.encoding in ext.encodings)
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_set_isolation_level(self):
|
def test_set_isolation_level(self):
|
||||||
conn = self.connect()
|
conn = self.connect()
|
||||||
curs = conn.cursor()
|
curs = conn.cursor()
|
||||||
|
@ -630,6 +647,7 @@ class IsolationLevelsTestCase(ConnectingTestCase):
|
||||||
curs.execute('show transaction_isolation;')
|
curs.execute('show transaction_isolation;')
|
||||||
self.assertEqual(curs.fetchone()[0], 'serializable')
|
self.assertEqual(curs.fetchone()[0], 'serializable')
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_set_isolation_level_default(self):
|
def test_set_isolation_level_default(self):
|
||||||
conn = self.connect()
|
conn = self.connect()
|
||||||
curs = conn.cursor()
|
curs = conn.cursor()
|
||||||
|
@ -704,6 +722,7 @@ class IsolationLevelsTestCase(ConnectingTestCase):
|
||||||
cur1.execute("select count(*) from isolevel;")
|
cur1.execute("select count(*) from isolevel;")
|
||||||
self.assertEqual(1, cur1.fetchone()[0])
|
self.assertEqual(1, cur1.fetchone()[0])
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_isolation_level_read_committed(self):
|
def test_isolation_level_read_committed(self):
|
||||||
cnn1 = self.connect()
|
cnn1 = self.connect()
|
||||||
cnn2 = self.connect()
|
cnn2 = self.connect()
|
||||||
|
@ -730,6 +749,7 @@ class IsolationLevelsTestCase(ConnectingTestCase):
|
||||||
cur1.execute("select count(*) from isolevel;")
|
cur1.execute("select count(*) from isolevel;")
|
||||||
self.assertEqual(2, cur1.fetchone()[0])
|
self.assertEqual(2, cur1.fetchone()[0])
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_isolation_level_serializable(self):
|
def test_isolation_level_serializable(self):
|
||||||
cnn1 = self.connect()
|
cnn1 = self.connect()
|
||||||
cnn2 = self.connect()
|
cnn2 = self.connect()
|
||||||
|
@ -767,6 +787,7 @@ class IsolationLevelsTestCase(ConnectingTestCase):
|
||||||
self.assertRaises(psycopg2.InterfaceError,
|
self.assertRaises(psycopg2.InterfaceError,
|
||||||
cnn.set_isolation_level, 1)
|
cnn.set_isolation_level, 1)
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_setattr_isolation_level_int(self):
|
def test_setattr_isolation_level_int(self):
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
self.conn.isolation_level = ext.ISOLATION_LEVEL_SERIALIZABLE
|
self.conn.isolation_level = ext.ISOLATION_LEVEL_SERIALIZABLE
|
||||||
|
@ -815,6 +836,7 @@ class IsolationLevelsTestCase(ConnectingTestCase):
|
||||||
cur.execute("SHOW default_transaction_isolation;")
|
cur.execute("SHOW default_transaction_isolation;")
|
||||||
self.assertEqual(cur.fetchone()[0], isol)
|
self.assertEqual(cur.fetchone()[0], isol)
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_setattr_isolation_level_str(self):
|
def test_setattr_isolation_level_str(self):
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
self.conn.isolation_level = "serializable"
|
self.conn.isolation_level = "serializable"
|
||||||
|
@ -911,6 +933,13 @@ class ConnectionTwoPhaseTests(ConnectingTestCase):
|
||||||
def make_test_table(self):
|
def make_test_table(self):
|
||||||
cnn = self.connect()
|
cnn = self.connect()
|
||||||
cur = cnn.cursor()
|
cur = cnn.cursor()
|
||||||
|
if crdb_version(cnn) is not None:
|
||||||
|
cur.execute("CREATE TABLE IF NOT EXISTS test_tpc (data text)")
|
||||||
|
cur.execute("TRUNCATE test_tpc")
|
||||||
|
cnn.commit()
|
||||||
|
cnn.close()
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cur.execute("DROP TABLE test_tpc;")
|
cur.execute("DROP TABLE test_tpc;")
|
||||||
except psycopg2.ProgrammingError:
|
except psycopg2.ProgrammingError:
|
||||||
|
@ -1244,6 +1273,7 @@ class ConnectionTwoPhaseTests(ConnectingTestCase):
|
||||||
self.assertEqual(None, xid.bqual)
|
self.assertEqual(None, xid.bqual)
|
||||||
|
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
class TransactionControlTests(ConnectingTestCase):
|
class TransactionControlTests(ConnectingTestCase):
|
||||||
def test_closed(self):
|
def test_closed(self):
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
|
@ -1672,6 +1702,7 @@ class PasswordLeakTestCase(ConnectingTestCase):
|
||||||
# the password away
|
# the password away
|
||||||
PasswordLeakTestCase.dsn = self.dsn
|
PasswordLeakTestCase.dsn = self.dsn
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_leak(self):
|
def test_leak(self):
|
||||||
self.assertRaises(psycopg2.DatabaseError,
|
self.assertRaises(psycopg2.DatabaseError,
|
||||||
self.GrassingConnection, "dbname=nosuch password=whateva")
|
self.GrassingConnection, "dbname=nosuch password=whateva")
|
||||||
|
@ -1857,6 +1888,7 @@ class TestConnectionInfo(ConnectingTestCase):
|
||||||
self.assert_(self.conn.info.socket >= 0)
|
self.assert_(self.conn.info.socket >= 0)
|
||||||
self.assert_(self.bconn.info.socket < 0)
|
self.assert_(self.bconn.info.socket < 0)
|
||||||
|
|
||||||
|
@skip_if_crdb
|
||||||
def test_backend_pid(self):
|
def test_backend_pid(self):
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -248,6 +248,9 @@ def skip_if_tpc_disabled(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def skip_if_tpc_disabled_(self):
|
def skip_if_tpc_disabled_(self):
|
||||||
cnn = self.connect()
|
cnn = self.connect()
|
||||||
|
if crdb_version(cnn):
|
||||||
|
self.skipTest("two phase transction not supported on CockroachDB")
|
||||||
|
|
||||||
cur = cnn.cursor()
|
cur = cnn.cursor()
|
||||||
try:
|
try:
|
||||||
cur.execute("SHOW max_prepared_transactions;")
|
cur.execute("SHOW max_prepared_transactions;")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user