diff --git a/tests/Makefile b/tests/Makefile index 10fc66d046b..36963cbf2c7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -61,16 +61,16 @@ sess: currdir python3 -m pytest -m "not skip" -k "not tck" job/test_session.py jobs: currdir - python3 -m pytest -m "not skip" -k "not tck" job/test_jobs.py + python3 -m pytest -m "not skip" tck/steps/test_jobs.py -test: sess jobs +test: sess python3 -m pytest -n$(J) --dist=loadfile -m "not skip" -k "not tck" $(TEST_DIR) slow-query: currdir python3 -m pytest -n$(J) -m "not skip" tck/steps/test_kill_slow_query_via_same_service.py && \ python3 -m pytest -n$(J) -m "not skip" tck/steps/test_kill_slow_query_via_different_service.py -tck: slow-query +tck: jobs slow-query python3 -m pytest -n$(J) -m "not skip" tck/steps/test_tck.py fail: currdir diff --git a/tests/job/test_jobs.py b/tests/job/test_jobs.py deleted file mode 100644 index ace541646bb..00000000000 --- a/tests/job/test_jobs.py +++ /dev/null @@ -1,89 +0,0 @@ -# --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 re -import time - -from nebula2.common import ttypes -from tests.common.nebula_test_suite import NebulaTestSuite - -class TestJobs(NebulaTestSuite): - def test_failed(self): - # submit without space - resp = self.client.execute('SUBMIT JOB COMPACT;') - self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) - # show one not exists - resp = self.client.execute('SHOW JOB 233;') - self.check_resp_failed(resp, ttypes.ErrorCode.E_EXECUTION_ERROR) - # stop one not exists - resp = self.client.execute('STOP JOB 233;') - self.check_resp_failed(resp, ttypes.ErrorCode.E_EXECUTION_ERROR) - - def test_succeeded(self): - def check_jobs_resp_obj(resp_row, job_name): - assert resp_row[1].as_string() == job_name - assert resp_row[2].is_string() - assert resp_row[3].is_datetime() - assert resp_row[4].is_datetime() - - resp = self.client.execute('CREATE SPACE IF NOT EXISTS space_for_jobs(partition_num=9, replica_factor=1, vid_type=FIXED_STRING(20));' - 'USE space_for_jobs;') - self.check_resp_succeeded(resp) - - resp = self.client.execute('SUBMIT JOB COMPACT;') - self.check_resp_succeeded(resp) - expect_col_names = ['New Job Id'] - self.check_column_names(resp, expect_col_names) - expect_values = [[re.compile(r'\d+')]] - self.check_result(resp, expect_values, is_regex=True) - time.sleep(1) - - resp = self.client.execute('SUBMIT JOB FLUSH;') - self.check_resp_succeeded(resp) - expect_col_names = ['New Job Id'] - self.check_column_names(resp, expect_col_names) - expect_values = [[re.compile(r'\d+')]] - self.check_result(resp, expect_values, is_regex=True) - time.sleep(1) - - resp = self.client.execute('SUBMIT JOB STATS;') - self.check_resp_succeeded(resp) - expect_col_names = ['New Job Id'] - self.check_column_names(resp, expect_col_names) - expect_values = [[re.compile(r'\d+')]] - self.check_result(resp, expect_values, is_regex=True) - - time.sleep(10) - resp = self.client.execute('SHOW JOBS;') - self.check_resp_succeeded(resp) - expect_col_names = ['Job Id', 'Command', 'Status', 'Start Time', 'Stop Time'] - self.check_column_names(resp, expect_col_names) - check_jobs_resp_obj(resp.row_values(0), 'STATS') - check_jobs_resp_obj(resp.row_values(1), 'FLUSH') - check_jobs_resp_obj(resp.row_values(2), 'COMPACT') - - job_id = resp.row_values(0)[0].as_int() - resp = self.client.execute('SHOW JOB {};'.format(job_id)) - self.check_resp_succeeded(resp) - expect_col_names = ['Job Id(TaskId)', 'Command(Dest)', 'Status', 'Start Time', 'Stop Time'] - check_jobs_resp_obj(resp.row_values(0), 'STATS') - - job_id = resp.row_values(0)[0].as_int() - stop_job_resp = self.client.execute('STOP JOB {};'.format(job_id)) - if resp.row_values(0)[2].as_string() == "FINISHED": - # Executin error if the job is finished - self.check_resp_failed(stop_job_resp, ttypes.ErrorCode.E_EXECUTION_ERROR) - else: - self.check_resp_succeeded(stop_job_resp) - - # This is skipped becuase it is hard to simulate the situation - # resp = self.client.execute('RECOVER JOB;') - # self.check_resp_succeeded(resp) - # expect_col_names = ['Recovered job num'] - # self.check_column_names(resp, expect_col_names) - # expect_values = [[0]] - # self.check_result(resp, expect_values) diff --git a/tests/tck/features/job/Job.feature b/tests/tck/job/Job.feature similarity index 84% rename from tests/tck/features/job/Job.feature rename to tests/tck/job/Job.feature index f9322b6e546..1a6cb364912 100644 --- a/tests/tck/features/job/Job.feature +++ b/tests/tck/job/Job.feature @@ -1,4 +1,7 @@ -@job +# Copyright (c) 2021 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. Feature: Submit job space requirements Scenario: submit job require space @@ -85,16 +88,14 @@ Feature: Submit job space requirements SHOW JOB {}; """ Then the result should be, in order: - | Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | - | /\d+/ | "STATS" | /\^"FINISHED"/ | /\w+/ | /\w+/ | - | /\d+/ | /\w+/ | /\w+/ | /\w+/ | /\w+/ | + | Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | + | /\d+/ | "STATS" | "FINISHED" | /\w+/ | /\w+/ | + | /\d+/ | /\w+/ | "FINISHED" | /\w+/ | /\w+/ | When executing query, fill replace holders with element index of 0 in job_id: """ STOP JOB {}; """ - Then the result should be, in order: - | Result | - | "Job stopped" | + Then an ExecutionError should be raised at runtime: Save job failure! # This is skipped becuase it is hard to simulate the situation # When executing query: diff --git a/tests/tck/steps/test_jobs.py b/tests/tck/steps/test_jobs.py new file mode 100644 index 00000000000..26a53060d95 --- /dev/null +++ b/tests/tck/steps/test_jobs.py @@ -0,0 +1,9 @@ +# 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. + +from pytest_bdd import scenarios + + +scenarios('job/Job.feature')