#!/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