Skip to content

Commit ef8cfd9

Browse files
test: fix compatibility with Tarantool master
New Tarantool 3.0 patch introduces a breaking change [1]. This patch adds a compatibility layer to test instance. It was decided to explicitly set SEQSCAN in our tests and change session options for DBAPI tests. 1. tarantool/tarantool#8602
1 parent b073ae6 commit ef8cfd9

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

Diff for: test/suites/box.lua

+6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
#!/usr/bin/env tarantool
22

3+
local is_compat, compat = pcall(require, "compat")
34
local os = require('os')
45

56
local admin_listen = os.getenv("ADMIN")
67
local primary_listen = os.getenv("LISTEN")
78
local auth_type = os.getenv("AUTH_TYPE")
89

10+
local SQL_SEQ_SCAN_DEFAULT = os.getenv("SQL_SEQ_SCAN_DEFAULT")
11+
if is_compat and SQL_SEQ_SCAN_DEFAULT then
12+
compat.sql_seq_scan_default = SQL_SEQ_SCAN_DEFAULT
13+
end
14+
915
require('console').listen(admin_listen)
1016
box.cfg{
1117
listen = primary_listen,

Diff for: test/suites/lib/tarantool_server.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ def __new__(cls,
189189
ssl_password=None,
190190
ssl_password_file=None,
191191
create_unix_socket=False,
192-
auth_type=None):
192+
auth_type=None,
193+
sql_seq_scan_default=None):
193194
# pylint: disable=unused-argument
194195

195196
if os.name == 'nt':
@@ -205,7 +206,8 @@ def __init__(self,
205206
ssl_password=None,
206207
ssl_password_file=None,
207208
create_unix_socket=False,
208-
auth_type=None):
209+
auth_type=None,
210+
sql_seq_scan_default=None):
209211
# pylint: disable=consider-using-with
210212

211213
os.popen('ulimit -c unlimited').close()
@@ -235,6 +237,7 @@ def __init__(self,
235237
self.ssl_password = ssl_password
236238
self.ssl_password_file = ssl_password_file
237239
self.auth_type = auth_type
240+
self.sql_seq_scan_default = sql_seq_scan_default
238241
self._binary = None
239242
self._log_des = None
240243

@@ -289,6 +292,8 @@ def generate_configuration(self):
289292
os.putenv("AUTH_TYPE", self.auth_type)
290293
else:
291294
os.putenv("AUTH_TYPE", "")
295+
if self.sql_seq_scan_default is not None:
296+
os.putenv("SQL_SEQ_SCAN_DEFAULT", self.sql_seq_scan_default)
292297

293298
def prepare_args(self):
294299
"""

Diff for: test/suites/test_dbapi.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ class TestSuiteDBAPI(dbapi20.DatabaseAPI20Test):
2727
def setUpClass(cls):
2828
print(' DBAPI '.center(70, '='), file=sys.stderr)
2929
print('-' * 70, file=sys.stderr)
30-
cls.srv = TarantoolServer()
30+
# Select scans are not allowed with compat.sql_seq_scan_default = "new",
31+
# but tests create cursors with fullscan.
32+
cls.srv = TarantoolServer(sql_seq_scan_default="old")
3133
cls.srv.script = 'test/suites/box.lua'
3234
cls.srv.start()
3335
cls.con = tarantool.Connection(cls.srv.host, cls.srv.args['primary'])

Diff for: test/suites/test_schema.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,21 @@ def test_07_schema_version_update(self):
454454
def _run_test_schema_fetch_disable(self, con, mode=None):
455455
# Enable SQL test case for tarantool 2.* and higher.
456456
if int(str(self.srv.admin.tnt_version)[0]) > 1:
457-
self.testing_methods['available']['execute'] = {
458-
'input': ['SELECT * FROM "tester"'],
459-
'output': [[1, None]],
460-
}
457+
if self.srv.admin.tnt_version >= pkg_resources.parse_version('2.11.0'):
458+
# SEQSCAN keyword is explicitly allowing to use seqscan
459+
# https://github.com/tarantool/tarantool/commit/77648827326ad268ec0ffbcd620c2371b65ef2b4
460+
# It was introduced in 2.11.0-rc1. If compat.sql_seq_scan_default
461+
# set to "new" (default value since 3.0), returns error
462+
# if trying to scan without keyword.
463+
self.testing_methods['available']['execute'] = {
464+
'input': ['SELECT * FROM SEQSCAN "tester"'],
465+
'output': [[1, None]],
466+
}
467+
else:
468+
self.testing_methods['available']['execute'] = {
469+
'input': ['SELECT * FROM "tester"'],
470+
'output': [[1, None]],
471+
}
461472

462473
# Testing the schemaless connection with methods
463474
# that should NOT be available.

0 commit comments

Comments
 (0)