Changeset: 8111bc42eca5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8111bc42eca5
Modified Files:
        sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.SQL.py
        sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.out
        sql/test/BugTracker-2011/Tests/user_create_temp_table.Bug-2916.SQL.py
        
sql/test/BugTracker-2011/Tests/user_create_temp_table.Bug-2916.stable.err
        
sql/test/BugTracker-2011/Tests/user_create_temp_table.Bug-2916.stable.out
Branch: mtest
Log Message:

Converted Python tests into pymonetdb


diffs (truncated from 591 to 300 lines):

diff --git a/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.SQL.py 
b/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.SQL.py
--- a/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.SQL.py
+++ b/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.SQL.py
@@ -1,66 +1,56 @@
-import os, sys
-try:
-    from MonetDBtesting import process
-except ImportError:
-    import process
+import sys, os, pymonetdb, threading
+
+db = os.getenv("TSTDB")
+port = int(os.getenv("MAPIPORT"))
 
-with process.client('sql',
-                   args=['-s', '''CREATE USER "testuser" WITH ENCRYPTED 
PASSWORD 
\'e9e633097ab9ceb3e48ec3f70ee2beba41d05d5420efee5da85f97d97005727587fda33ef4ff2322088f4c79e8133cc9cd9f3512f4d3a303cbdb5bc585415a00\'
 NAME \'Test User\' SCHEMA "sys";
+client = pymonetdb.connect(database=db, port=port, autocommit=True)
+cursor = client.cursor()
+cursor.execute("""
+CREATE USER "testuser" WITH ENCRYPTED PASSWORD 
\'e9e633097ab9ceb3e48ec3f70ee2beba41d05d5420efee5da85f97d97005727587fda33ef4ff2322088f4c79e8133cc9cd9f3512f4d3a303cbdb5bc585415a00\'
 NAME \'Test User\' SCHEMA "sys";
 CREATE SCHEMA "testschema" AUTHORIZATION "testuser";
-ALTER USER "testuser" SET SCHEMA "testschema"'''],
-                   stdout=process.PIPE,
-                   stderr=process.PIPE) as c:
-    out, err = c.communicate()
-    if out:
-        sys.stdout.write(out)
-    if err:
-        sys.stderr.write(err)
+ALTER USER "testuser" SET SCHEMA "testschema"
+""")
+cursor.close()
+client.close()
+
+client = pymonetdb.connect(database=db, port=port, autocommit=True, 
username='testuser', password='testpassword')
+cursor = client.cursor()
+cursor.execute('CREATE FUNCTION rad(d DOUBLE) RETURNS DOUBLE BEGIN RETURN d * 
PI() / 180; END')
+cursor.close()
+client.close()
 
-with process.client('sql',
-                   args=['-s', 'CREATE FUNCTION rad(d DOUBLE) RETURNS DOUBLE 
BEGIN RETURN d * PI() / 180; END'],
-                   user='testuser', passwd='testpassword',
-                   stdout=process.PIPE,
-                   stderr=process.PIPE) as c:
-    out, err = c.communicate()
-    if out:
-        sys.stdout.write(out)
-    if err:
-        sys.stderr.write(err)
+class ConnectionClient(threading.Thread):
+    def __init__(self):
+        self._conn = pymonetdb.connect(database=db, port=port, 
autocommit=True, username='testuser', password='testpassword')
+        self._cursor = self._conn.cursor()
+        threading.Thread.__init__(self)
+
+    def run(self):
+        self._cursor.execute('SELECT rad(55.81689)')
+        self._cursor.close()
+        self._conn.close()
 
 clients = []
 for i in range(50):
-    c = process.client('sql', args=['-s', 'SELECT rad(55.81689)'],
-                       user='testuser', passwd='testpassword',
-                       stdout=process.PIPE, stderr=process.PIPE)
+    c = ConnectionClient()
+    c.start()
     clients.append(c)
 
 for c in clients:
-    out, err = c.communicate()
-    if out:
-        sys.stdout.write(out)
-    if err:
-        sys.stderr.write(err)
+    c.join()
+
+client = pymonetdb.connect(database=db, port=port, autocommit=True, 
username='testuser', password='testpassword')
+cursor = client.cursor()
+cursor.execute('DROP FUNCTION rad')
+cursor.close()
+client.close()
 
-with process.client('sql',
-                    args=['-s', 'DROP FUNCTION rad'],
-                    user='testuser', passwd='testpassword',
-                    stdout=process.PIPE,
-                    stderr=process.PIPE) as c:
-    out, err = c.communicate()
-    if out:
-        sys.stdout.write(out)
-    if err:
-        sys.stderr.write(err)
-
-# undo damage
-with process.client('sql',
-                    args=['-s', '''ALTER USER "testuser" SET SCHEMA "sys";
+client = pymonetdb.connect(database=db, autocommit=True, port=port)
+cursor = client.cursor()
+cursor.execute("""
+ALTER USER "testuser" SET SCHEMA "sys";
 DROP SCHEMA "testschema";
-DROP USER "testuser"'''],
-                    stdout=process.PIPE,
-                    stderr=process.PIPE) as c:
-    out, err = c.communicate()
-    if out:
-        sys.stdout.write(out)
-    if err:
-        sys.stderr.write(err)
+DROP USER "testuser"
+""")
+cursor.close()
+client.close()
diff --git 
a/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.out 
b/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.out
--- a/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.out
+++ b/sql/test/BugTracker-2011/Tests/many-connects-cache.Bug-2904.stable.out
@@ -17,353 +17,7 @@ stdout of test 'many-connects-cache.Bug-
 # MonetDB/GIS module loaded
 # MonetDB/SQL module loaded
 
-# SQL catalog created, loading sql scripts once
-# loading sql script: 10_math.sql
-# loading sql script: 11_times.sql
-# loading sql script: 12_url.sql
-# loading sql script: 13_date.sql
-# loading sql script: 14_inet.sql
-# loading sql script: 15_history.sql
-# loading sql script: 16_tracelog.sql
-# loading sql script: 17_compress.sql
-# loading sql script: 18_dictionary.sql
-# loading sql script: 19_cluster.sql
-# loading sql script: 20_vacuum.sql
-# loading sql script: 21_dependency_functions.sql
-# loading sql script: 22_clients.sql
-# loading sql script: 23_skyserver.sql
-# loading sql script: 24_zorder.sql
-# loading sql script: 25_debug.sql
-# loading sql script: 40_geom.sql
-# loading sql script: 80_udf.sql
-# loading sql script: 99_system.sql
-
-# 14:18:16 >  
-# 14:18:16 >  "/usr/bin/python" "many-connects-cache.Bug-2904.SQL.py" 
"many-connects-cache.Bug-2904"
-# 14:18:16 >  
+# 10:26:44 >  
+# 10:26:44 >  "Done."
+# 10:26:44 >  
 
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
-#SELECT rad(55.81689)
-% . # table_name
-% %1 # name
-% double # type
-% 24 # length
-[ 0.9741885087 ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to