ClickHouse/dbms/tests/queries/0_stateless/00963_temporary_live_view_watch_live_timeout.py
Vitaliy Zakaznikov 2930965938 * Renaming live_view_heartbeat_delay setting to live_view_heartbeat_interval
and making the setting to be in seconds instead of usec
* Updated LIVE VIEW table to keep version consistent as long as the server is up
* Removed calculation of hash in writeIntoLiveView method as it is recalculated
  in the LiveViewBlockOutputStream
* Changed to using values from the local context for live_view_heartbeat_interval and
  temporary_live_view_timeout instead of the global context
* Updated LIVE VIEW tests to match the changes
2019-06-06 21:10:56 -04:00

54 lines
1.6 KiB
Python
Executable File

#!/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('SET temporary_live_view_timeout=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')
client2.send('INSERT INTO test.mt VALUES (1),(2),(3)')
client2.expect(prompt)
client1.expect(r'6.*2' + end_of_block)
client2.send('INSERT INTO test.mt VALUES (4),(5),(6)')
client2.expect(prompt)
client1.expect(r'21.*3' + end_of_block)
# send Ctrl-C
os.kill(client1.process.pid,signal.SIGINT)
client1.expect(prompt)
client1.send('SELECT sleep(1)')
client1.expect(prompt)
client1.send('DROP TABLE test.lv')
client1.expect('Table test.lv doesn\'t exist')
client1.expect(prompt)
client1.send('DROP TABLE test.mt')
client1.expect(prompt)