From 39c2646d6a5fc1b6b2fc3ab17e8e095799a3c2d7 Mon Sep 17 00:00:00 2001 From: xtcyclist <7731943+xtcyclist@users.noreply.github.com> Date: Sat, 3 Sep 2022 10:19:52 +0800 Subject: [PATCH] Add a new mode in tck to execute a query and retry in on failure. Have applied in some tck cases. --- tests/tck/conftest.py | 15 +++++++++++++ .../delete/DeleteVertexWithoutEdge.feature | 4 ++-- tests/tck/features/geo/GeoBase.feature | 8 +++---- tests/tck/features/index/Index.feature | 6 ++--- .../features/insert/insertVertexOnly.feature | 2 +- tests/tck/features/lookup/LookUp.feature | 22 +++++++++---------- tests/tck/features/lookup/LookupTag2.feature | 2 +- 7 files changed, 37 insertions(+), 22 deletions(-) diff --git a/tests/tck/conftest.py b/tests/tck/conftest.py index 96c52d3d2a8..140064f7cc0 100644 --- a/tests/tck/conftest.py +++ b/tests/tck/conftest.py @@ -405,6 +405,21 @@ def executing_query(query, exec_ctx, request): ngql = combine_query(query) exec_query(request, ngql, exec_ctx) +@when(parse("executing query and retrying it on failure every {secs:d} seconds for {retryTimes:d} times:\n{query}")) +def executing_query_with_retry(query, exec_ctx, request, secs, retryTimes): + ngql = combine_query(query) + exec_query(request, ngql, exec_ctx) + res = exec_ctx["result_set"] + if not res.is_succeeded(): + retryCounter = 0 + while retryCounter < retryTimes: + time.sleep(secs) + exec_query(request, ngql, exec_ctx) + resRetry = exec_ctx["result_set"] + if not resRetry.is_succeeded(): + retryCounter = retryCounter + 1 + else: + break @when(parse("executing query with user {username} with password {password}:\n{query}")) def executing_query( diff --git a/tests/tck/features/delete/DeleteVertexWithoutEdge.feature b/tests/tck/features/delete/DeleteVertexWithoutEdge.feature index cdc7bb3d6ab..6d30864bd1a 100644 --- a/tests/tck/features/delete/DeleteVertexWithoutEdge.feature +++ b/tests/tck/features/delete/DeleteVertexWithoutEdge.feature @@ -17,7 +17,7 @@ Feature: delete vertex without edge CREATE EDGE e(); """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 9 times: """ INSERT VERTEX t(id) VALUES 1:(1),2:(2),3:(3); INSERT EDGE e() VALUES 1->2:(),1->3:(); @@ -74,7 +74,7 @@ Feature: delete vertex without edge CREATE EDGE e(); """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX t(id) VALUES 1:(1),2:(2),3:(2); INSERT EDGE e() VALUES 1->2:(),1->3:(); diff --git a/tests/tck/features/geo/GeoBase.feature b/tests/tck/features/geo/GeoBase.feature index d40c7b96389..8baa29d71cf 100644 --- a/tests/tck/features/geo/GeoBase.feature +++ b/tests/tck/features/geo/GeoBase.feature @@ -93,7 +93,7 @@ Feature: Geo base """ Then the execution should be successful And wait 3 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX test_1() VALUES "test_101":() """ @@ -245,7 +245,7 @@ Feature: Geo base Then the execution should be successful And wait 3 seconds # Show create tag index - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ SHOW CREATE TAG INDEX any_shape_geo_index; """ @@ -741,7 +741,7 @@ Feature: Geo base """ Then the execution should be successful And wait 3 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ LOOKUP ON any_shape YIELD id(vertex) as id; """ @@ -753,7 +753,7 @@ Feature: Geo base """ Then the execution should be successful And wait 3 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ LOOKUP ON any_shape_edge YIELD edge as e; """ diff --git a/tests/tck/features/index/Index.feature b/tests/tck/features/index/Index.feature index f07fc1bab45..8fcc8763177 100644 --- a/tests/tck/features/index/Index.feature +++ b/tests/tck/features/index/Index.feature @@ -839,7 +839,7 @@ Feature: IndexTest_Vid_String CREATE EDGE INDEX name_edge_index ON name_edge(name(10)); """ Then the execution should be successful - And wait 6 seconds + And wait 12 seconds When submit a job: """ REBUILD EDGE INDEX; @@ -1000,7 +1000,7 @@ Feature: IndexTest_Vid_String CREATE TAG student(name string, age int); """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX student(name, age) @@ -1021,7 +1021,7 @@ Feature: IndexTest_Vid_String """ Then the execution should be successful And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ CREATE TAG INDEX student_name_teacher ON student(name(10), teacher(10)) """ diff --git a/tests/tck/features/insert/insertVertexOnly.feature b/tests/tck/features/insert/insertVertexOnly.feature index f8eb92ec5f6..f127d84a81a 100644 --- a/tests/tck/features/insert/insertVertexOnly.feature +++ b/tests/tck/features/insert/insertVertexOnly.feature @@ -16,7 +16,7 @@ Feature: insert vertex without tag CREATE EDGE e(); """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX VALUES 1:(),2:(),3:(); INSERT EDGE e() VALUES 1->2:(),2->3:(); diff --git a/tests/tck/features/lookup/LookUp.feature b/tests/tck/features/lookup/LookUp.feature index 769d1503148..99c5624e8d2 100644 --- a/tests/tck/features/lookup/LookUp.feature +++ b/tests/tck/features/lookup/LookUp.feature @@ -19,7 +19,7 @@ Feature: LookUpTest_Vid_String CREATE TAG INDEX t_index_5 ON lookup_tag_2(col4); """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX lookup_tag_1(col1, col2, col3) @@ -55,7 +55,7 @@ Feature: LookUpTest_Vid_String CREATE EDGE INDEX e_index_4 ON lookup_edge_2(col3, col4); """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT EDGE lookup_edge_1(col1, col2, col3) @@ -94,7 +94,7 @@ Feature: LookUpTest_Vid_String CREATE TAG INDEX t_index_5 ON lookup_tag_2(col4); """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX lookup_tag_2(col1, col2, col3, col4) @@ -244,7 +244,7 @@ Feature: LookUpTest_Vid_String CREATE EDGE INDEX e_index_4 ON lookup_edge_2(col3, col4); """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT EDGE lookup_edge_2(col1, col2, col3, col4) @@ -389,7 +389,7 @@ Feature: LookUpTest_Vid_String CREATE TAG INDEX t_index_5 ON lookup_tag_2(col4); """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX lookup_tag_2(col1, col2, col3, col4) @@ -518,7 +518,7 @@ Feature: LookUpTest_Vid_String CREATE TAG teacher(number int, age int) """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX student(number, age), teacher(number, age) VALUES "220":(1, 20, 1, 30), "221":(2, 22, 2, 32) """ @@ -573,7 +573,7 @@ Feature: LookUpTest_Vid_String CREATE TAG INDEX i5 ON t1(c1, c2, c3, c5) """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ LOOKUP ON t1 WHERE t1.c1 == 1 YIELD vertex as node """ @@ -651,7 +651,7 @@ Feature: LookUpTest_Vid_String CREATE TAG INDEX i5_str ON t1_str(c1, c2, c3(30), c4(30)) """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ LOOKUP ON t1_str WHERE t1_str.c1 == 1 YIELD t1_str.c1 """ @@ -711,7 +711,7 @@ Feature: LookUpTest_Vid_String CREATE TAG INDEX i3_with_str ON tag_with_str(c1, c2(30), c3(30)) """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX tag_with_str(c1, c2, c3) @@ -781,7 +781,7 @@ Feature: LookUpTest_Vid_String identity(BIRTHDAY, NATION(30), BIRTHPLACE_CITY(30)) """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX identity(BIRTHDAY, NATION, BIRTHPLACE_CITY) VALUES "1" : (19860413, "汉族", "aaa") """ @@ -973,7 +973,7 @@ Feature: LookUpTest_Vid_String CREATE TAG player(name string, age int); """ And wait 6 seconds - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ INSERT VERTEX player(name, age) VALUES 'Tim':('Tim', 20); """ diff --git a/tests/tck/features/lookup/LookupTag2.feature b/tests/tck/features/lookup/LookupTag2.feature index 1ed10b7d328..784653cdef7 100644 --- a/tests/tck/features/lookup/LookupTag2.feature +++ b/tests/tck/features/lookup/LookupTag2.feature @@ -58,7 +58,7 @@ Feature: Test lookup on tag index 2 Then drop the used space Scenario Outline: [tag] scan without hints - When executing query: + When executing query and retrying it on failure every 6 seconds for 3 times: """ LOOKUP ON lookup_tag_1