Changeset: e18e5ac9afce for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e18e5ac9afce Modified Files: sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.py sql/test/remote/Tests/ssbm.SQL.py sql/test/testdb-reload/Tests/reload.py sql/test/wlcr/Tests/wlc01.py sql/test/wlcr/Tests/wlc100.py sql/test/wlcr/Tests/wlc20.py sql/test/wlcr/Tests/wlc21.py sql/test/wlcr/Tests/wlc30.py sql/test/wlcr/Tests/wlc40.py sql/test/wlcr/Tests/wlc50.py sql/test/wlcr/Tests/wlc70.py sql/test/wlcr/Tests/wlr01.py sql/test/wlcr/Tests/wlr100.py sql/test/wlcr/Tests/wlr20.py sql/test/wlcr/Tests/wlr30.py sql/test/wlcr/Tests/wlr40.py sql/test/wlcr/Tests/wlr50.py sql/test/wlcr/Tests/wlr70.py testing/process.py Branch: Aug2018 Log Message:
Make it easier for a call to process.client to specify the server. A new keyword argument `server' exists which can be assigned the server instance to which the client is to connect. diffs (truncated from 439 to 300 lines): diff --git a/sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.py b/sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.py --- a/sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.py +++ b/sql/test/BugTracker-2011/Tests/interrupted-initialization.Bug-2875.py @@ -35,7 +35,7 @@ c = process.client(lang = 'sqldump', stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE, - dbname = dbname) + server = s) out, err = c.communicate() sys.stdout.write(out) sys.stderr.write(err) diff --git a/sql/test/remote/Tests/ssbm.SQL.py b/sql/test/remote/Tests/ssbm.SQL.py --- a/sql/test/remote/Tests/ssbm.SQL.py +++ b/sql/test/remote/Tests/ssbm.SQL.py @@ -203,7 +203,7 @@ queries = glob.glob(os.path.join(ssbmpat queries.sort() for q in queries: print('# Running Q %s' % os.path.basename(q).replace('.sql','')) - mc = process.client('sql', stdin=open(q), dbname='master', host='localhost', port=masterport, stdout=process.PIPE, stderr=process.PIPE, log=1) + mc = process.client('sql', server=masterproc, stdin=open(q), stdout=process.PIPE, stderr=process.PIPE, log=1) out, err = mc.communicate() sys.stdout.write(out) sys.stderr.write(err) diff --git a/sql/test/testdb-reload/Tests/reload.py b/sql/test/testdb-reload/Tests/reload.py --- a/sql/test/testdb-reload/Tests/reload.py +++ b/sql/test/testdb-reload/Tests/reload.py @@ -35,6 +35,7 @@ s1 = process.server(stdin=process.PIPE, stderr=process.PIPE) # load data into the first server's database c1 = process.client(lang='sql', + server=s1, args=[os.path.join(tstsrcdir, os.pardir, os.pardir, 'testdb', 'Tests', 'load.sql')], stdin=process.PIPE, stdout=process.PIPE, @@ -48,13 +49,13 @@ s2 = process.server(dbname=tstdb2, stderr=process.PIPE) # dump the first server's database d1 = process.client(lang='sqldump', + server=s1, stdin=process.PIPE, stdout='PIPE', stderr=process.PIPE) # and pipe it straight into the second server c2 = process.client(lang='sql', - dbname=tstdb2, - port=port2, + server=s2, stdin=d1.stdout, stdout=process.PIPE, stderr=process.PIPE) @@ -67,8 +68,7 @@ sys.stdout.write(s1out) sys.stderr.write(s1err) # dump the second server's database d2 = process.client(lang='sqldump', - dbname=tstdb2, - port=port2) + server=s2) d2out, d2err = d2.communicate() s2out, s2err = s2.communicate() sys.stdout.write(s2out) diff --git a/sql/test/wlcr/Tests/wlc01.py b/sql/test/wlcr/Tests/wlc01.py --- a/sql/test/wlcr/Tests/wlc01.py +++ b/sql/test/wlcr/Tests/wlc01.py @@ -19,7 +19,7 @@ dbnameclone = tstdb + '-clone' s = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = s, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ call masterbeat(0); diff --git a/sql/test/wlcr/Tests/wlc100.py b/sql/test/wlcr/Tests/wlc100.py --- a/sql/test/wlcr/Tests/wlc100.py +++ b/sql/test/wlcr/Tests/wlc100.py @@ -17,7 +17,7 @@ dbname = tstdb s = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = s, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ call stopmaster(); diff --git a/sql/test/wlcr/Tests/wlc20.py b/sql/test/wlcr/Tests/wlc20.py --- a/sql/test/wlcr/Tests/wlc20.py +++ b/sql/test/wlcr/Tests/wlc20.py @@ -17,7 +17,7 @@ dbname = tstdb s = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = s, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ insert into tmp values(3,'blah'),(4,'bloh'); diff --git a/sql/test/wlcr/Tests/wlc21.py b/sql/test/wlcr/Tests/wlc21.py --- a/sql/test/wlcr/Tests/wlc21.py +++ b/sql/test/wlcr/Tests/wlc21.py @@ -17,7 +17,7 @@ dbname = tstdb s = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = s, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ insert into tmp values(5,'red'),(6,'fox'); diff --git a/sql/test/wlcr/Tests/wlc30.py b/sql/test/wlcr/Tests/wlc30.py --- a/sql/test/wlcr/Tests/wlc30.py +++ b/sql/test/wlcr/Tests/wlc30.py @@ -17,7 +17,7 @@ dbname = tstdb s = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = s, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ update tmp set i = 3 where i = 1; diff --git a/sql/test/wlcr/Tests/wlc40.py b/sql/test/wlcr/Tests/wlc40.py --- a/sql/test/wlcr/Tests/wlc40.py +++ b/sql/test/wlcr/Tests/wlc40.py @@ -17,7 +17,7 @@ dbname = tstdb s = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = s, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ select * from tmp; diff --git a/sql/test/wlcr/Tests/wlc50.py b/sql/test/wlcr/Tests/wlc50.py --- a/sql/test/wlcr/Tests/wlc50.py +++ b/sql/test/wlcr/Tests/wlc50.py @@ -17,7 +17,7 @@ dbname = tstdb s = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = s, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ delete from tmp; diff --git a/sql/test/wlcr/Tests/wlc70.py b/sql/test/wlcr/Tests/wlc70.py --- a/sql/test/wlcr/Tests/wlc70.py +++ b/sql/test/wlcr/Tests/wlc70.py @@ -19,7 +19,7 @@ dbnameclone = tstdb + '-clone' s = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = s, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) #continue logging cout, cerr = c.communicate('''\ diff --git a/sql/test/wlcr/Tests/wlr01.py b/sql/test/wlcr/Tests/wlr01.py --- a/sql/test/wlcr/Tests/wlr01.py +++ b/sql/test/wlcr/Tests/wlr01.py @@ -28,7 +28,7 @@ dbnameclone = tstdb + '-clone' #master = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) slave = process.server(dbname = dbnameclone, mapiport = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbnameclone, port = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = slave, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ call replicate('%s',1); diff --git a/sql/test/wlcr/Tests/wlr100.py b/sql/test/wlcr/Tests/wlr100.py --- a/sql/test/wlcr/Tests/wlr100.py +++ b/sql/test/wlcr/Tests/wlr100.py @@ -28,7 +28,7 @@ dbnameclone = tstdb + '-clone' #master = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) slave = process.server(dbname = dbnameclone, mapiport = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbnameclone, port = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = slave, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ call replicate(); diff --git a/sql/test/wlcr/Tests/wlr20.py b/sql/test/wlcr/Tests/wlr20.py --- a/sql/test/wlcr/Tests/wlr20.py +++ b/sql/test/wlcr/Tests/wlr20.py @@ -28,7 +28,7 @@ dbnameclone = tstdb + '-clone' # master = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) slave = process.server(dbname = dbnameclone, mapiport = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbnameclone, port = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = slave, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) #two step roll forward, where first step shouldn't do anything because already in previous test cout, cerr = c.communicate('''\ diff --git a/sql/test/wlcr/Tests/wlr30.py b/sql/test/wlcr/Tests/wlr30.py --- a/sql/test/wlcr/Tests/wlr30.py +++ b/sql/test/wlcr/Tests/wlr30.py @@ -28,7 +28,7 @@ dbnameclone = tstdb + '-clone' #master = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) slave = process.server(dbname = dbnameclone, mapiport = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbnameclone, port = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = slave, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ select * from tmp; diff --git a/sql/test/wlcr/Tests/wlr40.py b/sql/test/wlcr/Tests/wlr40.py --- a/sql/test/wlcr/Tests/wlr40.py +++ b/sql/test/wlcr/Tests/wlr40.py @@ -28,7 +28,7 @@ dbnameclone = tstdb + '-clone' #master = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) slave = process.server(dbname = dbnameclone, mapiport = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbnameclone, port = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = slave, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) # be aware that the replication thread may be running behind # For testing we need to wait for it. diff --git a/sql/test/wlcr/Tests/wlr50.py b/sql/test/wlcr/Tests/wlr50.py --- a/sql/test/wlcr/Tests/wlr50.py +++ b/sql/test/wlcr/Tests/wlr50.py @@ -28,7 +28,7 @@ dbnameclone = tstdb + '-clone' #master = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) slave = process.server(dbname = dbnameclone, mapiport = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbnameclone, port = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = slave, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ call replicate(); diff --git a/sql/test/wlcr/Tests/wlr70.py b/sql/test/wlcr/Tests/wlr70.py --- a/sql/test/wlcr/Tests/wlr70.py +++ b/sql/test/wlcr/Tests/wlr70.py @@ -28,7 +28,7 @@ dbnameclone = tstdb + '-clone' #master = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) slave = process.server(dbname = dbnameclone, mapiport = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) -c = process.client('sql', dbname = dbnameclone, port = cloneport, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) +c = process.client('sql', server = slave, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) cout, cerr = c.communicate('''\ call replicate(now()); diff --git a/testing/process.py b/testing/process.py --- a/testing/process.py +++ b/testing/process.py @@ -67,7 +67,7 @@ def _delfiles(): atexit.register(_delfiles) class _BufferedPipe: - def __init__(self, fd, waitfor = None, skip = None): + def __init__(self, fd, waitfor=None, skip=None): self._pipe = fd self._queue = queue.Queue() self._eof = False @@ -76,8 +76,8 @@ class _BufferedPipe: self._wfq = queue.Queue() else: self._wfq = None - self._thread = threading.Thread(target = self._readerthread, - args = (fd, self._queue, waitfor, self._wfq, skip)) + self._thread = threading.Thread(target=self._readerthread, + args=(fd, self._queue, waitfor, self._wfq, skip)) self._thread.setDaemon(True) self._thread.start() @@ -162,7 +162,7 @@ class _BufferedPipe: self._thread.join() self._thread = None - def read(self, size = -1): + def read(self, size=-1): if self._eof: return self._empty if size < 0: @@ -186,7 +186,7 @@ class _BufferedPipe: break # EOF return self._empty.join(ret) - def readline(self, size = -1): + def readline(self, size=-1): ret = [] while size != 0: c = self.read(1) @@ -212,7 +212,7 @@ class Popen(subprocess.Popen): pass return ret - def communicate(self, input = None): + def communicate(self, input=None): # since we always use threads for stdout/stderr, we can just read() stdout = None stderr = None @@ -232,11 +232,11 @@ class Popen(subprocess.Popen): self.wait() return stdout, stderr -def client(lang, args = [], stdin = None, stdout = None, stderr = None, - port = os.getenv('MAPIPORT'), dbname = os.getenv('TSTDB'), host = None, - user = 'monetdb', passwd = 'monetdb', log = False, - interactive = None, echo = None, format = None, - input = None, communicate = False, universal_newlines = True): _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list