mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 00:28:02 +01:00
Remove legacy delete-via-REST plumbing
This commit is contained in:
committed by
Jon Chambers
parent
7604306818
commit
389d44fd80
@@ -8,8 +8,8 @@ package org.whispersystems.textsecuregcm.storage;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.whispersystems.textsecuregcm.backup.BackupsDb;
|
||||
import org.whispersystems.textsecuregcm.scheduler.JobScheduler;
|
||||
import org.whispersystems.textsecuregcm.experiment.PushNotificationExperimentSamples;
|
||||
import org.whispersystems.textsecuregcm.scheduler.JobScheduler;
|
||||
import org.whispersystems.textsecuregcm.storage.devicecheck.AppleDeviceChecks;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition;
|
||||
import software.amazon.awssdk.services.dynamodb.model.GlobalSecondaryIndex;
|
||||
@@ -246,20 +246,8 @@ public final class DynamoDbExtensionSchema {
|
||||
MessagesDynamoDb.KEY_SORT,
|
||||
List.of(
|
||||
AttributeDefinition.builder().attributeName(MessagesDynamoDb.KEY_PARTITION).attributeType(ScalarAttributeType.B).build(),
|
||||
AttributeDefinition.builder().attributeName(MessagesDynamoDb.KEY_SORT).attributeType(ScalarAttributeType.B).build(),
|
||||
AttributeDefinition.builder().attributeName(MessagesDynamoDb.LOCAL_INDEX_MESSAGE_UUID_KEY_SORT)
|
||||
.attributeType(ScalarAttributeType.B).build()),
|
||||
List.of(),
|
||||
List.of(LocalSecondaryIndex.builder()
|
||||
.indexName(MessagesDynamoDb.LOCAL_INDEX_MESSAGE_UUID_NAME)
|
||||
.keySchema(
|
||||
KeySchemaElement.builder().attributeName(MessagesDynamoDb.KEY_PARTITION).keyType(KeyType.HASH).build(),
|
||||
KeySchemaElement.builder()
|
||||
.attributeName(MessagesDynamoDb.LOCAL_INDEX_MESSAGE_UUID_KEY_SORT)
|
||||
.keyType(KeyType.RANGE)
|
||||
.build())
|
||||
.projection(Projection.builder().projectionType(ProjectionType.KEYS_ONLY).build())
|
||||
.build())),
|
||||
AttributeDefinition.builder().attributeName(MessagesDynamoDb.KEY_SORT).attributeType(ScalarAttributeType.B).build()),
|
||||
List.of(), List.of()),
|
||||
|
||||
ONETIME_DONATIONS("onetime_donations_test",
|
||||
OneTimeDonationsManager.KEY_PAYMENT_ID,
|
||||
|
||||
@@ -11,9 +11,9 @@ import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyByte;
|
||||
import static org.mockito.ArgumentMatchers.anyList;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNotNull;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -346,15 +346,16 @@ class MessagePersisterTest {
|
||||
.thenReturn(Flux.concat(
|
||||
Flux.fromIterable(persistedMessages),
|
||||
Flux.fromIterable(cachedMessages)));
|
||||
when(messagesManager.delete(any(), any(), any(), any()))
|
||||
when(messagesManager.delete(any(), any(), any(), anyLong()))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.empty()));
|
||||
|
||||
assertTimeoutPreemptively(Duration.ofSeconds(10), () ->
|
||||
messagePersister.persistNextQueues(Clock.systemUTC().instant()));
|
||||
|
||||
verify(messagesManager, times(expectedClearedGuids.size()))
|
||||
.delete(eq(DESTINATION_ACCOUNT_UUID), eq(primary), argThat(expectedClearedGuids::contains), isNotNull());
|
||||
verify(messagesManager, never()).delete(any(), any(), argThat(guid -> !expectedClearedGuids.contains(guid)), any());
|
||||
.delete(eq(DESTINATION_ACCOUNT_UUID), eq(primary), argThat(expectedClearedGuids::contains), anyLong());
|
||||
verify(messagesManager, never())
|
||||
.delete(any(), any(), argThat(guid -> !expectedClearedGuids.contains(guid)), anyLong());
|
||||
|
||||
final List<String> queuesToPersist = messagesCache.getQueuesToPersist(SlotHash.getSlot(queueName),
|
||||
Clock.systemUTC().instant(), 1);
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.google.protobuf.ByteString;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -188,47 +187,6 @@ class MessagesDynamoDbTest {
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteMessageByDestinationAndGuid() throws Exception {
|
||||
final UUID destinationUuid = UUID.randomUUID();
|
||||
final UUID secondDestinationUuid = UUID.randomUUID();
|
||||
final Device primary = DevicesHelper.createDevice((byte) 1);
|
||||
final Device device2 = DevicesHelper.createDevice((byte) 2);
|
||||
|
||||
messagesDynamoDb.store(List.of(MESSAGE1), destinationUuid, primary);
|
||||
messagesDynamoDb.store(List.of(MESSAGE2), secondDestinationUuid, primary);
|
||||
messagesDynamoDb.store(List.of(MESSAGE3), destinationUuid, device2);
|
||||
|
||||
assertThat(load(destinationUuid, primary, MessagesDynamoDb.RESULT_SET_CHUNK_SIZE)).isNotNull().hasSize(1)
|
||||
.element(0).isEqualTo(MESSAGE1);
|
||||
assertThat(load(destinationUuid, device2, MessagesDynamoDb.RESULT_SET_CHUNK_SIZE)).isNotNull()
|
||||
.hasSize(1)
|
||||
.element(0).isEqualTo(MESSAGE3);
|
||||
assertThat(load(secondDestinationUuid, primary, MessagesDynamoDb.RESULT_SET_CHUNK_SIZE)).isNotNull()
|
||||
.hasSize(1).element(0).isEqualTo(MESSAGE2);
|
||||
|
||||
final Optional<MessageProtos.Envelope> deletedMessage = messagesDynamoDb.deleteMessageByDestinationAndGuid(
|
||||
secondDestinationUuid, primary,
|
||||
UUID.fromString(MESSAGE2.getServerGuid())).get(5, TimeUnit.SECONDS);
|
||||
|
||||
assertThat(deletedMessage).isPresent();
|
||||
|
||||
assertThat(load(destinationUuid, primary, MessagesDynamoDb.RESULT_SET_CHUNK_SIZE)).isNotNull().hasSize(1)
|
||||
.element(0).isEqualTo(MESSAGE1);
|
||||
assertThat(load(destinationUuid, device2, MessagesDynamoDb.RESULT_SET_CHUNK_SIZE)).isNotNull()
|
||||
.hasSize(1)
|
||||
.element(0).isEqualTo(MESSAGE3);
|
||||
assertThat(load(secondDestinationUuid, primary, MessagesDynamoDb.RESULT_SET_CHUNK_SIZE)).isNotNull()
|
||||
.isEmpty();
|
||||
|
||||
final Optional<MessageProtos.Envelope> alreadyDeletedMessage = messagesDynamoDb.deleteMessageByDestinationAndGuid(
|
||||
secondDestinationUuid, primary,
|
||||
UUID.fromString(MESSAGE2.getServerGuid())).get(5, TimeUnit.SECONDS);
|
||||
|
||||
assertThat(alreadyDeletedMessage).isNotPresent();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteSingleMessage() throws Exception {
|
||||
final UUID destinationUuid = UUID.randomUUID();
|
||||
@@ -274,19 +232,14 @@ class MessagesDynamoDbTest {
|
||||
final Device primary = DevicesHelper.createDevice((byte) 1);
|
||||
primary.setCreated(System.currentTimeMillis());
|
||||
|
||||
messagesDynamoDb.store(List.of(MESSAGE1, MESSAGE2, MESSAGE3), destinationUuid, primary);
|
||||
messagesDynamoDb.store(List.of(MESSAGE1, MESSAGE2), destinationUuid, primary);
|
||||
assertThat(load(destinationUuid, primary, MessagesDynamoDb.RESULT_SET_CHUNK_SIZE))
|
||||
.as("load should return all messages stored").containsOnly(MESSAGE1, MESSAGE2, MESSAGE3);
|
||||
.as("load should return all messages stored").containsOnly(MESSAGE1, MESSAGE2);
|
||||
|
||||
messagesDynamoDb.deleteMessageByDestinationAndGuid(destinationUuid, primary, UUID.fromString(MESSAGE1.getServerGuid()))
|
||||
messagesDynamoDb.deleteMessage(destinationUuid, primary, UUID.fromString(MESSAGE1.getServerGuid()), MESSAGE1.getServerTimestamp())
|
||||
.get(1, TimeUnit.SECONDS);
|
||||
assertThat(load(destinationUuid, primary, MessagesDynamoDb.RESULT_SET_CHUNK_SIZE))
|
||||
.as("deleting message by guid should work").containsExactly(MESSAGE3, MESSAGE2);
|
||||
|
||||
messagesDynamoDb.deleteMessage(destinationUuid, primary, UUID.fromString(MESSAGE2.getServerGuid()), MESSAGE2.getServerTimestamp())
|
||||
.get(1, TimeUnit.SECONDS);
|
||||
assertThat(load(destinationUuid, primary, MessagesDynamoDb.RESULT_SET_CHUNK_SIZE))
|
||||
.as("deleting message by guid and timestamp should work").containsExactly(MESSAGE3);
|
||||
.as("deleting message by guid and timestamp should work").containsExactly(MESSAGE2);
|
||||
|
||||
primary.setCreated(primary.getCreated() + 1000);
|
||||
assertThat(load(destinationUuid, primary, MessagesDynamoDb.RESULT_SET_CHUNK_SIZE))
|
||||
|
||||
Reference in New Issue
Block a user