Skip to content

Commit

Permalink
updted job testcases to drop test jobs before every test
Browse files Browse the repository at this point in the history
  • Loading branch information
dungnmaster committed Nov 11, 2023
1 parent 4a26f3d commit d3ca46a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion evadb/utils/job_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _update_next_schedule_run(self, job_catalog_entry: JobCatalogEntry) -> bool:
next_trigger_time = datetime.datetime.now() + datetime.timedelta(
seconds=job_catalog_entry.repeat_interval
)
if next_trigger_time < job_end_time:
if not job_end_time or next_trigger_time < job_end_time:
active_status = True

next_trigger_time = (
Expand Down
5 changes: 4 additions & 1 deletion test/integration_tests/long/test_job_scheduler_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ def setUpClass(cls):
cls.job_name_1 = "test_async_job_1"
cls.job_name_2 = "test_async_job_2"

def setUp(self):
execute_query_fetch_all(self.evadb, f"DROP JOB IF EXISTS {self.job_name_1};")
execute_query_fetch_all(self.evadb, f"DROP JOB IF EXISTS {self.job_name_2};")

@classmethod
def tearDownClass(cls):
shutdown_ray()

execute_query_fetch_all(cls.evadb, f"DROP JOB IF EXISTS {cls.job_name_1};")
execute_query_fetch_all(cls.evadb, f"DROP JOB IF EXISTS {cls.job_name_2};")

Expand Down
25 changes: 13 additions & 12 deletions test/integration_tests/short/test_create_job_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def setUpClass(cls):
# reset the catalog manager before running each test
cls.evadb.catalog().reset()
cls.job_name = "test_async_job"
execute_query_fetch_all(cls.evadb, f"DROP JOB IF EXISTS {cls.job_name};")

def setUp(self):
execute_query_fetch_all(self.evadb, f"DROP JOB IF EXISTS {self.job_name};")

@classmethod
def tearDownClass(cls):
Expand All @@ -36,17 +38,16 @@ def tearDownClass(cls):

def test_invalid_query_in_job_should_raise_exception(self):
# missing closing paranthesis in the query
query = """
CREATE JOB test_async_job AS {
CREATE OR REPLACE FUNCTION HomeSalesForecast FROM
( SELECT * FROM postgres_data.home_sales
TYPE Forecasting
PREDICT 'price';
}
START '2023-04-01 01:10:00'
END '2023-05-01'
EVERY 2 week;
"""
query = f"""CREATE JOB {self.job_name} AS {{
CREATE OR REPLACE FUNCTION HomeSalesForecast FROM
( SELECT * FROM postgres_data.home_sales
TYPE Forecasting
PREDICT 'price';
}}
START '2023-04-01 01:10:00'
END '2023-05-01'
EVERY 2 week;
"""
with self.assertRaisesRegex(Exception, "Failed to parse the job query"):
execute_query_fetch_all(self.evadb, query)

Expand Down

0 comments on commit d3ca46a

Please sign in to comment.