diff --git a/tests/Makefile b/tests/Makefile index acca9cdcaa2..5200dc86219 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -118,6 +118,7 @@ test: sess $(test_j) --dist=loadfile -k "not tck" $(TEST_DIR) slow-query: currdir + $(test_j) tck/steps/test_kill_slow_query_base_test.py && \ $(test_j) tck/steps/test_kill_slow_query_via_same_service.py && \ $(test_j) tck/steps/test_kill_slow_query_via_different_service.py && \ $(test_j) tck/steps/test_kill_permission_via_same_service.py && \ diff --git a/tests/tck/slowquery/KillSlowQueryBaseTest.feature b/tests/tck/slowquery/KillSlowQueryBaseTest.feature new file mode 100644 index 00000000000..76badfb4601 --- /dev/null +++ b/tests/tck/slowquery/KillSlowQueryBaseTest.feature @@ -0,0 +1,101 @@ +# Copyright (c) 2022 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: Slow Query Test + + Background: + Given a graph with space named "nba" + + Scenario: [slowquery_test_001] without sessionId and planId + When executing query: + """ + KILL QUERY () + """ + Then a SyntaxError should be raised at runtime: syntax error near `)' + + Scenario: [slowquery_test_002] without sessionId + When executing query: + """ + KILL QUERY (session=123) + """ + Then a SyntaxError should be raised at runtime: syntax error near `)' + + Scenario: [slowquery_test_003] without planId + When executing query: + """ + KILL QUERY (plan=987654321) + """ + Then an ExecutionError should be raised at runtime: ExecutionPlanId[987654321] does not exist in current Session. + + Scenario: [slowquery_test_004] wrong sessionId and planId + When executing query: + """ + KILL QUERY (session=987654321, plan=987654321) + """ + Then an ExecutionError should be raised at runtime: SessionId[987654321] does not exist + + Scenario: [slowquery_test_005] sessionId is STRING + When executing query: + """ + KILL QUERY (session="100", plan=101) + """ + Then a SyntaxError should be raised at runtime: syntax error near `", plan=' + + Scenario: [slowquery_test_006] planId is STRING + When executing query: + """ + KILL QUERY (session=100, plan="101") + """ + Then a SyntaxError should be raised at runtime: syntax error near `")' + + Scenario: [slowquery_test_007] sessionId and planId are STRING + When executing query: + """ + KILL QUERY (session="100", plan="101") + """ + Then a SyntaxError should be raised at runtime: syntax error near `", plan=' + + Scenario: [slowquery_test_008] wrong sessionId + When executing query: + """ + KILL QUERY (session=$-.sid) + """ + Then an SyntaxError should be raised at runtime: syntax error near `)' + + Scenario: [slowquery_test_009] wrong planId + When executing query: + """ + KILL QUERY (plan=$-.eid) + """ + Then an SemanticError should be raised at runtime: `$-.eid', not exist prop `eid' + + Scenario: [slowquery_test_010] wrong sessionId and planId + When executing query: + """ + KILL QUERY (session=$-.sid, plan=$-.eid) + """ + Then an SemanticError should be raised at runtime: `$-.sid', not exist prop `sid' + + Scenario: [slowquery_test_011] show queries + When executing query: + """ + SHOW LOCAL QUERIES + """ + Then the execution should be successful + + Scenario: [slowquery_test_012] show queries + When executing query: + """ + SHOW QUERIES + """ + Then the execution should be successful + + Scenario: [slowquery_test_013] sessionId is string + When executing query via graph 1: + """ + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.`Query` AS eid, $-.DurationInUSec AS dur WHERE $-.DurationInUSec > 10000000 + | ORDER BY $-.dur + | KILL QUERY (session=$-.sid, plan=$-.eid) + """ + Then an SemanticError should be raised at runtime: $-.eid, Session ID must be an integer but was STRING diff --git a/tests/tck/slowquery/KillSlowQueryViaDiffrentService.feature b/tests/tck/slowquery/KillSlowQueryViaDiffrentService.feature index 63a6fe57642..bd049e943bf 100644 --- a/tests/tck/slowquery/KillSlowQueryViaDiffrentService.feature +++ b/tests/tck/slowquery/KillSlowQueryViaDiffrentService.feature @@ -3,36 +3,26 @@ # This source code is licensed under Apache 2.0 License. Feature: Slow Query Test + Background: + Given a graph with space named "nba" + # There should be a least 2 thread to run this test case suite. - Scenario: Set up slow query at first graph service + Scenario: [slowquery_test_101] Setup slow query # Set up a slow query which will be killed later. - Given a graph with space named "nba" When executing query via graph 0: """ GO 100000 STEPS FROM "Tim Duncan" OVER like YIELD like._dst """ Then an ExecutionError should be raised at runtime: Execution had been killed - Scenario: Show all queries and kill all slow queries at second graph service - When executing query via graph 1: - """ - SHOW LOCAL QUERIES - """ - Then the execution should be successful + Scenario: [slowquery_test_102] Kill go sentence When executing query via graph 1: """ SHOW QUERIES """ Then the execution should be successful - # In case that rebuild indexes cost too much time. + # make sure the record exists And wait 10 seconds - When executing query via graph 1: - """ - SHOW QUERIES - """ - Then the result should be, in order: - | SessionID | ExecutionPlanID | User | Host | StartTime | DurationInUSec | Status | Query | - | /\d+/ | /\d+/ | "root" | /.*/ | /.*/ | /\d+/ | "RUNNING" | "GO 100000 STEPS FROM \"Tim Duncan\" OVER like YIELD like._dst" | When executing query via graph 1: """ SHOW QUERIES @@ -42,49 +32,32 @@ Feature: Slow Query Test Then the result should be, in order: | sid | eid | dur | | /\d+/ | /\d+/ | /\d+/ | + # sessionId not exist When executing query via graph 1: """ - KILL QUERY () - """ - Then a SyntaxError should be raised at runtime: syntax error near `)' - When executing query via graph 1: - """ - KILL QUERY (session=123) - """ - Then a SyntaxError should be raised at runtime: syntax error near `)' - When executing query via graph 1: - """ - KILL QUERY (plan=987654321) - """ - Then an ExecutionError should be raised at runtime: ExecutionPlanId[987654321] does not exist in current Session. - When executing query via graph 1: - """ - KILL QUERY (session=987654321, plan=987654321) - """ - Then an ExecutionError should be raised at runtime: SessionId[987654321] does not exist - When executing query via graph 1: - """ - KILL QUERY (session=$-.sid, plan=$-.eid) - """ - Then an SemanticError should be raised at runtime: `$-.sid', not exist prop `sid' - When executing query via graph 1: - """ - KILL QUERY (plan=$-.eid) + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100000 STEPS" + | ORDER BY $-.dur + | KILL QUERY(session=200, plan=$-.eid) """ - Then an SemanticError should be raised at runtime: `$-.eid', not exist prop `eid' + Then an ExecutionError should be raised at runtime: SessionId[200] does not exist + # planId not exist When executing query via graph 1: """ SHOW QUERIES - | YIELD $-.SessionID AS sid, $-.`Query` AS eid, $-.DurationInUSec AS dur WHERE $-.DurationInUSec > 10000000 + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100000 STEPS" | ORDER BY $-.dur - | KILL QUERY (session=$-.sid, plan=$-.eid) + | KILL QUERY(session=$-.sid, plan=201) """ - Then an SemanticError should be raised at runtime: $-.eid, Session ID must be an integer but was STRING + Then an ExecutionError should be raised at runtime. + # Kill go sentence When executing query via graph 1: """ SHOW QUERIES | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur - WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO" + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100000 STEPS" | ORDER BY $-.dur | KILL QUERY(session=$-.sid, plan=$-.eid) """ diff --git a/tests/tck/slowquery/KillSlowQueryViaSameService.feature b/tests/tck/slowquery/KillSlowQueryViaSameService.feature index 55e70185f60..b911704d0e3 100644 --- a/tests/tck/slowquery/KillSlowQueryViaSameService.feature +++ b/tests/tck/slowquery/KillSlowQueryViaSameService.feature @@ -3,36 +3,26 @@ # This source code is licensed under Apache 2.0 License. Feature: Slow Query Test + Background: + Given a graph with space named "nba" + # There should be a least 2 thread to run this test case suite. - Scenario: Set up slow query + Scenario: [slowquery_test_201] Setup slow query # Set up a slow query which will be killed later. - Given a graph with space named "nba" When executing query: """ GO 100000 STEPS FROM "Tim Duncan" OVER like YIELD like._dst """ Then an ExecutionError should be raised at runtime: Execution had been killed - Scenario: Show all queries and kill all slow queries - When executing query: - """ - SHOW LOCAL QUERIES - """ - Then the execution should be successful + Scenario: [slowquery_test_202] kill go sentence on same service When executing query: """ SHOW QUERIES """ Then the execution should be successful - # In case that rebuild indexes cost too much time. And wait 10 seconds - When executing query: - """ - SHOW QUERIES - """ - Then the result should be, in order: - | SessionID | ExecutionPlanID | User | Host | StartTime | DurationInUSec | Status | Query | - | /\d+/ | /\d+/ | "root" | /.*/ | /.*/ | /\d+/ | "RUNNING" | "GO 100000 STEPS FROM \"Tim Duncan\" OVER like YIELD like._dst" | + # make sure the record exists When executing query: """ SHOW QUERIES @@ -42,49 +32,11 @@ Feature: Slow Query Test Then the result should be, in order: | sid | eid | dur | | /\d+/ | /\d+/ | /\d+/ | - When executing query: - """ - KILL QUERY () - """ - Then a SyntaxError should be raised at runtime: syntax error near `)' - When executing query: - """ - KILL QUERY (session=123) - """ - Then a SyntaxError should be raised at runtime: syntax error near `)' - When executing query: - """ - KILL QUERY (plan=987654321) - """ - Then an ExecutionError should be raised at runtime: ExecutionPlanId[987654321] does not exist in current Session. - When executing query: - """ - KILL QUERY (session=987654321, plan=987654321) - """ - Then an ExecutionError should be raised at runtime: SessionId[987654321] does not exist - When executing query: - """ - KILL QUERY (session=$-.sid, plan=$-.eid) - """ - Then an SemanticError should be raised at runtime: `$-.sid', not exist prop `sid' - When executing query: - """ - KILL QUERY (plan=$-.eid) - """ - Then an SemanticError should be raised at runtime: `$-.eid', not exist prop `eid' - When executing query: - """ - SHOW QUERIES - | YIELD $-.SessionID AS sid, $-.`Query` AS eid, $-.DurationInUSec AS dur WHERE $-.DurationInUSec > 10000000 - | ORDER BY $-.dur - | KILL QUERY (session=$-.sid, plan=$-.eid) - """ - Then an SemanticError should be raised at runtime: $-.eid, Session ID must be an integer but was STRING When executing query: """ SHOW QUERIES | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur - WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO" + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100000 STEPS" | ORDER BY $-.dur | KILL QUERY(session=$-.sid, plan=$-.eid) """ diff --git a/tests/tck/slowquery/PermissionViaDifferentService.feature b/tests/tck/slowquery/PermissionViaDifferentService.feature new file mode 100644 index 00000000000..de27708c250 --- /dev/null +++ b/tests/tck/slowquery/PermissionViaDifferentService.feature @@ -0,0 +1,146 @@ +# Copyright (c) 2021 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: Test kill queries permission from different services + + Background: + Given a graph with space named "nba" + + Scenario: [slowquery_test_301] Setup slow query by user root + # Set up a slow query which will be killed later. + When executing query via graph 1: + """ + USE nba; + GO 100001 STEPS FROM "Tim Duncan" OVER like YIELD like._dst + """ + Then an ExecutionError should be raised at runtime: Execution had been killed + + Scenario: [slowquery_test_302] Kill successful by user root + When executing query: + """ + CREATE USER IF NOT EXISTS test_permission WITH PASSWORD 'test'; + GRANT ROLE USER ON nba TO test_permission; + """ + Then the execution should be successful + And wait 10 seconds + # Make sure the record exists + When executing query with user test_permission with password test: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100001 STEPS"; + """ + Then the result should be, in order: + | sid | eid | dur | + | /\d+/ | /\d+/ | /\d+/ | + # Kill failed by user test_permission + When executing query with user test_permission with password test: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100001 STEPS" + | ORDER BY $-.dur + | KILL QUERY(session=$-.sid, plan=$-.eid) + """ + Then an PermissionError should be raised at runtime: Only GOD role could kill others' queries. + # Kill successful by user root + When executing query with user root with password nebula: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100001 STEPS" + | ORDER BY $-.dur + | KILL QUERY(session=$-.sid, plan=$-.eid) + """ + Then the execution should be successful + + Scenario: [slowquery_test_303] Setup slow query by user test_permission + When executing query: + """ + CREATE USER IF NOT EXISTS test_permission WITH PASSWORD 'test'; + GRANT ROLE USER ON nba TO test_permission; + """ + Then the execution should be successful + And wait 5 seconds + When executing query with user test_permission with password test: + """ + USE nba; + GO 100002 STEPS FROM "Tim Duncan" OVER like YIELD like._dst + """ + Then an ExecutionError should be raised at runtime: Execution had been killed + + Scenario: [slowquery_test_304] Kill successful by user test_permission + When executing query: + """ + SHOW QUERIES + """ + Then the execution should be successful + And wait 15 seconds + # Make sure the record exists + When executing query with user test_permission with password test: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100002 STEPS"; + """ + Then the result should be, in order: + | sid | eid | dur | + | /\d+/ | /\d+/ | /\d+/ | + When executing query with user test_permission with password test: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100002 STEPS" + | ORDER BY $-.dur + | KILL QUERY(session=$-.sid, plan=$-.eid) + """ + Then the execution should be successful + + Scenario: [slowquery_test_305] Setup slow query by user test_permission + When executing query: + """ + CREATE USER IF NOT EXISTS test_permission WITH PASSWORD 'test'; + GRANT ROLE USER ON nba TO test_permission; + """ + Then the execution should be successful + And wait 5 seconds + When executing query with user test_permission with password test: + """ + USE nba; + GO 100003 STEPS FROM "Tim Duncan" OVER like YIELD like._dst + """ + Then an ExecutionError should be raised at runtime: Execution had been killed + + Scenario: [slowquery_test_306] Kill successful by user root + When executing query: + """ + SHOW QUERIES + """ + Then the execution should be successful + And wait 15 seconds + # Make sure the record exists + When executing query with user root with password nebula: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100003 STEPS"; + """ + Then the result should be, in order: + | sid | eid | dur | + | /\d+/ | /\d+/ | /\d+/ | + When executing query with user root with password nebula: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100003 STEPS" + | ORDER BY $-.dur + | KILL QUERY(session=$-.sid, plan=$-.eid) + """ + Then the execution should be successful diff --git a/tests/tck/slowquery/PermissionViaSameService.feature b/tests/tck/slowquery/PermissionViaSameService.feature new file mode 100644 index 00000000000..a09e816df51 --- /dev/null +++ b/tests/tck/slowquery/PermissionViaSameService.feature @@ -0,0 +1,99 @@ +# Copyright (c) 2021 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: Test kill queries from same service + + Background: + Given a graph with space named "nba" + + Scenario: [slowquery_test_401] Setup slow query + # Set up a slow query which will be killed later. + When executing query: + """ + GO 100001 STEPS FROM "Tim Duncan" OVER like YIELD like._dst + """ + Then an ExecutionError should be raised at runtime: Execution had been killed + + Scenario: [slowquery_test_402] Kill successful by user root + When executing query: + """ + CREATE USER IF NOT EXISTS test_permission WITH PASSWORD 'test'; + GRANT ROLE USER ON nba TO test_permission; + """ + Then the execution should be successful + And wait 10 seconds + # Make sure the record exists + When executing query with user test_permission with password test: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100001 STEPS"; + """ + Then the result should be, in order: + | sid | eid | dur | + | /\d+/ | /\d+/ | /\d+/ | + When executing query with user test_permission with password test: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100001 STEPS" + | ORDER BY $-.dur + | KILL QUERY(session=$-.sid, plan=$-.eid) + """ + Then an PermissionError should be raised at runtime: Only GOD role could kill others' queries. + When executing query with user root with password nebula: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100001 STEPS" + | ORDER BY $-.dur + | KILL QUERY(session=$-.sid, plan=$-.eid) + """ + Then the execution should be successful + + Scenario: [slowquery_test_403] Setup slow query + When executing query: + """ + CREATE USER IF NOT EXISTS test_permission WITH PASSWORD 'test'; + GRANT ROLE USER ON nba TO test_permission; + """ + Then the execution should be successful + And wait 5 seconds + When executing query with user test_permission with password test: + """ + USE nba; + GO 100002 STEPS FROM "Tim Duncan" OVER like YIELD like._dst + """ + Then an ExecutionError should be raised at runtime: Execution had been killed + + Scenario: [slowquery_test_404] Kill successful by user test_permission + When executing query: + """ + SHOW QUERIES + """ + Then the execution should be successful + # Make sure the record exists + And wait 15 seconds + When executing query with user test_permission with password test: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100002 STEPS"; + """ + Then the result should be, in order: + | sid | eid | dur | + | /\d+/ | /\d+/ | /\d+/ | + When executing query with user test_permission with password test: + """ + USE nba; + SHOW QUERIES + | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur + WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO 100002 STEPS" + | ORDER BY $-.dur + | KILL QUERY(session=$-.sid, plan=$-.eid) + """ + Then the execution should be successful diff --git a/tests/tck/slowquery/permissionViaDifferentService.feature b/tests/tck/slowquery/permissionViaDifferentService.feature deleted file mode 100644 index 9dd4e23b073..00000000000 --- a/tests/tck/slowquery/permissionViaDifferentService.feature +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) 2022 vesoft inc. All rights reserved. -# -# This source code is licensed under Apache 2.0 License. -Feature: Test kill queries permission from different services - - Scenario: Setup slow query in service 1 - # Set up a slow query which will be killed later. - Given a graph with space named "nba" - When executing query via graph 1: - """ - USE nba; - GO 100000 STEPS FROM "Tim Duncan" OVER like YIELD like._dst - """ - Then an ExecutionError should be raised at runtime: Execution had been killed - - Scenario: Test permisson of kill queries from service 0 - Given a graph with space named "nba" - When executing query: - """ - CREATE USER IF NOT EXISTS test_permission WITH PASSWORD 'test'; - GRANT ROLE USER ON nba TO test_permission; - """ - Then the execution should be successful - And wait 3 seconds - When executing query with user test_permission with password test: - """ - USE nba; - SHOW QUERIES - | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur - WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO" - | ORDER BY $-.dur - | KILL QUERY(session=$-.sid, plan=$-.eid) - """ - Then an PermissionError should be raised at runtime: Only GOD role could kill others' queries. - When executing query with user root with password nebula: - """ - USE nba; - SHOW QUERIES - | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur - WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO" - | ORDER BY $-.dur - | KILL QUERY(session=$-.sid, plan=$-.eid) - """ - Then the execution should be successful diff --git a/tests/tck/slowquery/permissionViaSameService.feature b/tests/tck/slowquery/permissionViaSameService.feature deleted file mode 100644 index 61043e82385..00000000000 --- a/tests/tck/slowquery/permissionViaSameService.feature +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2022 vesoft inc. All rights reserved. -# -# This source code is licensed under Apache 2.0 License. -Feature: Test kill queries from same service - - Scenario: Setup slow query - # Set up a slow query which will be killed later. - Given a graph with space named "nba" - When executing query: - """ - GO 100000 STEPS FROM "Tim Duncan" OVER like YIELD like._dst - """ - Then an ExecutionError should be raised at runtime: Execution had been killed - - Scenario: Test permisson of kill queries - Given a graph with space named "nba" - When executing query: - """ - CREATE USER IF NOT EXISTS test_permission WITH PASSWORD 'test'; - GRANT ROLE USER ON nba TO test_permission; - """ - Then the execution should be successful - And wait 3 seconds - When executing query with user test_permission with password test: - """ - USE nba; - SHOW QUERIES - | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur - WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO" - | ORDER BY $-.dur - | KILL QUERY(session=$-.sid, plan=$-.eid) - """ - Then an PermissionError should be raised at runtime: Only GOD role could kill others' queries. - When executing query with user root with password nebula: - """ - USE nba; - SHOW QUERIES - | YIELD $-.SessionID AS sid, $-.ExecutionPlanID AS eid, $-.DurationInUSec AS dur - WHERE $-.DurationInUSec > 1000000 AND $-.`Query` CONTAINS "GO" - | ORDER BY $-.dur - | KILL QUERY(session=$-.sid, plan=$-.eid) - """ - Then the execution should be successful diff --git a/tests/tck/steps/test_kill_permission_via_different_service.py b/tests/tck/steps/test_kill_permission_via_different_service.py index bbbb0fd842c..c20146ea4d9 100644 --- a/tests/tck/steps/test_kill_permission_via_different_service.py +++ b/tests/tck/steps/test_kill_permission_via_different_service.py @@ -4,4 +4,4 @@ from pytest_bdd import scenarios -scenarios('slowquery/permissionViaDifferentService.feature') +scenarios('slowquery/PermissionViaDifferentService.feature') diff --git a/tests/tck/steps/test_kill_permission_via_same_service.py b/tests/tck/steps/test_kill_permission_via_same_service.py index 0eb0b764eb5..e160535c8f3 100644 --- a/tests/tck/steps/test_kill_permission_via_same_service.py +++ b/tests/tck/steps/test_kill_permission_via_same_service.py @@ -4,4 +4,4 @@ from pytest_bdd import scenarios -scenarios('slowquery/permissionViaSameService.feature') +scenarios('slowquery/PermissionViaSameService.feature') diff --git a/tests/tck/steps/test_kill_slow_query_base_test.py b/tests/tck/steps/test_kill_slow_query_base_test.py new file mode 100644 index 00000000000..ead91174493 --- /dev/null +++ b/tests/tck/steps/test_kill_slow_query_base_test.py @@ -0,0 +1,7 @@ +# Copyright (c) 2022 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. + +from pytest_bdd import scenarios + +scenarios('slowquery/KillSlowQueryBaseTest.feature')