mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
* Adding more LIVE VIEW tests
This commit is contained in:
parent
7d69496fbb
commit
a946d09f1b
46
dbms/tests/queries/0_stateless/00960_live_view_watch_events_live.py
Executable file
46
dbms/tests/queries/0_stateless/00960_live_view_watch_events_live.py
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python
|
||||
import imp
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
|
||||
CURDIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
uexpect = imp.load_source('uexpect', os.path.join(CURDIR, 'uexpect.py'))
|
||||
|
||||
def client(name=''):
|
||||
client = uexpect.spawn(os.environ.get('CLICKHOUSE_CLIENT'))
|
||||
client.eol('\r')
|
||||
# Note: uncomment this line for debugging
|
||||
#client.logger(sys.stdout, prefix=name)
|
||||
client.timeout(2)
|
||||
return client
|
||||
|
||||
prompt = ':\) '
|
||||
end_of_block = r'.*\xe2\x94\x82\r\n.*\xe2\x94\x98\r\n'
|
||||
client1 = client('client1>')
|
||||
client2 = client('client2>')
|
||||
|
||||
client1.expect(prompt)
|
||||
client2.expect(prompt)
|
||||
|
||||
client1.send('DROP TABLE IF EXISTS test.lv')
|
||||
client1.expect(prompt)
|
||||
client1.send(' DROP TABLE IF EXISTS test.mt')
|
||||
client1.expect(prompt)
|
||||
client1.send('CREATE TABLE test.mt (a Int32) Engine=MergeTree order by tuple()')
|
||||
client1.expect(prompt)
|
||||
client1.send('CREATE LIVE VIEW test.lv AS SELECT sum(a) FROM test.mt')
|
||||
client1.expect(prompt)
|
||||
client1.send('WATCH test.lv EVENTS')
|
||||
client2.send('INSERT INTO test.mt VALUES (1),(2),(3)')
|
||||
client1.expect('2.*4cd0592103888d4682de9a32a23602e3' + end_of_block)
|
||||
client2.send('INSERT INTO test.mt VALUES (4),(5),(6)')
|
||||
client1.expect('3.*2186dbea325ee4c56b67e9b792e993a3' + end_of_block)
|
||||
# send Ctrl-C
|
||||
os.kill(client1.process.pid,signal.SIGINT)
|
||||
client1.expect(prompt)
|
||||
client1.send('DROP TABLE test.lv')
|
||||
client1.expect(prompt)
|
||||
client1.send('DROP TABLE test.mt')
|
||||
client1.expect(prompt)
|
47
dbms/tests/queries/0_stateless/00964_live_view_watch_events_heartbeat.py
Executable file
47
dbms/tests/queries/0_stateless/00964_live_view_watch_events_heartbeat.py
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
import imp
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
|
||||
CURDIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
uexpect = imp.load_source('uexpect', os.path.join(CURDIR, 'uexpect.py'))
|
||||
|
||||
def client(name=''):
|
||||
client = uexpect.spawn(os.environ.get('CLICKHOUSE_CLIENT'))
|
||||
client.eol('\r')
|
||||
# Note: uncomment this line for debugging
|
||||
#client.logger(sys.stdout, prefix=name)
|
||||
client.timeout(2)
|
||||
return client
|
||||
|
||||
prompt = ':\) '
|
||||
end_of_block = r'.*\xe2\x94\x82\r\n.*\xe2\x94\x98\r\n'
|
||||
client1 = client('client1>')
|
||||
client2 = client('client2>')
|
||||
|
||||
client1.expect(prompt)
|
||||
client2.expect(prompt)
|
||||
|
||||
client1.send('DROP TABLE IF EXISTS test.lv')
|
||||
client1.expect(prompt)
|
||||
client1.send(' DROP TABLE IF EXISTS test.mt')
|
||||
client1.expect(prompt)
|
||||
client1.send('CREATE TABLE test.mt (a Int32) Engine=MergeTree order by tuple()')
|
||||
client1.expect(prompt)
|
||||
client1.send('CREATE TEMPORARY LIVE VIEW test.lv AS SELECT sum(a) FROM test.mt')
|
||||
client1.expect(prompt)
|
||||
client1.send('WATCH test.lv EVENTS')
|
||||
client2.send('INSERT INTO test.mt VALUES (1),(2),(3)')
|
||||
client1.expect('2.*4cd0592103888d4682de9a32a23602e3' + end_of_block)
|
||||
client1.expect('Progress: 2.00 rows.*\)')
|
||||
# wait for heartbeat
|
||||
client1.expect('Progress: 2.00 rows.*\)', timeout=15)
|
||||
# send Ctrl-C
|
||||
os.kill(client1.process.pid,signal.SIGINT)
|
||||
client1.expect(prompt)
|
||||
client1.send('DROP TABLE test.lv')
|
||||
client1.expect(prompt)
|
||||
client1.send('DROP TABLE test.mt')
|
||||
client1.expect(prompt)
|
47
dbms/tests/queries/0_stateless/00965_live_view_watch_heartbeat.py
Executable file
47
dbms/tests/queries/0_stateless/00965_live_view_watch_heartbeat.py
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
import imp
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
|
||||
CURDIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
uexpect = imp.load_source('uexpect', os.path.join(CURDIR, 'uexpect.py'))
|
||||
|
||||
def client(name=''):
|
||||
client = uexpect.spawn(os.environ.get('CLICKHOUSE_CLIENT'))
|
||||
client.eol('\r')
|
||||
# Note: uncomment this line for debugging
|
||||
#client.logger(sys.stdout, prefix=name)
|
||||
client.timeout(2)
|
||||
return client
|
||||
|
||||
prompt = ':\) '
|
||||
end_of_block = r'.*\xe2\x94\x82\r\n.*\xe2\x94\x98\r\n'
|
||||
client1 = client('client1>')
|
||||
client2 = client('client2>')
|
||||
|
||||
client1.expect(prompt)
|
||||
client2.expect(prompt)
|
||||
|
||||
client1.send('DROP TABLE IF EXISTS test.lv')
|
||||
client1.expect(prompt)
|
||||
client1.send(' DROP TABLE IF EXISTS test.mt')
|
||||
client1.expect(prompt)
|
||||
client1.send('CREATE TABLE test.mt (a Int32) Engine=MergeTree order by tuple()')
|
||||
client1.expect(prompt)
|
||||
client1.send('CREATE TEMPORARY LIVE VIEW test.lv AS SELECT sum(a) FROM test.mt')
|
||||
client1.expect(prompt)
|
||||
client1.send('WATCH test.lv')
|
||||
client2.send('INSERT INTO test.mt VALUES (1),(2),(3)')
|
||||
client1.expect(r'6.*2' + end_of_block)
|
||||
client1.expect('Progress: 2.00 rows.*\)')
|
||||
# wait for heartbeat
|
||||
client1.expect('Progress: 2.00 rows.*\)', timeout=15)
|
||||
# send Ctrl-C
|
||||
os.kill(client1.process.pid,signal.SIGINT)
|
||||
client1.expect(prompt)
|
||||
client1.send('DROP TABLE test.lv')
|
||||
client1.expect(prompt)
|
||||
client1.send('DROP TABLE test.mt')
|
||||
client1.expect(prompt)
|
51
dbms/tests/queries/0_stateless/00966_live_view_watch_events_http.py
Executable file
51
dbms/tests/queries/0_stateless/00966_live_view_watch_events_http.py
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python
|
||||
import imp
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
|
||||
CURDIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
uexpect = imp.load_source('uexpect', os.path.join(CURDIR, 'uexpect.py'))
|
||||
|
||||
def client(name='', command=None):
|
||||
if command is None:
|
||||
client = uexpect.spawn(os.environ.get('CLICKHOUSE_CLIENT'))
|
||||
else:
|
||||
client = uexpect.spawn(command)
|
||||
client.eol('\r')
|
||||
# Note: uncomment this line for debugging
|
||||
#client.logger(sys.stdout, prefix=name)
|
||||
client.timeout(2)
|
||||
return client
|
||||
|
||||
prompt = ':\) '
|
||||
end_of_block = r'.*\xe2\x94\x82\r\n.*\xe2\x94\x98\r\n'
|
||||
client1 = client('client1>')
|
||||
client1.expect(prompt)
|
||||
|
||||
client1.send('DROP TABLE IF EXISTS test.lv')
|
||||
client1.expect(prompt)
|
||||
client1.send(' DROP TABLE IF EXISTS test.mt')
|
||||
client1.expect(prompt)
|
||||
client1.send('CREATE TABLE test.mt (a Int32) Engine=MergeTree order by tuple()')
|
||||
client1.expect(prompt)
|
||||
client1.send('CREATE LIVE VIEW test.lv AS SELECT sum(a) FROM test.mt')
|
||||
client1.expect(prompt)
|
||||
|
||||
client2 = client('client2>', ['bash', '--noediting'])
|
||||
client2.expect('\$ ')
|
||||
client2.send('wget -O- -q "http://localhost:8123/?query=WATCH test.lv EVENTS"')
|
||||
client2.expect('.*1\tc9d39b11cce79112219a73aaa319b475\r\n')
|
||||
|
||||
client1.send('INSERT INTO test.mt VALUES (1),(2),(3)')
|
||||
client1.expect(prompt)
|
||||
|
||||
client2.expect('.*2\t.*\r\n')
|
||||
## send Ctrl-C
|
||||
os.kill(client2.process.pid,signal.SIGINT)
|
||||
|
||||
client1.send('DROP TABLE test.lv')
|
||||
client1.expect(prompt)
|
||||
client1.send('DROP TABLE test.mt')
|
||||
client1.expect(prompt)
|
51
dbms/tests/queries/0_stateless/00967_live_view_watch_http.py
Executable file
51
dbms/tests/queries/0_stateless/00967_live_view_watch_http.py
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python
|
||||
import imp
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
|
||||
CURDIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
uexpect = imp.load_source('uexpect', os.path.join(CURDIR, 'uexpect.py'))
|
||||
|
||||
def client(name='', command=None):
|
||||
if command is None:
|
||||
client = uexpect.spawn(os.environ.get('CLICKHOUSE_CLIENT'))
|
||||
else:
|
||||
client = uexpect.spawn(command)
|
||||
client.eol('\r')
|
||||
# Note: uncomment this line for debugging
|
||||
#client.logger(sys.stdout, prefix=name)
|
||||
client.timeout(2)
|
||||
return client
|
||||
|
||||
prompt = ':\) '
|
||||
end_of_block = r'.*\xe2\x94\x82\r\n.*\xe2\x94\x98\r\n'
|
||||
client1 = client('client1>')
|
||||
client1.expect(prompt)
|
||||
|
||||
client1.send('DROP TABLE IF EXISTS test.lv')
|
||||
client1.expect(prompt)
|
||||
client1.send(' DROP TABLE IF EXISTS test.mt')
|
||||
client1.expect(prompt)
|
||||
client1.send('CREATE TABLE test.mt (a Int32) Engine=MergeTree order by tuple()')
|
||||
client1.expect(prompt)
|
||||
client1.send('CREATE LIVE VIEW test.lv AS SELECT sum(a) FROM test.mt')
|
||||
client1.expect(prompt)
|
||||
|
||||
client2 = client('client2>', ['bash', '--noediting'])
|
||||
client2.expect('\$ ')
|
||||
client2.send('wget -O- -q "http://localhost:8123/?query=WATCH test.lv"')
|
||||
client2.expect('.*0\t1\r\n')
|
||||
|
||||
client1.send('INSERT INTO test.mt VALUES (1),(2),(3)')
|
||||
client1.expect(prompt)
|
||||
|
||||
client2.expect('.*6\t2\r\n')
|
||||
## send Ctrl-C
|
||||
os.kill(client2.process.pid,signal.SIGINT)
|
||||
|
||||
client1.send('DROP TABLE test.lv')
|
||||
client1.expect(prompt)
|
||||
client1.send('DROP TABLE test.mt')
|
||||
client1.expect(prompt)
|
@ -102,10 +102,12 @@ class IO(object):
|
||||
def write(self, data):
|
||||
return os.write(self.master, data)
|
||||
|
||||
def expect(self, pattern, timeout=None):
|
||||
def expect(self, pattern, timeout=None, escape=False):
|
||||
self.match = None
|
||||
self.before = None
|
||||
self.after = None
|
||||
if escape:
|
||||
pattern = re.escape(pattern)
|
||||
pattern = re.compile(pattern)
|
||||
if timeout is None:
|
||||
timeout = self._timeout
|
||||
@ -151,7 +153,7 @@ class IO(object):
|
||||
pass
|
||||
return data
|
||||
|
||||
def spawn(*command):
|
||||
def spawn(command):
|
||||
master, slave = pty.openpty()
|
||||
process = Popen(command, preexec_fn=os.setsid, stdout=slave, stdin=slave, stderr=slave, bufsize=1)
|
||||
os.close(slave)
|
||||
@ -169,7 +171,7 @@ def reader(out, queue):
|
||||
queue.put(data)
|
||||
|
||||
if __name__ == '__main__':
|
||||
io = spawn('/bin/bash')
|
||||
io = spawn(['/bin/bash','--noediting'])
|
||||
prompt = '\$ '
|
||||
io.logger(sys.stdout)
|
||||
io.timeout(2)
|
||||
@ -182,6 +184,6 @@ if __name__ == '__main__':
|
||||
io.send('SELECT 1')
|
||||
io.expect(prompt)
|
||||
io.send('SHOW TABLES')
|
||||
io.expect('test')
|
||||
io.expect('.*\r\n.*')
|
||||
io.expect(prompt)
|
||||
io.close()
|
||||
|
Loading…
Reference in New Issue
Block a user