ClickHouse/tests/queries/0_stateless/02456_progress_tty.expect

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.9 KiB
Plaintext
Raw Normal View History

2022-10-01 21:00:23 +00:00
#!/usr/bin/expect -f
set basedir [file dirname $argv0]
set basename [file tail $argv0]
2024-03-23 17:12:20 +00:00
if {[info exists env(CLICKHOUSE_TMP)]} {
set CLICKHOUSE_TMP $env(CLICKHOUSE_TMP)
} else {
set CLICKHOUSE_TMP "."
}
exp_internal -f $CLICKHOUSE_TMP/$basename.debuglog 0
2022-10-01 21:00:23 +00:00
2022-10-01 21:18:54 +00:00
log_user 0
2022-10-01 21:00:23 +00:00
set timeout 60
match_max 100000
2022-10-01 21:17:49 +00:00
set stty_init "rows 25 cols 120"
2022-10-01 21:00:23 +00:00
expect_after {
-i $any_spawn_id eof { exp_continue }
-i $any_spawn_id timeout { exit 1 }
2022-10-01 21:00:23 +00:00
}
2022-10-01 21:17:49 +00:00
spawn bash
send "source $basedir/../shell_config.sh\r"
# Progress is not displayed by default
2024-03-23 17:12:20 +00:00
send "\$CLICKHOUSE_LOCAL --format TSV --query 'SELECT sleep(1), \$\$Hello\$\$ FROM numbers(3) SETTINGS max_block_size = 1' 2>/dev/null\r"
expect -exact "0\tHello\r\n"
2022-10-01 21:17:49 +00:00
send "\3"
2022-10-01 21:00:23 +00:00
# The option --progress has implicit value of true
2024-03-23 17:12:20 +00:00
send "\$CLICKHOUSE_LOCAL --format TSV --progress --query 'SELECT sum(sleep(1) = 0) FROM numbers(3) SETTINGS max_block_size = 1' >/dev/null\r"
2022-10-01 21:00:23 +00:00
expect "Progress: "
expect "█"
2022-10-01 21:17:49 +00:00
send "\3"
2022-10-01 21:00:23 +00:00
# It works even if we redirect both stdout and stderr to /dev/null
2024-03-23 17:12:20 +00:00
send "\$CLICKHOUSE_LOCAL --format TSV --progress --query 'SELECT sum(sleep(1) = 0) FROM numbers(3) SETTINGS max_block_size = 1' >/dev/null 2>&1\r"
2022-10-01 21:00:23 +00:00
expect "Progress: "
expect "█"
2022-10-01 21:17:49 +00:00
send "\3"
2022-10-01 21:00:23 +00:00
# But we can set it to false
2024-03-23 17:12:20 +00:00
send "\$CLICKHOUSE_LOCAL --format TSV --progress false --query 'SELECT sleep(1), \$\$Hello\$\$ FROM numbers(3) SETTINGS max_block_size = 1' 2>/dev/null\r"
expect -exact "0\tHello\r\n"
send "\3"
# As well as to 0 for the same effect
2024-03-23 17:12:20 +00:00
send "\$CLICKHOUSE_LOCAL --format TSV --progress 0 --query 'SELECT sleep(1), \$\$Hello\$\$ FROM numbers(3) SETTINGS max_block_size = 1' 2>/dev/null\r"
expect -exact "0\tHello\r\n"
send "\3"
2022-10-01 21:00:23 +00:00
# If we set it to 1, the progress will be displayed as well
2024-03-23 17:12:20 +00:00
send "\$CLICKHOUSE_LOCAL --format TSV --progress 1 --query 'SELECT sum(sleep(1) = 0) FROM numbers(3) SETTINGS max_block_size = 1' >/dev/null 2>&1\r"
2022-10-01 21:00:23 +00:00
expect "Progress: "
expect "█"
2022-10-01 21:17:49 +00:00
send "\3"
send "exit\r"
expect eof