diff --git a/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.py b/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.py index 30729c49903..8dacdd788f7 100755 --- a/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.py +++ b/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.py @@ -14,56 +14,57 @@ log = None # uncomment the line below for debugging #log=sys.stdout -server = start_server(1) +server = start_server(3) server.start() -with client(name='client1>', log=log) as client1, client(name='client2>', log=log) as client2: - client1.expect(prompt) - client2.expect(prompt) +for output_format in ['CSV', 'JSONEachRow', 'JSONEachRowWithProgress']: + with client(name='client1>', log=log) as client1, client(name='client2>', log=log) as client2: + client1.expect(prompt) + client2.expect(prompt) - client1.send('SET allow_experimental_live_view = 1') - client1.expect(prompt) + client1.send('SET allow_experimental_live_view = 1') + client1.expect(prompt) - client1.send('SET output_format_enable_streaming = 1') - client1.expect(prompt) + client1.send('SET output_format_enable_streaming = 1') + 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) AS s FROM test.mt') - 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) AS s FROM test.mt') + client1.expect(prompt) - client1.send("INSERT INTO FUNCTION url('%s', CSV, 's Int32, version Int32') WATCH test.lv" % HTTP_SERVER_URL_STR) - client1.expect(r'0.*1' + end_of_block) - time.sleep(0.25) - sys.stdout.write("-- first insert --\n") - sys.stdout.write(server.out.read() + "\n") + client1.send("INSERT INTO FUNCTION url('%s', %s, 's Int32, version Int32') WATCH test.lv" % (HTTP_SERVER_URL_STR, output_format)) + client1.expect(r'0.*1' + end_of_block) + time.sleep(0.25) + sys.stdout.write("-- first insert --\n") + sys.stdout.write(server.out.read() + "\n") - client2.send('INSERT INTO test.mt VALUES (1),(2),(3)') - client2.expect(prompt) - time.sleep(0.25) - sys.stdout.write("-- second insert --\n") - sys.stdout.write(server.out.read() + "\n") + client2.send('INSERT INTO test.mt VALUES (1),(2),(3)') + client2.expect(prompt) + time.sleep(0.25) + sys.stdout.write("-- second insert --\n") + sys.stdout.write(server.out.read() + "\n") - client2.send('INSERT INTO test.mt VALUES (4),(5),(6)') - client2.expect(prompt) - time.sleep(0.25) - sys.stdout.write("-- third insert --\n") - sys.stdout.write(server.out.read() + "\n") + client2.send('INSERT INTO test.mt VALUES (4),(5),(6)') + client2.expect(prompt) + time.sleep(0.25) + sys.stdout.write("-- third insert --\n") + sys.stdout.write(server.out.read() + "\n") - # send Ctrl-C - client1.send('\x03', eol='') - match = client1.expect('(%s)|([#\$] )' % prompt) - if match.groups()[1]: - client1.send(client1.command) - client1.expect(prompt) - - client1.send('DROP TABLE test.lv') - client1.expect(prompt) - client1.send('DROP TABLE test.mt') - client1.expect(prompt) + # send Ctrl-C + client1.send('\x03', eol='') + match = client1.expect('(%s)|([#\$] )' % prompt) + if match.groups()[1]: + client1.send(client1.command) + client1.expect(prompt) + + client1.send('DROP TABLE test.lv') + client1.expect(prompt) + client1.send('DROP TABLE test.mt') + client1.expect(prompt) server.join() diff --git a/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.reference b/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.reference index 99bb308dbb5..aa3146539cd 100644 --- a/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.reference +++ b/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.reference @@ -7,3 +7,21 @@ -- third insert -- 21,3 +-- first insert -- +{"s":0,"version":1} + +-- second insert -- +{"s":6,"version":2} + +-- third insert -- +{"s":21,"version":3} + +-- first insert -- +{"row":{"s":0,"version":1}} + +-- second insert -- +{"row":{"s":6,"version":2}} + +-- third insert -- +{"row":{"s":21,"version":3}} + diff --git a/tests/queries/0_stateless/helpers/httpechoserver.py b/tests/queries/0_stateless/helpers/httpechoserver.py index 1519bf9cd97..938f1b4bba1 100644 --- a/tests/queries/0_stateless/helpers/httpechoserver.py +++ b/tests/queries/0_stateless/helpers/httpechoserver.py @@ -25,7 +25,7 @@ istream = StringIO() class EchoCSVHTTPServer(BaseHTTPRequestHandler): def _set_headers(self): self.send_response(200) - self.send_header('Content-type', 'text/csv') + self.send_header('Content-type', 'text/plain') self.end_headers() def do_GET(self):