diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index a64bb0b83..daf659e91 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -18,7 +18,7 @@ jobs: - ubuntu1604 - ubuntu1804 - ubuntu2004 - - centos6 + # - centos6 - centos7 - centos8 container: diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 2540b9b84..11f2f8acf 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -92,7 +92,7 @@ jobs: -DENABLE_TESTING=on \ -DENABLE_BUILD_STORAGE=on \ -B build - echo "::set-output name=j::8" + echo "::set-output name=j::10" ;; ubuntu1804) # build with Debug type @@ -103,7 +103,7 @@ jobs: -DENABLE_TESTING=on \ -DENABLE_BUILD_STORAGE=on \ -B build - echo "::set-output name=j::8" + echo "::set-output name=j::10" ;; esac ;; @@ -117,7 +117,7 @@ jobs: -DENABLE_TESTING=on \ -DENABLE_BUILD_STORAGE=on \ -B build - echo "::set-output name=j::4" + echo "::set-output name=j::6" ;; esac - name: Make graph diff --git a/tests/Makefile b/tests/Makefile index 7f024111b..bb0e180ec 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -11,7 +11,7 @@ gherkin_fmt = ~/.local/bin/reformat-gherkin RM_DIR ?= true TEST_DIR ?= $(CURR_DIR) -J ?= 8 +J ?= 10 install-deps: pip3 install --user -U setuptools wheel -i $(PYPI_MIRROR) diff --git a/tests/common/comparator.py b/tests/common/comparator.py index b938a5a53..3468f7616 100644 --- a/tests/common/comparator.py +++ b/tests/common/comparator.py @@ -6,6 +6,7 @@ import math import re +from enum import Enum from typing import Union, Dict, List from nebula2.common.ttypes import ( DataSet, @@ -20,17 +21,19 @@ KV = Dict[Union[str, bytes], Value] Pattern = type(re.compile(r'/')) +CmpType = Enum('CmpType', ('EQUAL', 'CONTAINS', 'NOT_CONTAINS')) + class DataSetComparator: def __init__(self, strict=True, order=False, - included=False, - decode_type: str = 'utf-8', + contains=CmpType.EQUAL, + decode_type='utf-8', vid_fn=None): self._strict = strict self._order = order - self._included = included + self._contains = contains self._decode_type = decode_type self._vid_fn = vid_fn @@ -43,12 +46,18 @@ def b(self, v: str) -> bytes: def s(self, b: bytes) -> str: return b.decode(self._decode_type) + def _whether_return(self, cmp: bool) -> bool: + return ((self._contains == CmpType.EQUAL and not cmp) + or (self._contains == CmpType.NOT_CONTAINS and cmp)) + def compare(self, resp: DataSet, expect: DataSet): + if self._contains == CmpType.NOT_CONTAINS and len(resp.rows) == 0: + return True, None if all(x is None for x in [expect, resp]): return True, None if None in [expect, resp]: return False, -1 - if len(resp.rows) < len(expect.rows): + if len(resp.rows) < len(expect.rows) and self._contains == CmpType.EQUAL: return False, -1 if len(resp.column_names) != len(expect.column_names): return False, -1 @@ -57,13 +66,14 @@ def compare(self, resp: DataSet, expect: DataSet): return False, -2 if self._order: for i in range(0, len(expect.rows)): - if not self.compare_row(resp.rows[i], expect.rows[i]): + cmp = self.compare_row(resp.rows[i], expect.rows[i]) + if self._whether_return(cmp): return False, i - if self._included: + if self._contains == CmpType.CONTAINS: return True, None return len(resp.rows) == len(expect.rows), -1 return self._compare_list(resp.rows, expect.rows, self.compare_row, - self._included) + self._contains) def compare_value(self, lhs: Value, rhs: Union[Value, Pattern]) -> bool: """ @@ -327,7 +337,7 @@ def compare_row(self, lhs: Row, rhs: Row): return all( self.compare_value(l, r) for (l, r) in zip(lhs.values, rhs.values)) - def _compare_list(self, lhs, rhs, cmp_fn, included=False): + def _compare_list(self, lhs, rhs, cmp_fn, contains=False): visited = [] for j, rr in enumerate(rhs): found = False @@ -336,9 +346,11 @@ def _compare_list(self, lhs, rhs, cmp_fn, included=False): visited.append(i) found = True break - if not found: + if self._whether_return(found): return False, j size = len(lhs) - if included: + if contains == CmpType.CONTAINS: return len(visited) <= size, -1 + if contains == CmpType.NOT_CONTAINS: + return True, -1 return len(visited) == size, -1 diff --git a/tests/common/types.py b/tests/common/types.py index 404666ce7..335eb9bd5 100644 --- a/tests/common/types.py +++ b/tests/common/types.py @@ -48,6 +48,9 @@ def use_stmt(self) -> str: def drop_stmt(self) -> str: return f"DROP SPACE IF EXISTS `{self.name}`;" + def is_int_vid(self) -> bool: + return self.vid_type == 'int' + class Column: def __init__(self, index: int): diff --git a/tests/common/utils.py b/tests/common/utils.py index ecfe27c08..e200dac62 100644 --- a/tests/common/utils.py +++ b/tests/common/utils.py @@ -321,37 +321,72 @@ def space_generator(size=6, chars=string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) -def check_resp(resp, stmt): - assert resp is not None, "response is None" +def check_resp(resp, stmt: str): + assert resp is not None, f"response is None, stmt: {stmt}" msg = f"Fail to exec: {stmt}, error: {resp.error_msg()}" assert resp.is_succeeded(), msg -def response(sess, stmt): +def retry(times: int, predicate=lambda x: x and x.is_succeeded()): + def _retry(func): + def wrapper(*args, **kwargs): + resp = None + for i in range(times): + resp = func(*args, **kwargs) + if predicate(resp): + return resp + time.sleep(0.5) + return resp + + return wrapper + + return _retry + + +@retry(30) +def try_execute(sess: Session, stmt: str): + return sess.execute(stmt) + + +def return_if_not_leader_changed(resp) -> bool: + if not resp: + return True + if resp.is_succeeded(): + return True + + err_msg = resp.error_msg() + return err_msg.find('Storage Error: The leader has changed') < 0 + + +@retry(30, return_if_not_leader_changed) +def process_leader_changed(sess: Session, stmt: str): + return sess.execute(stmt) + + +def response(sess: Session, stmt: str, need_try: bool = False): try: - resp = sess.execute(stmt) - check_resp(resp, stmt) - return resp + if need_try: + return try_execute(sess, stmt) + return process_leader_changed(sess, stmt) except Exception as ex: assert not ex, f"Fail to exec: {stmt}, exception: {ex}" -def create_space(space_desc: SpaceDesc, sess: Session): - def exec(stmt): - response(sess, stmt) +def resp_ok(sess: Session, stmt: str, need_try: bool = False): + resp = response(sess, stmt, need_try) + check_resp(resp, stmt) + return resp - stmts = [ - space_desc.drop_stmt(), - space_desc.create_stmt(), - space_desc.use_stmt(), - ] - exec(";".join(stmts)) +def create_space(space_desc: SpaceDesc, sess: Session): + resp_ok(sess, space_desc.drop_stmt(), True) + resp_ok(sess, space_desc.create_stmt(), True) + resp_ok(sess, space_desc.use_stmt(), True) def _load_data_from_file(sess, data_dir, fd): for stmt in CSVImporter(fd, data_dir): - response(sess, stmt) + response(sess, stmt, True) def load_csv_data( @@ -374,6 +409,7 @@ def load_csv_data( assert space is not None if not space_name: space_name = space.get('name', "A" + space_generator()) + space_desc = SpaceDesc( name=space_name, vid_type=space.get('vidType', 'FIXED_STRING(32)'), @@ -386,10 +422,8 @@ def load_csv_data( create_space(space_desc, sess) schemas = config['schema'] - stmts = ' '.join(map(lambda x: x.strip(), schemas.splitlines())) - response(sess, stmts) - - time.sleep(3) + for line in schemas.splitlines(): + resp_ok(sess, line.strip(), True) for fd in config["files"]: _load_data_from_file(sess, data_dir, fd) diff --git a/tests/tck/conftest.py b/tests/tck/conftest.py index 342fb712c..396d979fd 100644 --- a/tests/tck/conftest.py +++ b/tests/tck/conftest.py @@ -16,7 +16,7 @@ from pytest_bdd import given, parsers, then, when from tests.common.dataset_printer import DataSetPrinter -from tests.common.comparator import DataSetComparator +from tests.common.comparator import DataSetComparator, CmpType from tests.common.plan_differ import PlanDiffer from tests.common.configs import DATA_DIR from tests.common.types import SpaceDesc @@ -26,6 +26,7 @@ space_generator, check_resp, response, + resp_ok, ) from tests.tck.utils.table import dataset, table from tests.tck.utils.nbv import murmurhash2 @@ -46,6 +47,48 @@ def combine_query(query: str) -> str: return " ".join(line.strip() for line in query.splitlines()) +def is_job_finished(sess, job): + rsp = resp_ok(sess, f"SHOW JOB {job}") + assert rsp.row_size() > 0 + + def is_finished(val) -> bool: + return val.is_string() and "FINISHED" == val.as_string() + + return any(is_finished(val) for val in rsp.row_values(0)) + + +def wait_all_jobs_finished(sess, jobs=[]): + times = 30 + while jobs and times > 0: + jobs = [job for job in jobs if not is_job_finished(sess, job)] + time.sleep(0.5) + times -= 1 + return len(jobs) == 0 + + +def job_id(resp): + for key in resp.keys(): + for job in resp.column_values(key): + assert job.is_int(), f"job id is not int: {job}" + return job.as_int() + + +def wait_tag_or_edge_indexes_ready(sess, schema: str = "TAG"): + resp = resp_ok(sess, f"SHOW {schema} INDEXES") + jobs = [] + for key in resp.keys(): + for val in resp.column_values(key): + job = val.as_string() + resp = resp_ok(sess, f"REBUILD {schema} INDEX {job}", True) + jobs.append(job_id(resp)) + wait_all_jobs_finished(sess, jobs) + + +def wait_indexes_ready(sess): + wait_tag_or_edge_indexes_ready(sess, "TAG") + wait_tag_or_edge_indexes_ready(sess, "EDGE") + + @pytest.fixture def graph_spaces(): return dict(result_set=None) @@ -70,8 +113,8 @@ def preload_space( graph_spaces["space_desc"] = load_student_data else: raise ValueError(f"Invalid space name given: {space}") - stmt = f'USE {space};' - response(session, stmt) + resp_ok(session, f'USE {space};', True) + wait_indexes_ready(session) @given("an empty graph") @@ -83,7 +126,8 @@ def empty_graph(session, graph_spaces): def having_executed(query, session, request): ngql = combine_query(query) ngql = normalize_outline_scenario(request, ngql) - response(session, ngql) + for stmt in ngql.split(';'): + stmt and resp_ok(session, stmt, True) @given(parse("create a space with following options:\n{options}")) @@ -116,14 +160,17 @@ def import_csv_data(request, data, graph_spaces, session, pytestconfig): data_dir, "I" + space_generator(), ) + wait_indexes_ready(session) assert space_desc is not None graph_spaces["space_desc"] = space_desc graph_spaces["drop_space"] = True -def exec_query(request, ngql, session, graph_spaces): +def exec_query(request, ngql, session, graph_spaces, need_try: bool = False): + if not ngql: + return ngql = normalize_outline_scenario(request, ngql) - graph_spaces['result_set'] = session.execute(ngql) + graph_spaces['result_set'] = response(session, ngql, need_try) graph_spaces['ngql'] = ngql @@ -139,6 +186,38 @@ def profiling_query(query, graph_spaces, session, request): exec_query(request, ngql, session, graph_spaces) +@when(parse("try to execute query:\n{query}")) +def try_to_execute_query(query, graph_spaces, session, request): + ngql = normalize_outline_scenario(request, combine_query(query)) + for stmt in ngql.split(';'): + exec_query(request, stmt, session, graph_spaces, True) + + +@given("wait all indexes ready") +@when("wait all indexes ready") +@then("wait all indexes ready") +def wait_index_ready(graph_spaces, session): + space_desc = graph_spaces.get("space_desc", None) + assert space_desc is not None + space = space_desc.name + resp_ok(session, f"USE {space}", True) + wait_indexes_ready(session) + + +@when(parse("submit a job:\n{query}")) +def submit_job(query, graph_spaces, session, request): + ngql = normalize_outline_scenario(request, combine_query(query)) + exec_query(request, ngql, session, graph_spaces, True) + + +@then("wait the job to finish") +def wait_job_to_finish(graph_spaces, session): + resp = graph_spaces['result_set'] + jid = job_id(resp) + is_finished = wait_all_jobs_finished(session, [jid]) + assert is_finished, f"Fail to finish job {jid}" + + @given(parse("wait {secs:d} seconds")) @when(parse("wait {secs:d} seconds")) @then(parse("wait {secs:d} seconds")) @@ -153,41 +232,38 @@ def line_number(steps, result): return step.line_number return -1 + # IN literal `1, 2, 3...' def parse_list(s: str): - numbers = s.split(',') - numbers_list = [] - for num in numbers: - numbers_list.append(int(num)) - return numbers_list + return [int(num) for num in s.split(',')] + def hash_columns(ds, hashed_columns): if len(hashed_columns) == 0: return ds - for col in hashed_columns: - assert col < len(ds.column_names), "The hashed column should in range." + assert all(col < len(ds.column_names) for col in hashed_columns) for row in ds.rows: for col in hashed_columns: - if row.values[col].getType() != Value.NVAL and row.values[col].getType() != Value.__EMPTY__: - row.values[col] = Value(iVal = murmurhash2(row.values[col])) + val = row.values[col] + if val.getType() not in [Value.NVAL, Value.__EMPTY__]: + row.values[col] = Value(iVal=murmurhash2(val)) return ds + def cmp_dataset( request, graph_spaces, result, order: bool, strict: bool, - included=False, - hashed_columns = [], + contains=CmpType.EQUAL, + hashed_columns=[], ) -> None: rs = graph_spaces['result_set'] ngql = graph_spaces['ngql'] check_resp(rs, ngql) space_desc = graph_spaces.get('space_desc', None) - vid_fn = None - if space_desc is not None: - vid_fn = murmurhash2 if space_desc.vid_type == 'int' else None + vid_fn = murmurhash2 if space_desc and space_desc.is_int_vid() else None ds = dataset( table(result, lambda x: normalize_outline_scenario(request, x)), graph_spaces.get("variables", {}), @@ -195,7 +271,7 @@ def cmp_dataset( ds = hash_columns(ds, hashed_columns) dscmp = DataSetComparator(strict=strict, order=order, - included=included, + contains=contains, decode_type=rs._decode_type, vid_fn=vid_fn) @@ -246,51 +322,70 @@ def define_list_var_alias(text, graph_spaces): def result_should_be_in_order(request, result, graph_spaces): cmp_dataset(request, graph_spaces, result, order=True, strict=True) + @then(parse("the result should be, in order, and the columns {hashed_columns} should be hashed:\n{result}")) def result_should_be_in_order_and_hash(request, result, graph_spaces, hashed_columns): cmp_dataset(request, graph_spaces, result, order=True, strict=True, hashed_columns=parse_list(hashed_columns)) + @then(parse("the result should be, in order, with relax comparison:\n{result}")) def result_should_be_in_order_relax_cmp(request, result, graph_spaces): cmp_dataset(request, graph_spaces, result, order=True, strict=False) + @then(parse("the result should be, in order, with relax comparison, and the columns {hashed_columns} should be hashed:\n{result}")) def result_should_be_in_order_relax_cmp_and_hash(request, result, graph_spaces, hashed_columns): cmp_dataset(request, graph_spaces, result, order=True, strict=False, hashed_columns=parse_list(hashed_columns)) + @then(parse("the result should be, in any order:\n{result}")) def result_should_be(request, result, graph_spaces): cmp_dataset(request, graph_spaces, result, order=False, strict=True) + @then(parse("the result should be, in any order, and the columns {hashed_columns} should be hashed:\n{result}")) def result_should_be_and_hash(request, result, graph_spaces, hashed_columns): cmp_dataset(request, graph_spaces, result, order=False, strict=True, hashed_columns=parse_list(hashed_columns)) + @then(parse("the result should be, in any order, with relax comparison:\n{result}")) def result_should_be_relax_cmp(request, result, graph_spaces): cmp_dataset(request, graph_spaces, result, order=False, strict=False) + @then(parse("the result should be, in any order, with relax comparison, and the columns {hashed_columns} should be hashed:\n{result}")) def result_should_be_relax_cmp_and_hash(request, result, graph_spaces, hashed_columns): cmp_dataset(request, graph_spaces, result, order=False, strict=False, hashed_columns=parse_list(hashed_columns)) -@then(parse("the result should include:\n{result}")) -def result_should_include(request, result, graph_spaces): + +@then(parse("the result should contain:\n{result}")) +def result_should_contain(request, result, graph_spaces): + cmp_dataset(request, + graph_spaces, + result, + order=False, + strict=True, + contains=CmpType.CONTAINS) + + +@then(parse("the result should not contain:\n{result}")) +def result_should_not_contain(request, result, graph_spaces): cmp_dataset(request, graph_spaces, result, order=False, strict=True, - included=True) + contains=CmpType.NOT_CONTAINS) + -@then(parse("the result should include, and the columns {hashed_columns} should be hashed:\n{result}")) -def result_should_include_and_hash(request, result, graph_spaces, hashed_columns): +@then(parse("the result should contain, and the columns {hashed_columns} should be hashed:\n{result}")) +def result_should_contain_and_hash(request, result, graph_spaces, hashed_columns): cmp_dataset(request, graph_spaces, result, order=False, strict=True, - included=True, + contains=True, hashed_columns=parse_list(hashed_columns)) diff --git a/tests/tck/features/bugfix/MatchReturnEmptyTag.feature b/tests/tck/features/bugfix/MatchReturnEmptyTag.feature index fc809d301..972a7493a 100644 --- a/tests/tck/features/bugfix/MatchReturnEmptyTag.feature +++ b/tests/tck/features/bugfix/MatchReturnEmptyTag.feature @@ -15,7 +15,6 @@ Feature: Fix match losing undefined vertex tag info """ CREATE TAG IF NOT EXISTS empty_tag(); """ - And wait 3 seconds And having executed: """ INSERT VERTEX empty_tag() values :() @@ -39,6 +38,7 @@ Feature: Fix match losing undefined vertex tag info Then the result should be, in any order: | Labels | | ["player", "empty_tag", "bachelor"] | + And drop the used space Scenario Outline: one step with direction When executing query: @@ -69,6 +69,7 @@ Feature: Fix match losing undefined vertex tag info | ["player", "empty_tag", "bachelor"] | | ["player", "empty_tag", "bachelor"] | | ["player", "empty_tag", "bachelor"] | + And drop the used space Scenario Outline: one step without direction When executing query: @@ -123,3 +124,4 @@ Feature: Fix match losing undefined vertex tag info | ["empty_tag", "bachelor", "player"] | | ["empty_tag", "bachelor", "player"] | | ["empty_tag", "bachelor", "player"] | + And drop the used space diff --git a/tests/tck/features/delete/DeleteEdge.IntVid.feature b/tests/tck/features/delete/DeleteEdge.IntVid.feature index 7a67682aa..c72403bdb 100644 --- a/tests/tck/features/delete/DeleteEdge.IntVid.feature +++ b/tests/tck/features/delete/DeleteEdge.IntVid.feature @@ -4,7 +4,7 @@ # attached with Common Clause Condition 1.0, found in the LICENSES directory. Feature: Delete int vid of edge - Background: Prepare space + Scenario: delete edges Given an empty graph And create a space with following options: | partition_num | 9 | @@ -17,28 +17,32 @@ Feature: Delete int vid of edge CREATE EDGE IF NOT EXISTS schoolmate(likeness int); CREATE EDGE IF NOT EXISTS transfer(money int); """ - And wait 3 seconds - - Scenario: delete edges - When executing query: + And having executed: """ - INSERT VERTEX person(name, age) VALUES - hash("Zhangsan"):("Zhangsan", 22), - hash("Lisi"):("Lisi", 23), - hash("Jack"):("Jack", 18), - hash("Rose"):("Rose", 19); - INSERT EDGE friend(intimacy) VALUES - hash("Zhangsan")->hash("Lisi")@15:(90), - hash("Zhangsan")->hash("Jack")@12:(50), - hash("Jack")->hash("Rose")@13:(100); - INSERT EDGE schoolmate(likeness) VALUES - hash("Zhangsan")->hash("Jack"):(60), - hash("Lisi")->hash("Rose"):(70); - INSERT EDGE transfer(money) VALUES - hash("Zhangsan")->hash("Lisi")@1561013236:(33), - hash("Zhangsan")->hash("Lisi")@1561013237:(77); + INSERT VERTEX + person(name, age) + VALUES + hash("Zhangsan"):("Zhangsan", 22), + hash("Lisi"):("Lisi", 23), + hash("Jack"):("Jack", 18), + hash("Rose"):("Rose", 19); + INSERT EDGE + friend(intimacy) + VALUES + hash("Zhangsan")->hash("Lisi")@15:(90), + hash("Zhangsan")->hash("Jack")@12:(50), + hash("Jack")->hash("Rose")@13:(100); + INSERT EDGE + schoolmate(likeness) + VALUES + hash("Zhangsan")->hash("Jack"):(60), + hash("Lisi")->hash("Rose"):(70); + INSERT EDGE + transfer(money) + VALUES + hash("Zhangsan")->hash("Lisi")@1561013236:(33), + hash("Zhangsan")->hash("Lisi")@1561013237:(77); """ - Then the execution should be successful # before get result by go When executing query: """ diff --git a/tests/tck/features/delete/DeleteEdge.feature b/tests/tck/features/delete/DeleteEdge.feature index c3c1e5a9b..68a1043d6 100644 --- a/tests/tck/features/delete/DeleteEdge.feature +++ b/tests/tck/features/delete/DeleteEdge.feature @@ -17,26 +17,32 @@ Feature: Delete string vid of edge CREATE EDGE IF NOT EXISTS schoolmate(likeness int); CREATE EDGE IF NOT EXISTS transfer(money int); """ - And wait 3 seconds - When executing query: - """ - INSERT VERTEX person(name, age) VALUES - "Zhangsan":("Zhangsan", 22), - "Lisi":("Lisi", 23), - "Jack":("Jack", 18), - "Rose":("Rose", 19); - INSERT EDGE friend(intimacy) VALUES - "Zhangsan"->"Lisi"@15:(90), - "Zhangsan"->"Jack"@12:(50), - "Jack"->"Rose"@13:(100); - INSERT EDGE schoolmate(likeness) VALUES - "Zhangsan"->"Jack":(60), - "Lisi"->"Rose":(70); - INSERT EDGE transfer(money) VALUES - "Zhangsan"->"Lisi"@1561013236:(33), - "Zhangsan"->"Lisi"@1561013237:(77); + And having executed: + """ + INSERT VERTEX + person(name, age) + VALUES + "Zhangsan":("Zhangsan", 22), + "Lisi":("Lisi", 23), + "Jack":("Jack", 18), + "Rose":("Rose", 19); + INSERT EDGE + friend(intimacy) + VALUES + "Zhangsan"->"Lisi"@15:(90), + "Zhangsan"->"Jack"@12:(50), + "Jack"->"Rose"@13:(100); + INSERT EDGE + schoolmate(likeness) + VALUES + "Zhangsan"->"Jack":(60), + "Lisi"->"Rose":(70); + INSERT EDGE + transfer(money) + VALUES + "Zhangsan"->"Lisi"@1561013236:(33), + "Zhangsan"->"Lisi"@1561013237:(77); """ - Then the execution should be successful # before get result by go When executing query: """ diff --git a/tests/tck/features/delete/DeleteVertex.IntVid.feature b/tests/tck/features/delete/DeleteVertex.IntVid.feature index c8127b12e..0a5b08d71 100644 --- a/tests/tck/features/delete/DeleteVertex.IntVid.feature +++ b/tests/tck/features/delete/DeleteVertex.IntVid.feature @@ -4,10 +4,8 @@ # attached with Common Clause Condition 1.0, found in the LICENSES directory. Feature: Delete int vid of vertex - Background: Prepare space - Given load "nba_int_vid" csv data to a new space - Scenario: delete int vid vertex + Given load "nba_int_vid" csv data to a new space # get vertex info When executing query: """ diff --git a/tests/tck/features/fetch/FetchEmpty.feature b/tests/tck/features/fetch/FetchEmpty.feature index 64e9770ec..43a5821d0 100644 --- a/tests/tck/features/fetch/FetchEmpty.feature +++ b/tests/tck/features/fetch/FetchEmpty.feature @@ -16,7 +16,6 @@ Feature: Fetch prop on empty tag/edge CREATE TAG person(money int); CREATE EDGE zero_prop_edge(); """ - And wait 3 seconds And having executed: """ INSERT VERTEX zero_prop_tag_0() values "1":(), "2":(); @@ -24,7 +23,6 @@ Feature: Fetch prop on empty tag/edge INSERT VERTEX person(money) values "1":(78), "3":(88); INSERT EDGE zero_prop_edge() values "1"->"2":(); """ - And wait 3 seconds Scenario: fetch prop on all tags When executing query: @@ -34,6 +32,7 @@ Feature: Fetch prop on empty tag/edge Then the result should be, in any order, with relax comparison: | vertices_ | | ("1":zero_prop_tag_0:zero_prop_tag_1:person) | + And drop the used space Scenario: fetch prop on a empty tag When executing query: @@ -52,6 +51,7 @@ Feature: Fetch prop on empty tag/edge Then the result should be, in any order, with relax comparison: | vertices_ | | ("2":zero_prop_tag_0) | + And drop the used space Scenario: fetch prop on empty edge When executing query: @@ -82,3 +82,4 @@ Feature: Fetch prop on empty tag/edge Then the result should be, in any order: | edges_ | | [:zero_prop_edge "1"->"2" @0{}] | + And drop the used space diff --git a/tests/tck/features/index/Index.IntVid.feature b/tests/tck/features/index/Index.IntVid.feature index 4bec8b0e8..4ff8aaaba 100644 --- a/tests/tck/features/index/Index.IntVid.feature +++ b/tests/tck/features/index/Index.IntVid.feature @@ -12,7 +12,6 @@ Feature: IndexTest_Vid_Int """ CREATE TAG tag_1(col1 string, col2 int, col3 double, col4 timestamp); """ - And wait 6 seconds When executing query: """ CREATE TAG INDEX single_tag_index ON tag_1(col2); @@ -58,15 +57,17 @@ Feature: IndexTest_Vid_Int CREATE TAG INDEX disorder_tag_index ON tag_1(col3, col2); """ Then the execution should be successful + And wait 6 seconds When executing query: """ - INSERT VERTEX tag_1(col1, col2, col3, col4) VALUES - hash("Tim"): ("Tim", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - hash("Tony"): ("Tony", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - hash("May"): ("May", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - hash("Tom"): ("Tom", 18, 11.11, `timestamp`("2000-10-10T10:00:00")) + INSERT VERTEX + tag_1(col1, col2, col3, col4) + VALUES + hash("Tim"): ("Tim", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + hash("Tony"): ("Tony", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + hash("May"): ("May", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + hash("Tom"): ("Tom", 18, 11.11, `timestamp`("2000-10-10T10:00:00")) """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -156,7 +157,6 @@ Feature: IndexTest_Vid_Int """ CREATE EDGE edge_1(col1 string, col2 int, col3 double, col4 timestamp) """ - And wait 6 seconds When executing query: """ CREATE EDGE INDEX single_edge_index ON edge_1(col2); @@ -202,15 +202,17 @@ Feature: IndexTest_Vid_Int CREATE EDGE INDEX disorder_edge_1_index ON edge_1(col3, col2) """ Then the execution should be successful + And wait 6 seconds When executing query: """ - INSERT EDGE edge_1(col1, col2, col3, col4) VALUES - hash("Tim") -> hash("May"): ("Good", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - hash("Tim") -> hash("Tony"): ("Good", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - hash("Tony") -> hash("May"): ("Like", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - hash("May") -> hash("Tim"): ("Like", 18, 11.11, `timestamp`("2000-10-10T10:00:00")) + INSERT EDGE + edge_1(col1, col2, col3, col4) + VALUES + hash("Tim") -> hash("May"): ("Good", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + hash("Tim") -> hash("Tony"): ("Good", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + hash("Tony") -> hash("May"): ("Like", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + hash("May") -> hash("Tim"): ("Like", 18, 11.11, `timestamp`("2000-10-10T10:00:00")) """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -295,7 +297,6 @@ Feature: IndexTest_Vid_Int """ CREATE TAG person_ttl(number int, age int, gender int, email string); """ - And wait 6 seconds When executing query: """ CREATE TAG INDEX single_person_ttl_index ON person_ttl(age) @@ -396,7 +397,6 @@ Feature: IndexTest_Vid_Int """ CREATE EDGE edge_1_ttl(degree int, start_time int) """ - And wait 6 seconds When executing query: """ CREATE EDGE INDEX single_edge_1_ttl_index ON edge_1_ttl(start_time) @@ -501,36 +501,32 @@ Feature: IndexTest_Vid_Int """ CREATE TAG tag_1(col1 bool, col2 int, col3 double, col4 timestamp) """ - And wait 12 seconds When executing query: """ CREATE TAG INDEX single_person_index ON tag_1(col1) """ Then the execution should be successful + And wait 6 seconds When executing query: """ - INSERT VERTEX tag_1(col1, col2, col3, col4) VALUES - 100:(true, 18, 1.1, `timestamp`("2000-10-10T10:00:00")) + INSERT VERTEX tag_1(col1, col2, col3, col4) VALUES 100:(true, 18, 1.1, `timestamp`("2000-10-10T10:00:00")) """ Then the execution should be successful When executing query: """ ALTER TAG tag_1 ADD (col5 int) """ - And wait 6 seconds Then the execution should be successful When executing query: """ CREATE TAG INDEX single_person_index2 ON tag_1(col5) """ - And wait 6 seconds Then the execution should be successful + And wait 6 seconds When executing query: """ - INSERT VERTEX tag_1(col1, col2, col3, col4, col5) VALUES - 100:(true, 18, 1.1, `timestamp`("2000-10-10T10:00:00"), 5) + INSERT VERTEX tag_1(col1, col2, col3, col4, col5) VALUES 100:(true, 18, 1.1, `timestamp`("2000-10-10T10:00:00"), 5) """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -560,12 +556,10 @@ Feature: IndexTest_Vid_Int """ CREATE TAG tag_status(col1 int) """ - And wait 6 seconds When executing query: """ CREATE TAG INDEX tag_index_status ON tag_status(col1); """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -573,23 +567,21 @@ Feature: IndexTest_Vid_Int """ Then the result should be, in any order: | Name | Index Status | - When executing query: + And wait 3 seconds + When submit a job: """ REBUILD TAG INDEX tag_index_status """ - And wait 6 seconds - Then the execution should be successful + Then wait the job to finish When executing query: """ DROP TAG INDEX tag_index_status """ - And wait 6 seconds Then the execution should be successful When executing query: """ DESCRIBE TAG INDEX tag_index_status """ - And wait 6 seconds Then a ExecutionError should be raised at runtime: When executing query: """ @@ -612,12 +604,10 @@ Feature: IndexTest_Vid_Int """ CREATE EDGE edge_status(col1 int) """ - And wait 6 seconds When executing query: """ CREATE EDGE INDEX edge_index_status ON edge_status(col1); """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -625,12 +615,12 @@ Feature: IndexTest_Vid_Int """ Then the result should be, in any order: | Name | Index Status | - When executing query: + And wait 3 seconds + When submit a job: """ REBUILD EDGE INDEX edge_index_status """ - And wait 6 seconds - Then the execution should be successful + Then wait the job to finish When executing query: """ DROP EDGE INDEX edge_index_status @@ -662,18 +652,16 @@ Feature: IndexTest_Vid_Int """ CREATE TAG alter_tag(id int); """ - And wait 6 seconds When executing query: """ CREATE TAG INDEX alter_index ON alter_tag(id); """ Then the execution should be successful + And wait 6 seconds When executing query: """ - INSERT VERTEX alter_tag(id) VALUES - 100:(1), 200:(2) + INSERT VERTEX alter_tag(id) VALUES 100:(1), 200:(2) """ - And wait 6 seconds Then the execution should be successful When executing query: """ diff --git a/tests/tck/features/index/Index.feature b/tests/tck/features/index/Index.feature index 033a8dda4..e67bd6ea5 100644 --- a/tests/tck/features/index/Index.feature +++ b/tests/tck/features/index/Index.feature @@ -12,7 +12,6 @@ Feature: IndexTest_Vid_String """ CREATE TAG tag_1(col1 string, col2 int, col3 double, col4 timestamp); """ - And wait 6 seconds When executing query: """ CREATE TAG INDEX single_tag_index ON tag_1(col2); @@ -58,15 +57,17 @@ Feature: IndexTest_Vid_String CREATE TAG INDEX disorder_tag_index ON tag_1(col3, col2); """ Then the execution should be successful + And wait 6 seconds When executing query: """ - INSERT VERTEX tag_1(col1, col2, col3, col4) VALUES - "Tim": ("Tim", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - "Tony": ("Tony", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - "May": ("May", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - "Tom": ("Tom", 18, 11.11, `timestamp`("2000-10-10T10:00:00")) + INSERT VERTEX + tag_1(col1, col2, col3, col4) + VALUES + "Tim": ("Tim", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + "Tony": ("Tony", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + "May": ("May", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + "Tom": ("Tom", 18, 11.11, `timestamp`("2000-10-10T10:00:00")) """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -156,7 +157,6 @@ Feature: IndexTest_Vid_String """ CREATE EDGE edge_1(col1 string, col2 int, col3 double, col4 timestamp) """ - And wait 6 seconds When executing query: """ CREATE EDGE INDEX single_edge_index ON edge_1(col2); @@ -202,15 +202,17 @@ Feature: IndexTest_Vid_String CREATE EDGE INDEX disorder_edge_1_index ON edge_1(col3, col2) """ Then the execution should be successful + And wait 6 seconds When executing query: """ - INSERT EDGE edge_1(col1, col2, col3, col4) VALUES - "Tim" -> "May": ("Good", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - "Tim" -> "Tony": ("Good", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - "Tony" -> "May": ("Like", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), - "May" -> "Tim": ("Like", 18, 11.11, `timestamp`("2000-10-10T10:00:00")) + INSERT EDGE + edge_1(col1, col2, col3, col4) + VALUES + "Tim" -> "May": ("Good", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + "Tim" -> "Tony": ("Good", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + "Tony" -> "May": ("Like", 18, 11.11, `timestamp`("2000-10-10T10:00:00")), + "May" -> "Tim": ("Like", 18, 11.11, `timestamp`("2000-10-10T10:00:00")) """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -295,7 +297,6 @@ Feature: IndexTest_Vid_String """ CREATE TAG person_ttl(number int, age int, gender int, email string); """ - And wait 6 seconds When executing query: """ CREATE TAG INDEX single_person_ttl_index ON person_ttl(age) @@ -396,7 +397,6 @@ Feature: IndexTest_Vid_String """ CREATE EDGE edge_1_ttl(degree int, start_time int) """ - And wait 6 seconds When executing query: """ CREATE EDGE INDEX single_edge_1_ttl_index ON edge_1_ttl(start_time) @@ -501,36 +501,38 @@ Feature: IndexTest_Vid_String """ CREATE TAG tag_1(col1 bool, col2 int, col3 double, col4 timestamp) """ - And wait 6 seconds When executing query: """ CREATE TAG INDEX single_person_index ON tag_1(col1) """ Then the execution should be successful + And wait 3 seconds When executing query: """ - INSERT VERTEX tag_1(col1, col2, col3, col4) VALUES - "100": (true, 18, 1.1, `timestamp`("2000-10-10T10:00:00")) + INSERT VERTEX + tag_1(col1, col2, col3, col4) + VALUES + "100": (true, 18, 1.1, `timestamp`("2000-10-10T10:00:00")) """ Then the execution should be successful When executing query: """ ALTER TAG tag_1 ADD (col5 int) """ - And wait 6 seconds Then the execution should be successful When executing query: """ CREATE TAG INDEX single_person_index2 ON tag_1(col5) """ - And wait 6 seconds Then the execution should be successful + And wait 3 seconds When executing query: """ - INSERT VERTEX tag_1(col1, col2, col3, col4, col5) VALUES - "100":(true, 18, 1.1, `timestamp`("2000-10-10T10:00:00"), 5) + INSERT VERTEX + tag_1(col1, col2, col3, col4, col5) + VALUES + "100":(true, 18, 1.1, `timestamp`("2000-10-10T10:00:00"), 5) """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -560,12 +562,10 @@ Feature: IndexTest_Vid_String """ CREATE TAG tag_status(col1 int) """ - And wait 6 seconds When executing query: """ CREATE TAG INDEX tag_index_status ON tag_status(col1); """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -573,23 +573,21 @@ Feature: IndexTest_Vid_String """ Then the result should be, in any order: | Name | Index Status | - When executing query: + And wait 3 seconds + When submit a job: """ REBUILD TAG INDEX tag_index_status """ - And wait 6 seconds - Then the execution should be successful + Then wait the job to finish When executing query: """ DROP TAG INDEX tag_index_status """ - And wait 6 seconds Then the execution should be successful When executing query: """ DESCRIBE TAG INDEX tag_index_status """ - And wait 6 seconds Then a ExecutionError should be raised at runtime: When executing query: """ @@ -612,12 +610,10 @@ Feature: IndexTest_Vid_String """ CREATE EDGE edge_status(col1 int) """ - And wait 6 seconds When executing query: """ CREATE EDGE INDEX edge_index_status ON edge_status(col1); """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -625,12 +621,12 @@ Feature: IndexTest_Vid_String """ Then the result should be, in any order: | Name | Index Status | - When executing query: + And wait 3 seconds + When submit a job: """ REBUILD EDGE INDEX edge_index_status """ - And wait 6 seconds - Then the execution should be successful + Then wait the job to finish When executing query: """ DROP EDGE INDEX edge_index_status @@ -645,7 +641,7 @@ Feature: IndexTest_Vid_String """ SHOW EDGE INDEX STATUS; """ - Then the result should include: + Then the result should contain: | Name | Index Status | | "edge_index_status" | "FINISHED" | Then drop the used space @@ -662,25 +658,23 @@ Feature: IndexTest_Vid_String """ CREATE TAG alter_tag(id int); """ - And wait 6 seconds When executing query: """ CREATE TAG INDEX alter_index ON alter_tag(id); """ Then the execution should be successful + And wait 6 seconds When executing query: """ - INSERT VERTEX alter_tag(id) VALUES - "100":(1), "200":(2) + INSERT VERTEX alter_tag(id) VALUES "100":(1), "200":(2) """ - And wait 6 seconds Then the execution should be successful When executing query: """ ALTER TAG alter_tag ADD (type int) """ - And wait 6 seconds Then the execution should be successful + And wait 6 seconds When executing query: """ LOOKUP ON alter_tag WHERE alter_tag.id == 1 YIELD alter_tag.type @@ -698,8 +692,7 @@ Feature: IndexTest_Vid_String CREATE TAG id_tag(id int); CREATE TAG name_tag(name string); """ - And wait 6 seconds - When executing query: + When try to execute query: """ INSERT VERTEX id_tag(id) VALUES "100":(100), "200":(100); INSERT VERTEX name_tag(name) VALUES "300":("100"), "400":("100"); @@ -712,17 +705,16 @@ Feature: IndexTest_Vid_String """ Then the execution should be successful And wait 6 seconds - When executing query: + When submit a job: """ REBUILD TAG INDEX; """ - Then the execution should be successful - And wait 6 seconds + Then wait the job to finish When executing query: """ SHOW TAG INDEX STATUS; """ - Then the result should include: + Then the result should contain: | Name | Index Status | | "rebuild_tag_space_all_tag_indexes" | "FINISHED" | When executing query: @@ -753,8 +745,7 @@ Feature: IndexTest_Vid_String CREATE TAG name_tag(name string); CREATE TAG age_tag(age int); """ - And wait 6 seconds - When executing query: + When try to execute query: """ INSERT VERTEX id_tag(id) VALUES "100":(100), "200":(100); INSERT VERTEX name_tag(name) VALUES "300":("100"), "400":("100"); @@ -769,17 +760,16 @@ Feature: IndexTest_Vid_String """ Then the execution should be successful And wait 6 seconds - When executing query: + When submit a job: """ REBUILD TAG INDEX id_tag_index, name_tag_index; """ - Then the execution should be successful - And wait 6 seconds + Then wait the job to finish When executing query: """ SHOW TAG INDEX STATUS; """ - Then the result should include: + Then the result should contain: | Name | Index Status | | "id_tag_index,name_tag_index" | "FINISHED" | When executing query: @@ -816,8 +806,7 @@ Feature: IndexTest_Vid_String CREATE EDGE id_edge(id int); CREATE EDGE name_edge(name string); """ - And wait 6 seconds - When executing query: + When try to execute query: """ INSERT EDGE id_edge(id) VALUES "100"->"200":(100); INSERT EDGE name_edge(name) VALUES "300"->"400":("100"); @@ -830,17 +819,16 @@ Feature: IndexTest_Vid_String """ Then the execution should be successful And wait 6 seconds - When executing query: + When submit a job: """ REBUILD EDGE INDEX; """ - Then the execution should be successful - And wait 6 seconds + Then wait the job to finish When executing query: """ SHOW EDGE INDEX STATUS; """ - Then the result should include: + Then the result should contain: | Name | Index Status | | "rebuild_edge_space_all_edge_indexes" | "FINISHED" | When executing query: @@ -869,8 +857,7 @@ Feature: IndexTest_Vid_String CREATE EDGE name_edge(name string); CREATE EDGE age_edge(age int); """ - And wait 6 seconds - When executing query: + When try to execute query: """ INSERT EDGE id_edge(id) VALUES "100"->"200":(100); INSERT EDGE name_edge(name) VALUES "300"->"400":("100"); @@ -885,17 +872,16 @@ Feature: IndexTest_Vid_String """ Then the execution should be successful And wait 6 seconds - When executing query: + When submit a job: """ REBUILD EDGE INDEX id_edge_index,name_edge_index; """ - Then the execution should be successful - And wait 6 seconds + Then wait the job to finish When executing query: """ SHOW EDGE INDEX STATUS; """ - Then the result should include: + Then the result should contain: | Name | Index Status | | "id_edge_index,name_edge_index" | "FINISHED" | When executing query: diff --git a/tests/tck/features/insert/Insert.IntVid.feature b/tests/tck/features/insert/Insert.IntVid.feature index 99208ab7d..d3f56808c 100644 --- a/tests/tck/features/insert/Insert.IntVid.feature +++ b/tests/tck/features/insert/Insert.IntVid.feature @@ -13,10 +13,12 @@ Feature: Insert int vid of vertex and edge And having executed: """ CREATE TAG IF NOT EXISTS person(name string, age int); - CREATE TAG IF NOT EXISTS personWithDefault(name string DEFAULT "", - age int DEFAULT 18, isMarried bool DEFAULT false, - BMI double DEFAULT 18.5, department string DEFAULT "engineering", - birthday timestamp DEFAULT timestamp("2020-01-10T10:00:00")); + CREATE TAG IF NOT EXISTS personWithDefault( + name string DEFAULT "", + age int DEFAULT 18, isMarried bool DEFAULT false, + BMI double DEFAULT 18.5, department string DEFAULT "engineering", + birthday timestamp DEFAULT timestamp("2020-01-10T10:00:00") + ); CREATE TAG IF NOT EXISTS student(grade string, number int); CREATE TAG IF NOT EXISTS studentWithDefault(grade string DEFAULT "one", number int); CREATE TAG IF NOT EXISTS employee(name int); @@ -26,9 +28,9 @@ Feature: Insert int vid of vertex and edge CREATE EDGE IF NOT EXISTS schoolmateWithDefault(likeness int DEFAULT 80); CREATE EDGE IF NOT EXISTS study(start_time timestamp, end_time timestamp); """ - And wait 3 seconds Scenario: insert vertex and edge test + Given wait 3 seconds # insert vertex wrong type value When executing query: """ @@ -78,10 +80,11 @@ Feature: Insert int vid of vertex and edge hash("Laura")->hash("sun_school"):(timestamp("2300-01-01T10:00:00"), now()+3600*24*365*3); """ Then a ExecutionError should be raised at runtime: + And drop the used space Scenario: insert vertex unordered order prop vertex succeeded # insert vertex succeeded - When executing query: + When try to execute query: """ INSERT VERTEX person(name, age) VALUES hash("Tom"):("Tom", 22) """ @@ -108,8 +111,7 @@ Feature: Insert int vid of vertex and edge # insert vertex with string timestamp succeeded When executing query: """ - INSERT VERTEX school(name, create_time) VALUES - hash("sun_school"):("sun_school", timestamp("2010-01-01T10:00:00")) + INSERT VERTEX school(name, create_time) VALUES hash("sun_school"):("sun_school", timestamp("2010-01-01T10:00:00")) """ Then the execution should be successful # insert edge succeeded @@ -259,11 +261,16 @@ Feature: Insert int vid of vertex and edge # test same prop name diff type When executing query: """ - INSERT VERTEX person(name, age), employee(name) VALUES - hash("Joy"):("Joy", 18, 123), - hash("Petter"):("Petter", 19, 456); - INSERT EDGE schoolmate(likeness, nickname) VALUES - hash("Joy")->hash("Petter"):(90, "Petter"); + INSERT VERTEX + person(name, age), + employee(name) + VALUES + hash("Joy"):("Joy", 18, 123), + hash("Petter"):("Petter", 19, 456); + INSERT EDGE + schoolmate(likeness, nickname) + VALUES + hash("Joy")->hash("Petter"):(90, "Petter"); """ Then the execution should be successful # get result through go @@ -324,8 +331,12 @@ Feature: Insert int vid of vertex and edge # insert vertices multi tags with default value When executing query: """ - INSERT VERTEX personWithDefault(name, BMI), studentWithDefault(number) VALUES - hash("Laura"):("Laura", 21.5, 20190901008),hash("Amber"):("Amber", 22.5, 20180901003) + INSERT VERTEX + personWithDefault(name, BMI), + studentWithDefault(number) + VALUES + hash("Laura"):("Laura", 21.5, 20190901008), + hash("Amber"):("Amber", 22.5, 20180901003); """ Then the execution should be successful # multi vertices one tag with default value @@ -361,11 +372,13 @@ Feature: Insert int vid of vertex and edge # insert multi edges with default value When executing query: """ - INSERT EDGE schoolmateWithDefault() VALUES - hash("Tom")->hash("Kitty"):(), - hash("Tom")->hash("Peter"):(), - hash("Lucy")->hash("Laura"):(), - hash("Lucy")->hash("Amber"):() + INSERT EDGE + schoolmateWithDefault() + VALUES + hash("Tom")->hash("Kitty"):(), + hash("Tom")->hash("Peter"):(), + hash("Lucy")->hash("Laura"):(), + hash("Lucy")->hash("Amber"):() """ Then the execution should be successful # get result through go diff --git a/tests/tck/features/insert/Insert.feature b/tests/tck/features/insert/Insert.feature index 46985b9de..1a7a36c07 100644 --- a/tests/tck/features/insert/Insert.feature +++ b/tests/tck/features/insert/Insert.feature @@ -13,10 +13,12 @@ Feature: Insert string vid of vertex and edge And having executed: """ CREATE TAG IF NOT EXISTS person(name string, age int); - CREATE TAG IF NOT EXISTS personWithDefault(name string DEFAULT "", - age int DEFAULT 18, isMarried bool DEFAULT false, - BMI double DEFAULT 18.5, department string DEFAULT "engineering", - birthday timestamp DEFAULT timestamp("2020-01-10T10:00:00")); + CREATE TAG IF NOT EXISTS personWithDefault( + name string DEFAULT "", + age int DEFAULT 18, isMarried bool DEFAULT false, + BMI double DEFAULT 18.5, department string DEFAULT "engineering", + birthday timestamp DEFAULT timestamp("2020-01-10T10:00:00") + ); CREATE TAG IF NOT EXISTS student(grade string, number int); CREATE TAG IF NOT EXISTS studentWithDefault(grade string DEFAULT "one", number int); CREATE TAG IF NOT EXISTS employee(name int); @@ -26,7 +28,12 @@ Feature: Insert string vid of vertex and edge CREATE EDGE IF NOT EXISTS schoolmateWithDefault(likeness int DEFAULT 80); CREATE EDGE IF NOT EXISTS study(start_time timestamp, end_time timestamp); """ - And wait 3 seconds + # insert vertex succeeded + When try to execute query: + """ + INSERT VERTEX person(name, age) VALUES "Tom":("Tom", 22) + """ + Then the execution should be successful # insert vertex wrong type value When executing query: """ @@ -54,8 +61,7 @@ Feature: Insert string vid of vertex and edge # insert edge wrong number of value When executing query: """ - INSERT EDGE schoolmate(likeness, nickname) VALUES - "Laura"->"Amber":("hello", "87", ""); + INSERT EDGE schoolmate(likeness, nickname) VALUES "Laura"->"Amber":("hello", "87", ""); """ Then a SemanticError should be raised at runtime: # insert edge wrong num of prop @@ -73,16 +79,12 @@ Feature: Insert string vid of vertex and edge # insert edge invalid timestamp When executing query: """ - INSERT EDGE study(start_time, end_time) VALUES - "Laura"->"sun_school":(timestamp("2300-01-01T10:00:00"), now()+3600*24*365*3); + INSERT EDGE + study(start_time, end_time) + VALUES + "Laura"->"sun_school":(timestamp("2300-01-01T10:00:00"), now()+3600*24*365*3); """ Then a ExecutionError should be raised at runtime: - # insert vertex succeeded - When executing query: - """ - INSERT VERTEX person(name, age) VALUES "Tom":("Tom", 22) - """ - Then the execution should be successful # insert vertex unordered order prop vertex succeeded When executing query: """ @@ -100,8 +102,7 @@ Feature: Insert string vid of vertex and edge # insert vertex with string timestamp succeeded When executing query: """ - INSERT VERTEX school(name, create_time) VALUES - "sun_school":("sun_school", timestamp("2010-01-01T10:00:00")) + INSERT VERTEX school(name, create_time) VALUES "sun_school":("sun_school", timestamp("2010-01-01T10:00:00")) """ Then the execution should be successful # insert edge succeeded @@ -127,8 +128,7 @@ Feature: Insert string vid of vertex and edge # insert edge with timestamp succeed When executing query: """ - INSERT EDGE study(start_time, end_time) VALUES - "Laura"->"sun_school":(timestamp("2019-01-01T10:00:00"), now()+3600*24*365*3) + INSERT EDGE study(start_time, end_time) VALUES "Laura"->"sun_school":(timestamp("2019-01-01T10:00:00"), now()+3600*24*365*3) """ Then the execution should be successful # check edge result with go @@ -323,10 +323,12 @@ Feature: Insert string vid of vertex and edge # insert vertices multi tags with default value When executing query: """ - INSERT VERTEX personWithDefault(name, BMI), - studentWithDefault(number) VALUES - "Laura":("Laura", 21.5, 20190901008), - "Amber":("Amber", 22.5, 20180901003) + INSERT VERTEX + personWithDefault(name, BMI), + studentWithDefault(number) + VALUES + "Laura":("Laura", 21.5, 20190901008), + "Amber":("Amber", 22.5, 20180901003) """ Then the execution should be successful # multi vertices one tag with default value @@ -430,7 +432,12 @@ Feature: Insert string vid of vertex and edge CREATE TAG student(name string NOT NULL, age int); CREATE TAG course(name fixed_string(5) NOT NULL, introduce string DEFAULT NULL); """ - And wait 3 seconds + # test insert with fixed_string + When try to execute query: + """ + INSERT VERTEX course(name) VALUES "Math":("Math") + """ + Then the execution should be successful # test insert out of range id size When executing query: """ @@ -448,12 +455,6 @@ Feature: Insert string vid of vertex and edge INSERT VERTEX student(name, age) VALUES "Tom":(NULL, 12) """ Then a ExecutionError should be raised at runtime: Storage Error: The not null field cannot be null. - # test insert with fixed_string - When executing query: - """ - INSERT VERTEX course(name) VALUES "Math":("Math") - """ - Then the execution should be successful # out of fixed_string's size When executing query: """ diff --git a/tests/tck/features/lookup/ByIndex.feature b/tests/tck/features/lookup/ByIndex.feature index 2fc286e33..09c8a571d 100644 --- a/tests/tck/features/lookup/ByIndex.feature +++ b/tests/tck/features/lookup/ByIndex.feature @@ -3,7 +3,6 @@ Feature: Lookup by index itself Background: Given an empty graph And load "nba" csv data to a new space - And wait 6 seconds Scenario: [1] tag index When executing query: @@ -78,6 +77,7 @@ Feature: Lookup by index itself | '76ers' | '76ers' | | 'Trail Blazers' | 'Trail Blazers' | | 'Bulls' | 'Bulls' | + And drop the used space Scenario: [1] Tag TODO When executing query: @@ -100,6 +100,7 @@ Feature: Lookup by index itself LOOKUP ON team WHERE team.name CONTAINS 'Jazz' YIELD team.name AS Name """ Then a SemanticError should be raised at runtime: + And drop the used space Scenario: [2] edge index When executing query: @@ -418,6 +419,7 @@ Feature: Lookup by index itself | 'Dwight Howard' | 'Hawks' | 0 | 2016 | | 'Dwight Howard' | 'Hornets' | 0 | 2017 | | 'Dwight Howard' | 'Wizards' | 0 | 2018 | + And drop the used space Scenario: [2] Edge TODO When executing query: @@ -440,6 +442,7 @@ Feature: Lookup by index itself LOOKUP ON serve WHERE serve.start_year == serve.end_year YIELD serve.start_year AS startYear """ Then a SemanticError should be raised at runtime: + And drop the used space Scenario: [1] Compare INT and FLOAT during IndexScan When executing query: @@ -542,34 +545,24 @@ Feature: Lookup by index itself | "Amar'e Stoudemire" | 36 | "Amar'e Stoudemire" | | "Boris Diaw" | 36 | "Boris Diaw" | | "Tony Parker" | 36 | "Tony Parker" | + And drop the used space Scenario: [2] Compare INT and FLOAT during IndexScan Given having executed: """ - CREATE TAG weight (WEIGHT double) - """ - And having executed: - """ - CREATE TAG INDEX weight_index - ON weight(WEIGHT) + CREATE TAG weight (WEIGHT double); + CREATE TAG INDEX weight_index ON weight(WEIGHT); """ And wait 6 seconds When executing query: """ - INSERT VERTEX weight(WEIGHT) - VALUES "Tim Duncan" : (70.5) - """ - Then the execution should be successful - When executing query: - """ - INSERT VERTEX weight(WEIGHT) - VALUES "Tony Parker" : (80.0) + INSERT VERTEX weight(WEIGHT) VALUES "Tim Duncan" : (70.5); + INSERT VERTEX weight(WEIGHT) VALUES "Tony Parker" : (80.0); """ Then the execution should be successful When executing query: """ - LOOKUP ON weight - WHERE weight.WEIGHT > 70; + LOOKUP ON weight WHERE weight.WEIGHT > 70; """ Then the result should be, in any order: | VertexID | @@ -577,8 +570,7 @@ Feature: Lookup by index itself | "Tony Parker" | When executing query: """ - LOOKUP ON weight - WHERE weight.WEIGHT > 70.4; + LOOKUP ON weight WHERE weight.WEIGHT > 70.4; """ Then the result should be, in any order: | VertexID | @@ -586,8 +578,7 @@ Feature: Lookup by index itself | "Tony Parker" | When executing query: """ - LOOKUP ON weight - WHERE weight.WEIGHT >= 70.5; + LOOKUP ON weight WHERE weight.WEIGHT >= 70.5; """ Then the result should be, in any order: | VertexID | diff --git a/tests/tck/features/lookup/ByIndex.intVid.feature b/tests/tck/features/lookup/ByIndex.intVid.feature index 8e80c600c..b2a2eb7c2 100644 --- a/tests/tck/features/lookup/ByIndex.intVid.feature +++ b/tests/tck/features/lookup/ByIndex.intVid.feature @@ -3,7 +3,6 @@ Feature: Lookup by index itself in integer vid Background: Given an empty graph And load "nba_int_vid" csv data to a new space - And wait 6 seconds Scenario: [1] tag index When executing query: @@ -78,6 +77,7 @@ Feature: Lookup by index itself in integer vid | '76ers' | '76ers' | | 'Trail Blazers' | 'Trail Blazers' | | 'Bulls' | 'Bulls' | + And drop the used space Scenario: [1] Tag TODO When executing query: @@ -100,6 +100,7 @@ Feature: Lookup by index itself in integer vid LOOKUP ON team WHERE team.name CONTAINS 'Jazz' YIELD team.name AS Name """ Then a SemanticError should be raised at runtime: + And drop the used space Scenario: [2] edge index When executing query: @@ -418,6 +419,7 @@ Feature: Lookup by index itself in integer vid | 'Dwight Howard' | 'Hawks' | 0 | 2016 | | 'Dwight Howard' | 'Hornets' | 0 | 2017 | | 'Dwight Howard' | 'Wizards' | 0 | 2018 | + And drop the used space Scenario: [2] Edge TODO When executing query: @@ -440,6 +442,7 @@ Feature: Lookup by index itself in integer vid LOOKUP ON serve WHERE serve.start_year == serve.end_year YIELD serve.start_year AS startYear """ Then a SemanticError should be raised at runtime: + And drop the used space Scenario: [1] Compare INT and FLOAT during IndexScan When executing query: @@ -542,34 +545,23 @@ Feature: Lookup by index itself in integer vid | "Amar'e Stoudemire" | 36 | "Amar'e Stoudemire" | | "Boris Diaw" | 36 | "Boris Diaw" | | "Tony Parker" | 36 | "Tony Parker" | + And drop the used space Scenario: [2] Compare INT and FLOAT during IndexScan Given having executed: """ - CREATE TAG weight (WEIGHT double) - """ - And having executed: - """ - CREATE TAG INDEX weight_index - ON weight(WEIGHT) + CREATE TAG weight (WEIGHT double); + CREATE TAG INDEX weight_index ON weight(WEIGHT); """ And wait 6 seconds When executing query: """ - INSERT VERTEX weight(WEIGHT) - VALUES hash("Tim Duncan") : (70.5) - """ - Then the execution should be successful - When executing query: - """ - INSERT VERTEX weight(WEIGHT) - VALUES hash("Tony Parker") : (80.0) + INSERT VERTEX weight(WEIGHT) VALUES hash("Tim Duncan") : (70.5); + INSERT VERTEX weight(WEIGHT) VALUES hash("Tony Parker") : (80.0); """ - Then the execution should be successful When executing query: """ - LOOKUP ON weight - WHERE weight.WEIGHT > 70; + LOOKUP ON weight WHERE weight.WEIGHT > 70; """ Then the result should be, in any order, and the columns 0 should be hashed: | VertexID | @@ -577,8 +569,7 @@ Feature: Lookup by index itself in integer vid | "Tony Parker" | When executing query: """ - LOOKUP ON weight - WHERE weight.WEIGHT > 70.4; + LOOKUP ON weight WHERE weight.WEIGHT > 70.4; """ Then the result should be, in any order, and the columns 0 should be hashed: | VertexID | @@ -586,8 +577,7 @@ Feature: Lookup by index itself in integer vid | "Tony Parker" | When executing query: """ - LOOKUP ON weight - WHERE weight.WEIGHT >= 70.5; + LOOKUP ON weight WHERE weight.WEIGHT >= 70.5; """ Then the result should be, in any order, and the columns 0 should be hashed: | VertexID | diff --git a/tests/tck/features/lookup/LookUp.IntVid.feature b/tests/tck/features/lookup/LookUp.IntVid.feature index ba366daac..1c0999495 100644 --- a/tests/tck/features/lookup/LookUp.IntVid.feature +++ b/tests/tck/features/lookup/LookUp.IntVid.feature @@ -19,7 +19,6 @@ Feature: LookUpTest_Vid_Int """ INSERT VERTEX lookup_tag_1(col1, col2, col3) VALUES 200:(200, 200, 200),201:(201, 201, 201), 202:(202, 202, 202); """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -66,9 +65,11 @@ Feature: LookUpTest_Vid_Int And wait 6 seconds When executing query: """ - INSERT EDGE lookup_edge_1(col1, col2, col3) VALUES - 200 -> 201@0:(201, 201, 201), - 200 -> 202@0:(202, 202, 202) + INSERT EDGE + lookup_edge_1(col1, col2, col3) + VALUES + 200 -> 201@0:(201, 201, 201), + 200 -> 202@0:(202, 202, 202) """ Then the execution should be successful When executing query: @@ -119,10 +120,12 @@ Feature: LookUpTest_Vid_Int And wait 6 seconds When executing query: """ - INSERT VERTEX lookup_tag_1(col1, col2, col3) VALUES - 200:(200, 200, 200), - 201:(201, 201, 201), - 202:(202, 202, 202) + INSERT VERTEX + lookup_tag_1(col1, col2, col3) + VALUES + 200:(200, 200, 200), + 201:(201, 201, 201), + 202:(202, 202, 202) """ Then the execution should be successful When executing query: @@ -159,9 +162,11 @@ Feature: LookUpTest_Vid_Int And wait 6 seconds When executing query: """ - INSERT EDGE lookup_edge_1(col1, col2, col3) VALUES - 200 -> 201@0:(201, 201, 201), - 200 -> 202@0:(202, 202, 202) + INSERT EDGE + lookup_edge_1(col1, col2, col3) + VALUES + 200 -> 201@0:(201, 201, 201), + 200 -> 202@0:(202, 202, 202) """ Then the execution should be successful When executing query: @@ -197,13 +202,15 @@ Feature: LookUpTest_Vid_Int And wait 6 seconds When executing query: """ - INSERT VERTEX lookup_tag_2(col1, col2, col3, col4) VALUES - 220:(true, 100, 100.5, true), - 221:(true, 200, 200.5, true), - 222:(true, 300, 300.5, true), - 223:(true, 400, 400.5, true), - 224:(true, 500, 500.5, true), - 225:(true, 600, 600.5, true) + INSERT VERTEX + lookup_tag_2(col1, col2, col3, col4) + VALUES + 220:(true, 100, 100.5, true), + 221:(true, 200, 200.5, true), + 222:(true, 300, 300.5, true), + 223:(true, 400, 400.5, true), + 224:(true, 500, 500.5, true), + 225:(true, 600, 600.5, true) """ Then the execution should be successful When executing query: @@ -349,12 +356,14 @@ Feature: LookUpTest_Vid_Int And wait 6 seconds When executing query: """ - INSERT EDGE lookup_edge_2(col1, col2, col3, col4) VALUES - 220 -> 221@0:(true, 100, 100.5, true), - 220 -> 222@0:(true, 200, 200.5, true), - 220 -> 223@0:(true, 300, 300.5, true), - 220 -> 224@0:(true, 400, 400.5, true), - 220 -> 225@0:(true, 500, 500.5, true) + INSERT EDGE + lookup_edge_2(col1, col2, col3, col4) + VALUES + 220 -> 221@0:(true, 100, 100.5, true), + 220 -> 222@0:(true, 200, 200.5, true), + 220 -> 223@0:(true, 300, 300.5, true), + 220 -> 224@0:(true, 400, 400.5, true), + 220 -> 225@0:(true, 500, 500.5, true) """ Then the execution should be successful When executing query: @@ -497,13 +506,15 @@ Feature: LookUpTest_Vid_Int And wait 6 seconds When executing query: """ - INSERT VERTEX lookup_tag_2(col1, col2, col3, col4) VALUES - 220:(true, 100, 100.5, true), - 221:(true, 200, 200.5, true), - 222:(true, 300, 300.5, true), - 223:(true, 400, 400.5, true), - 224:(true, 500, 500.5, true), - 225:(true, 600, 600.5, true) + INSERT VERTEX + lookup_tag_2(col1, col2, col3, col4) + VALUES + 220:(true, 100, 100.5, true), + 221:(true, 200, 200.5, true), + 222:(true, 300, 300.5, true), + 223:(true, 400, 400.5, true), + 224:(true, 500, 500.5, true), + 225:(true, 600, 600.5, true) """ Then the execution should be successful When executing query: @@ -620,30 +631,30 @@ Feature: LookUpTest_Vid_Int | vid_type | int64 | | charset | utf8 | | collate | utf8_bin | - And wait 6 seconds When executing query: """ CREATE TAG student(number int, age int) """ - And wait 6 seconds Then the execution should be successful When executing query: """ CREATE TAG INDEX student_index ON student(number, age) """ - And wait 6 seconds Then the execution should be successful When executing query: """ CREATE TAG teacher(number int, age int) """ - And wait 6 seconds Then the execution should be successful + And wait 6 seconds When executing query: """ - INSERT VERTEX student(number, age), teacher(number, age) VALUES - 220:(1, 20, 1, 30), - 221:(2, 22, 2, 32) + INSERT VERTEX + student(number, age), + teacher(number, age) + VALUES + 220:(1, 20, 1, 30), + 221:(2, 22, 2, 32) """ Then the execution should be successful When executing query: @@ -854,19 +865,16 @@ Feature: LookUpTest_Vid_Int """ CREATE TAG tag_with_str(c1 int, c2 string, c3 string) """ - And wait 6 seconds Then the execution should be successful When executing query: """ CREATE TAG INDEX i1_with_str ON tag_with_str(c1, c2(30)) """ - And wait 6 seconds Then the execution should be successful When executing query: """ CREATE TAG INDEX i2_with_str ON tag_with_str(c2(30), c3(30)) """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -876,13 +884,15 @@ Feature: LookUpTest_Vid_Int Then the execution should be successful When executing query: """ - INSERT VERTEX tag_with_str(c1, c2, c3) VALUES - 1:(1, "c1_row1", "c2_row1"), - 2:(2, "c1_row2", "c2_row2"), - 3:(3, "abc", "abc"), - 4:(4, "abc", "abc"), - 5:(5, "ab", "cabc"), - 6:(5, "abca", "bc") + INSERT VERTEX + tag_with_str(c1, c2, c3) + VALUES + 1:(1, "c1_row1", "c2_row1"), + 2:(2, "c1_row2", "c2_row2"), + 3:(3, "abc", "abc"), + 4:(4, "abc", "abc"), + 5:(5, "ab", "cabc"), + 6:(5, "abca", "bc") """ Then the execution should be successful When executing query: @@ -941,28 +951,30 @@ Feature: LookUpTest_Vid_Int """ create tag identity (BIRTHDAY int, NATION string, BIRTHPLACE_CITY string) """ - And wait 6 seconds Then the execution should be successful When executing query: """ - CREATE TAG INDEX idx_identity_cname_birth_gender_nation_city - ON identity(BIRTHDAY, NATION(30), BIRTHPLACE_CITY(30)) + CREATE TAG INDEX + idx_identity_cname_birth_gender_nation_city + ON + identity(BIRTHDAY, NATION(30), BIRTHPLACE_CITY(30)) """ And wait 6 seconds Then the execution should be successful When executing query: """ - INSERT VERTEX identity (BIRTHDAY, NATION, BIRTHPLACE_CITY) - VALUES 1:(19860413, "汉族", "aaa") + INSERT VERTEX identity (BIRTHDAY, NATION, BIRTHPLACE_CITY) VALUES 1:(19860413, "汉族", "aaa") """ Then the execution should be successful When executing query: """ - lookup on identity where - identity.NATION == "汉族" and - identity.BIRTHDAY > 19620101 and - identity.BIRTHDAY < 20021231 and - identity.BIRTHPLACE_CITY == "bbb"; + LOOKUP ON + identity + WHERE + identity.NATION == "汉族" AND + identity.BIRTHDAY > 19620101 AND + identity.BIRTHDAY < 20021231 AND + identity.BIRTHPLACE_CITY == "bbb"; """ Then the result should be, in any order: | VertexID | diff --git a/tests/tck/features/lookup/LookUp.feature b/tests/tck/features/lookup/LookUp.feature index 778a9c09a..51205d66a 100644 --- a/tests/tck/features/lookup/LookUp.feature +++ b/tests/tck/features/lookup/LookUp.feature @@ -19,7 +19,6 @@ Feature: LookUpTest_Vid_String """ INSERT VERTEX lookup_tag_1(col1, col2, col3) VALUES "200":(200, 200, 200),"201":(201, 201, 201), "202":(202, 202, 202); """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -59,9 +58,7 @@ Feature: LookUpTest_Vid_String And wait 6 seconds When executing query: """ - INSERT EDGE lookup_edge_1(col1, col2, col3) VALUES - "200" -> "201"@0:(201, 201, 201), - "200" -> "202"@0:(202, 202, 202) + INSERT EDGE lookup_edge_1(col1, col2, col3) VALUES "200" -> "201"@0:(201, 201, 201), "200" -> "202"@0:(202, 202, 202) """ Then the execution should be successful When executing query: @@ -105,10 +102,12 @@ Feature: LookUpTest_Vid_String And wait 6 seconds When executing query: """ - INSERT VERTEX lookup_tag_1(col1, col2, col3) VALUES - "200":(200, 200, 200), - "201":(201, 201, 201), - "202":(202, 202, 202) + INSERT VERTEX + lookup_tag_1(col1, col2, col3) + VALUES + "200":(200, 200, 200), + "201":(201, 201, 201), + "202":(202, 202, 202) """ Then the execution should be successful When executing query: @@ -138,9 +137,11 @@ Feature: LookUpTest_Vid_String And wait 6 seconds When executing query: """ - INSERT EDGE lookup_edge_1(col1, col2, col3) VALUES - "200" -> "201"@0:(201, 201, 201), - "200" -> "202"@0:(202, 202, 202) + INSERT EDGE + lookup_edge_1(col1, col2, col3) + VALUES + "200" -> "201"@0:(201, 201, 201), + "200" -> "202"@0:(202, 202, 202) """ Then the execution should be successful When executing query: @@ -169,13 +170,15 @@ Feature: LookUpTest_Vid_String And wait 6 seconds When executing query: """ - INSERT VERTEX lookup_tag_2(col1, col2, col3, col4) VALUES - "220":(true, 100, 100.5, true), - "221":(true, 200, 200.5, true), - "222":(true, 300, 300.5, true), - "223":(true, 400, 400.5, true), - "224":(true, 500, 500.5, true), - "225":(true, 600, 600.5, true) + INSERT VERTEX + lookup_tag_2(col1, col2, col3, col4) + VALUES + "220":(true, 100, 100.5, true), + "221":(true, 200, 200.5, true), + "222":(true, 300, 300.5, true), + "223":(true, 400, 400.5, true), + "224":(true, 500, 500.5, true), + "225":(true, 600, 600.5, true) """ Then the execution should be successful When executing query: @@ -314,12 +317,14 @@ Feature: LookUpTest_Vid_String And wait 6 seconds When executing query: """ - INSERT EDGE lookup_edge_2(col1, col2, col3, col4) VALUES - "220" -> "221"@0:(true, 100, 100.5, true), - "220" -> "222"@0:(true, 200, 200.5, true), - "220" -> "223"@0:(true, 300, 300.5, true), - "220" -> "224"@0:(true, 400, 400.5, true), - "220" -> "225"@0:(true, 500, 500.5, true) + INSERT EDGE + lookup_edge_2(col1, col2, col3, col4) + VALUES + "220" -> "221"@0:(true, 100, 100.5, true), + "220" -> "222"@0:(true, 200, 200.5, true), + "220" -> "223"@0:(true, 300, 300.5, true), + "220" -> "224"@0:(true, 400, 400.5, true), + "220" -> "225"@0:(true, 500, 500.5, true) """ Then the execution should be successful When executing query: @@ -455,13 +460,15 @@ Feature: LookUpTest_Vid_String And wait 6 seconds When executing query: """ - INSERT VERTEX lookup_tag_2(col1, col2, col3, col4) VALUES - "220":(true, 100, 100.5, true), - "221":(true, 200, 200.5, true), - "222":(true, 300, 300.5, true), - "223":(true, 400, 400.5, true), - "224":(true, 500, 500.5, true), - "225":(true, 600, 600.5, true) + INSERT VERTEX + lookup_tag_2(col1, col2, col3, col4) + VALUES + "220":(true, 100, 100.5, true), + "221":(true, 200, 200.5, true), + "222":(true, 300, 300.5, true), + "223":(true, 400, 400.5, true), + "224":(true, 500, 500.5, true), + "225":(true, 600, 600.5, true) """ Then the execution should be successful When executing query: @@ -586,9 +593,7 @@ Feature: LookUpTest_Vid_String And wait 6 seconds When executing query: """ - INSERT VERTEX student(number, age), teacher(number, age) VALUES - "220":(1, 20, 1, 30), - "221":(2, 22, 2, 32) + INSERT VERTEX student(number, age), teacher(number, age) VALUES "220":(1, 20, 1, 30), "221":(2, 22, 2, 32) """ Then the execution should be successful When executing query: @@ -781,13 +786,15 @@ Feature: LookUpTest_Vid_String And wait 6 seconds When executing query: """ - INSERT VERTEX tag_with_str(c1, c2, c3) VALUES - "1":(1, "c1_row1", "c2_row1"), - "2":(2, "c1_row2", "c2_row2"), - "3":(3, "abc", "abc"), - "4":(4, "abc", "abc"), - "5":(5, "ab", "cabc"), - "6":(5, "abca", "bc") + INSERT VERTEX + tag_with_str(c1, c2, c3) + VALUES + "1":(1, "c1_row1", "c2_row1"), + "2":(2, "c1_row2", "c2_row2"), + "3":(3, "abc", "abc"), + "4":(4, "abc", "abc"), + "5":(5, "ab", "cabc"), + "6":(5, "abca", "bc") """ Then the execution should be successful When executing query: @@ -841,20 +848,26 @@ Feature: LookUpTest_Vid_String """ And having executed: """ - CREATE TAG INDEX idx_identity_cname_birth_gender_nation_city - ON identity(BIRTHDAY, NATION(30), BIRTHPLACE_CITY(30)) + CREATE TAG INDEX + idx_identity_cname_birth_gender_nation_city + ON + identity(BIRTHDAY, NATION(30), BIRTHPLACE_CITY(30)) """ And wait 6 seconds When executing query: """ - INSERT VERTEX identity (BIRTHDAY, NATION, BIRTHPLACE_CITY) - VALUES "1" : (19860413, "汉族", "aaa") + INSERT VERTEX identity(BIRTHDAY, NATION, BIRTHPLACE_CITY) VALUES "1" : (19860413, "汉族", "aaa") """ Then the execution should be successful When executing query: """ - LOOKUP ON identity - WHERE identity.NATION == "汉族" AND identity.BIRTHDAY > 19620101 AND identity.BIRTHDAY < 20021231 AND identity.BIRTHPLACE_CITY == "bbb"; + LOOKUP ON + identity + WHERE + identity.NATION == "汉族" AND + identity.BIRTHDAY > 19620101 AND + identity.BIRTHDAY < 20021231 AND + identity.BIRTHPLACE_CITY == "bbb"; """ Then the result should be, in any order: | VertexID | diff --git a/tests/tck/features/mutate/InsertWithTimeType.feature b/tests/tck/features/mutate/InsertWithTimeType.feature index eb57ffe25..882c9ded8 100644 --- a/tests/tck/features/mutate/InsertWithTimeType.feature +++ b/tests/tck/features/mutate/InsertWithTimeType.feature @@ -1,6 +1,6 @@ Feature: Insert with time-dependent types - Background: Prepare space + Scenario: insert wrong format timestamp Given an empty graph And create a space with following options: | partition_num | 9 | @@ -13,19 +13,16 @@ Feature: Insert with time-dependent types CREATE TAG IF NOT EXISTS TAG_DATE(a date); CREATE TAG IF NOT EXISTS TAG_DATETIME(a datetime); """ - And wait 3 seconds - - Scenario: insert wrong format timestamp - When executing query: + When try to execute query: """ - INSERT VERTEX TAG_TIMESTAMP(a) VALUES "TEST_VERTEX":("2000.0.0 10:0:0") + INSERT VERTEX TAG_TIMESTAMP(a) VALUES "TEST_VERTEX":(NULL) """ - Then a ExecutionError should be raised at runtime:Storage Error: The data type does not meet the requirements. Use the correct type of data. + Then the execution should be successful When executing query: """ - INSERT VERTEX TAG_TIMESTAMP(a) VALUES "TEST_VERTEX":(NULL) + INSERT VERTEX TAG_TIMESTAMP(a) VALUES "TEST_VERTEX":("2000.0.0 10:0:0") """ - Then the execution should be successful + Then a ExecutionError should be raised at runtime:Storage Error: The data type does not meet the requirements. Use the correct type of data. When executing query: """ INSERT VERTEX TAG_TIME(a) VALUES "TEST_VERTEX":("10:0:0") @@ -56,3 +53,4 @@ Feature: Insert with time-dependent types INSERT VERTEX TAG_DATETIME(a) VALUES "TEST_VERTEX":(NULL) """ Then the execution should be successful + And drop the used space diff --git a/tests/tck/features/parser/Example.feature b/tests/tck/features/parser/Example.feature index 2c6027666..f56e4c181 100644 --- a/tests/tck/features/parser/Example.feature +++ b/tests/tck/features/parser/Example.feature @@ -24,7 +24,7 @@ Feature: Feature examples """ SHOW HOSTS """ - Then the result should include: + Then the result should contain: | Host | Port | Status | Leader count | Leader distribution | Partition distribution | | /\w+/ | /\d+/ | "ONLINE" | /\d+/ | /.*/ | /.*/ | When executing query: diff --git a/tests/tck/features/schema/Schema.feature b/tests/tck/features/schema/Schema.feature index ac30e0818..0dc32def9 100644 --- a/tests/tck/features/schema/Schema.feature +++ b/tests/tck/features/schema/Schema.feature @@ -10,7 +10,6 @@ Feature: Insert string vid of vertex and edge | partition_num | 9 | | replica_factor | 1 | | vid_type | FIXED_STRING(20) | - And wait 3 seconds # empty prop When executing query: """ @@ -176,10 +175,12 @@ Feature: Insert string vid of vertex and edge # Tag with expression DEFAULT value When executing query: """ - CREATE TAG default_tag_expr(id int64 DEFAULT 3/2*4-5, - male bool DEFAULT 3 > 2, - height double DEFAULT abs(-176.0), - adult bool DEFAULT true AND false) + CREATE TAG default_tag_expr( + id int64 DEFAULT 3/2*4-5, + male bool DEFAULT 3 > 2, + height double DEFAULT abs(-176.0), + adult bool DEFAULT true AND false + ); """ Then the execution should be successful # drop tag succeeded @@ -360,10 +361,11 @@ Feature: Insert string vid of vertex and edge When executing query: """ CREATE EDGE default_edge_expr( - id int DEFAULT 3/2*4-5, - male bool DEFAULT 3 > 2, - height double DEFAULT abs(-176.0), - adult bool DEFAULT true AND false) + id int DEFAULT 3/2*4-5, + male bool DEFAULT 3 > 2, + height double DEFAULT abs(-176.0), + adult bool DEFAULT true AND false + ); """ Then the execution should be successful # test drop edge @@ -391,6 +393,7 @@ Feature: Insert string vid of vertex and edge DROP EDGE IF EXISTS exist_edge; """ Then the execution should be successful + And drop the used space # test same tag in different space When executing query: """ @@ -399,7 +402,6 @@ Feature: Insert string vid of vertex and edge CREATE TAG animal(name string, kind string); """ Then the execution should be successful - Given wait 3 seconds # check result When executing query: """ @@ -434,9 +436,8 @@ Feature: Insert string vid of vertex and edge Then the result should be, in any order: | Name | | "test_tag" | - Given wait 3 seconds # test same tag in different space - When executing query: + When try to execute query: """ USE test_multi; CREATE TAG test_tag1(); @@ -455,7 +456,8 @@ Feature: Insert string vid of vertex and edge # reserved keyword When executing query: """ - USE my_space; CREATE TAG `tag` (`edge` string); + USE my_space; + CREATE TAG `tag` (`edge` string); """ Then the execution should be successful # test drop space @@ -463,7 +465,7 @@ Feature: Insert string vid of vertex and edge """ SHOW SPACES; """ - Then the result should include: + Then the result should contain: | Name | | "my_space" | # test drop space @@ -477,15 +479,16 @@ Feature: Insert string vid of vertex and edge """ SHOW SPACES; """ - Then the result should include: - | Name | - | /EmptyGraph_.*/ | + Then the result should not contain: + | Name | + | "my_space" | + | "test_multi" | # test alter tag with default When executing query: """ CREATE SPACE tag_space(partition_num=9); USE tag_space; - CREATE TAG t(name string DEFAULT "N/A", age int DEFAULT -1) + CREATE TAG t(name string DEFAULT "N/A", age int DEFAULT -1); """ Then the execution should be successful # test alter add @@ -494,7 +497,7 @@ Feature: Insert string vid of vertex and edge ALTER TAG t ADD (description string DEFAULT "none") """ Then the execution should be successful - Given wait 3 seconds + And wait 3 seconds # insert When executing query: """ @@ -515,7 +518,7 @@ Feature: Insert string vid of vertex and edge ALTER TAG t CHANGE (description string NOT NULL) """ Then the execution should be successful - Given wait 3 seconds + And wait 3 seconds # insert When executing query: """ @@ -547,7 +550,7 @@ Feature: Insert string vid of vertex and edge ALTER EDGE e ADD (description string DEFAULT "none") """ Then the execution should be successful - Given wait 3 seconds + And wait 3 seconds When executing query: """ INSERT VERTEX t(description) VALUES "1":("some one") @@ -567,7 +570,7 @@ Feature: Insert string vid of vertex and edge ALTER EDGE e CHANGE (description string NOT NULL) """ Then the execution should be successful - Given wait 3 seconds + And wait 3 seconds # insert without default prop, failed When executing query: """ @@ -577,21 +580,22 @@ Feature: Insert string vid of vertex and edge # test alter edge with timestamp default When executing query: """ + DROP SPACE tag_space; CREATE SPACE issue2009(vid_type = FIXED_STRING(20)); - USE issue2009 + USE issue2009; """ Then the execution should be successful When executing query: """ CREATE EDGE IF NOT EXISTS relation ( - intimacy int DEFAULT 0, - isReversible bool DEFAULT false, - name string DEFAULT "N/A", - startTime timestamp DEFAULT 0) + intimacy int DEFAULT 0, + isReversible bool DEFAULT false, + name string DEFAULT "N/A", + startTime timestamp DEFAULT 0 + ) """ Then the execution should be successful - Given wait 3 seconds - When executing query: + When try to execute query: """ INSERT EDGE relation (intimacy) VALUES "person.Tom" -> "person.Marry"@0:(3) """ @@ -765,4 +769,8 @@ Feature: Insert string vid of vertex and edge ALTER EDGE edge_not_null_default1 CHANGE (name FIXED_STRING(10) DEFAULT 10) """ Then a ExecutionError should be raised at runtime: Invalid parm! - Then drop the used space + When executing query: + """ + DROP SPACE issue2009; + """ + Then the execution should be successful diff --git a/tests/tck/features/ttl/TTL.feature b/tests/tck/features/ttl/TTL.feature index c8e49b426..134cf26ad 100644 --- a/tests/tck/features/ttl/TTL.feature +++ b/tests/tck/features/ttl/TTL.feature @@ -12,7 +12,6 @@ Feature: TTLTest """ CREATE TAG person(name string, email string, age int, gender string, row_timestamp timestamp); """ - And wait 6 seconds When executing query: """ DESCRIBE TAG person; @@ -98,7 +97,6 @@ Feature: TTLTest """ ALTER TAG woman Drop (name) ttl_duration = 200; """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -121,7 +119,6 @@ Feature: TTLTest """ ALTER TAG woman Drop (row_timestamp); """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -134,7 +131,6 @@ Feature: TTLTest """ ALTER TAG woman ttl_duration = 100, ttl_col = "age"; """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -196,7 +192,6 @@ Feature: TTLTest """ CREATE EDGE work1(name string, email string, age int, gender string, row_timestamp timestamp) ttl_duration = 100, ttl_col = "row_timestamp"; """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -331,6 +326,7 @@ Feature: TTLTest Then the result should be, in any order: | Edge | Create Edge | | "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` string NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' | + And drop the used space Scenario: TTLTest Datatest Given having executed: @@ -340,15 +336,13 @@ Feature: TTLTest CREATE Edge like(id int) ttl_col="id", ttl_duration=100; CREATE Edge friend(id int); """ - And wait 6 seconds - When executing query: + When try to execute query: """ INSERT VERTEX person(id) VALUES "1":(100), "2":(200); INSERT VERTEX career(id) VALUES "2":(200); INSERT EDGE like(id) VALUES "100"->"1":(100), "100"->"2":(200); INSERT EDGE friend(id) VALUES "100"->"1":(100), "100"->"2":(200); """ - And wait 6 seconds Then the execution should be successful When executing query: """ @@ -422,19 +416,19 @@ Feature: TTLTest """ Then the result should be, in any order: | like._src | like._dst | like._rank | id | + And drop the used space Scenario: TTLTest expire time Given having executed: """ CREATE TAG person(id timestamp, age int) ttl_col="id", ttl_duration=5; """ - And wait 6 seconds - When executing query: + When try to execute query: """ INSERT VERTEX person(id, age) VALUES "1":(now(), 20); """ - And wait 1 seconds Then the execution should be successful + And wait 1 seconds When executing query: """ FETCH PROP ON person "1" YIELD person.age as age; @@ -442,10 +436,11 @@ Feature: TTLTest Then the result should be, in any order, with relax comparison: | VertexID | age | | "1" | 20 | - And wait 10 seconds + And wait 7 seconds When executing query: """ FETCH PROP ON person "1" YIELD person.age as age; """ Then the result should be, in any order: | VertexID | age | + And drop the used space diff --git a/tests/tck/features/update/Update.IntVid.feature b/tests/tck/features/update/Update.IntVid.feature index ba54b45f9..c4ccbe58f 100644 --- a/tests/tck/features/update/Update.IntVid.feature +++ b/tests/tck/features/update/Update.IntVid.feature @@ -4,7 +4,7 @@ # attached with Common Clause Condition 1.0, found in the LICENSES directory. Feature: Update int vid of vertex and edge - Background: Prepare space + Scenario: update and upsert test Given an empty graph And create a space with following options: | partition_num | 9 | @@ -15,36 +15,45 @@ Feature: Update int vid of vertex and edge CREATE TAG IF NOT EXISTS course(name string, credits int); CREATE TAG IF NOT EXISTS building(name string); CREATE TAG IF NOT EXISTS student(name string, age int, gender string); - CREATE TAG IF NOT EXISTS student_default(name string NOT NULL, - age int NOT NULL,gender string DEFAULT "one", birthday int DEFAULT 2010); + CREATE TAG IF NOT EXISTS student_default( + name string NOT NULL, + age int NOT NULL, + gender string DEFAULT "one", + birthday int DEFAULT 2010 + ); CREATE EDGE IF NOT EXISTS like(likeness double); CREATE EDGE IF NOT EXISTS select(grade int, year int); CREATE EDGE IF NOT EXISTS select_default(grade int NOT NULL,year TIMESTAMP DEFAULT 1546308000); """ - And wait 6 seconds - - Scenario: update and upsert test - When executing query: + And having executed: """ - INSERT VERTEX student(name, age, gender) VALUES - 200:("Monica", 16, "female"), - 201:("Mike", 18, "male"), - 202:("Jane", 17, "female"); - INSERT VERTEX course(name, credits),building(name) VALUES - 101:("Math", 3, "No5"), - 102:("English", 6, "No11"); + INSERT VERTEX + student(name, age, gender) + VALUES + 200:("Monica", 16, "female"), + 201:("Mike", 18, "male"), + 202:("Jane", 17, "female"); + INSERT VERTEX + course(name, credits), + building(name) + VALUES + 101:("Math", 3, "No5"), + 102:("English", 6, "No11"); INSERT VERTEX course(name, credits) VALUES 103:("CS", 5); - INSERT EDGE select(grade, year) VALUES - 200 -> 101@0:(5, 2018), - 200 -> 102@0:(3, 2018), - 201 -> 102@0:(3, 2019), - 202 -> 102@0:(3, 2019); - INSERT EDGE like(likeness) VALUES - 200 -> 201@0:(92.5), - 201 -> 200@0:(85.6), - 201 -> 202@0:(93.2); + INSERT EDGE + select(grade, year) + VALUES + 200 -> 101@0:(5, 2018), + 200 -> 102@0:(3, 2018), + 201 -> 102@0:(3, 2019), + 202 -> 102@0:(3, 2019); + INSERT EDGE + like(likeness) + VALUES + 200 -> 201@0:(92.5), + 201 -> 200@0:(85.6), + 201 -> 202@0:(93.2); """ - Then the execution should be successful When executing query: """ UPDATE VERTEX 101 @@ -556,7 +565,7 @@ Feature: Update int vid of vertex and edge ALTER TAG building ADD (new_field string default "123"); """ Then the execution should be successful - Given wait 3 seconds + And wait 3 seconds # upsert after alter schema When executing query: """ @@ -603,7 +612,7 @@ Feature: Update int vid of vertex and edge ALTER EDGE like ADD (new_field string default "123"); """ Then the execution should be successful - Given wait 3 seconds + And wait 3 seconds When executing query: """ UPSERT EDGE 1->100 OF like SET likeness = 2.0; diff --git a/tests/tck/features/update/Update.feature b/tests/tck/features/update/Update.feature index dd75755e5..aa6dc2b2b 100644 --- a/tests/tck/features/update/Update.feature +++ b/tests/tck/features/update/Update.feature @@ -15,32 +15,44 @@ Feature: Update string vid of vertex and edge CREATE TAG IF NOT EXISTS course(name string, credits int); CREATE TAG IF NOT EXISTS building(name string); CREATE TAG IF NOT EXISTS student(name string, age int, gender string); - CREATE TAG IF NOT EXISTS student_default(name string NOT NULL, - age int NOT NULL,gender string DEFAULT "one", birthday int DEFAULT 2010); + CREATE TAG IF NOT EXISTS student_default( + name string NOT NULL, + age int NOT NULL, + gender string DEFAULT "one", + birthday int DEFAULT 2010 + ); CREATE EDGE IF NOT EXISTS like(likeness double); CREATE EDGE IF NOT EXISTS select(grade int, year int); CREATE EDGE IF NOT EXISTS select_default(grade int NOT NULL,year TIMESTAMP DEFAULT 1546308000); """ - And wait 3 seconds And having executed: """ - INSERT VERTEX student(name, age, gender) VALUES - "200":("Monica", 16, "female"), - "201":("Mike", 18, "male"), - "202":("Jane", 17, "female"); - INSERT VERTEX course(name, credits),building(name) VALUES - "101":("Math", 3, "No5"), - "102":("English", 6, "No11"); + INSERT VERTEX + student(name, age, gender) + VALUES + "200":("Monica", 16, "female"), + "201":("Mike", 18, "male"), + "202":("Jane", 17, "female"); + INSERT VERTEX + course(name, credits), + building(name) + VALUES + "101":("Math", 3, "No5"), + "102":("English", 6, "No11"); INSERT VERTEX course(name, credits) VALUES "103":("CS", 5); - INSERT EDGE select(grade, year) VALUES - "200"->"101"@0:(5, 2018), - "200" -> "102"@0:(3, 2018), - "201" -> "102"@0:(3, 2019), - "202" -> "102"@0:(3, 2019); - INSERT EDGE like(likeness) VALUES - "200" -> "201"@0:(92.5), - "201" -> "200"@0:(85.6), - "201" -> "202"@0:(93.2); + INSERT EDGE + select(grade, year) + VALUES + "200"->"101"@0:(5, 2018), + "200" -> "102"@0:(3, 2018), + "201" -> "102"@0:(3, 2019), + "202" -> "102"@0:(3, 2019); + INSERT EDGE + like(likeness) + VALUES + "200" -> "201"@0:(92.5), + "201" -> "200"@0:(85.6), + "201" -> "202"@0:(93.2); """ Scenario: update and upsert test with 1.0 syntax @@ -600,7 +612,7 @@ Feature: Update string vid of vertex and edge ALTER TAG building ADD (new_field string default "123"); """ Then the execution should be successful - Given wait 3 seconds + And wait 3 seconds # upsert after alter schema When executing query: """ @@ -647,7 +659,7 @@ Feature: Update string vid of vertex and edge ALTER EDGE like ADD (new_field string default "123"); """ Then the execution should be successful - Given wait 3 seconds + And wait 3 seconds When executing query: """ UPSERT EDGE "1"->"100" OF like SET likeness = 2.0; @@ -1102,7 +1114,7 @@ Feature: Update string vid of vertex and edge ALTER TAG building ADD (new_field string default "123"); """ Then the execution should be successful - Given wait 3 seconds + And wait 3 seconds # upsert after alter schema When executing query: """ @@ -1149,7 +1161,7 @@ Feature: Update string vid of vertex and edge ALTER EDGE like ADD (new_field string default "123"); """ Then the execution should be successful - Given wait 3 seconds + And wait 3 seconds When executing query: """ UPSERT EDGE ON like "1"->"100" SET likeness = 2.0; diff --git a/tests/tck/features/user/User.feature b/tests/tck/features/user/User.feature index d29409269..068aef6d0 100644 --- a/tests/tck/features/user/User.feature +++ b/tests/tck/features/user/User.feature @@ -38,7 +38,7 @@ Feature: User & privilege Test """ SHOW USERS """ - Then the result should include: + Then the result should contain: | Account | | "root" | | "user1" | @@ -150,8 +150,8 @@ Feature: User & privilege Test """ CREATE SPACE IF NOT EXISTS user_tmp_space(partition_num=1, replica_factor=1) """ - And wait 10 seconds Then the execution should be successful + And wait 10 seconds When executing query: """ GRANT DBA TO user1 @@ -196,10 +196,15 @@ Feature: User & privilege Test """ SHOW ROLES IN user_tmp_space """ - Then the result should include: + Then the result should contain: | Account | Role Type | | "usertmp" | "DBA" | | "usertmp_2" | "GUEST" | + When executing query: + """ + DROP SPACE user_tmp_space; + """ + Then the execution should be successful Scenario: Grant privilege on not existing space When executing query: @@ -223,8 +228,8 @@ Feature: User & privilege Test """ CREATE SPACE IF NOT EXISTS user_tmp_space_3(partition_num=1, replica_factor=1) """ - And wait 10 seconds Then the execution should be successful + And wait 10 seconds When executing query: """ CREATE USER IF NOT EXISTS user1 WITH PASSWORD "pwd1" @@ -270,3 +275,8 @@ Feature: User & privilege Test REVOKE ROLE DBA ON user_tmp_space_3 FROM user_revoke_tmp """ Then a ExecutionError should be raised at runtime: Not existed! + When executing query: + """ + DROP SPACE user_tmp_space_3; + """ + Then the execution should be successful