From dc4945916579fd5984cf8949ccfed75ee167c003 Mon Sep 17 00:00:00 2001 From: Chris Zhai Date: Fri, 21 Jun 2024 15:51:56 +0800 Subject: [PATCH 1/2] add test cases for TD-30642 --- tests/army/grant/grantBugs.py | 66 ++++++++++++++++++++++++++++++++++ tests/parallel_test/cases.task | 1 + 2 files changed, 67 insertions(+) create mode 100644 tests/army/grant/grantBugs.py diff --git a/tests/army/grant/grantBugs.py b/tests/army/grant/grantBugs.py new file mode 100644 index 0000000000..acddefe51a --- /dev/null +++ b/tests/army/grant/grantBugs.py @@ -0,0 +1,66 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import frame.etool + +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame import * +from frame.autogen import * + + +class TDTestCase(TBase): + + def td_30642(self): + tdLog.info("create database td_30642") + tdSql.execute(f"create database td_30642") + tdSql.execute(f"use td_30642") + sqls = [ + "CREATE DATABASE IF NOT EXISTS `_xTest2`", + "CREATE USER `_xTest` PASS 'taosdata'", + "CREATE TABLE IF NOT EXISTS `_xTest2`.`meters` (ts timestamp, v1 int) tags(t1 int)", + + "CREATE DATABASE IF NOT EXISTS `test2`", + "CREATE USER `user1` PASS 'taosdata'", + "CREATE TABLE IF NOT EXISTS `test2`.`meters2` (ts timestamp, v1 int) tags(t1 int)" + ] + tdSql.executes(sqls) + + sql1 = 'GRANT read ON `_xTest2`.`meters` WITH (t1 = 1) TO `_xTest`' + tdSql.query(sql1) + sql1_verify = "select * from information_schema.ins_user_privileges where user_name='_xTest' and privilege='read' and db_name='_xTest2' and table_name='meters'" + tdSql.query(sql1_verify) + tdSql.checkRows(1) + + sql2 = 'GRANT write ON test2.meters2 WITH (t1 = 1) TO user1' + tdSql.query(sql2) + sql2_verify = "select * from information_schema.ins_user_privileges where user_name='user1' and privilege='write' and db_name='test2' and table_name='meters2'" + tdSql.query(sql2_verify) + tdSql.checkRows(1) + + # run + def run(self): + tdLog.debug(f"start to excute {__file__}") + + # TD-30642 + self.td_30642() + + + tdLog.success(f"{__file__} successfully executed") + + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 6114a560dc..b96c8eb030 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -30,6 +30,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f query/subquery/subqueryBugs.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f storage/oneStageComp.py -N 3 -L 3 -D 1 ,,y,army,./pytest.sh python3 ./test.py -f storage/compressBasic.py -N 3 +,,y,army,./pytest.sh python3 ./test.py -f grant/grantBugs.py -N 3 # # system test From f3bc93ce6aca31c54d696ae9a16f0bb668f6aa76 Mon Sep 17 00:00:00 2001 From: Chris Zhai Date: Sat, 22 Jun 2024 12:55:15 +0800 Subject: [PATCH 2/2] add data verification --- tests/army/grant/grantBugs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/army/grant/grantBugs.py b/tests/army/grant/grantBugs.py index acddefe51a..8888d50861 100644 --- a/tests/army/grant/grantBugs.py +++ b/tests/army/grant/grantBugs.py @@ -24,9 +24,6 @@ from frame.autogen import * class TDTestCase(TBase): def td_30642(self): - tdLog.info("create database td_30642") - tdSql.execute(f"create database td_30642") - tdSql.execute(f"use td_30642") sqls = [ "CREATE DATABASE IF NOT EXISTS `_xTest2`", "CREATE USER `_xTest` PASS 'taosdata'", @@ -43,12 +40,14 @@ class TDTestCase(TBase): sql1_verify = "select * from information_schema.ins_user_privileges where user_name='_xTest' and privilege='read' and db_name='_xTest2' and table_name='meters'" tdSql.query(sql1_verify) tdSql.checkRows(1) + tdSql.checkData(0, 4, '(`_xTest2`.`meters`.`t1` = 1)') sql2 = 'GRANT write ON test2.meters2 WITH (t1 = 1) TO user1' tdSql.query(sql2) sql2_verify = "select * from information_schema.ins_user_privileges where user_name='user1' and privilege='write' and db_name='test2' and table_name='meters2'" tdSql.query(sql2_verify) tdSql.checkRows(1) + tdSql.checkData(0, 4, '(`test2`.`meters2`.`t1` = 1)') # run def run(self):