Skip to content

Commit

Permalink
update tck of kill-query (#5025)
Browse files Browse the repository at this point in the history
* update tck of kill-query

* format

* fix tck

* add some tck

* fix copyright

* copyright

Co-authored-by: Sophie <[email protected]>
  • Loading branch information
caton-hpg and Sophie-Xie authored Dec 27, 2022
1 parent ab790b1 commit f8935e0
Show file tree
Hide file tree
Showing 11 changed files with 383 additions and 191 deletions.
1 change: 1 addition & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
101 changes: 101 additions & 0 deletions tests/tck/slowquery/KillSlowQueryBaseTest.feature
Original file line number Diff line number Diff line change
@@ -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
67 changes: 20 additions & 47 deletions tests/tck/slowquery/KillSlowQueryViaDiffrentService.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
"""
Expand Down
62 changes: 7 additions & 55 deletions tests/tck/slowquery/KillSlowQueryViaSameService.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
"""
Expand Down
Loading

0 comments on commit f8935e0

Please sign in to comment.