* Updating tests to send Ctrl-C instead of SIGINT signal to abort WATCH query

* Updating client.py to start commands inside shell
* Removing test code from uexpect.py
This commit is contained in:
Vitaliy Zakaznikov 2019-07-09 23:27:19 -04:00
parent c84fd80345
commit 9c5514135d
8 changed files with 10 additions and 27 deletions

View File

@ -31,7 +31,7 @@ with client(name='client1>', log=log) as client1, client(name='client2>', log=lo
client2.send('INSERT INTO test.mt VALUES (4),(5),(6)')
client1.expect('3.*' + end_of_block)
# send Ctrl-C
os.kill(client1.process.pid, signal.SIGINT)
client1.send('\x03', eol='')
client1.expect(prompt)
client1.send('DROP TABLE test.lv')
client1.expect(prompt)

View File

@ -31,7 +31,7 @@ with client(name='client1>', log=log) as client1, client(name='client2>', log=lo
client2.send('INSERT INTO test.mt VALUES (4),(5),(6)')
client1.expect(r'21.*3' + end_of_block)
# send Ctrl-C
os.kill(client1.process.pid, signal.SIGINT)
client1.send('\x03', eol='')
client1.expect(prompt)
client1.send('DROP TABLE test.lv')
client1.expect(prompt)

View File

@ -35,7 +35,7 @@ with client(name='client1>', log=log) as client1, client(name='client2>', log=lo
client2.expect(prompt)
client1.expect(r'21.*3' + end_of_block)
# send Ctrl-C
os.kill(client1.process.pid, signal.SIGINT)
client1.send('\x03', eol='')
client1.expect(prompt)
client1.send('SELECT sleep(1)')
client1.expect(prompt)

View File

@ -33,7 +33,7 @@ with client(name='client1>', log=log) as client1, client(name='client2>', log=lo
# wait for heartbeat
client1.expect('Progress: 2.00 rows.*\)')
# send Ctrl-C
os.kill(client1.process.pid, signal.SIGINT)
client1.send('\x03', eol='')
client1.expect(prompt)
client1.send('DROP TABLE test.lv')
client1.expect(prompt)

View File

@ -34,7 +34,7 @@ with client(name='client1>', log=log) as client1, client(name='client2>', log=lo
# wait for heartbeat
client1.expect('Progress: 2.00 rows.*\)')
# send Ctrl-C
os.kill(client1.process.pid, signal.SIGINT)
client1.send('\x03', eol='')
client1.expect(prompt)
client1.send('DROP TABLE test.lv')
client1.expect(prompt)

View File

@ -37,7 +37,7 @@ with client(name='client1>', log=log) as client1, client(name='client2>', log=lo
client1.expect(r'%d.*%d' % (21+i, 3+i) + end_of_block)
client2.expect(prompt)
# send Ctrl-C
os.kill(client1.process.pid, signal.SIGINT)
client1.send('\x03', eol='')
client1.expect(prompt)
client1.send('DROP TABLE test.lv')
client1.expect(prompt)

View File

@ -11,11 +11,12 @@ prompt = ':\) '
end_of_block = r'.*\r\n.*\r\n'
def client(command=None, name='', log=None):
client = uexpect.spawn(['/bin/bash','--noediting'])
if command is None:
client = uexpect.spawn(os.environ.get('CLICKHOUSE_BINARY', 'clickhouse') + '-client')
else:
client = uexpect.spawn(command)
command = os.environ.get('CLICKHOUSE_BINARY', 'clickhouse') + '-client'
client.eol('\r')
client.logger(log, prefix=name)
client.timeout(20)
client.expect('[#\$] ', timeout=2)
client.send(command)
return client

View File

@ -202,21 +202,3 @@ def reader(process, out, queue, kill_event):
if e.errno == 5 and kill_event.is_set():
break
raise
if __name__ == '__main__':
io = spawn(['/bin/bash','--noediting'])
prompt = '\$ '
io.logger(sys.stdout)
io.timeout(2)
io.eol('\r')
io.expect(prompt)
io.send('clickhouse-client')
prompt = ':\) '
io.expect(prompt)
io.send('SELECT 1')
io.expect(prompt)
io.send('SHOW TABLES')
io.expect('.*\r\n.*')
io.expect(prompt)
io.close()