2021-01-30 14:00:42 +00:00
|
|
|
#!/usr/bin/env python3
|
2021-09-12 12:35:27 +00:00
|
|
|
# Tags: no-replicated-database, no-parallel, no-fasttest
|
|
|
|
|
2021-01-30 14:00:42 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import signal
|
|
|
|
|
|
|
|
CURDIR = os.path.dirname(os.path.realpath(__file__))
|
2022-03-22 16:39:58 +00:00
|
|
|
sys.path.insert(0, os.path.join(CURDIR, "helpers"))
|
2021-01-30 14:00:42 +00:00
|
|
|
|
|
|
|
from client import client, prompt, end_of_block
|
|
|
|
|
|
|
|
log = None
|
|
|
|
# uncomment the line below for debugging
|
2022-03-22 16:39:58 +00:00
|
|
|
# log=sys.stdout
|
2021-01-30 14:00:42 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
with client(name="client1>", log=log) as client1, client(
|
|
|
|
name="client2>", log=log
|
|
|
|
) as client2:
|
2021-01-30 14:00:42 +00:00
|
|
|
client1.expect(prompt)
|
|
|
|
client2.expect(prompt)
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
client1.send("SET allow_experimental_live_view = 1")
|
2021-01-30 14:00:42 +00:00
|
|
|
client1.expect(prompt)
|
2022-03-22 16:39:58 +00:00
|
|
|
client2.send("SET allow_experimental_live_view = 1")
|
2021-01-30 14:00:42 +00:00
|
|
|
client2.expect(prompt)
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
client1.send("DROP TABLE IF EXISTS test.lv")
|
2021-01-30 14:00:42 +00:00
|
|
|
client1.expect(prompt)
|
2022-03-22 16:39:58 +00:00
|
|
|
client1.send(
|
|
|
|
"CREATE LIVE VIEW test.lv WITH REFRESH 1"
|
|
|
|
" AS SELECT value FROM system.events WHERE event = 'OSCPUVirtualTimeMicroseconds'"
|
|
|
|
)
|
2021-01-30 14:00:42 +00:00
|
|
|
client1.expect(prompt)
|
2022-03-22 16:39:58 +00:00
|
|
|
client1.send("WATCH test.lv FORMAT JSONEachRow")
|
2021-01-30 14:00:42 +00:00
|
|
|
client1.expect(r'"_version":' + end_of_block)
|
|
|
|
client1.expect(r'"_version":' + end_of_block)
|
|
|
|
client1.expect(r'"_version":' + end_of_block)
|
|
|
|
# send Ctrl-C
|
2022-03-22 16:39:58 +00:00
|
|
|
client1.send("\x03", eol="")
|
|
|
|
match = client1.expect("(%s)|([#\$] )" % prompt)
|
2021-01-30 14:00:42 +00:00
|
|
|
if match.groups()[1]:
|
|
|
|
client1.send(client1.command)
|
|
|
|
client1.expect(prompt)
|
2022-03-22 16:39:58 +00:00
|
|
|
client1.send("DROP TABLE test.lv")
|
2021-01-30 14:00:42 +00:00
|
|
|
client1.expect(prompt)
|