diff --git a/tests/admin/test_space.py b/tests/admin/test_space.py index 9bf47ef6f72766c40b8dc027a89989f51a88daa0..acfcdf35cff901c052ffac90133160cce70160c5 100644 --- a/tests/admin/test_space.py +++ b/tests/admin/test_space.py @@ -8,7 +8,7 @@ import time import re -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestSpace(NebulaTestSuite): diff --git a/tests/bench/delete.py b/tests/bench/delete.py index f5e90ca921e91ee2b89f5ccca7b3be02b3af2bf5..0a420a03fe23676edb0b46daffac97540071f0c4 100644 --- a/tests/bench/delete.py +++ b/tests/bench/delete.py @@ -1,8 +1,8 @@ import time import pytest from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite -from bench.data_generate import insert_vertexs, insert_edges +from tests.common.nebula_test_suite import NebulaTestSuite +from tests.bench.data_generate import insert_vertexs, insert_edges class TestDeleteBench(NebulaTestSuite): @@ -65,4 +65,4 @@ class TestDeleteBench(NebulaTestSuite): warmup=False ) def test_delete(self, benchmark): - benchmark(self.delete) \ No newline at end of file + benchmark(self.delete) diff --git a/tests/bench/insert.py b/tests/bench/insert.py index a4acc3c7815f1a3dce1954d53b083f008c2d1ce1..813a774698498aad743a80b134994322d75eaced 100644 --- a/tests/bench/insert.py +++ b/tests/bench/insert.py @@ -1,8 +1,8 @@ import time import pytest -from nebula_test_common.nebula_test_suite import NebulaTestSuite -from bench.data_generate import generate_insert_student_vertex, generate_insert_likeness_edge +from tests.common.nebula_test_suite import NebulaTestSuite +from tests.bench.data_generate import generate_insert_student_vertex, generate_insert_likeness_edge class TestInsertBench(NebulaTestSuite): @@ -69,4 +69,4 @@ class TestInsertBench(NebulaTestSuite): warmup=False ) def test_insert_edge(self, benchmark): - benchmark(self.insert_edge) \ No newline at end of file + benchmark(self.insert_edge) diff --git a/tests/bench/lookup.py b/tests/bench/lookup.py index 418fdc1a3392b6f5d1010c68a599f91770b0fdf3..fc6f766641e5cd6e80d0b0f93b2e36dedca6feb2 100644 --- a/tests/bench/lookup.py +++ b/tests/bench/lookup.py @@ -1,8 +1,8 @@ import time import pytest from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite -from bench.data_generate import insert_vertexs, insert_edges +from tests.common.nebula_test_suite import NebulaTestSuite +from tests.bench.data_generate import insert_vertexs, insert_edges class TestLookupBench(NebulaTestSuite): @@ -71,4 +71,4 @@ class TestLookupBench(NebulaTestSuite): warmup=False ) def test_lookup(self, benchmark): - benchmark(self.lookup) \ No newline at end of file + benchmark(self.lookup) diff --git a/tests/nebula_test_common/__init__.py b/tests/common/__init__.py similarity index 100% rename from tests/nebula_test_common/__init__.py rename to tests/common/__init__.py diff --git a/tests/common/nebula_manager.py b/tests/common/nebula_manager.py new file mode 100644 index 0000000000000000000000000000000000000000..416d1b6ba244c40b5388c9de53f24e1e227f71b5 --- /dev/null +++ b/tests/common/nebula_manager.py @@ -0,0 +1,117 @@ +# --coding:utf-8-- +# +# Copyright (c) 2020 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License, +# attached with Common Clause Condition 1.0, found in the LICENSES directory. + +import os +import random +import subprocess +import time +import shutil +import socket +import glob +import signal +from contextlib import closing + +NEBULA_START_COMMAND_FORMAT = "bin/nebula-{} --flagfile conf/nebula-{}.conf {}" + + +class NebulaManager(object): + def __init__(self, build_dir, src_dir): + self.build_dir = build_dir + self.src_dir = src_dir + self.work_dir = "/tmp/nebula-" + str( + random.randrange(1000000, 100000000)) + self.pids = {} + + def set_work_dir(self, work_dir): + self.work_dir = work_dir + + def _copy_nebula_conf(self): + graph_path = self.build_dir + '/bin' + graph_conf_path = self.src_dir + '/conf' + storage_path = self.src_dir + '/modules/storage/src/daemons/_build' + storage_conf_path = self.src_dir + '/modules/storage/conf' + + # graph + shutil.copy(graph_path + '/nebula-graphd', self.work_dir + '/bin/') + shutil.copy(graph_conf_path + '/nebula-graphd.conf.default', + self.work_dir + '/conf/nebula-graphd.conf') + # storage + shutil.copy(storage_path + '/nebula-storaged', self.work_dir + '/bin/') + shutil.copy(storage_conf_path + '/nebula-storaged.conf.default', + self.work_dir + '/conf/nebula-storaged.conf') + # meta + shutil.copy(storage_path + '/nebula-metad', self.work_dir + '/bin/') + shutil.copy(storage_conf_path + '/nebula-metad.conf.default', + self.work_dir + '/conf/nebula-metad.conf') + + def _format_nebula_command(self, name, meta_port, ports): + param_format = "--meta_server_addrs={} --port={} --ws_http_port={} --ws_h2_port={} -v=4" + param = param_format.format("127.0.0.1:" + str(meta_port), ports[0], + ports[1], ports[2]) + command = NEBULA_START_COMMAND_FORMAT.format(name, name, param) + return command + + def _find_free_port(self): + ports = [] + for i in range(0, 3): + with closing(socket.socket(socket.AF_INET, + socket.SOCK_STREAM)) as s: + s.bind(('', 0)) + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + ports.append(s.getsockname()[1]) + return ports + + def install(self): + os.mkdir(self.work_dir) + print("created work directory:" + self.work_dir) + os.chdir(self.work_dir) + installed_files = ['logs', 'bin', 'conf', 'data', 'pids', 'scripts'] + for f in installed_files: + os.mkdir(self.work_dir + '/' + f) + self._copy_nebula_conf() + + def start(self): + os.chdir(self.work_dir) + + metad_ports = self._find_free_port() + command = '' + graph_port = 0 + for server_name in ['metad', 'storaged', 'graphd']: + ports = [] + if server_name != 'metad': + ports = self._find_free_port() + else: + ports = metad_ports + command = self._format_nebula_command(server_name, metad_ports[0], + ports) + print("exec: " + command) + p = subprocess.Popen([command], shell=True, stdout=subprocess.PIPE) + p.wait() + if p.returncode != 0: + print("error: " + p.communicate()[0]) + else: + graph_port = ports[0] + + # wait nebula start + time.sleep(8) + for pf in glob.glob(self.work_dir + '/pids/*.pid'): + with open(pf) as f: + pid = int(f.readline()) + self.pids[f.name] = pid + + return graph_port + + def stop(self, cleanup): + print("try to stop nebula services...") + for p in self.pids: + try: + os.kill(self.pids[p], signal.SIGTERM) + except OSError as err: + print("nebula stop " + p + " failed: " + str(err)) + time.sleep(3) + if cleanup: + shutil.rmtree(self.work_dir) diff --git a/tests/nebula_test_common/nebula_test_suite.py b/tests/common/nebula_test_suite.py similarity index 97% rename from tests/nebula_test_common/nebula_test_suite.py rename to tests/common/nebula_test_suite.py index 8efce0c9f4aa4293a10df3c009d2168867cdf75d..fce6ed861036d46d21cba7b2ace099ccdc91002a 100644 --- a/tests/nebula_test_common/nebula_test_suite.py +++ b/tests/common/nebula_test_suite.py @@ -130,7 +130,7 @@ class NebulaTestSuite(object): @classmethod def teardown_class(self): - if self.client != None: + if self.client is not None: self.cleanup() self.drop_data() self.close_nebula_clients() @@ -144,12 +144,14 @@ class NebulaTestSuite(object): return self.client.execute_query(ngql) @classmethod - def prepare(self): - self.prepare() + def prepare(cls): + if hasattr(cls.prepare, 'is_overridden'): + cls.prepare() @classmethod - def cleanup(self): - self.cleanup() + def cleanup(cls): + if hasattr(cls.cleanup, 'is_overridden'): + cls.cleanup() @classmethod def check_resp_succeeded(self, resp): @@ -269,9 +271,9 @@ class NebulaTestSuite(object): @classmethod def check_column_names(self, resp, expect): for i in range(len(expect)): - ok = (expect[i] == bytes.decode(resp.data.column_names[i])) - assert ok, "different column name, expect: {} vs. result: {}".format( - expect[i], resp.data.column_names[i]) + result = bytes.decode(resp.data.column_names[i]) + ok = (expect[i] == result) + assert ok, "different column name, expect: {} vs. result: {}".format(expect[i], result) @classmethod def convert_expect(self, expect): diff --git a/tests/maintain/test_comments.py b/tests/maintain/test_comments.py index 4d3d6ac0b2469aba5aef67f66eab9e66e3b805d8..9c0194a9bd5ebbccfbd7b941f7575addfc2aa16c 100644 --- a/tests/maintain/test_comments.py +++ b/tests/maintain/test_comments.py @@ -5,7 +5,7 @@ # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestComment(NebulaTestSuite): diff --git a/tests/maintain/test_tag_edge.py b/tests/maintain/test_tag_edge.py index f92fdebc30633705f1d941834391150020919684..1df495001da129b9ab3f7e58d09df3225e859fb1 100644 --- a/tests/maintain/test_tag_edge.py +++ b/tests/maintain/test_tag_edge.py @@ -7,8 +7,8 @@ import time -from nebula_test_common.nebula_test_suite import NebulaTestSuite -from nebula_test_common.nebula_test_suite import T_EMPTY, T_NULL +from tests.common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import T_EMPTY, T_NULL class TestSchema(NebulaTestSuite): @@ -150,7 +150,7 @@ class TestSchema(NebulaTestSuite): 'CHANGE (age string), ' 'DROP (gender)') self.check_resp_succeeded(resp) - + # drop not exist prop resp = self.client.execute('ALTER TAG person DROP (gender)') self.check_resp_failed(resp) diff --git a/tests/mutate/test_delete_edges.py b/tests/mutate/test_delete_edges.py index 4660df553f6f1c201d373c533bed811301f909a6..61d9aeac0251abcb57d728fa9ce00c480695290e 100644 --- a/tests/mutate/test_delete_edges.py +++ b/tests/mutate/test_delete_edges.py @@ -8,7 +8,7 @@ import time import pytest -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestDeleteEdges(NebulaTestSuite): @@ -106,5 +106,3 @@ class TestDeleteEdges(NebulaTestSuite): self.check_resp_succeeded(resp) expect_result = [["Zhangsan", 50, "Jack"]] self.check_result(resp, expect_result) - - diff --git a/tests/mutate/test_delete_edges_2.py b/tests/mutate/test_delete_edges_2.py index 1ab2c9cf7a3538ec0da97504ad8bf265753bb6bc..18febf43fd52a3f43d4d2ce5f6c94286e1d1d784 100644 --- a/tests/mutate/test_delete_edges_2.py +++ b/tests/mutate/test_delete_edges_2.py @@ -8,7 +8,7 @@ import time import pytest -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestDeleteEdges2(NebulaTestSuite): diff --git a/tests/mutate/test_delete_vertices.py b/tests/mutate/test_delete_vertices.py index 4d2d9e0e46f3214fd1f1c32140cee42e9d5a8e5b..3f1f02e430a18e46351d4f5c1bcfcc357c59f9ae 100644 --- a/tests/mutate/test_delete_vertices.py +++ b/tests/mutate/test_delete_vertices.py @@ -8,7 +8,7 @@ import time import pytest -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestDeleteVertices(NebulaTestSuite): diff --git a/tests/mutate/test_delete_vertices_2.py b/tests/mutate/test_delete_vertices_2.py index f4b3d58eb37361f65f445fec44b0d7fb670c5b74..1ab5604210b518ccaccb8805e4a86800f87055a6 100644 --- a/tests/mutate/test_delete_vertices_2.py +++ b/tests/mutate/test_delete_vertices_2.py @@ -8,7 +8,7 @@ import time import pytest -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestDeleteVertices(NebulaTestSuite): diff --git a/tests/mutate/test_insert_1.py b/tests/mutate/test_insert_1.py index 5568bcb715652c9a6576adf90babc0f6aa1371d9..71f1b1dbb1101ab5a0df72a931a7b6cda0ca8892 100644 --- a/tests/mutate/test_insert_1.py +++ b/tests/mutate/test_insert_1.py @@ -8,7 +8,7 @@ import time import pytest -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestInsert1(NebulaTestSuite): @@ -556,4 +556,4 @@ class TestInsert1(NebulaTestSuite): self.check_resp_failed(resp) resp = self.execute('MATCH') - self.check_resp_failed(resp) \ No newline at end of file + self.check_resp_failed(resp) diff --git a/tests/mutate/test_insert_2.py b/tests/mutate/test_insert_2.py index 1ba5177219f06d1fae58dce46c97127dbc714e3e..5340e907ce38f7230818b98be44bfe3bbcbabf0c 100644 --- a/tests/mutate/test_insert_2.py +++ b/tests/mutate/test_insert_2.py @@ -8,7 +8,7 @@ import time import pytest -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestInsert2(NebulaTestSuite): diff --git a/tests/nebula-test-run.py b/tests/nebula-test-run.py index 920694e10d1cf23272bfb2b7da017ec43c7a00e2..af9974756f8ffa0cd60e13e52177aa5f7b196be6 100755 --- a/tests/nebula-test-run.py +++ b/tests/nebula-test-run.py @@ -9,33 +9,26 @@ import itertools import os import pytest -import sys, time +import sys import logging -import random -import shutil -import socket -from contextlib import closing -from _pytest.main import ExitCode from time import localtime, strftime from pathlib import Path -from distutils.dir_util import copy_tree -import subprocess from pathlib import Path -import glob -import signal - TEST_DIR = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, TEST_DIR) +NEBULA_HOME = TEST_DIR + '/../' +sys.path.insert(0, NEBULA_HOME) + +from tests.common.nebula_manager import NebulaManager TEST_LOGS_DIR = os.getenv('NEBULA_TEST_LOGS_DIR') if TEST_LOGS_DIR is None or TEST_LOGS_DIR == "": TEST_LOGS_DIR = os.environ['HOME'] -NEBULA_BUILD_DIR=os.getenv('NEBULA_BUILD_DIR') +NEBULA_BUILD_DIR = os.getenv('NEBULA_BUILD_DIR') if NEBULA_BUILD_DIR is None: NEBULA_BUILD_DIR = str(Path(TEST_DIR).parent) -NEBULA_SOURCE_DIR=os.getenv('NEBULA_SOURCE_DIR') +NEBULA_SOURCE_DIR = os.getenv('NEBULA_SOURCE_DIR') if NEBULA_SOURCE_DIR is None: NEBULA_SOURCE_DIR = str(Path(TEST_DIR).parent) @@ -43,24 +36,21 @@ NEBULA_DATA_DIR = os.getenv('NEBULA_DATA_DIR') if NEBULA_DATA_DIR is None or NEBULA_DATA_DIR == "": NEBULA_DATA_DIR = TEST_DIR + "/data" -NEBULA_START_COMMAND_FORMAT="bin/nebula-{} --flagfile conf/nebula-{}.conf {}" - RESULT_DIR = os.path.join(TEST_LOGS_DIR, 'results') -LOGGING_ARGS = { - '--html': 'TEST-nebula-{0}.html' -} +LOGGING_ARGS = {'--html': 'TEST-nebula-{0}.html'} LOG_FORMAT = "-- %(asctime)s %(levelname)-8s %(threadName)s: %(message)s" DOCKER_GRAPHD_DIGESTS = os.getenv('NEBULA_GRAPHD_DIGESTS') if DOCKER_GRAPHD_DIGESTS is None: - DOCKER_GRAPHD_DIGESTS = 0 + DOCKER_GRAPHD_DIGESTS = '0' DOCKER_METAD_DIGESTS = os.getenv('NEBULA_METAD_DIGESTS') if DOCKER_METAD_DIGESTS is None: - DOCKER_METAD_DIGESTS = 0 + DOCKER_METAD_DIGESTS = '0' DOCKER_STORAGED_DIGESTS = os.getenv('NEBULA_STORAGED_DIGESTS') if DOCKER_STORAGED_DIGESTS is None: - DOCKER_STORAGED_DIGESTS = 0 + DOCKER_STORAGED_DIGESTS = '0' + def configure_logging(): logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) @@ -113,8 +103,8 @@ class NebulaTestPlugin(object): default=1, help='the replica_factor of Nebula\'s space') parser.addoption('--data_dir', - dest='data_dir', - help='Data Preload Directory for Nebula') + dest='data_dir', + help='Data Preload Directory for Nebula') parser.addoption('--stop_nebula', dest='stop_nebula', @@ -153,8 +143,8 @@ class TestExecutor(object): plugin = NebulaTestPlugin() try: - pytest_exit_code = pytest.main(args, plugins=[plugin]) - except: + pytest.main(args, plugins=[plugin]) + except Exception: sys.stderr.write( "Unexpected exception with pytest {0}".format(args)) raise @@ -165,81 +155,6 @@ class TestExecutor(object): self.total_executed += len(plugin.tests_executed) -def find_free_port(): - ports = [] - for i in range(0, 3): - with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s: - s.bind(('', 0)) - s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - ports.append(s.getsockname()[1]) - return ports - -def copy_nebula_conf(nebula_test_dir): - shutil.copy(NEBULA_BUILD_DIR+'/bin/nebula-graphd', nebula_test_dir + '/bin/') - shutil.copy(NEBULA_SOURCE_DIR+'/modules/storage/src/daemons/_build/nebula-storaged', nebula_test_dir + '/bin/') - shutil.copy(NEBULA_SOURCE_DIR+'/modules/storage/src/daemons/_build/nebula-metad', nebula_test_dir + '/bin/') - shutil.copy(NEBULA_SOURCE_DIR+'/conf/nebula-graphd.conf.default', nebula_test_dir+'/conf/nebula-graphd.conf') - shutil.copy(NEBULA_SOURCE_DIR+'/modules/storage/conf/nebula-metad.conf.default', nebula_test_dir + '/conf/nebula-metad.conf') - shutil.copy(NEBULA_SOURCE_DIR+'/modules/storage/conf/nebula-storaged.conf.default', nebula_test_dir + '/conf/nebula-storaged.conf') - -def installNebula(): - test_dir = "/tmp/nebula-" + str(random.randrange(1000000, 100000000)) - os.mkdir(test_dir) - print("created directory:" + test_dir) - os.chdir(test_dir) - nebula_install_file = ['logs', 'bin', 'conf', 'data', 'pids', 'scripts'] - for f in nebula_install_file: - os.mkdir(test_dir+'/'+f) - copy_nebula_conf(test_dir) - return test_dir - -def formatNebulaCommand(name, meta_port, ports): - param_format = "--meta_server_addrs={} --port={} --ws_http_port={} --ws_h2_port={} -v=4" - param = param_format.format("127.0.0.1:" + str(meta_port), ports[0], ports[1], ports[2]) - command=NEBULA_START_COMMAND_FORMAT.format(name, name, param) - return command - -def startNebula(nebula_test_dir): - os.chdir(nebula_test_dir) - - pids = {} - metad_ports = find_free_port() - command = '' - graph_port = 0 - for server_name in ['metad', 'storaged', 'graphd']: - ports = [] - if server_name != 'metad': - ports = find_free_port() - else: - ports = metad_ports - command = formatNebulaCommand(server_name, metad_ports[0], ports) - print("exec: " + command) - p = subprocess.Popen([command], shell=True, stdout=subprocess.PIPE) - p.wait() - if p.returncode != 0: - print("error: " + p.communicate()[0]) - else: - graph_port = ports[0] - - #wait nebula start - time.sleep(8) - for pf in glob.glob(nebula_test_dir+'/pids/*.pid'): - with open(pf) as f: - pid = int(f.readline()) - pids[f.name] = pid - - return graph_port, pids - -def stopNebula(pids, test_dir): - print("try to stop nebula services...") - for p in pids: - try: - os.kill(pids[p], signal.SIGTERM) - except OSError as err: - print("nebula stop " + p + " failed: " + str(err)) - time.sleep(3) - if pytest.cmdline.rm_dir.lower() == 'true': - shutil.rmtree(test_dir) if __name__ == "__main__": # If the user is just asking for --help, just print the help test and then exit. @@ -247,9 +162,8 @@ if __name__ == "__main__": if '-h' in sys.argv[1:] or '--help' in sys.argv[1:]: executor.run_tests(sys.argv[1:]) sys.exit(0) + nebula_mgr = NebulaManager(NEBULA_BUILD_DIR, NEBULA_SOURCE_DIR) stop_nebula = True - pids = [] - test_dir = '' try: os.chdir(TEST_DIR) # Create the test result directory if it doesn't already exist. @@ -261,21 +175,22 @@ if __name__ == "__main__": current_time = strftime("%Y-%m-%d-%H:%M:%S", localtime()) args = [] for arg, log in LOGGING_ARGS.items(): - args.extend([arg, os.path.join(RESULT_DIR, log.format(current_time))]) + args.extend( + [arg, os.path.join(RESULT_DIR, log.format(current_time))]) args.extend(list(commandline_args)) if '--address' not in args: - test_dir = installNebula() - port,pids = startNebula(test_dir) - args.extend(['--address', '127.0.0.1:'+str(port)]) + nebula_mgr.install() + port = nebula_mgr.start() + args.extend(['--address', '127.0.0.1:' + str(port)]) else: stop_nebula = False print("Running TestExecutor with args: {} ".format(args)) executor.run_tests(args) finally: if stop_nebula and pytest.cmdline.stop_nebula.lower() == 'true': - stopNebula(pids, test_dir) + nebula_mgr.stop(pytest.cmdline.rm_dir.lower() == 'true') if executor.total_executed == 0: sys.exit(1) diff --git a/tests/query/bugs/fixed_bigint_2031.py b/tests/query/bugs/fixed_bigint_2031.py index 56c4fce7f96c3e8208d37f8a4bccae872abf70c0..db42ce286115e7f049310361ee3d31978d9d49fa 100644 --- a/tests/query/bugs/fixed_bigint_2031.py +++ b/tests/query/bugs/fixed_bigint_2031.py @@ -11,7 +11,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestBigInt(NebulaTestSuite): @classmethod @@ -47,4 +47,3 @@ class TestBigInt(NebulaTestSuite): def cleanup(self): resp = self.execute('drop space BigInt2031') self.check_resp_succeeded(resp) - diff --git a/tests/query/bugs/fixed_delete_vertex_1996.py b/tests/query/bugs/fixed_delete_vertex_1996.py index 3ff17c12600920dd731276d7cd1179e9001ee12a..7ec9fb1b5e28f0baf9142b3d0158164ebe579d67 100644 --- a/tests/query/bugs/fixed_delete_vertex_1996.py +++ b/tests/query/bugs/fixed_delete_vertex_1996.py @@ -11,7 +11,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestSimpleQuery(NebulaTestSuite): @classmethod @@ -29,7 +29,7 @@ class TestSimpleQuery(NebulaTestSuite): self.check_resp_succeeded(resp) def test_issue1996(self): - time.sleep(self.delay) + time.sleep(self.delay) resp = self.execute('INSERT VERTEX person(name, age) VALUES 101:("Tony Parker", 36)') self.check_resp_succeeded(resp) resp = self.execute('DELETE VERTEX 101') diff --git a/tests/query/bugs/fixed_issue2020.py b/tests/query/bugs/fixed_issue2020.py index d1cf00fccf4bd50a1851bf3f43933538f662c72a..99acea8db319907119aa2ecc3127d90b7ce8f728 100644 --- a/tests/query/bugs/fixed_issue2020.py +++ b/tests/query/bugs/fixed_issue2020.py @@ -9,7 +9,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestSimpleQuery(NebulaTestSuite): @classmethod @@ -31,11 +31,11 @@ class TestSimpleQuery(NebulaTestSuite): self.check_resp_succeeded(resp) time.sleep(self.delay) - + resp = self.execute('INSERT VERTEX person(name) VALUES hash("Laura"):("Laura");' 'INSERT VERTEX person(name) VALUES hash("Lucy"):("Lucy")') self.check_resp_succeeded(resp) - + resp = self.execute('INSERT EDGE relation() VALUES hash("Laura")->hash("Lucy"):();') self.check_resp_succeeded(resp) diff --git a/tests/query/bugs/fixed_negative_ttl.py b/tests/query/bugs/fixed_negative_ttl.py index 78a2719a19d2136ddeea842a97b9fae3c4b0e1e1..2ede44d38cfb0f3436a3bc8c571686b29249aace 100644 --- a/tests/query/bugs/fixed_negative_ttl.py +++ b/tests/query/bugs/fixed_negative_ttl.py @@ -11,7 +11,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestNegativeTTL(NebulaTestSuite): @classmethod @@ -55,4 +55,3 @@ class TestNegativeTTL(NebulaTestSuite): def cleanup(self): resp = self.execute('drop space NegativeTTL') self.check_resp_succeeded(resp) - diff --git a/tests/query/bugs/fixed_over_all_pr1962.py b/tests/query/bugs/fixed_over_all_pr1962.py index 3e367f0cbfb8efc93347399d1a2b27092e135f9f..0ea76ce8db37cf038295868b7d1912e053e8d088 100644 --- a/tests/query/bugs/fixed_over_all_pr1962.py +++ b/tests/query/bugs/fixed_over_all_pr1962.py @@ -11,7 +11,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestSimpleQuery(NebulaTestSuite): @classmethod @@ -34,7 +34,7 @@ class TestSimpleQuery(NebulaTestSuite): self.check_resp_succeeded(resp) def test_over_all(self): - time.sleep(self.delay) + time.sleep(self.delay) resp = self.execute( 'INSERT VERTEX person(name, age) VALUES 1:(\'Bob\', 10)') self.check_resp_succeeded(resp) diff --git a/tests/query/bugs/fixed_pr2042.py b/tests/query/bugs/fixed_pr2042.py index 3ec92f74d0b53f9d8b2d9d2bdf5d85a403829178..a6b342a2d87344f24cf5edf683b4c3271c918ccd 100644 --- a/tests/query/bugs/fixed_pr2042.py +++ b/tests/query/bugs/fixed_pr2042.py @@ -9,7 +9,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestSimpleQuery(NebulaTestSuite): @classmethod diff --git a/tests/query/bugs/fixed_update_issue1827.py b/tests/query/bugs/fixed_update_issue1827.py index d97333af983803605a4b64d536f8307085cb312b..051e50a6a0c2ca2ce62f2a3bca3fcdc92e8e58a6 100644 --- a/tests/query/bugs/fixed_update_issue1827.py +++ b/tests/query/bugs/fixed_update_issue1827.py @@ -4,7 +4,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestBugUpdate(NebulaTestSuite): @classmethod @@ -47,4 +47,4 @@ class TestBugUpdate(NebulaTestSuite): @classmethod def cleanup(self): resp = self.execute('drop space issue1827_update') - self.check_resp_succeeded(resp) \ No newline at end of file + self.check_resp_succeeded(resp) diff --git a/tests/query/bugs/remove_unreasonable_error_message_pr1983.py b/tests/query/bugs/remove_unreasonable_error_message_pr1983.py index b634cef15e4abe3b7452df39eee1e5b0df27e183..d18bd5e1ec52b41c1d2492b0e5361b72b381381c 100644 --- a/tests/query/bugs/remove_unreasonable_error_message_pr1983.py +++ b/tests/query/bugs/remove_unreasonable_error_message_pr1983.py @@ -11,7 +11,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestPR1983(NebulaTestSuite): @classmethod @@ -29,7 +29,7 @@ class TestPR1983(NebulaTestSuite): self.check_resp_succeeded(resp) def test_unreasonable_error_message(self): - time.sleep(self.delay) + time.sleep(self.delay) resp = self.execute( 'INSERT VERTEX person(name, age) VALUES 1:(\'Bob\', 10)') self.check_resp_succeeded(resp) diff --git a/tests/query/bugs/test_fixed_issue1888.py b/tests/query/bugs/test_fixed_issue1888.py index 40f569b4718c15e115d3413388895930707d3f2d..96b50dc5d94661f00bf941fcbbf426c0d0952e0f 100644 --- a/tests/query/bugs/test_fixed_issue1888.py +++ b/tests/query/bugs/test_fixed_issue1888.py @@ -6,7 +6,7 @@ import pytest from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite @pytest.mark.parametrize('sentence', ['UPDATE', 'UPSERT']) class TestBugUpdateFilterOut(NebulaTestSuite): diff --git a/tests/query/bugs/test_fixed_issue1987.py b/tests/query/bugs/test_fixed_issue1987.py index 2571f2e6cfcb7899e5a07d80deaa07cb345e5721..3fb35f490ea316f1c0b3d5bf334353b2ac6d637e 100644 --- a/tests/query/bugs/test_fixed_issue1987.py +++ b/tests/query/bugs/test_fixed_issue1987.py @@ -6,7 +6,7 @@ import pytest from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite @pytest.mark.parametrize('schema', [('TAG', 'VERTEX', '233'), ('EDGE', 'EDGE', '233->2333')]) diff --git a/tests/query/bugs/test_fixed_issue2009.py b/tests/query/bugs/test_fixed_issue2009.py index 74c7c4b8419eea52470c52a909d814788b021396..f107227fe9dfc4c321a76bc519b98076b7d97022 100644 --- a/tests/query/bugs/test_fixed_issue2009.py +++ b/tests/query/bugs/test_fixed_issue2009.py @@ -6,7 +6,7 @@ import pytest from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestBugUpdateFilterOut(NebulaTestSuite): diff --git a/tests/query/bugs/test_query_after_schema_altered_issue1185_1154_pr1606.py b/tests/query/bugs/test_query_after_schema_altered_issue1185_1154_pr1606.py index 7d7beb4c33698534304a0a643f9bc16eccc91e79..264ba0337008a6b37c713ed15b879905296c4952 100644 --- a/tests/query/bugs/test_query_after_schema_altered_issue1185_1154_pr1606.py +++ b/tests/query/bugs/test_query_after_schema_altered_issue1185_1154_pr1606.py @@ -7,7 +7,7 @@ import time -from query.stateless.prepare_data import PrepareData +from tests.query.stateless.prepare_data import PrepareData class TestQuery(PrepareData): @@ -153,4 +153,3 @@ class TestQuery(PrepareData): ['Sandy', 4], ['Lynn', 5], ['Bonnie', 5], ['Peter', 5], ['XiaMei', 6]] print(cmd) self.check_resp_succeeded(resp) - diff --git a/tests/query/bugs/test_query_after_schema_rebuilt_issue1843.py b/tests/query/bugs/test_query_after_schema_rebuilt_issue1843.py index 80b63c3fa75868a096a07f983f354ef7ca34dccf..6301c82d560ef7df00a458ffde57c5167671c2bf 100644 --- a/tests/query/bugs/test_query_after_schema_rebuilt_issue1843.py +++ b/tests/query/bugs/test_query_after_schema_rebuilt_issue1843.py @@ -7,7 +7,7 @@ import time -from query.stateless.prepare_data import PrepareData +from tests.query.stateless.prepare_data import PrepareData class TestQuery(PrepareData): diff --git a/tests/query/stateless/prepare_data.py b/tests/query/stateless/prepare_data.py index 23bd67310fc034d22b05de2652be5e4c54e0a222..5f47ccb2d6234c64c94fc8491b1ff5e74e27e2c2 100644 --- a/tests/query/stateless/prepare_data.py +++ b/tests/query/stateless/prepare_data.py @@ -11,7 +11,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class PrepareData(NebulaTestSuite): diff --git a/tests/query/stateless/test_admin.py b/tests/query/stateless/test_admin.py index 5ba15182184a88bb48960252cc8c0faf27f058cf..28834b56bed5ee6eab55a2f47514a3b2d3ae494b 100644 --- a/tests/query/stateless/test_admin.py +++ b/tests/query/stateless/test_admin.py @@ -7,7 +7,7 @@ import time -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestAdmin(NebulaTestSuite): diff --git a/tests/query/stateless/test_fetch.py b/tests/query/stateless/test_fetch.py index 5b2f3b39167806a043cacb963d825f8f993310ad..6cf1cc5574b53cf67cb2a2622091f933630d36e6 100644 --- a/tests/query/stateless/test_fetch.py +++ b/tests/query/stateless/test_fetch.py @@ -5,7 +5,7 @@ # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -from query.stateless.prepare_data import PrepareData +from tests.query.stateless.prepare_data import PrepareData class TestFetchQuery(PrepareData): diff --git a/tests/query/stateless/test_findpath.py b/tests/query/stateless/test_findpath.py index e732ea9776d5a1335e0ae27ffe0aa61bf0504caa..345b0600ebd67e63ed5bd36582e0704558481b60 100644 --- a/tests/query/stateless/test_findpath.py +++ b/tests/query/stateless/test_findpath.py @@ -5,7 +5,7 @@ # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -from query.stateless.prepare_data import PrepareData +from tests.query.stateless.prepare_data import PrepareData class TestFindPathQuery(PrepareData): diff --git a/tests/query/stateless/test_go.py b/tests/query/stateless/test_go.py index cddb41a4af08937525be194905b33dfd5187cb1d..076bfb01060e0c055d4b14456ddc8b40f1ee50df 100644 --- a/tests/query/stateless/test_go.py +++ b/tests/query/stateless/test_go.py @@ -6,7 +6,7 @@ # attached with Common Clause Condition 1.0, found in the LICENSES directory. import pytest -from query.stateless.prepare_data import PrepareData +from tests.query.stateless.prepare_data import PrepareData class TestGoQuery(PrepareData): @@ -224,7 +224,3 @@ class TestGoQuery(PrepareData): expect_result = [['male', 1], ['female', 3]] self.check_resp_succeeded(resp) self.check_out_of_order_result(resp, expect_result) - - - - diff --git a/tests/query/stateless/test_groupby.py b/tests/query/stateless/test_groupby.py index ea2f78de16ca0f92fe1f92b0ac0b9cde80b7aa8c..81502d02080909f267471bf2f4ea760aaad46674 100644 --- a/tests/query/stateless/test_groupby.py +++ b/tests/query/stateless/test_groupby.py @@ -5,7 +5,7 @@ # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -from query.stateless.prepare_data import PrepareData +from tests.query.stateless.prepare_data import PrepareData class TestGroupby(PrepareData): diff --git a/tests/query/stateless/test_if_exists.py b/tests/query/stateless/test_if_exists.py index 8dca6607233787ce7623f01a87bd92fecd4c43b8..9d6e52509747a15b77bb1aa522350630e906093e 100644 --- a/tests/query/stateless/test_if_exists.py +++ b/tests/query/stateless/test_if_exists.py @@ -13,7 +13,7 @@ import time from graph import ttypes import nebula.Client -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestDropSpaceIfExists(NebulaTestSuite): @classmethod @@ -95,4 +95,4 @@ class TestDropSpaceIfExists(NebulaTestSuite): @classmethod def cleanup(self): - print("Nothing to cleanup") \ No newline at end of file + print("Nothing to cleanup") diff --git a/tests/query/stateless/test_index.py b/tests/query/stateless/test_index.py index f8524deac60b42860160bd8a7ef88615737086db..702fb5e3640fb24eba472eb5450857ed3e181aec 100644 --- a/tests/query/stateless/test_index.py +++ b/tests/query/stateless/test_index.py @@ -6,7 +6,7 @@ # attached with Common Clause Condition 1.0, found in the LICENSES directory. import time -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestIndex(NebulaTestSuite): @classmethod diff --git a/tests/query/stateless/test_keyword.py b/tests/query/stateless/test_keyword.py index 0f9b0d8bb3aa963067b1daa4f6ca1f36fdc5a09c..a06017c460c848c4e9f3e9c74cd98ba14d518c63 100644 --- a/tests/query/stateless/test_keyword.py +++ b/tests/query/stateless/test_keyword.py @@ -13,7 +13,7 @@ import time from graph import ttypes import nebula.Client -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestReservedKeyword(NebulaTestSuite): @classmethod @@ -921,14 +921,14 @@ class TestReservedKeyword(NebulaTestSuite): self.check_resp_succeeded(resp) except Exception as e: assert "SyntaxError: syntax error" in str(e) - + try: cmd = 'create EDGE `EDGE` (`EDGE` string)' resp = self.execute_query(cmd) self.check_resp_succeeded(resp) except Exception as e: assert "SyntaxError: syntax error" in str(e) - + resp = self.execute('drop space test') self.check_resp_succeeded(resp) diff --git a/tests/query/stateless/test_lookup.py b/tests/query/stateless/test_lookup.py index 71202d94596c9478817b6aefc8d44186e202093c..f1a112a18b1f6b6e27f90a69eab08ee031e3e3e5 100644 --- a/tests/query/stateless/test_lookup.py +++ b/tests/query/stateless/test_lookup.py @@ -6,7 +6,7 @@ # attached with Common Clause Condition 1.0, found in the LICENSES directory. import time -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestIndex(NebulaTestSuite): @classmethod diff --git a/tests/query/stateless/test_match_find.py b/tests/query/stateless/test_match_find.py index 5ce15936d17b007dd658d67874399b60cffc229e..ba6fb384044120fb46dc135569b99db8c3cc6193 100644 --- a/tests/query/stateless/test_match_find.py +++ b/tests/query/stateless/test_match_find.py @@ -11,7 +11,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestFindAndMatch(NebulaTestSuite): diff --git a/tests/query/stateless/test_query_reversely.py b/tests/query/stateless/test_query_reversely.py index b2528a97a3726697c1a8f27a8373c025dd020fe1..e01560942d770f153b4bca34a6c83eed5363db8a 100644 --- a/tests/query/stateless/test_query_reversely.py +++ b/tests/query/stateless/test_query_reversely.py @@ -11,7 +11,7 @@ import time from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestQueryReversely(NebulaTestSuite): diff --git a/tests/query/stateless/test_range.py b/tests/query/stateless/test_range.py index 9ca1ff7f323d4197f5154bc3baf0bef128e10f05..117104049142e11cb10f20c5e7a955c855c010af 100644 --- a/tests/query/stateless/test_range.py +++ b/tests/query/stateless/test_range.py @@ -15,7 +15,7 @@ import pytest from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestRangeChecking(NebulaTestSuite): @classmethod diff --git a/tests/query/stateless/test_schema.py b/tests/query/stateless/test_schema.py index 6221a89e622e2a78654ef0f96f0ca9d42e74f620..cb555e9f84a32bb28c3f36959eacde4af6ef26e6 100644 --- a/tests/query/stateless/test_schema.py +++ b/tests/query/stateless/test_schema.py @@ -9,8 +9,8 @@ import re import sys import time -from nebula_test_common.nebula_test_suite import NebulaTestSuite -from nebula_test_common.nebula_test_suite import T_EMPTY, T_NULL +from tests.common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import T_EMPTY, T_NULL class TestSchema(NebulaTestSuite): diff --git a/tests/query/stateless/test_set.py b/tests/query/stateless/test_set.py index 29c2c7518342cbcde276704f0165d010c8584166..7120335577c7ce303982b6ec5ad06340403874c2 100644 --- a/tests/query/stateless/test_set.py +++ b/tests/query/stateless/test_set.py @@ -5,7 +5,7 @@ # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -from query.stateless.prepare_data import PrepareData +from tests.query.stateless.prepare_data import PrepareData class TestSetQuery(PrepareData): diff --git a/tests/query/stateless/test_simple_query.py b/tests/query/stateless/test_simple_query.py index e6b6361b700a2c20dc822b261826dd2430b9b4c6..48c4582d6dfa7435922add80e5bfd89f1211b68d 100644 --- a/tests/query/stateless/test_simple_query.py +++ b/tests/query/stateless/test_simple_query.py @@ -12,7 +12,7 @@ import pytest from graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestSimpleQuery(NebulaTestSuite): diff --git a/tests/query/stateless/test_update.py b/tests/query/stateless/test_update.py index 783a2651c529ffa609d65753551ec802845f28e5..a35c4d2e9e780eb74a802d1f949de8124007237c 100644 --- a/tests/query/stateless/test_update.py +++ b/tests/query/stateless/test_update.py @@ -7,7 +7,7 @@ import time -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestUpdate(NebulaTestSuite): @@ -286,5 +286,3 @@ class TestUpdate(NebulaTestSuite): def cleanup(self): resp = self.execute('drop space update_space') self.check_resp_succeeded(resp) - - diff --git a/tests/query/stateless/test_where.py b/tests/query/stateless/test_where.py index 0fb5e53ae6a01f6dcff064e94ccc85336cb49523..12a2b85c97a9f8ab57597170aec670164b0c003b 100644 --- a/tests/query/stateless/test_where.py +++ b/tests/query/stateless/test_where.py @@ -6,7 +6,7 @@ # attached with Common Clause Condition 1.0, found in the LICENSES directory. import time -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestWhere(NebulaTestSuite): @classmethod diff --git a/tests/query/stateless/test_yield.py b/tests/query/stateless/test_yield.py index 182dad7dc407a4e5dfbd8b4babdeaf1faa5c194f..9e85c781e9cb84103094ee5cdeba32795a4044b1 100644 --- a/tests/query/stateless/test_yield.py +++ b/tests/query/stateless/test_yield.py @@ -6,7 +6,7 @@ # attached with Common Clause Condition 1.0, found in the LICENSES directory. import time -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestYield(NebulaTestSuite): @classmethod @@ -182,4 +182,4 @@ class TestYield(NebulaTestSuite): cmd = 'yield (timestamp)(now())' resp = self.execute_query(cmd) - self.check_resp_succeeded(resp) \ No newline at end of file + self.check_resp_succeeded(resp) diff --git a/tests/query/v1/test_explain.py b/tests/query/v1/test_explain.py index 1be6b126954d79d3d3ef5672e0cc0bf8c184beba..9eea48a30b2970e76861181554f8871b673a660f 100644 --- a/tests/query/v1/test_explain.py +++ b/tests/query/v1/test_explain.py @@ -8,26 +8,26 @@ import time import pytest from nebula2.graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestExplain(NebulaTestSuite): @classmethod def prepare(cls): # cls.load_data() - resp = cls.execute( - 'CREATE SPACE IF NOT EXISTS mySpace(partition_num=1, vid_size=20)') + resp = cls.execute('CREATE SPACE IF NOT EXISTS explain_test') cls.check_resp_succeeded(resp) # 2.0 use space get from cache time.sleep(cls.delay) - resp = cls.execute('USE mySpace') + resp = cls.execute('USE explain_test') cls.check_resp_succeeded(resp) @classmethod def cleanup(cls): - pass + resp = cls.execute('DROP SPACE IF EXISTS explain_test') + cls.check_resp_succeeded(resp) def test_explain(self): query = 'EXPLAIN YIELD 1 AS id;' diff --git a/tests/query/v1/test_fetch_empty.py b/tests/query/v1/test_fetch_empty.py index f9a43440249ada56d10b2a14b54395d5c7f8d343..68e1f667b713a25cfa8fc6736525bb6756d7ac2c 100644 --- a/tests/query/v1/test_fetch_empty.py +++ b/tests/query/v1/test_fetch_empty.py @@ -8,7 +8,7 @@ import time import pytest -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestFetchEmptyVertices(NebulaTestSuite): diff --git a/tests/query/v1/test_set.py b/tests/query/v1/test_set.py index 55f78edae56e2b65cdb3c0456eee33b594f748ef..942710896223d3cd55b786eaccbd249029f83d53 100644 --- a/tests/query/v1/test_set.py +++ b/tests/query/v1/test_set.py @@ -8,7 +8,7 @@ import pytest from nebula2.graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestSetQuery(NebulaTestSuite): @@ -16,22 +16,18 @@ class TestSetQuery(NebulaTestSuite): def prepare(self): self.load_data() - @classmethod - def cleanup(cls): - pass - @pytest.mark.skip(reason="") def test_union_all(self): stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ UNION ALL GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' resp = self.execute_query(stmt) self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"], + column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] self.check_column_names(resp, column_names) expected_data = [["Tim Duncan", 1997, "Spurs"], ["Tony Parker", 1999, "Spurs"], ["Tony Parker", 2018, "Hornets"]] - self.check_result(resp, expected_data) + self.check_out_of_order_result(resp, expected_data) stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ UNION ALL GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ @@ -44,7 +40,7 @@ class TestSetQuery(NebulaTestSuite): ["Tony Parker", 1999, "Spurs"], ["Tony Parker", 2018, "Hornets"], ["Manu Ginobili", 2002, "Spurs"]] - self.check_result(resp, expected_data) + self.check_out_of_order_result(resp, expected_data) stmt = '''(GO FROM "Tim Duncan" OVER like YIELD like._dst AS id | \ GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name) \ @@ -58,7 +54,7 @@ class TestSetQuery(NebulaTestSuite): ["Tony Parker", 2018, "Hornets"], ["Tony Parker", 1999, "Spurs"], ["Tony Parker", 2018, "Hornets"]] - self.check_result(resp, expected_data) + self.check_out_of_order_result(resp, expected_data) stmt = '''GO FROM "Tim Duncan" OVER like YIELD like._dst AS id | \ GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ @@ -72,7 +68,7 @@ class TestSetQuery(NebulaTestSuite): ["Tony Parker", 2018, "Hornets"], ["Tony Parker", 1999, "Spurs"], ["Tony Parker", 2018, "Hornets"]] - self.check_result(resp, expected_data) + self.check_out_of_order_result(resp, expected_data) stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ UNION ALL (GO FROM "Tony Parker" OVER like YIELD like._dst AS id | \ @@ -86,7 +82,7 @@ class TestSetQuery(NebulaTestSuite): ["LaMarcus Aldridge", 2006, "Trail Blazers"], ["Manu Ginobili", 2002, "Spurs"], ["Tim Duncan", 1997, "Spurs"]] - self.check_result(resp, expected_data) + self.check_out_of_order_result(resp, expected_data) stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ UNION ALL GO FROM "Tony Parker" OVER like YIELD like._dst AS id | \ @@ -100,7 +96,7 @@ class TestSetQuery(NebulaTestSuite): ["LaMarcus Aldridge", 2006, "Trail Blazers"], ["Manu Ginobili", 2002, "Spurs"], ["Tim Duncan", 1997, "Spurs"]] - self.check_result(resp, expected_data) + self.check_out_of_order_result(resp, expected_data) stmt = '''(GO FROM "Tim Duncan" OVER like YIELD like._dst AS id \ UNION ALL GO FROM "Tony Parker" OVER like YIELD like._dst AS id) \ @@ -116,7 +112,7 @@ class TestSetQuery(NebulaTestSuite): ["LaMarcus Aldridge", 2006, "Trail Blazers"], ["Manu Ginobili", 2002, "Spurs"], ["Tim Duncan", 1997, "Spurs"]] - self.check_result(resp, expected_data) + self.check_out_of_order_result(resp, expected_data) stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name as name, $$.team.name as player \ UNION ALL \ @@ -128,7 +124,7 @@ class TestSetQuery(NebulaTestSuite): self.check_column_names(resp, column_names) expected_data = [["Tim Duncan", "Spurs"], ["Tony Parker", "1999"], ["Tony Parker", "2018"]] - self.check_result(resp, expected_data) + self.check_out_of_order_result(resp, expected_data) stmt = '''GO FROM "Nobody" OVER serve YIELD $^.player.name AS player, serve.start_year AS start \ UNION ALL \ @@ -138,7 +134,7 @@ class TestSetQuery(NebulaTestSuite): column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] self.check_column_names(resp, column_names) expected_data = [["Tony Parker", 1999], ["Tony Parker", 2018]] - self.check_result(resp, expected_data) + self.check_out_of_order_result(resp, expected_data) @pytest.mark.skip(reason="") def test_union_distinct(self): diff --git a/tests/query/v1/test_yield.py b/tests/query/v1/test_yield.py index 8ecbc2f76cb01c81dc6257c95cd29070f6bccfcd..1155938e6e190661fe5a289208d0800f9a5e5c58 100644 --- a/tests/query/v1/test_yield.py +++ b/tests/query/v1/test_yield.py @@ -10,7 +10,7 @@ import time import pytest from nebula2.graph import ttypes -from nebula_test_common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite class TestYield(NebulaTestSuite): @@ -18,10 +18,6 @@ class TestYield(NebulaTestSuite): def prepare(self): self.load_data() - @classmethod - def cleanup(cls): - pass - @pytest.mark.skip(reason="") def test_base(self): query = 'YIELD 1' @@ -34,8 +30,7 @@ class TestYield(NebulaTestSuite): resp = self.execute_query(query) self.check_resp_succeeded(resp) columns = [ - "(1+1)", "1+1", "(int)3.140000000000000", "(string)(1+1)", - "(string)true" + "(1+1)", "1+1", "(INT)3.14", "(STRING)(1+1)", "(STRING)true" ] self.check_column_names(resp, columns) expect_result = [[2, "1+1", 3, "2", "true"]] @@ -70,7 +65,7 @@ class TestYield(NebulaTestSuite): query = 'YIELD hash(123 + 456)' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["hash((123 + 456))"] + columns = ["hash((123+456))"] self.check_column_names(resp, columns) expect_result = [[579]] self.check_result(resp, expect_result) @@ -78,21 +73,47 @@ class TestYield(NebulaTestSuite): query = 'YIELD hash(123.0)' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["hash(123.000000000000000)"] - self.check_column_names(resp, columns) + columns = ["hash(123.0)"] + # self.check_column_names(resp, columns) expect_result = [[-2256853663865737834]] self.check_result(resp, expect_result) - query = 'YIELD hash(!0)' + # query = 'YIELD hash(!0)' + # resp = self.execute_query(query) + # self.check_resp_succeeded(resp) + # columns = ["hash(!(0))"] + # self.check_column_names(resp, columns) + # expect_result = [[1]] + # self.check_result(resp, expect_result) + + @pytest.mark.skip(reason="") + def test_logic(self): + query = 'YIELD NOT FALSE || FALSE AND FALSE XOR FALSE' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["hash(!(0))"] + columns = ["((!(false)||(false&&false))^false)"] self.check_column_names(resp, columns) - expect_result = [[1]] + expect_result = [[True]] + self.check_result(resp, expect_result) + + query = 'YIELD !false OR false && false XOR true' + resp = self.execute_query(query) + self.check_resp_succeeded(resp) + columns = ["((!(false)||(false&&false))^true)"] + self.check_column_names(resp, columns) + expect_result = [[False]] + self.check_result(resp, expect_result) + + query = 'YIELD (NOT false || false) AND false XOR true' + resp = self.execute_query(query) + self.check_resp_succeeded(resp) + columns = ["(((!(false)||false)&&false)^true)"] + self.check_column_names(resp, columns) + expect_result = [[True]] self.check_result(resp, expect_result) @pytest.mark.skip(reason="") - def test_logic(self): + def test_logic_2(self): query = 'YIELD NOT 0 || 0 AND 0 XOR 0' resp = self.execute_query(query) self.check_resp_succeeded(resp) @@ -153,7 +174,7 @@ class TestYield(NebulaTestSuite): columns = ["$-.team"] self.check_column_names(resp, columns) expect_result = [["Suns"], ["Hawks"], ["Spurs"], ["Hornets"], ["Jazz"]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) query = '''GO FROM "Boris Diaw" OVER serve \ YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team \ @@ -163,7 +184,7 @@ class TestYield(NebulaTestSuite): columns = ["$-.team"] self.check_column_names(resp, columns) expect_result = [["Suns"], ["Hawks"], ["Spurs"], ["Hornets"], ["Jazz"]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) query = '''GO FROM "Boris Diaw" OVER serve \ YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team \ @@ -173,7 +194,7 @@ class TestYield(NebulaTestSuite): columns = ["$-.team"] self.check_column_names(resp, columns) expect_result = [["Spurs"], ["Hornets"], ["Jazz"]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) query = '''GO FROM "Boris Diaw" OVER serve \ YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team \ @@ -187,7 +208,7 @@ class TestYield(NebulaTestSuite): ["Boris Diaw", 2012, "Spurs"], ["Boris Diaw", 2008, "Hornets"], ["Boris Diaw", 2016, "Jazz"]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) query = '''GO FROM "Boris Diaw" OVER serve \ YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team \ @@ -199,7 +220,7 @@ class TestYield(NebulaTestSuite): expect_result = [["Boris Diaw", 2012, "Spurs"], ["Boris Diaw", 2008, "Hornets"], ["Boris Diaw", 2016, "Jazz"]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) query = '''GO FROM "Boris Diaw" OVER serve \ YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team \ @@ -211,7 +232,7 @@ class TestYield(NebulaTestSuite): expect_result = [["Boris Diaw", 2012, "Spurs", 123], ["Boris Diaw", 2008, "Hornets", 123], ["Boris Diaw", 2016, "Jazz", 123]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) @pytest.mark.skip(reason="") def test_yield_var(self): @@ -223,7 +244,7 @@ class TestYield(NebulaTestSuite): columns = ["$var.team"] self.check_column_names(resp, columns) expect_result = [["Suns"], ["Hawks"], ["Spurs"], ["Hornets"], ["Jazz"]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) query = '''$var = GO FROM "Boris Diaw" OVER serve \ YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team; \ @@ -233,7 +254,7 @@ class TestYield(NebulaTestSuite): columns = ["$var.team"] self.check_column_names(resp, columns) expect_result = [["Suns"], ["Hawks"], ["Spurs"], ["Hornets"], ["Jazz"]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) query = '''$var = GO FROM "Boris Diaw" OVER serve \ YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team; \ @@ -243,7 +264,7 @@ class TestYield(NebulaTestSuite): columns = ["$var.team"] self.check_column_names(resp, columns) expect_result = [["Spurs"], ["Hornets"], ["Jazz"]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) query = '''$var = GO FROM "Boris Diaw" OVER serve \ YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team; \ @@ -257,7 +278,7 @@ class TestYield(NebulaTestSuite): ["Boris Diaw", 2012, "Spurs"], ["Boris Diaw", 2008, "Hornets"], ["Boris Diaw", 2016, "Jazz"]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) query = '''$var = GO FROM "Boris Diaw" OVER serve \ YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team; \ @@ -269,7 +290,7 @@ class TestYield(NebulaTestSuite): expect_result = [["Boris Diaw", 2012, "Spurs"], ["Boris Diaw", 2008, "Hornets"], ["Boris Diaw", 2016, "Jazz"]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) query = '''$var = GO FROM "Boris Diaw" OVER serve \ YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team; \ @@ -281,7 +302,7 @@ class TestYield(NebulaTestSuite): expect_result = [["Boris Diaw", 2012, "Spurs", 123], ["Boris Diaw", 2008, "Hornets", 123], ["Boris Diaw", 2016, "Jazz", 123]] - self.check_result(resp, expect_result) + self.check_out_of_order_result(resp, expect_result) @pytest.mark.skip(reason="") def test_error(self): @@ -292,36 +313,36 @@ class TestYield(NebulaTestSuite): query = '''$var = GO FROM "Boris Diaw" OVER serve YIELD $^.player.name AS name, serve.start_year AS start, $$.team.name AS team; \ YIELD $var.team WHERE $-.start > 2005''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SYNTAX_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) query = '''$var = GO FROM "Boris Diaw" OVER serve YIELD $^.player.name AS name, serve.start_year AS start, $$.team.name AS team; \ YIELD $var.team WHERE $var1.start > 2005''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SYNTAX_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) query = '''$var = GO FROM "Boris Diaw" OVER serve YIELD $^.player.name AS name, serve.start_year AS start, $$.team.name AS team; \ YIELD $var.abc''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SYNTAX_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) query = '''$var = GO FROM "Boris Diaw" OVER serve YIELD $^.player.name AS name, serve.start_year AS start, $$.team.name AS team; \ YIELD $$.a.team''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SYNTAX_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) query = '''$var = GO FROM "Boris Diaw" OVER serve YIELD $^.player.name AS name, serve.start_year AS start, $$.team.name AS team; \ YIELD $^.a.team''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SYNTAX_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) query = '''$var = GO FROM "Boris Diaw" OVER serve YIELD $^.player.name AS name, serve.start_year AS start, $$.team.name AS team; \ YIELD a.team''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SYNTAX_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) query = '''GO FROM "Boris Diaw" OVER like | YIELD $-.abc;''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SYNTAX_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) @pytest.mark.skip(reason="") def test_calculate_overflow(self): @@ -385,18 +406,26 @@ class TestYield(NebulaTestSuite): query = '''YIELD -9223372036854775809''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SYNTAX_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) @pytest.mark.skip(reason="") def test_agg_call(self): query = '''YIELD COUNT(1), $-.name''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_EXECUTION_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) + + # query = '''YIELD 1+COUNT(*), 1+1''' + # resp = self.execute_query(query) + # self.check_resp_succeeded(resp) + # columns = ["(1+count(*))", "(1+1)"] + # self.check_column_names(resp, columns) + # expect_result = [[2, 2]] + # self.check_result(resp, expect_result) query = '''YIELD COUNT(*), 1+1''' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["count(*)", "(1+1)"] + columns = ["COUNT(*)", "(1+1)"] self.check_column_names(resp, columns) expect_result = [[1, 2]] self.check_result(resp, expect_result) @@ -404,28 +433,28 @@ class TestYield(NebulaTestSuite): query = '''GO FROM "Carmelo Anthony" OVER like YIELD $$.player.age AS age, like.likeness AS like \ | YIELD COUNT(*), $-.age''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SYNTAX_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) # Test input query = '''GO FROM "Carmelo Anthony" OVER like YIELD $$.player.age AS age, like.likeness AS like \ | YIELD AVG($-.age), SUM($-.like), COUNT(*), 1+1''' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["$-.age", "$-.like", "count(*)", "(1+1)"] + columns = ["AVG($-.age)", "SUM($-.like)", "COUNT(*)", "(1+1)"] self.check_column_names(resp, columns) expect_result = [[34.666666666666664, 270, 3, 2]] self.check_result(resp, expect_result) # Yield field has not input - query = '''GO FROM "Carmelo Anthony"" OVER like | YIELD COUNT(*)''' + query = '''GO FROM "Carmelo Anthony" OVER like | YIELD COUNT(*)''' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["count(*)"] + columns = ["COUNT(*)"] self.check_column_names(resp, columns) expect_result = [[3]] self.check_result(resp, expect_result) - query = '''GO FROM "Carmelo Anthony"" OVER like | YIELD 1''' + query = '''GO FROM "Carmelo Anthony" OVER like | YIELD 1''' resp = self.execute_query(query) self.check_resp_succeeded(resp) columns = ["1"] @@ -446,7 +475,7 @@ class TestYield(NebulaTestSuite): YIELD AVG($var.age), SUM($var.like), COUNT(*)''' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["$var.age", "$var.like", "count(*)"] + columns = ["AVG($var.age)", "SUM($var.like)", "COUNT(*)"] self.check_column_names(resp, columns) expect_result = [[34.666666666666664, 270, 3]] self.check_result(resp, expect_result) @@ -458,7 +487,7 @@ class TestYield(NebulaTestSuite): | YIELD $-.team''' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["$-.team"], + columns = ["$-.team"] self.check_column_names(resp, columns) expect_result = [] self.check_result(resp, expect_result) @@ -468,7 +497,7 @@ class TestYield(NebulaTestSuite): YIELD $var.team''' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["$var.team"], + columns = ["$var.team"] self.check_column_names(resp, columns) expect_result = [] self.check_result(resp, expect_result) @@ -479,7 +508,7 @@ class TestYield(NebulaTestSuite): | YIELD $-.name AS name''' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["name"], + columns = ["name"] self.check_column_names(resp, columns) expect_result = [] self.check_result(resp, expect_result) @@ -489,7 +518,7 @@ class TestYield(NebulaTestSuite): query = 'YIELD 1, 1' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["1", "1"], + columns = ["1", "1"] self.check_column_names(resp, columns) expect_result = [[1, 1]] self.check_result(resp, expect_result) @@ -498,7 +527,13 @@ class TestYield(NebulaTestSuite): $^.player.name as team, serve.start_year as start, $$.team.name as team \ | YIELD $-.team''' resp = self.execute_query(query) - self.check_resp_failed(resp, ttypes.ErrorCode.E_EXECUTION_ERROR) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) + + query = '''$var=GO FROM "Boris Diaw" OVER serve YIELD \ + $^.player.name as team, serve.start_year as start, $$.team.name as team; \ + YIELD $var.team''' + resp = self.execute_query(query) + self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) @pytest.mark.skip(reason="") def test_pipe_yield_go(self): @@ -507,7 +542,7 @@ class TestYield(NebulaTestSuite): GO FROM $-.id OVER serve YIELD $$.team.name AS name''' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["name"], + columns = ["name"] self.check_column_names(resp, columns) expect_result = [["Spurs"]] self.check_result(resp, expect_result) @@ -516,7 +551,7 @@ class TestYield(NebulaTestSuite): GO FROM $var.id OVER serve YIELD $$.team.name AS name''' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["name"], + columns = ["name"] self.check_column_names(resp, columns) expect_result = [["Spurs"]] self.check_result(resp, expect_result) @@ -526,7 +561,7 @@ class TestYield(NebulaTestSuite): GO FROM $var2.id OVER serve YIELD $$.team.name AS name''' resp = self.execute_query(query) self.check_resp_succeeded(resp) - columns = ["name"], + columns = ["name"] self.check_column_names(resp, columns) expect_result = [["Spurs"]] self.check_result(resp, expect_result) @@ -544,3 +579,9 @@ class TestYield(NebulaTestSuite): self.check_resp_succeeded(resp) expect_result = [[1]] self.check_result(resp, expect_result) + + query = 'YIELD 1 --1' + resp = self.execute_query(query) + self.check_resp_succeeded(resp) + expect_result = [[1]] + self.check_result(resp, expect_result)