Changeset: 455157fc9677 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/455157fc9677
Modified Files:
        testing/Mtest.py.in
        testing/malmapi.py
        testing/process.py
Branch: Mar2025
Log Message:

New attempt: Try using UNIX domain sockets when testing.
The difference with the previous attempt is that now we have also fixed
the malmapi.connect code to work with a monetdb:///socketfile URL in the
database argument.


diffs (129 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1258,6 +1258,8 @@ def PerformDir(env, testdir, testlist, t
                     except:
                         pass
                     environ['MAPIPORT'] = pSrvr.port
+                    if pSrvr.usock is not None:
+                        environ['MAPIUSOCK'] = pSrvr.usock
                     SetExecEnv(env['exe'], pSrvr.port, verbosity > 1, environ)
                 if global_timeout and start_time + global_timeout < 
time.time():
                     if not testweb:
@@ -2885,6 +2887,7 @@ class ServerClass:
 
         port = None
         self.port = None
+        self.usock = None
         if self.pollfile:
             while True:
                 proc.poll()
@@ -2913,9 +2916,14 @@ class ServerClass:
                     return
                 time.sleep(0.1)
             with open(os.path.join(os.path.split(self.pollfile)[0], '.conn')) 
as fil:
-                connurl = fil.read()
-            res = mapiportre.search(connurl)
-            port = res.group('port')
+                connurls = fil.readlines()
+            for connurl in connurls:
+                connurl = connurl.strip()
+                res = mapiportre.search(connurl)
+                if res is not None:
+                    port = res.group('port')
+                elif 'monetdb:///' in connurl:
+                    self.usock = connurl
         else:
             loadedseen = False
             endtime = time.time() + 30
@@ -3130,7 +3138,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
                                         password=passwd or 'monetdb',
                                         hostname=HOST,
                                         port=int(pSrvr.port),
-                                        database=TSTDB,
+                                        database=TSTDB if pSrvr.usock is None 
else pSrvr.usock,
                                         language='sql',
                                         timeout=TIMEOUT,
                                         alltests=CONDITIONALS['KNOWNFAIL'])
@@ -3165,7 +3173,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
                                     password=passwd or 'monetdb',
                                     hostname=HOST,
                                     port=int(pSrvr.port),
-                                    database=TSTDB,
+                                    database=TSTDB if pSrvr.usock is None else 
pSrvr.usock,
                                     language=lang,
                                     timeout=TIMEOUT,
                                     alltests=CONDITIONALS['KNOWNFAIL'])
@@ -3202,6 +3210,8 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
                                 defines.append(f'TSTSRCBASE={TSTSRCBASE}')
                                 defines.append(f'TSTDB={TSTDB}')
                                 defines.append(f'MAPIPORT={pSrvr.port}')
+                                if pSrvr.usock is not None:
+                                    defines.append(f'MAPIUSOCK={pSrvr.usock}')
                             try:
                                 sql.parse(os.path.join(TSTTRGDIR, testfile), 
approve=open(os.path.join(TSTTRGDIR, TST+'.newtest'),'w') if approve else None, 
defines=defines)
                             except KeyboardInterrupt:
@@ -3244,9 +3254,11 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
                 for i in range(len(Clnt)):
                     Clnt[i] = Clnt[i].replace('${PORT}', pSrvr.port)
                 if user:
-                    Clnt.append('-u%s' % user)
+                    Clnt.append(f'-u{user}')
                 if passwd:
-                    Clnt.append('-P%s' % passwd)
+                    Clnt.append(f'-P{passwd}')
+                if pSrvr.usock:
+                    Clnt.append(f'-d{pSrvr.usock}')
                 for f in TSTs:
                     returncode = RunIt(Clnt, True, 
openutf8(os.path.join(TSTTRGDIR, f)), ClntOut, ClntErr, TIMEOUT, pSrvr, 
TSTTRGDIR, environ)
                     if returncode:
diff --git a/testing/malmapi.py b/testing/malmapi.py
--- a/testing/malmapi.py
+++ b/testing/malmapi.py
@@ -104,6 +104,12 @@ class Connection(object):
         unix_socket is used if hostname is not defined.
         """
 
+        if database.startswith('monetdb:///'):
+            unix_socket = database[10:]
+            hostname = database = None
+        elif database.startswith('mapi:monetdb:///'):
+            unix_socket = database[15:]
+            hostname = database = None
         if hostname and hostname.startswith('/') and not unix_socket:
             unix_socket = '%s/.s.monetdb.%d' % (hostname, port)
             hostname = None
diff --git a/testing/process.py b/testing/process.py
--- a/testing/process.py
+++ b/testing/process.py
@@ -376,10 +376,13 @@ class client(Popen):
         # if server instance is specified, it provides defaults for
         # database name and port
         if server is not None:
-            if port is None:
-                port = server.dbport
-            if dbname is None:
-                dbname = server.dbname
+            if port is None and dbname is None and hasattr(server, 'usock') 
and server.usock is not None:
+                dbname = server.usock
+            else:
+                if port is None:
+                    port = server.dbport
+                if dbname is None:
+                    dbname = server.dbname
 
         if port is not None:
             for i in range(len(cmd)):
@@ -392,7 +395,11 @@ class client(Popen):
                 if port:
                     raise
         if dbname is None:
-            dbname = os.getenv('TSTDB')
+            usock = os.getenv('MAPIUSOCK')
+            if usock is None:
+                dbname = os.getenv('TSTDB')
+            else:
+                dbname = usock
         if dbname is not None and dbname:
             cmd.append('--database=%s' % dbname)
         if user is not None or passwd is not None:
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to