2019-06-03 19:53:11 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import signal
|
|
|
|
|
|
|
|
CURDIR = os.path.dirname(os.path.realpath(__file__))
|
2019-06-12 01:28:20 +00:00
|
|
|
sys.path.insert(0, os.path.join(CURDIR, 'helpers'))
|
2019-06-03 19:53:11 +00:00
|
|
|
|
2019-06-12 01:28:20 +00:00
|
|
|
from client import client, prompt, end_of_block
|
2019-06-03 19:53:11 +00:00
|
|
|
|
2019-06-12 01:28:20 +00:00
|
|
|
log = None
|
|
|
|
# uncomment the line below for debugging
|
|
|
|
#log=sys.stdout
|
2019-06-03 19:53:11 +00:00
|
|
|
|
2019-06-12 01:28:20 +00:00
|
|
|
with client(name='client1>', log=log) as client1, client(name='client2>', log=log) as client2:
|
2019-06-10 22:12:06 +00:00
|
|
|
client1.expect(prompt)
|
|
|
|
client2.expect(prompt)
|
2019-06-03 19:53:11 +00:00
|
|
|
|
2019-06-10 22:12:06 +00:00
|
|
|
client1.send('DROP TABLE IF EXISTS test.lv')
|
|
|
|
client1.expect(prompt)
|
|
|
|
client1.send(' DROP TABLE IF EXISTS test.mt')
|
|
|
|
client1.expect(prompt)
|
|
|
|
client1.send('SET live_view_heartbeat_interval=1')
|
|
|
|
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)')
|
2019-06-16 11:09:43 +00:00
|
|
|
client1.expect('2.*' + end_of_block)
|
2019-06-10 22:12:06 +00:00
|
|
|
client1.expect('Progress: 2.00 rows.*\)')
|
|
|
|
# wait for heartbeat
|
|
|
|
client1.expect('Progress: 2.00 rows.*\)')
|
|
|
|
# send Ctrl-C
|
2019-07-10 03:27:19 +00:00
|
|
|
client1.send('\x03', eol='')
|
2019-07-10 12:22:31 +00:00
|
|
|
match = client1.expect('(%s)|([#\$] )' % prompt)
|
|
|
|
if match.groups()[1]:
|
|
|
|
client1.send(client1.command)
|
|
|
|
client1.expect(prompt)
|
2019-06-10 22:12:06 +00:00
|
|
|
client1.send('DROP TABLE test.lv')
|
|
|
|
client1.expect(prompt)
|
|
|
|
client1.send('DROP TABLE test.mt')
|
|
|
|
client1.expect(prompt)
|