Pārlūkot izejas kodu

chore: reset orchestrator after end to end test

Joao Andre 1 gadu atpakaļ
vecāks
revīzija
35ab038b18
3 mainītis faili ar 20 papildinājumiem un 1 dzēšanām
  1. 1 0
      pyproject.toml
  2. 16 0
      tests/rest/conftest.py
  3. 3 1
      tests/rest/test_end_to_end.py

+ 1 - 0
pyproject.toml

@@ -37,6 +37,7 @@ unfixable = []
 "_init.py" = ["F401", "F403"]  # unused import
 "taipy/config/stubs/pyi_header.py" = ["F401", "F403"]  # unused import
 "taipy/templates/*" = ["F401", "F403", "T201"]  # unused import, `print` found
+"taipy/gui/utils/types.py" = ["B024"] # abstract base class with no abstract methods
 
 [tool.ruff.lint.mccabe]
 max-complexity = 18

+ 16 - 0
tests/rest/conftest.py

@@ -13,6 +13,7 @@ import os
 import shutil
 import uuid
 from datetime import datetime, timedelta
+from queue import Queue
 
 import pandas as pd
 import pytest
@@ -22,6 +23,7 @@ from taipy.config import Config
 from taipy.config.common.frequency import Frequency
 from taipy.config.common.scope import Scope
 from taipy.core import Cycle, DataNodeId, Job, JobId, Scenario, Sequence, Task
+from taipy.core._orchestrator._orchestrator_factory import _OrchestratorFactory
 from taipy.core.cycle._cycle_manager import _CycleManager
 from taipy.core.data.in_memory import InMemoryDataNode
 from taipy.core.job._job_manager import _JobManager
@@ -323,3 +325,17 @@ def cleanup_files(reset_configuration_singleton, inject_core_sections):
     for path in [".data", ".my_data", "user_data", ".taipy"]:
         if os.path.exists(path):
             shutil.rmtree(path, ignore_errors=True)
+
+
+@pytest.fixture
+def init_orchestrator():
+    def _init_orchestrator():
+        _OrchestratorFactory._remove_dispatcher()
+
+        if _OrchestratorFactory._orchestrator is None:
+            _OrchestratorFactory._build_orchestrator()
+        _OrchestratorFactory._build_dispatcher(force_restart=True)
+        _OrchestratorFactory._orchestrator.jobs_to_run = Queue()
+        _OrchestratorFactory._orchestrator.blocked_jobs = []
+
+    return _init_orchestrator

+ 3 - 1
tests/rest/test_end_to_end.py

@@ -60,7 +60,7 @@ def delete(url, client):
     assert response.status_code == 200
 
 
-def test_end_to_end(client, setup_end_to_end):
+def test_end_to_end(client, setup_end_to_end, init_orchestrator):
     # Create Scenario: Should also create all of its dependencies(sequences, tasks, datanodes, etc)
     scenario = create_and_submit_scenario("scenario", client)
 
@@ -104,3 +104,5 @@ def test_end_to_end(client, setup_end_to_end):
     url_without_slash = url_for("api.scenarios")[:-1]
     get_all(url_with_slash, 1, client)
     get_all(url_without_slash, 1, client)
+
+    init_orchestrator()