2021-12-26 16:10:25 +00:00
|
|
|
|
#!/usr/bin/expect -f
|
|
|
|
|
|
|
|
|
|
log_user 0
|
|
|
|
|
set timeout 60
|
|
|
|
|
set uuid ""
|
|
|
|
|
match_max 100000
|
|
|
|
|
# A default timeout action is to do nothing, change it to fail
|
|
|
|
|
expect_after {
|
|
|
|
|
timeout {
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set basedir [file dirname $argv0]
|
|
|
|
|
spawn bash -c "source $basedir/../shell_config.sh ; \$CLICKHOUSE_CLIENT_BINARY \$CLICKHOUSE_CLIENT_OPT"
|
2021-12-28 18:16:20 +00:00
|
|
|
|
# wait until the process will be spawned to avoid terminating "expect" with "eof":
|
|
|
|
|
#
|
|
|
|
|
# send: sending "set max_distributed" to { exp4 }
|
|
|
|
|
#
|
|
|
|
|
# expect: does "" (spawn_id exp4) match glob pattern ":)"? no
|
|
|
|
|
# expect: read eof
|
|
|
|
|
# expect: set expect_out(spawn_id) "exp0"
|
|
|
|
|
# expect: set expect_out(buffer) ""
|
|
|
|
|
# send: sending "set max_distributed" to { exp4 }
|
|
|
|
|
#
|
|
|
|
|
# expect: does "" (spawn_id exp4) match glob pattern "set max_distributed"? no
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# NOTE: this is especially important since random database has "_" prefix,
|
|
|
|
|
# and this may break the whole test (see expect "_" below).
|
|
|
|
|
set is_done 0
|
|
|
|
|
while {$is_done == 0} {
|
|
|
|
|
send -- "\t"
|
|
|
|
|
expect {
|
|
|
|
|
":) " {
|
|
|
|
|
set is_done 1
|
|
|
|
|
}
|
|
|
|
|
default {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-26 16:10:25 +00:00
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
send -- ""
|
|
|
|
|
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
|
|
|
|
|
send -- "create database new_${uuid}_database\r"
|
|
|
|
|
expect ":) "
|
|
|
|
|
send -- "create table new_${uuid}_table (new_${uuid}_column Int) engine=Null()\r"
|
|
|
|
|
expect ":) "
|
|
|
|
|
|
|
|
|
|
# Check completion
|
|
|
|
|
send -- "new_${uuid}_data"
|
|
|
|
|
expect "new_${uuid}_data"
|
|
|
|
|
send -- "\t"
|
|
|
|
|
expect "base"
|
|
|
|
|
send -- ""
|
|
|
|
|
expect ":) "
|
|
|
|
|
|
|
|
|
|
send -- "new_${uuid}_ta"
|
|
|
|
|
expect "new_${uuid}_ta"
|
|
|
|
|
send -- "\t"
|
|
|
|
|
expect "ble"
|
|
|
|
|
send -- ""
|
|
|
|
|
expect ":) "
|
|
|
|
|
|
|
|
|
|
send -- "new_${uuid}_col"
|
|
|
|
|
expect "new_${uuid}_col"
|
|
|
|
|
send -- "\t"
|
|
|
|
|
expect "umn"
|
|
|
|
|
send -- ""
|
|
|
|
|
expect ":) "
|
|
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
|
send -- "drop database new_${uuid}_database\r"
|
|
|
|
|
expect ":) "
|
|
|
|
|
send -- "drop table new_${uuid}_table\r"
|
|
|
|
|
expect ":) "
|
|
|
|
|
|
|
|
|
|
send -- ""
|
|
|
|
|
expect eof
|