Skip to content

Commit

Permalink
chore: fix test privilege access (#14034)
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc authored Dec 15, 2023
1 parent 12deb22 commit 7559688
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 44 deletions.
52 changes: 28 additions & 24 deletions tests/suites/0_stateless/05_hints/05_0002_deduplicate_label.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# mariadb mysql client has some bug, please use mysql official client
# mysql --version
# mysql Ver 8.0.32-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
echo "drop table if exists t1;" | $BENDSQL_CLIENT_CONNECT
echo "drop stage if exists s1;" | $BENDSQL_CLIENT_CONNECT
echo "drop stage if exists s0;" | $BENDSQL_CLIENT_CONNECT

echo "CREATE TABLE t1(a Int, b bool) Engine = Fuse;" | $BENDSQL_CLIENT_CONNECT

echo "INSERT /*+ SET_VAR(deduplicate_label='insert-test') */ INTO t1 (a, b) VALUES(1, false)" | $BENDSQL_CLIENT_CONNECT
echo "INSERT /*+ SET_VAR(deduplicate_label='insert-test') */ INTO t1 (a, b) VALUES(1, false)" | $BENDSQL_CLIENT_CONNECT
echo "select * from t1" | $BENDSQL_CLIENT_CONNECT

echo "CREATE STAGE s0;" | $BENDSQL_CLIENT_CONNECT
echo "copy /*+SET_VAR(deduplicate_label='copy-test')*/ into @s0 from (select * from t1);" | $MYSQL_CLINEENRT_CONNECT
echo "select * from @s0;" | $MYSQL_CLINEENRT_CONNECT
echo "CREATE STAGE s1;" | $MYSQL_CLINEENRT_CONNECT
echo "copy /*+SET_VAR(deduplicate_label='copy-test')*/ into @s1 from (select * from t1);" | $MYSQL_CLINEENRT_CONNECT
echo "select * from @s1;" | $MYSQL_CLINEENRT_CONNECT

echo "UPDATE /*+ SET_VAR(deduplicate_label='update-test') */ t1 SET a = 20 WHERE b = false;" | $BENDSQL_CLIENT_CONNECT
echo "UPDATE /*+ SET_VAR(deduplicate_label='update-test') */ t1 SET a = 30 WHERE b = false;" | $BENDSQL_CLIENT_CONNECT
echo "select * from t1" | $BENDSQL_CLIENT_CONNECT

echo "replace /*+ SET_VAR(deduplicate_label='replace-test') */ into t1 on(a,b) values(40,false);" | $BENDSQL_CLIENT_CONNECT
echo "replace /*+ SET_VAR(deduplicate_label='replace-test') */ into t1 on(a,b) values(50,false);" | $BENDSQL_CLIENT_CONNECT
echo "select * from t1 order by a" | $BENDSQL_CLIENT_CONNECT
echo "drop table if exists t5;" | $BENDSQL_CLIENT_CONNECT
echo "drop stage if exists s5;" | $BENDSQL_CLIENT_CONNECT
echo "drop stage if exists s5_1;" | $BENDSQL_CLIENT_CONNECT

echo "CREATE TABLE t5(a Int, b bool) Engine = Fuse;" | $BENDSQL_CLIENT_CONNECT

echo "INSERT /*+ SET_VAR(deduplicate_label='insert-test') */ INTO t5 (a, b) VALUES(1, false)" | $BENDSQL_CLIENT_CONNECT
echo "INSERT /*+ SET_VAR(deduplicate_label='insert-test') */ INTO t5 (a, b) VALUES(1, false)" | $BENDSQL_CLIENT_CONNECT
echo "select * from t5" | $BENDSQL_CLIENT_CONNECT

echo "CREATE STAGE s5_1;" | $BENDSQL_CLIENT_CONNECT
echo "copy /*+SET_VAR(deduplicate_label='copy-test')*/ into @s5_1 from (select * from t5);" | $MYSQL_CLINEENRT_CONNECT
echo "select * from @s5_1;" | $MYSQL_CLINEENRT_CONNECT
echo "CREATE STAGE s5;" | $MYSQL_CLINEENRT_CONNECT
echo "copy /*+SET_VAR(deduplicate_label='copy-test')*/ into @s5 from (select * from t5);" | $MYSQL_CLINEENRT_CONNECT
echo "select * from @s5;" | $MYSQL_CLINEENRT_CONNECT

echo "UPDATE /*+ SET_VAR(deduplicate_label='update-test') */ t5 SET a = 20 WHERE b = false;" | $BENDSQL_CLIENT_CONNECT
echo "UPDATE /*+ SET_VAR(deduplicate_label='update-test') */ t5 SET a = 30 WHERE b = false;" | $BENDSQL_CLIENT_CONNECT
echo "select * from t5" | $BENDSQL_CLIENT_CONNECT

echo "replace /*+ SET_VAR(deduplicate_label='replace-test') */ into t5 on(a,b) values(40,false);" | $BENDSQL_CLIENT_CONNECT
echo "replace /*+ SET_VAR(deduplicate_label='replace-test') */ into t5 on(a,b) values(50,false);" | $BENDSQL_CLIENT_CONNECT
echo "select * from t5 order by a" | $BENDSQL_CLIENT_CONNECT

echo "drop table if exists t5;" | $BENDSQL_CLIENT_CONNECT
echo "drop stage if exists s5;" | $BENDSQL_CLIENT_CONNECT
echo "drop stage if exists s5_1;" | $BENDSQL_CLIENT_CONNECT
40 changes: 20 additions & 20 deletions tests/suites/0_stateless/18_rbac/20_0012_privilege_access.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,19 @@ rm -rf password.out
export TEST_USER_PASSWORD="password"
export USER_A_CONNECT="bendsql --user=a --password=password --host=${QUERY_MYSQL_HANDLER_HOST} --port ${QUERY_HTTP_HANDLER_PORT}"

echo "drop user if exists a" | $BENDSQL_CLIENT_CONNECT
echo "create user a identified by '$TEST_USER_PASSWORD'" | $BENDSQL_CLIENT_CONNECT
echo "drop database if exists nogrant" | $BENDSQL_CLIENT_CONNECT
echo "drop database if exists grant_db" | $BENDSQL_CLIENT_CONNECT
echo "create database grant_db" | $BENDSQL_CLIENT_CONNECT
echo "create table grant_db.t(c1 int not null)" | $BENDSQL_CLIENT_CONNECT
echo "create database nogrant" | $BENDSQL_CLIENT_CONNECT
echo "drop user if exists a" | $BENDSQL_CLIENT_CONNECT
echo "create user a identified by '$TEST_USER_PASSWORD'" | $BENDSQL_CLIENT_CONNECT
echo "drop database if exists nogrant" | $BENDSQL_CLIENT_CONNECT
echo "drop database if exists grant_db" | $BENDSQL_CLIENT_CONNECT
echo "create database grant_db" | $BENDSQL_CLIENT_CONNECT
echo "create table grant_db.t(c1 int not null)" | $BENDSQL_CLIENT_CONNECT
echo "create database nogrant" | $BENDSQL_CLIENT_CONNECT
echo "create table nogrant.t(id int not null)" | $BENDSQL_CLIENT_CONNECT
echo "grant select on default.* to a" | $BENDSQL_CLIENT_CONNECT
echo "grant select on grant_db.t to a" | $BENDSQL_CLIENT_CONNECT
echo "drop table if exists default.test_t" | $BENDSQL_CLIENT_CONNECT
echo "create table default.test_t(id int not null)" | $BENDSQL_CLIENT_CONNECT
echo "show grants for a" | $BENDSQL_CLIENT_CONNECT
echo "grant select on default.* to a" | $BENDSQL_CLIENT_CONNECT
echo "grant select on grant_db.t to a" | $BENDSQL_CLIENT_CONNECT
echo "drop table if exists default.test_t" | $BENDSQL_CLIENT_CONNECT
echo "create table default.test_t(id int not null)" | $BENDSQL_CLIENT_CONNECT
echo "show grants for a" | $BENDSQL_CLIENT_CONNECT
echo "show databases" | $USER_A_CONNECT
echo "select 'test -- show tables'" | $BENDSQL_CLIENT_CONNECT
echo "show tables" | $USER_A_CONNECT
Expand Down Expand Up @@ -179,27 +179,27 @@ export USER_B_CONNECT="bendsql --user=b --password=password --host=${QUERY_MYSQL

rm -rf /tmp/00_0020
mkdir -p /tmp/00_0020
cat << EOF > /tmp/00_0020/i0.csv
cat <<EOF >/tmp/00_0020/i0.csv
1
2
EOF

echo "drop user if exists b" | $BENDSQL_CLIENT_CONNECT
echo "create user b identified by '$TEST_USER_PASSWORD'" | $BENDSQL_CLIENT_CONNECT
echo "drop user if exists b" | $BENDSQL_CLIENT_CONNECT
echo "create user b identified by '$TEST_USER_PASSWORD'" | $BENDSQL_CLIENT_CONNECT

echo "drop table if exists t" | $BENDSQL_CLIENT_CONNECT
echo "drop table if exists t1" | $BENDSQL_CLIENT_CONNECT
echo "drop table if exists t2" | $BENDSQL_CLIENT_CONNECT
echo "drop stage if exists s3;" | $BENDSQL_CLIENT_CONNECT
echo "drop stage if exists s3;" | $BENDSQL_CLIENT_CONNECT

echo "create table t(id int)" | $BENDSQL_CLIENT_CONNECT
echo "create table t1(id int)" | $BENDSQL_CLIENT_CONNECT
echo "grant create on default.* to b" | $BENDSQL_CLIENT_CONNECT
echo "grant insert, delete on default.t to b" | $BENDSQL_CLIENT_CONNECT
echo "grant select on system.* to b" | $BENDSQL_CLIENT_CONNECT

echo "create stage s3;" | $BENDSQL_CLIENT_CONNECT
echo "copy into '@s3/a b' from (select 2);" | $BENDSQL_CLIENT_CONNECT
echo "create stage s3;" | $BENDSQL_CLIENT_CONNECT
echo "copy into '@s3/a b' from (select 2);" | $BENDSQL_CLIENT_CONNECT

# need err
echo "insert into t select * from t1" | $USER_B_CONNECT
Expand All @@ -225,11 +225,11 @@ echo "replace into t on(id) select * from t1;" | $USER_B_CONNECT
echo "drop user a" | $BENDSQL_CLIENT_CONNECT
echo "drop user b" | $BENDSQL_CLIENT_CONNECT
echo "drop database if exists no_grant" | $BENDSQL_CLIENT_CONNECT
echo "drop database grant_db" | $BENDSQL_CLIENT_CONNECT
echo "drop database grant_db" | $BENDSQL_CLIENT_CONNECT

echo "drop table if exists t" | $BENDSQL_CLIENT_CONNECT
echo "drop table if exists t1" | $BENDSQL_CLIENT_CONNECT
echo "drop table if exists t2" | $BENDSQL_CLIENT_CONNECT
echo "drop stage if exists s3;" | $BENDSQL_CLIENT_CONNECT
echo "drop stage if exists s3;" | $BENDSQL_CLIENT_CONNECT

echo "unset enable_experimental_rbac_check" | $BENDSQL_CLIENT_CONNECT

0 comments on commit 7559688

Please sign in to comment.