Skip to content

Commit ed3ebdd

Browse files
authored
Parallel kikimr stop in tests (#13033)
1 parent 2f62452 commit ed3ebdd

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

ydb/tests/library/harness/kikimr_runner.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
import tempfile
66
import time
77
import itertools
8+
import threading
89
from importlib_resources import read_binary
910
from google.protobuf import text_format
1011

12+
from six.moves.queue import Queue
13+
1114
import yatest
1215

1316
from ydb.tests.library.common.wait_for import wait_for
@@ -430,17 +433,23 @@ def __stop_node(self, node, kill=False):
430433
return ret
431434

432435
def stop(self, kill=False):
433-
saved_exceptions = []
434-
435-
for slot in self.slots.values():
436-
exception = self.__stop_node(slot, kill)
437-
if exception is not None:
438-
saved_exceptions.append(exception)
436+
saved_exceptions_queue = Queue()
439437

440-
for node in self.nodes.values():
438+
def stop_node(node, kill):
441439
exception = self.__stop_node(node, kill)
442440
if exception is not None:
443-
saved_exceptions.append(exception)
441+
saved_exceptions_queue.put(exception)
442+
443+
# do in parallel to faster stopping (important for tests)
444+
threads = []
445+
for node in list(self.slots.values()) + list(self.nodes.values()):
446+
thread = threading.Thread(target=stop_node, args=(node, kill))
447+
thread.start()
448+
threads.append(thread)
449+
for thread in threads:
450+
thread.join()
451+
452+
saved_exceptions = list(saved_exceptions_queue.queue)
444453

445454
self.__port_allocator.release_ports()
446455

0 commit comments

Comments
 (0)