ClickHouse/tests/queries/0_stateless/02160_client_autocomplete_parse_query.expect
Azat Khuzhin e4b81e6de9 Add exp_internal for expect tests
This is to catch possible issues like 01565_reconnect_after_client_error in [1].

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/38417/e33f236d502fe9f7906392f4ceffaee44e3c4ce4/stateless_tests__thread__actions__[3/3].html

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-07-02 17:08:06 +03:00

103 lines
2.1 KiB
Plaintext
Executable File

#!/usr/bin/expect -f
set basedir [file dirname $argv0]
set basename [file tail $argv0]
exp_internal -f $env(CLICKHOUSE_TMP)/$basename.debuglog 0
log_user 0
set timeout 60
set uuid ""
match_max 100000
expect_after {
# Do not ignore eof from read.
eof { exp_continue }
# A default timeout action is to do nothing, change it to fail
timeout { exit 1 }
}
spawn bash -c "source $basedir/../shell_config.sh ; \$CLICKHOUSE_CLIENT_BINARY \$CLICKHOUSE_CLIENT_OPT"
expect ":) "
# Make a query
send -- "set max_distributed"
expect "set max_distributed"
# Wait for suggestions to load, they are loaded in background
set is_done 0
set timeout 1
while {$is_done == 0} {
send -- "\t"
expect {
"_" {
set is_done 1
}
default {
# Reset the expect_after
}
}
}
set timeout 60
# Ctrl-C
send -- "\3"
expect ":) "
# Generate UIUD to avoid matching old database/tables/columns from previous test runs.
send -- "select 'begin-' || replace(toString(generateUUIDv4()), '-', '') || '-end' format TSV\r"
expect -re TSV.*TSV.*begin-(.*)-end.*
set uuid $expect_out(1,string)
expect ":) "
# CREATE DATABASE
send -- "create database new_${uuid}_database\r"
expect ":) "
send -- "new_${uuid}_data"
expect "new_${uuid}_data"
send -- "\t"
expect "base"
# Ctrl-C
send -- "\3"
expect ":) "
# CREATE TABLE
send -- "create table new_${uuid}_table (new_${uuid}_column Int) engine=Null()\r"
expect ":) "
send -- "new_${uuid}_ta"
expect "new_${uuid}_ta"
send -- "\t"
expect "ble"
# Ctrl-C
send -- "\3"
expect ":) "
# Column from table
send -- "new_${uuid}_col"
expect "new_${uuid}_col"
send -- "\t"
expect "umn"
# Ctrl-C
send -- "\3"
expect ":) "
# CREATE FUNCTION
send -- "create function new_${uuid}_function as x -> x\r"
expect ":) "
send -- "new_${uuid}_func"
expect "new_${uuid}_func"
send -- "\t"
expect "tion"
# Ctrl-C
send -- "\3"
expect ":) "
# Cleanup
send -- "drop database new_${uuid}_database\r"
expect ":) "
send -- "drop table new_${uuid}_table\r"
expect ":) "
send -- "drop function new_${uuid}_function\r"
expect ":) "
# Ctrl-D
send -- "\4"
expect eof