Changeset: 1554535c780d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1554535c780d
Added Files:
sql/test/2025/Tests/SingleServer
Modified Files:
sql/backends/monet5/Tests/persist_unlogged.SQL.py
sql/test/BugTracker-2009/Tests/create_on_ro_db_crash.SF-2830238.SQL.py
sql/test/BugTracker-2009/Tests/lost_update.SF-2790020.SQL.py
sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.SQL.py
sql/test/BugTracker-2012/Tests/table_functions_fail_after_restart.Bug-3063.py
sql/test/BugTracker-2013/Tests/corrupt-after-restart.Bug-3282.SQL.py
sql/test/BugTracker-2014/Tests/acidity-fail.Bug-3635.py
sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py
sql/test/BugTracker-2017/Tests/shutdown.Bug-6182.SQL.py
sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py
sql/test/BugTracker-2018/Tests/remote-table-where-is-null.Bug-6601.py
sql/test/BugTracker-2018/Tests/remote-table-where-not-equal.Bug-6621.py
sql/test/BugTracker-2019/Tests/alter_table_drop_column.Bug-6749.py
sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.py
sql/test/BugTracker-2020/Tests/dbfarm-foreign-chars.Bug-7031.py
sql/test/BugTracker-2020/Tests/functions-not-persist.Bug-6819.SQL.py
sql/test/BugTracker-2020/Tests/remote-table-like.Bug-6841.py
sql/test/BugTracker-2020/Tests/table-udf-on-remote.Bug-6971.py
sql/test/BugTracker-2021/Tests/remote-join-idxs.Bug-7165.py
sql/test/BugTracker-2021/Tests/remote-table-groupby.Bug-7110.py
sql/test/BugTracker-2021/Tests/remote-table-ranges.Bug-7089.py
sql/test/BugTracker-2021/Tests/shutdown-force.Bug-7167.SQL.py
sql/test/BugTracker-2021/Tests/truncate-restart.Bug-7173.py
sql/test/BugTracker-2022/Tests/pkey-restart.Bug-7263.SQL.py
sql/test/BugTracker/Tests/mdb_starts_with_sql_debug_64.SF-1999354.SQL.py
sql/test/BugTracker/Tests/set_a_new_user_password.SF-1844050.SQL.py
sql/test/BugTracker/Tests/set_sql_debug_64__breaking_the_DB.SF-1906287.SQL.py
sql/test/SQLancer/Tests/sqlancer12.SQL.py
sql/test/Tests/hot_snapshot.py
sql/test/Tests/selective_snapshot.py
sql/test/Triggers/Tests/trigger-restart.SQL.py
sql/test/UserDump/Tests/dump.SQL.py
sql/test/UserDump/Tests/dump_with_test.SQL.py
sql/test/UserDump/Tests/dump_with_voc.SQL.py
sql/test/dict/Tests/dict03.py
sql/test/merge-partitions/Tests/mergepart23.SQL.py
sql/test/merge-partitions/Tests/mergepart29.SQL.py
sql/test/miscellaneous/Tests/unlogged.py
sql/test/mserver5-sql-readonly/Tests/mserver5-sql-readonly-table.py
sql/test/mserver5-sql-readonly/Tests/mserver5-sql-readonly-view.py
sql/test/rel-optimizers/Tests/join-merge-remote-replica.py
sql/test/rel-optimizers/Tests/local-replica-with-actual-remote.py
sql/test/rel-optimizers/Tests/remote-replica.py
sql/test/rel-optimizers/Tests/replicas-join.py
sql/test/remote/Tests/creds.SQL.py
sql/test/remote/Tests/different_user.SQL.py
sql/test/remote/Tests/invalid_creds.SQL.py
sql/test/remote/Tests/ssbm.SQL.py
sql/test/rename/Tests/rename00.SQL.py
sql/test/rename/Tests/rename11.py
sql/test/replica/Tests/replica-perms.py
sql/test/scripts/Tests/alastair_udf_mergetable_bug.py
sql/test/strimps/Tests/persisted_strimp.py
sql/test/strimps/Tests/strimps_not_like.py
sql/test/strimps/Tests/strimps_stable_counts.py
sql/test/sysmon/Tests/sys_queue_multisessions.SQL.py
sql/test/sysmon/Tests/sys_user_statistics.SQL.py
testing/Mtest.py.in
testing/malmapi.py
testing/process.py
testing/sqllogictest.py
testing/sqltest.py
Branch: Mar2025
Log Message:
Use Unix-domain sockets when available; make SQLTestCase easier to use.
SQLTestCase now accepts a `server` argument which would normally be a
process.server() instance which provides default connection information.
When used in a `with` statement, there is then usually no longer a need
to call `connect` separately, especially since SQLTestCase also accepts
`username` and `password` arguments.
diffs (truncated from 1696 to 300 lines):
diff --git a/sql/backends/monet5/Tests/persist_unlogged.SQL.py
b/sql/backends/monet5/Tests/persist_unlogged.SQL.py
--- a/sql/backends/monet5/Tests/persist_unlogged.SQL.py
+++ b/sql/backends/monet5/Tests/persist_unlogged.SQL.py
@@ -10,8 +10,7 @@ with tempfile.TemporaryDirectory() as fa
os.mkdir(os.path.join(farm_dir, 'db1'))
with process.server(mapiport='0', dbname='db1',
dbfarm=os.path.join(farm_dir, 'db1'), stdin=process.PIPE, stdout=process.PIPE,
stderr=process.PIPE) as s:
- with SQLTestCase() as tc:
- tc.connect(username="monetdb", password="monetdb", port=s.dbport,
database='db1')
+ with SQLTestCase(server=s) as tc:
tc.execute("CREATE SCHEMA put").assertSucceeded()
tc.execute("SET SCHEMA put").assertSucceeded()
tc.execute("CREATE UNLOGGED TABLE foo (x INT)").assertSucceeded()
@@ -28,8 +27,7 @@ with tempfile.TemporaryDirectory() as fa
s.communicate()
with process.server(mapiport='0', dbname='db1',
dbfarm=os.path.join(farm_dir, 'db1'), stdin=process.PIPE, stdout=process.PIPE,
stderr=process.PIPE) as s:
- with SQLTestCase() as tc:
- tc.connect(username="monetdb", password="monetdb", port=s.dbport,
database='db1')
+ with SQLTestCase(server=s) as tc:
tc.execute("SET SCHEMA put").assertSucceeded()
tc.execute("SELECT COUNT(*) FROM
foo").assertSucceeded().assertDataResultMatch([(500,)])
s.communicate()
diff --git a/sql/test/2025/Tests/SingleServer b/sql/test/2025/Tests/SingleServer
new file mode 100644
diff --git
a/sql/test/BugTracker-2009/Tests/create_on_ro_db_crash.SF-2830238.SQL.py
b/sql/test/BugTracker-2009/Tests/create_on_ro_db_crash.SF-2830238.SQL.py
--- a/sql/test/BugTracker-2009/Tests/create_on_ro_db_crash.SF-2830238.SQL.py
+++ b/sql/test/BugTracker-2009/Tests/create_on_ro_db_crash.SF-2830238.SQL.py
@@ -19,7 +19,6 @@ with tempfile.TemporaryDirectory() as fa
args=["--set", "gdk_readonly=yes"],
stdin=process.PIPE,
stdout=process.PIPE, stderr=process.PIPE) as s:
- with SQLTestCase() as tc:
- tc.connect(username="monetdb", password="monetdb", port=s.dbport,
database='db1')
+ with SQLTestCase(server=s) as tc:
tc.execute("create table t2 (a
int);").assertFailed(err_message="Schema statements cannot be executed on a
readonly database.")
s.communicate()
diff --git a/sql/test/BugTracker-2009/Tests/lost_update.SF-2790020.SQL.py
b/sql/test/BugTracker-2009/Tests/lost_update.SF-2790020.SQL.py
--- a/sql/test/BugTracker-2009/Tests/lost_update.SF-2790020.SQL.py
+++ b/sql/test/BugTracker-2009/Tests/lost_update.SF-2790020.SQL.py
@@ -19,15 +19,13 @@ class server(process.server):
with tempfile.TemporaryDirectory() as farm_dir:
os.mkdir(os.path.join(farm_dir, 'db1'))
with server() as s:
- with SQLTestCase() as tc:
- tc.connect(username="monetdb", password="monetdb", port=s.dbport,
database="db1")
+ with SQLTestCase(server=s) as tc:
tc.execute("create table lost_update_t2 (a
int);").assertSucceeded()
tc.execute("insert into lost_update_t2 values
(1);").assertSucceeded().assertRowCount(1)
tc.execute("update lost_update_t2 set a =
2;").assertSucceeded().assertRowCount(1)
s.server_stop()
with server() as s:
- with SQLTestCase() as tc:
- tc.connect(username="monetdb", password="monetdb", port=s.dbport,
database="db1")
+ with SQLTestCase(server=s) as tc:
tc.execute("update lost_update_t2 set a =
3;").assertSucceeded().assertRowCount(1)
tc.execute("create table lost_update_t1 (a
int);").assertSucceeded()
tc.execute("insert into lost_update_t1 values
(1);").assertSucceeded().assertRowCount(1)
@@ -46,13 +44,11 @@ with tempfile.TemporaryDirectory() as fa
tc.execute("call sys.flush_log();").assertSucceeded()
s.server_stop()
with server() as s:
- with SQLTestCase() as tc:
- tc.connect(username="monetdb", password="monetdb", port=s.dbport,
database="db1")
+ with SQLTestCase(server=s) as tc:
tc.execute("select a from
lost_update_t2;").assertSucceeded().assertRowCount(1).assertDataResultMatch([(3,)])
s.server_stop()
with server() as s:
- with SQLTestCase() as tc:
- tc.connect(username="monetdb", password="monetdb", port=s.dbport,
database="db1")
+ with SQLTestCase(server=s) as tc:
tc.execute("drop table lost_update_t1;").assertSucceeded()
tc.execute("drop table lost_update_t2;").assertSucceeded()
s.server_stop()
diff --git
a/sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.SQL.py
b/sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.SQL.py
--- a/sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.SQL.py
+++ b/sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.SQL.py
@@ -16,7 +16,7 @@ with tempfile.TemporaryDirectory() as fa
dbfarm=os.path.join(farm_dir, 'db1'),
stdin=process.PIPE,
stdout=process.PIPE, stderr=process.PIPE) as s:
- client = pymonetdb.connect(database='db1', port=s.dbport,
autocommit=True)
+ client = pymonetdb.connect(database=s.usock or 'db1', port=s.dbport,
autocommit=True)
cursor = client.cursor()
cursor.execute("""
with describe_all_objects as (
diff --git
a/sql/test/BugTracker-2012/Tests/table_functions_fail_after_restart.Bug-3063.py
b/sql/test/BugTracker-2012/Tests/table_functions_fail_after_restart.Bug-3063.py
---
a/sql/test/BugTracker-2012/Tests/table_functions_fail_after_restart.Bug-3063.py
+++
b/sql/test/BugTracker-2012/Tests/table_functions_fail_after_restart.Bug-3063.py
@@ -13,7 +13,7 @@ with tempfile.TemporaryDirectory() as fa
dbfarm=os.path.join(farm_dir, 'db'),
stdin=process.PIPE, stdout=process.PIPE,
stderr=process.PIPE) as dproc:
- client1 = pymonetdb.connect(database='db', port=dproc.dbport,
autocommit=True)
+ client1 = pymonetdb.connect(database=dproc.usock or 'db',
port=dproc.dbport, autocommit=True)
cur1 = client1.cursor()
cur1.execute("""
CREATE schema ft;
@@ -31,7 +31,7 @@ with tempfile.TemporaryDirectory() as fa
dbfarm=os.path.join(farm_dir, 'db'),
stdin=process.PIPE, stdout=process.PIPE,
stderr=process.PIPE) as dproc:
- client1 = pymonetdb.connect(database='db', port=dproc.dbport,
autocommit=True)
+ client1 = pymonetdb.connect(database=dproc.usock or 'db',
port=dproc.dbport, autocommit=True)
cur1 = client1.cursor()
cur1.execute("select * from ft.func() as ftf;")
if cur1.fetchall() != [('1',)]:
diff --git
a/sql/test/BugTracker-2013/Tests/corrupt-after-restart.Bug-3282.SQL.py
b/sql/test/BugTracker-2013/Tests/corrupt-after-restart.Bug-3282.SQL.py
--- a/sql/test/BugTracker-2013/Tests/corrupt-after-restart.Bug-3282.SQL.py
+++ b/sql/test/BugTracker-2013/Tests/corrupt-after-restart.Bug-3282.SQL.py
@@ -11,7 +11,9 @@ with tempfile.TemporaryDirectory() as fa
dbfarm=os.path.join(farm_dir, 'db1'),
stdin=process.PIPE,
stdout=process.PIPE, stderr=process.PIPE) as s:
- cli = pymonetdb.connect(port=s.dbport,database='db1',autocommit=True)
+ cli = pymonetdb.connect(port=s.dbport,
+ database=s.usock or 'db1',
+ autocommit=True)
cur = cli.cursor()
cur.execute('''
start transaction;
@@ -50,7 +52,9 @@ with tempfile.TemporaryDirectory() as fa
dbfarm=os.path.join(farm_dir, 'db1'),
stdin=process.PIPE,
stdout=process.PIPE, stderr=process.PIPE) as s:
- cli = pymonetdb.connect(port=s.dbport,database='db1',autocommit=True)
+ cli = pymonetdb.connect(port=s.dbport,
+ database=s.usock or 'db1',
+ autocommit=True)
cur = cli.cursor()
cur.execute('select count(*) from table3282;')
if cur.fetchall()[0][0] != 2097152:
@@ -62,7 +66,9 @@ with tempfile.TemporaryDirectory() as fa
dbfarm=os.path.join(farm_dir, 'db1'),
stdin=process.PIPE,
stdout=process.PIPE, stderr=process.PIPE) as s:
- cli = pymonetdb.connect(port=s.dbport,database='db1',autocommit=True)
+ cli = pymonetdb.connect(port=s.dbport,
+ database=s.usock or 'db1',
+ autocommit=True)
cur = cli.cursor()
cur.execute('select count(*) from table3282;')
if cur.fetchall()[0][0] != 2097152:
diff --git a/sql/test/BugTracker-2014/Tests/acidity-fail.Bug-3635.py
b/sql/test/BugTracker-2014/Tests/acidity-fail.Bug-3635.py
--- a/sql/test/BugTracker-2014/Tests/acidity-fail.Bug-3635.py
+++ b/sql/test/BugTracker-2014/Tests/acidity-fail.Bug-3635.py
@@ -6,13 +6,13 @@ except ImportError:
from MonetDBtesting import tpymonetdb as pymonetdb
import sys, time, os
-def connect(autocommit):
- return pymonetdb.connect(database = os.getenv('TSTDB'),
- hostname = '127.0.0.1',
- port = int(os.getenv('MAPIPORT')),
- username = 'monetdb',
- password = 'monetdb',
- autocommit = autocommit)
+def connect(autocommit, srv):
+ return pymonetdb.connect(database=srv.usock or srv.dbname,
+ hostname='127.0.0.1',
+ port=srv.dbport,
+ username='monetdb',
+ password='monetdb',
+ autocommit=autocommit)
def query(conn, sql):
cur = conn.cursor()
@@ -21,10 +21,12 @@ def query(conn, sql):
cur.close()
return r
+dbname = os.getenv('TSTDB') + '_acid'
+
# no timeout since we need to kill mserver5, not the inbetween Mtimeout
-with process.server(stdin = process.PIPE, stdout = process.PIPE, stderr =
process.PIPE) as s:
+with process.server(dbname=dbname, mapiport='0', stdin=process.PIPE,
stdout=process.PIPE, stderr=process.PIPE, cleandb=True) as s:
# boring setup and schema creation stuff:
- c1 = connect(True)
+ c1 = connect(True, s)
c1.execute('create table foo (a int)')
c1.execute('create table bar (a int)')
c1.execute('insert into foo values (1),(2),(3)')
@@ -34,7 +36,7 @@ with process.server(stdin = process.PIPE
# Run 'delete from foo' with store_nr_active > 1
# This causes MonetDB to allocate a new file for foo rather than
# wiping the existing one
- c2 = connect(True)
+ c2 = connect(True, s)
c2.execute('start transaction')
c1.execute('delete from foo')
c2.execute('rollback')
@@ -55,21 +57,25 @@ with process.server(stdin = process.PIPE
if query(c1, 'select * from foo') != [(4,), (5,), (6,)]:
sys.stderr.write('Expected [(4,), (5,), (6,)]')
- s.communicate()
+ out, err = s.communicate()
c2.close()
+ print(out, end='')
+ print(err, end='', file=sys.stderr)
-with process.server(stdin = process.PIPE, stdout = process.PIPE, stderr =
process.PIPE) as t:
- c3 = connect(True)
+with process.server(dbname=dbname, mapiport='0', stdin=process.PIPE,
stdout=process.PIPE, stderr=process.PIPE) as t:
+ c3 = connect(True, t)
# This prints the wrong data. It should print exactly the same as the
# previous line: "[(4,), (5,), (6,)]" , but actually prints "[(1,),
# (2,), (3,)]"
- if query(c1, 'select * from foo') != [(4,), (5,), (6,)]:
+ if query(c3, 'select * from foo') != [(4,), (5,), (6,)]:
sys.stderr.write('Expected [(4,), (5,), (6,)]')
# cleanup
c3.execute('drop table foo')
c3.execute('drop table bar')
- t.communicate()
+ out, err = t.communicate()
c1.close()
c3.close()
+ print(out, end='')
+ print(err, end='', file=sys.stderr)
diff --git a/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py
b/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py
--- a/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py
+++ b/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.SQL.py
@@ -34,7 +34,7 @@ def worker_load(workerrec):
c = workerrec['conn'].cursor()
stable = shardtable + workerrec['tpf']
- screateq = 'create table ' + stable + ' ' +
shardedtabledefslightlydifferent;
+ screateq = f'create table {stable} {shardedtabledefslightlydifferent}'
c.execute(screateq)
c.execute(tabledata.replace("%SHARD%", stable))
@@ -45,7 +45,7 @@ with tempfile.TemporaryDirectory() as tm
with process.server(mapiport='0', dbname="master",
dbfarm=os.path.join(tmpdir, 'master'),
stdin=process.PIPE, stdout=process.PIPE) as masterproc:
- masterconn = pymonetdb.connect(database='', port=masterproc.dbport,
autocommit=True)
+ masterconn = pymonetdb.connect(database=masterproc.usock or '',
port=masterproc.dbport, autocommit=True)
try:
# setup and start workers
@@ -65,10 +65,10 @@ with tempfile.TemporaryDirectory() as tm
dbfarm=workerrec['dbfarm'],
stdin=process.PIPE,
stdout=process.PIPE)
- workerrec['port'] = workerrec['proc'].dbport
- workerrec['mapi'] =
'mapi:monetdb://localhost:{}/{}'.format(workerrec['port'], workerdbname)
- workerrec['conn'] =
pymonetdb.connect(database=workerrec['dbname'],
- port=workerrec['port'],
+ port = workerrec['proc'].dbport
+ workerrec['mapi'] =
f'mapi:monetdb://localhost:{port}/{workerdbname}'
+ workerrec['conn'] =
pymonetdb.connect(database=workerrec['proc'].usock or workerrec['dbname'],
+ port=port,
autocommit=True)
t = threading.Thread(target=worker_load, args=[workerrec])
t.start()
@@ -80,17 +80,17 @@ with tempfile.TemporaryDirectory() as tm
workerrec['loadthread'].join()
# glue everything together on the master
- mtable = 'create merge table ' + shardtable + ' ' + shardedtabledef
+ mtable = f'create merge table {shardtable} {shardedtabledef}'
c = masterconn.cursor()
c.execute(mtable)
for workerrec in workers:
- rtable = 'create remote table ' + shardtable +
workerrec['tpf'] + ' ' + shardedtabledef + ' on \'' + workerrec['mapi'] + '\''
- atable = 'alter table ' + shardtable + ' add table ' +
shardtable + workerrec['tpf'];
+ rtable = f"create remote table {shardtable}{workerrec['tpf']}
{shardedtabledef} on '{workerrec['mapi']}'"
+ atable = f'alter table {shardtable} add table
{shardtable}{workerrec["tpf"]}'
c.execute(rtable)
c.execute(atable)
try:
- c.execute("select * from " + shardtable + workers[0]['tpf'] )
+ c.execute(f"select * from {shardtable}{workers[0]['tpf']}")
if c.fetchall() != [(42,)]:
sys.stderr.write('(42,) expected')
except pymonetdb.DatabaseError as e:
diff --git a/sql/test/BugTracker-2017/Tests/shutdown.Bug-6182.SQL.py
b/sql/test/BugTracker-2017/Tests/shutdown.Bug-6182.SQL.py
--- a/sql/test/BugTracker-2017/Tests/shutdown.Bug-6182.SQL.py
+++ b/sql/test/BugTracker-2017/Tests/shutdown.Bug-6182.SQL.py
@@ -11,8 +11,7 @@ with tempfile.TemporaryDirectory() as fa
with process.server(mapiport='0', dbname='db1',
dbfarm=os.path.join(farm_dir, 'db1'),
stdin=process.PIPE,
- stdout=process.PIPE, stderr=process.PIPE) as srv:
- with SQLTestCase() as tc:
- tc.connect(username="monetdb", password="monetdb",
port=srv.dbport, database='db1')
+ stdout=process.PIPE, stderr=process.PIPE) as srv:
+ with SQLTestCase(server=srv) as tc:
tc.execute("call sys.shutdown(10);").assertSucceeded()
srv.communicate()
diff --git
a/sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py
b/sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py
---
a/sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py
+++
b/sql/test/BugTracker-2018/Tests/local_replica_table_not_detected.Bug-6620.py
@@ -15,7 +15,7 @@ with tempfile.TemporaryDirectory() as fa
dbfarm=os.path.join(farm_dir, 'node1'),
stdin=process.PIPE, stdout=process.PIPE,
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]