Remove MessagePersister from WhisperServerService environment

Persistence is now exclusively done by a separate command.
This commit is contained in:
Chris Eager
2023-06-23 12:22:08 -05:00
committed by Chris Eager
parent b81a0e99d4
commit c93af9e31e
7 changed files with 16 additions and 74 deletions

View File

@@ -359,14 +359,13 @@ class DynamicConfigurationTest {
final DynamicConfiguration emptyConfig =
DynamicConfigurationManager.parseConfiguration(emptyConfigYaml, DynamicConfiguration.class).orElseThrow();
assertTrue(emptyConfig.getMessagePersisterConfiguration().isServerPersistenceEnabled());
assertFalse(emptyConfig.getMessagePersisterConfiguration().isDedicatedProcessEnabled());
assertTrue(emptyConfig.getMessagePersisterConfiguration().isPersistenceEnabled());
}
{
final String messagePersisterEnabledYaml = REQUIRED_CONFIG.concat("""
messagePersister:
serverPersistenceEnabled: true
persistenceEnabled: true
dedicatedProcessEnabled: true
""");
@@ -374,22 +373,20 @@ class DynamicConfigurationTest {
DynamicConfigurationManager.parseConfiguration(messagePersisterEnabledYaml, DynamicConfiguration.class)
.orElseThrow();
assertTrue(config.getMessagePersisterConfiguration().isServerPersistenceEnabled());
assertTrue(config.getMessagePersisterConfiguration().isDedicatedProcessEnabled());
assertTrue(config.getMessagePersisterConfiguration().isPersistenceEnabled());
}
{
final String messagePersisterDisabledYaml = REQUIRED_CONFIG.concat("""
messagePersister:
serverPersistenceEnabled: false
persistenceEnabled: false
""");
final DynamicConfiguration config =
DynamicConfigurationManager.parseConfiguration(messagePersisterDisabledYaml, DynamicConfiguration.class)
.orElseThrow();
assertFalse(config.getMessagePersisterConfiguration().isServerPersistenceEnabled());
assertFalse(config.getMessagePersisterConfiguration().isDedicatedProcessEnabled());
assertFalse(config.getMessagePersisterConfiguration().isPersistenceEnabled());
}
}

View File

@@ -83,7 +83,7 @@ class MessagePersisterIntegrationTest {
messagesManager = new MessagesManager(messagesDynamoDb, messagesCache, mock(ReportMessageManager.class),
messageDeletionExecutorService);
messagePersister = new MessagePersister(messagesCache, messagesManager, accountsManager,
dynamicConfigurationManager, PERSIST_DELAY, Optional.empty());
dynamicConfigurationManager, PERSIST_DELAY, 1);
account = mock(Account.class);

View File

@@ -37,12 +37,9 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.mockito.ArgumentCaptor;
import org.mockito.stubbing.Answer;
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicMessagePersisterConfiguration;
import org.whispersystems.textsecuregcm.entities.MessageProtos;
import org.whispersystems.textsecuregcm.redis.RedisClusterExtension;
import reactor.core.scheduler.Scheduler;
@@ -91,7 +88,7 @@ class MessagePersisterTest {
REDIS_CLUSTER_EXTENSION.getRedisCluster(), sharedExecutorService, messageDeliveryScheduler,
sharedExecutorService, Clock.systemUTC());
messagePersister = new MessagePersister(messagesCache, messagesManager, accountsManager,
dynamicConfigurationManager, PERSIST_DELAY, Optional.empty());
dynamicConfigurationManager, PERSIST_DELAY, 1);
doAnswer(invocation -> {
final UUID destinationUuid = invocation.getArgument(0);
@@ -229,31 +226,6 @@ class MessagePersisterTest {
() -> messagePersister.persistQueue(DESTINATION_ACCOUNT_UUID, DESTINATION_DEVICE_ID)));
}
@ParameterizedTest
@CsvSource({
"true, true, false, false",
"true, false, true, true",
"false, true, false, true",
"false, false, true, false",
})
void testEnabled(final boolean dedicatedProcess, final boolean serverPersistenceEnabled,
final boolean dedicatedProcessEnabled, final boolean expectEnabled) {
final DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager = mock(
DynamicConfigurationManager.class);
final DynamicConfiguration dynamicConfiguration = mock(DynamicConfiguration.class);
when(dynamicConfigurationManager.getConfiguration()).thenReturn(dynamicConfiguration);
final DynamicMessagePersisterConfiguration dynamicMessagePersisterConfiguration = mock(
DynamicMessagePersisterConfiguration.class);
when(dynamicConfiguration.getMessagePersisterConfiguration()).thenReturn(dynamicMessagePersisterConfiguration);
when(dynamicMessagePersisterConfiguration.isDedicatedProcessEnabled()).thenReturn(dedicatedProcessEnabled);
when(dynamicMessagePersisterConfiguration.isServerPersistenceEnabled()).thenReturn(serverPersistenceEnabled);
messagePersister = new MessagePersister(messagesCache, messagesManager, accountsManager,
dynamicConfigurationManager, PERSIST_DELAY, dedicatedProcess ? Optional.of(4) : Optional.empty());
assertEquals(expectEnabled, messagePersister.enabled(dynamicConfigurationManager));
}
@SuppressWarnings("SameParameterValue")
private static String generateRandomQueueNameForSlot(final int slot) {
final UUID uuid = UUID.randomUUID();