mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 11:48:07 +01:00
Remove old Postgres-backed remote config machinery
This commit is contained in:
committed by
Jon Chambers
parent
342323a7e6
commit
e23a1fac50
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2021 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.storage;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition;
|
||||
import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType;
|
||||
|
||||
class RemoteConfigsDynamoDbTest extends RemoteConfigsTest {
|
||||
|
||||
private static final String REMOTE_CONFIGS_TABLE_NAME = "remote_configs_test";
|
||||
|
||||
@RegisterExtension
|
||||
static DynamoDbExtension dynamoDbExtension = DynamoDbExtension.builder()
|
||||
.tableName(REMOTE_CONFIGS_TABLE_NAME)
|
||||
.hashKey(RemoteConfigsDynamoDb.KEY_NAME)
|
||||
.attributeDefinition(AttributeDefinition.builder()
|
||||
.attributeName(RemoteConfigsDynamoDb.KEY_NAME)
|
||||
.attributeType(ScalarAttributeType.S)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
private RemoteConfigsDynamoDb remoteConfigs;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
remoteConfigs = new RemoteConfigsDynamoDb(dynamoDbExtension.getDynamoDbClient(), REMOTE_CONFIGS_TABLE_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemoteConfigStore getRemoteConfigStore() {
|
||||
return remoteConfigs;
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,12 @@ import org.junit.Test;
|
||||
|
||||
public class RemoteConfigsManagerTest {
|
||||
|
||||
private RemoteConfigStore remoteConfigs;
|
||||
private RemoteConfigs remoteConfigs;
|
||||
private RemoteConfigsManager remoteConfigsManager;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.remoteConfigs = mock(RemoteConfigStore.class);
|
||||
this.remoteConfigs = mock(RemoteConfigs.class);
|
||||
this.remoteConfigsManager = new RemoteConfigsManager(remoteConfigs);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2021 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.storage;
|
||||
|
||||
import com.opentable.db.postgres.embedded.LiquibasePreparer;
|
||||
import com.opentable.db.postgres.junit5.EmbeddedPostgresExtension;
|
||||
import com.opentable.db.postgres.junit5.PreparedDbExtension;
|
||||
import org.jdbi.v3.core.Jdbi;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.whispersystems.textsecuregcm.configuration.CircuitBreakerConfiguration;
|
||||
|
||||
public class RemoteConfigsPostgresTest extends RemoteConfigsTest {
|
||||
|
||||
@RegisterExtension
|
||||
static PreparedDbExtension ACCOUNTS_POSTGRES_EXTENSION =
|
||||
EmbeddedPostgresExtension.preparedDatabase(LiquibasePreparer.forClasspathLocation("accountsdb.xml"));
|
||||
|
||||
private RemoteConfigs remoteConfigs;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
final FaultTolerantDatabase remoteConfigDatabase = new FaultTolerantDatabase("remote_configs-test", Jdbi.create(ACCOUNTS_POSTGRES_EXTENSION.getTestDatabase()), new CircuitBreakerConfiguration());
|
||||
|
||||
remoteConfigDatabase.use(jdbi -> jdbi.useHandle(handle ->
|
||||
handle.createUpdate("DELETE FROM remote_config").execute()));
|
||||
|
||||
this.remoteConfigs = new RemoteConfigs(remoteConfigDatabase);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemoteConfigStore getRemoteConfigStore() {
|
||||
return remoteConfigs;
|
||||
}
|
||||
}
|
||||
@@ -5,21 +5,40 @@
|
||||
|
||||
package org.whispersystems.textsecuregcm.storage;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.whispersystems.textsecuregcm.tests.util.AuthHelper;
|
||||
import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition;
|
||||
import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
abstract class RemoteConfigsTest {
|
||||
class RemoteConfigsTest {
|
||||
|
||||
protected abstract RemoteConfigStore getRemoteConfigStore();
|
||||
private static final String REMOTE_CONFIGS_TABLE_NAME = "remote_configs_test";
|
||||
|
||||
@RegisterExtension
|
||||
static DynamoDbExtension dynamoDbExtension = DynamoDbExtension.builder()
|
||||
.tableName(REMOTE_CONFIGS_TABLE_NAME)
|
||||
.hashKey(RemoteConfigs.KEY_NAME)
|
||||
.attributeDefinition(AttributeDefinition.builder()
|
||||
.attributeName(RemoteConfigs.KEY_NAME)
|
||||
.attributeType(ScalarAttributeType.S)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
private RemoteConfigs remoteConfigs;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
remoteConfigs = new RemoteConfigs(dynamoDbExtension.getDynamoDbClient(), REMOTE_CONFIGS_TABLE_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStore() {
|
||||
final RemoteConfigStore remoteConfigs = getRemoteConfigStore();
|
||||
|
||||
remoteConfigs.set(new RemoteConfig("android.stickers", 50, Set.of(AuthHelper.VALID_UUID, AuthHelper.VALID_UUID_TWO), "FALSE", "TRUE", null));
|
||||
remoteConfigs.set(new RemoteConfig("value.sometimes", 25, Set.of(AuthHelper.VALID_UUID_TWO), "default", "custom", null));
|
||||
|
||||
@@ -48,8 +67,6 @@ abstract class RemoteConfigsTest {
|
||||
|
||||
@Test
|
||||
void testUpdate() {
|
||||
final RemoteConfigStore remoteConfigs = getRemoteConfigStore();
|
||||
|
||||
remoteConfigs.set(new RemoteConfig("android.stickers", 50, Set.of(), "FALSE", "TRUE", null));
|
||||
remoteConfigs.set(new RemoteConfig("value.sometimes", 22, Set.of(), "def", "!", null));
|
||||
remoteConfigs.set(new RemoteConfig("ios.stickers", 50, Set.of(AuthHelper.DISABLED_UUID), "FALSE", "TRUE", null));
|
||||
@@ -81,8 +98,6 @@ abstract class RemoteConfigsTest {
|
||||
|
||||
@Test
|
||||
void testDelete() {
|
||||
final RemoteConfigStore remoteConfigs = getRemoteConfigStore();
|
||||
|
||||
remoteConfigs.set(new RemoteConfig("android.stickers", 50, Set.of(AuthHelper.VALID_UUID), "FALSE", "TRUE", null));
|
||||
remoteConfigs.set(new RemoteConfig("ios.stickers", 50, Set.of(), "FALSE", "TRUE", null));
|
||||
remoteConfigs.set(new RemoteConfig("ios.stickers", 75, Set.of(), "FALSE", "TRUE", null));
|
||||
|
||||
Reference in New Issue
Block a user