mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 02:28:06 +01:00
Enqueue async operations from a dedicated thread
This commit is contained in:
committed by
Jon Chambers
parent
33c0a27b85
commit
a96c0ec7a3
@@ -51,6 +51,7 @@ class WebSocketConnectionEventManagerTest {
|
||||
private WebSocketConnectionEventManager remoteEventManager;
|
||||
|
||||
private static ExecutorService webSocketConnectionEventExecutor;
|
||||
private static ExecutorService asyncOperationQueueingExecutor;
|
||||
|
||||
@RegisterExtension
|
||||
static final RedisClusterExtension REDIS_CLUSTER_EXTENSION = RedisClusterExtension.builder().build();
|
||||
@@ -73,6 +74,7 @@ class WebSocketConnectionEventManagerTest {
|
||||
@BeforeAll
|
||||
static void setUpBeforeAll() {
|
||||
webSocketConnectionEventExecutor = Executors.newVirtualThreadPerTaskExecutor();
|
||||
asyncOperationQueueingExecutor = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@@ -80,12 +82,14 @@ class WebSocketConnectionEventManagerTest {
|
||||
localEventManager = new WebSocketConnectionEventManager(mock(AccountsManager.class),
|
||||
mock(PushNotificationManager.class),
|
||||
REDIS_CLUSTER_EXTENSION.getRedisCluster(),
|
||||
webSocketConnectionEventExecutor);
|
||||
webSocketConnectionEventExecutor,
|
||||
asyncOperationQueueingExecutor);
|
||||
|
||||
remoteEventManager = new WebSocketConnectionEventManager(mock(AccountsManager.class),
|
||||
mock(PushNotificationManager.class),
|
||||
REDIS_CLUSTER_EXTENSION.getRedisCluster(),
|
||||
webSocketConnectionEventExecutor);
|
||||
webSocketConnectionEventExecutor,
|
||||
asyncOperationQueueingExecutor);
|
||||
|
||||
localEventManager.start();
|
||||
remoteEventManager.start();
|
||||
@@ -100,6 +104,7 @@ class WebSocketConnectionEventManagerTest {
|
||||
@AfterAll
|
||||
static void tearDownAfterAll() {
|
||||
webSocketConnectionEventExecutor.shutdown();
|
||||
asyncOperationQueueingExecutor.shutdown();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@@ -242,6 +247,7 @@ class WebSocketConnectionEventManagerTest {
|
||||
mock(AccountsManager.class),
|
||||
mock(PushNotificationManager.class),
|
||||
clusterClient,
|
||||
Runnable::run,
|
||||
Runnable::run);
|
||||
|
||||
eventManager.start();
|
||||
@@ -309,6 +315,7 @@ class WebSocketConnectionEventManagerTest {
|
||||
mock(AccountsManager.class),
|
||||
mock(PushNotificationManager.class),
|
||||
clusterClient,
|
||||
Runnable::run,
|
||||
Runnable::run);
|
||||
|
||||
eventManager.start();
|
||||
@@ -366,6 +373,7 @@ class WebSocketConnectionEventManagerTest {
|
||||
accountsManager,
|
||||
pushNotificationManager,
|
||||
clusterClient,
|
||||
Runnable::run,
|
||||
Runnable::run);
|
||||
|
||||
eventManager.start();
|
||||
|
||||
@@ -54,6 +54,7 @@ class MessagePersisterIntegrationTest {
|
||||
private Scheduler messageDeliveryScheduler;
|
||||
private ExecutorService messageDeletionExecutorService;
|
||||
private ExecutorService websocketConnectionEventExecutor;
|
||||
private ExecutorService asyncOperationQueueingExecutor;
|
||||
private MessagesCache messagesCache;
|
||||
private MessagesManager messagesManager;
|
||||
private WebSocketConnectionEventManager webSocketConnectionEventManager;
|
||||
@@ -86,10 +87,12 @@ class MessagePersisterIntegrationTest {
|
||||
messageDeletionExecutorService);
|
||||
|
||||
websocketConnectionEventExecutor = Executors.newVirtualThreadPerTaskExecutor();
|
||||
asyncOperationQueueingExecutor = Executors.newSingleThreadExecutor();
|
||||
webSocketConnectionEventManager = new WebSocketConnectionEventManager(mock(AccountsManager.class),
|
||||
mock(PushNotificationManager.class),
|
||||
REDIS_CLUSTER_EXTENSION.getRedisCluster(),
|
||||
websocketConnectionEventExecutor);
|
||||
websocketConnectionEventExecutor,
|
||||
asyncOperationQueueingExecutor);
|
||||
|
||||
webSocketConnectionEventManager.start();
|
||||
|
||||
@@ -108,6 +111,7 @@ class MessagePersisterIntegrationTest {
|
||||
when(dynamicConfigurationManager.getConfiguration()).thenReturn(new DynamicConfiguration());
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
@AfterEach
|
||||
void tearDown() throws Exception {
|
||||
messageDeletionExecutorService.shutdown();
|
||||
@@ -116,6 +120,9 @@ class MessagePersisterIntegrationTest {
|
||||
websocketConnectionEventExecutor.shutdown();
|
||||
websocketConnectionEventExecutor.awaitTermination(15, TimeUnit.SECONDS);
|
||||
|
||||
asyncOperationQueueingExecutor.shutdown();
|
||||
asyncOperationQueueingExecutor.awaitTermination(15, TimeUnit.SECONDS);
|
||||
|
||||
messageDeliveryScheduler.dispose();
|
||||
|
||||
webSocketConnectionEventManager.stop();
|
||||
|
||||
Reference in New Issue
Block a user