From c488fc9fe58c3ee545b473c8f810f77721bfb258 Mon Sep 17 00:00:00 2001 From: lkk Date: Wed, 11 Dec 2024 14:53:38 +0000 Subject: [PATCH] fix ut. --- tests/cores/mega/test_aio.py | 13 +++++++++---- tests/cores/mega/test_runtime_graph.py | 15 ++++++++++----- .../mega/test_service_orchestrator_streaming.py | 7 +++++-- ...ice_orchestrator_with_retriever_rerank_fake.py | 10 +++++++--- .../mega/test_service_orchestrator_with_yaml.py | 9 ++++++--- 5 files changed, 37 insertions(+), 17 deletions(-) diff --git a/tests/cores/mega/test_aio.py b/tests/cores/mega/test_aio.py index fc735e70a..b0c2bfd0a 100644 --- a/tests/cores/mega/test_aio.py +++ b/tests/cores/mega/test_aio.py @@ -16,7 +16,7 @@ import json import time import unittest - +import multiprocessing from comps import ServiceOrchestrator, TextDoc, opea_microservices, register_microservice @@ -55,9 +55,14 @@ def setUp(self): self.s1 = opea_microservices["s1"] self.s2 = opea_microservices["s2"] self.s3 = opea_microservices["s3"] - self.s1.start() - self.s2.start() - self.s3.start() + + self.process1 = multiprocessing.Process(target=self.s1.start, daemon=False, name="s1") + self.process2 = multiprocessing.Process(target=self.s2.start, daemon=False, name="s2") + self.process3 = multiprocessing.Process(target=self.s3.start, daemon=False, name="s2") + + self.process1.start() + self.process2.start() + self.process3.start() self.service_builder = ServiceOrchestrator() diff --git a/tests/cores/mega/test_runtime_graph.py b/tests/cores/mega/test_runtime_graph.py index 9a140e0b1..dee8977d3 100644 --- a/tests/cores/mega/test_runtime_graph.py +++ b/tests/cores/mega/test_runtime_graph.py @@ -4,7 +4,7 @@ import unittest from fastapi.testclient import TestClient - +import multiprocessing from comps import ServiceOrchestrator, TextDoc, opea_microservices, register_microservice @@ -54,10 +54,15 @@ def setUp(self): self.s3 = opea_microservices["s3"] self.s4 = opea_microservices["s4"] - self.s1.start() - self.s2.start() - self.s3.start() - self.s4.start() + self.process1 = multiprocessing.Process(target=self.s1.start, daemon=False, name="s1") + self.process2 = multiprocessing.Process(target=self.s2.start, daemon=False, name="s2") + self.process3 = multiprocessing.Process(target=self.s3.start, daemon=False, name="s3") + self.process4 = multiprocessing.Process(target=self.s4.start, daemon=False, name="s4") + + self.process1.start() + self.process2.start() + self.process3.start() + self.process4.start() self.service_builder = ServiceOrchestrator() self.service_builder.add(self.s1).add(self.s2).add(self.s3).add(self.s4) diff --git a/tests/cores/mega/test_service_orchestrator_streaming.py b/tests/cores/mega/test_service_orchestrator_streaming.py index d2331dab6..7d12616c6 100644 --- a/tests/cores/mega/test_service_orchestrator_streaming.py +++ b/tests/cores/mega/test_service_orchestrator_streaming.py @@ -6,6 +6,7 @@ import unittest from fastapi.responses import StreamingResponse +import multiprocessing from comps import ServiceOrchestrator, ServiceType, TextDoc, opea_microservices, register_microservice @@ -38,8 +39,10 @@ class TestServiceOrchestratorStreaming(unittest.IsolatedAsyncioTestCase): def setUpClass(cls): cls.s0 = opea_microservices["s0"] cls.s1 = opea_microservices["s1"] - cls.s0.start() - cls.s1.start() + cls.process1 = multiprocessing.Process(target=cls.s0.start, daemon=False, name="s0") + cls.process2 = multiprocessing.Process(target=cls.s1.start, daemon=False, name="s1") + cls.process1.start() + cls.process2.start() cls.service_builder = ServiceOrchestrator() diff --git a/tests/cores/mega/test_service_orchestrator_with_retriever_rerank_fake.py b/tests/cores/mega/test_service_orchestrator_with_retriever_rerank_fake.py index 17831219a..5880e0cd1 100644 --- a/tests/cores/mega/test_service_orchestrator_with_retriever_rerank_fake.py +++ b/tests/cores/mega/test_service_orchestrator_with_retriever_rerank_fake.py @@ -3,7 +3,7 @@ import json import unittest - +import multiprocessing from comps import EmbedDoc, ServiceOrchestrator, TextDoc, opea_microservices, register_microservice from comps.cores.mega.constants import ServiceType from comps.cores.proto.docarray import RerankerParms, RetrieverParms @@ -45,8 +45,12 @@ class TestServiceOrchestratorParams(unittest.IsolatedAsyncioTestCase): def setUp(self): self.s1 = opea_microservices["s1"] self.s2 = opea_microservices["s2"] - self.s1.start() - self.s2.start() + + self.process1 = multiprocessing.Process(target=self.s1.start, daemon=False, name="s1") + self.process2 = multiprocessing.Process(target=self.s2.start, daemon=False, name="s2") + + self.process1.start() + self.process2.start() ServiceOrchestrator.align_inputs = align_inputs ServiceOrchestrator.align_outputs = align_outputs diff --git a/tests/cores/mega/test_service_orchestrator_with_yaml.py b/tests/cores/mega/test_service_orchestrator_with_yaml.py index 3a3c6509d..77ad0e1a0 100644 --- a/tests/cores/mega/test_service_orchestrator_with_yaml.py +++ b/tests/cores/mega/test_service_orchestrator_with_yaml.py @@ -3,7 +3,7 @@ import json import unittest - +import multiprocessing from comps import ServiceOrchestratorWithYaml, TextDoc, opea_microservices, register_microservice @@ -29,8 +29,11 @@ class TestYAMLOrchestrator(unittest.IsolatedAsyncioTestCase): def setUp(self) -> None: self.s1 = opea_microservices["s1"] self.s2 = opea_microservices["s2"] - self.s1.start() - self.s2.start() + + self.process1 = multiprocessing.Process(target=self.s1.start, daemon=False, name="s1") + self.process2 = multiprocessing.Process(target=self.s2.start, daemon=False, name="s2") + self.process1.start() + self.process2.start() def tearDown(self): self.s1.stop()