Skip to content

Commit

Permalink
fix ut.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkk12014402 committed Dec 11, 2024
1 parent 6f5ce8e commit c488fc9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
13 changes: 9 additions & 4 deletions tests/cores/mega/test_aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import json
import time
import unittest

import multiprocessing
from comps import ServiceOrchestrator, TextDoc, opea_microservices, register_microservice


Expand Down Expand Up @@ -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()

Expand Down
15 changes: 10 additions & 5 deletions tests/cores/mega/test_runtime_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest

from fastapi.testclient import TestClient

import multiprocessing
from comps import ServiceOrchestrator, TextDoc, opea_microservices, register_microservice


Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions tests/cores/mega/test_service_orchestrator_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import unittest

from fastapi.responses import StreamingResponse
import multiprocessing

from comps import ServiceOrchestrator, ServiceType, TextDoc, opea_microservices, register_microservice

Expand Down Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions tests/cores/mega/test_service_orchestrator_with_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import json
import unittest

import multiprocessing
from comps import ServiceOrchestratorWithYaml, TextDoc, opea_microservices, register_microservice


Expand All @@ -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()
Expand Down

0 comments on commit c488fc9

Please sign in to comment.