mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Merge pull request #37597 from azat/fix-01317_no_password_in_command_line
tests: fix 01317_no_password_in_command_line flakiness (and make it race free)
This commit is contained in:
commit
975f16049e
@ -1,2 +0,0 @@
|
||||
0
|
||||
0
|
@ -7,52 +7,40 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
|
||||
set -e
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP USER IF EXISTS user"
|
||||
$CLICKHOUSE_CLIENT --query "CREATE USER user IDENTIFIED WITH PLAINTEXT_PASSWORD BY 'hello'"
|
||||
|
||||
# False positive result due to race condition with sleeps is Ok.
|
||||
|
||||
$CLICKHOUSE_CLIENT --user user --password hello --query "SELECT sleep(1)" &
|
||||
bg_query=$!
|
||||
user=user_$CLICKHOUSE_TEST_UNIQUE_NAME
|
||||
$CLICKHOUSE_CLIENT --query "DROP USER IF EXISTS $user"
|
||||
$CLICKHOUSE_CLIENT --query "CREATE USER $user IDENTIFIED WITH PLAINTEXT_PASSWORD BY 'hello'"
|
||||
trap '$CLICKHOUSE_CLIENT --query "DROP USER $user"' EXIT
|
||||
|
||||
# Wait for query to start executing. At that time, the password should be cleared.
|
||||
for _ in {1..20}
|
||||
do
|
||||
if $CLICKHOUSE_CLIENT --query "SHOW PROCESSLIST" | grep -q 'SELECT sleep(1)'
|
||||
then
|
||||
break
|
||||
fi
|
||||
function wait_query_pid()
|
||||
{
|
||||
local query_id=$1 && shift
|
||||
|
||||
if ! kill -0 -- $bg_query 2>/dev/null
|
||||
then
|
||||
# The SELECT sleep(1) query finished earlier that we could grep for it in the process list, but it should have run for at least one second. It is Ok.
|
||||
break
|
||||
fi
|
||||
done
|
||||
for _ in {1..20}; do
|
||||
if [ "$($CLICKHOUSE_CLIENT --param_query_id "$query_id" --query "SELECT count() FROM system.processes WHERE query_id = {query_id:String}")" -eq 1 ]; then
|
||||
break
|
||||
fi
|
||||
sleep 0.3
|
||||
done
|
||||
}
|
||||
|
||||
ps auxw | grep -F -- '--password' | grep -F hello ||:
|
||||
wait
|
||||
|
||||
# Once again with different syntax
|
||||
$CLICKHOUSE_CLIENT --user user --password=hello --query "SELECT sleep(1)" &
|
||||
# --password <pass>
|
||||
query_id=first-$CLICKHOUSE_TEST_UNIQUE_NAME
|
||||
$CLICKHOUSE_CLIENT --query_id "$query_id" --user "$user" --password hello --max_block_size 1 --query "SELECT sleepEachRow(1) FROM system.numbers LIMIT 100" >& /dev/null &
|
||||
bg_query=$!
|
||||
|
||||
# Wait for query to start executing. At that time, the password should be cleared.
|
||||
for _ in {1..20}
|
||||
do
|
||||
if $CLICKHOUSE_CLIENT --query "SHOW PROCESSLIST" | grep -q 'SELECT sleep(1)'
|
||||
then
|
||||
break
|
||||
fi
|
||||
|
||||
if ! kill -0 -- $bg_query 2>/dev/null
|
||||
then
|
||||
# The SELECT sleep(1) query finished earlier that we could grep for it in the process list, but it should have run for at least one second. It is Ok.
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
ps auxw | grep -F -- '--password' | grep -F hello ||:
|
||||
wait_query_pid "$query_id"
|
||||
ps u --no-header $bg_query | grep -F -- '--password' | grep -F hello ||:
|
||||
grep -F -- '--password' < "/proc/$bg_query/comm" | grep -F hello ||:
|
||||
$CLICKHOUSE_CLIENT --format Null --param_query_id "$query_id" -q "KILL QUERY WHERE query_id = {query_id:String} SYNC"
|
||||
wait
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP USER user"
|
||||
# --password=<pass>
|
||||
query_id=second-$CLICKHOUSE_TEST_UNIQUE_NAME
|
||||
$CLICKHOUSE_CLIENT --query_id "$query_id" --user "$user" --password=hello --max_block_size 1 --query "SELECT sleepEachRow(1) FROM system.numbers LIMIT 100" >& /dev/null &
|
||||
bg_query=$!
|
||||
wait_query_pid "$query_id"
|
||||
ps u --no-header $bg_query | grep -F -- '--password' | grep -F hello ||:
|
||||
grep -F -- '--password' < "/proc/$bg_query/comm" | grep -F hello ||:
|
||||
$CLICKHOUSE_CLIENT --format Null --param_query_id "$query_id" -q "KILL QUERY WHERE query_id = {query_id:String} SYNC"
|
||||
wait
|
||||
|
Loading…
Reference in New Issue
Block a user