mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 09:10:35 +01:00
Compare results of reads from old and new Redis caches.
This commit is contained in:
committed by
Jon Chambers
parent
c2a4a2778e
commit
52310b5dd9
@@ -1,6 +1,7 @@
|
||||
package org.whispersystems.textsecuregcm.tests.storage;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.whispersystems.textsecuregcm.experiment.Experiment;
|
||||
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
||||
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
|
||||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
@@ -36,7 +37,7 @@ public class AccountsManagerTest {
|
||||
when(jedis.get(eq("AccountMap::+14152222222"))).thenReturn(uuid.toString());
|
||||
when(jedis.get(eq("Account3::" + uuid.toString()))).thenReturn("{\"number\": \"+14152222222\", \"name\": \"test\"}");
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<Account> account = accountsManager.get("+14152222222");
|
||||
|
||||
assertTrue(account.isPresent());
|
||||
@@ -63,7 +64,7 @@ public class AccountsManagerTest {
|
||||
when(cacheClient.getReadResource()).thenReturn(jedis);
|
||||
when(jedis.get(eq("Account3::" + uuid.toString()))).thenReturn("{\"number\": \"+14152222222\", \"name\": \"test\"}");
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<Account> account = accountsManager.get(uuid);
|
||||
|
||||
assertTrue(account.isPresent());
|
||||
@@ -93,7 +94,7 @@ public class AccountsManagerTest {
|
||||
when(jedis.get(eq("AccountMap::+14152222222"))).thenReturn(null);
|
||||
when(accounts.get(eq("+14152222222"))).thenReturn(Optional.of(account));
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<Account> retrieved = accountsManager.get("+14152222222");
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -124,7 +125,7 @@ public class AccountsManagerTest {
|
||||
when(jedis.get(eq("Account3::" + uuid))).thenReturn(null);
|
||||
when(accounts.get(eq(uuid))).thenReturn(Optional.of(account));
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<Account> retrieved = accountsManager.get(uuid);
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -155,7 +156,7 @@ public class AccountsManagerTest {
|
||||
when(jedis.get(eq("AccountMap::+14152222222"))).thenThrow(new JedisException("Connection lost!"));
|
||||
when(accounts.get(eq("+14152222222"))).thenReturn(Optional.of(account));
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<Account> retrieved = accountsManager.get("+14152222222");
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -186,7 +187,7 @@ public class AccountsManagerTest {
|
||||
when(jedis.get(eq("Account3::" + uuid))).thenThrow(new JedisException("Connection lost!"));
|
||||
when(accounts.get(eq(uuid))).thenReturn(Optional.of(account));
|
||||
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster);
|
||||
AccountsManager accountsManager = new AccountsManager(accounts, directoryManager, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<Account> retrieved = accountsManager.get(uuid);
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.whispersystems.textsecuregcm.tests.storage;
|
||||
|
||||
import org.whispersystems.textsecuregcm.experiment.Experiment;
|
||||
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
||||
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
|
||||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
@@ -70,7 +71,7 @@ public class ActiveUserCounterTest {
|
||||
private final FaultTolerantRedisCluster cacheCluster = mock(FaultTolerantRedisCluster.class);
|
||||
private final MetricsFactory metricsFactory = mock(MetricsFactory.class);
|
||||
|
||||
private final ActiveUserCounter activeUserCounter = new ActiveUserCounter(metricsFactory, jedisPool, cacheCluster);
|
||||
private final ActiveUserCounter activeUserCounter = new ActiveUserCounter(metricsFactory, jedisPool, cacheCluster, mock(Experiment.class));
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.whispersystems.textsecuregcm.tests.storage;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.whispersystems.textsecuregcm.experiment.Experiment;
|
||||
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
||||
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
|
||||
import org.whispersystems.textsecuregcm.storage.Profiles;
|
||||
@@ -35,7 +36,7 @@ public class ProfilesManagerTest {
|
||||
when(cacheClient.getReadResource()).thenReturn(jedis);
|
||||
when(jedis.hget(eq("profiles::" + uuid.toString()), eq("someversion"))).thenReturn("{\"version\": \"someversion\", \"name\": \"somename\", \"avatar\": \"someavatar\", \"commitment\":\"" + Base64.encodeBytes("somecommitment".getBytes()) + "\"}");
|
||||
|
||||
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheClient, cacheCluster);
|
||||
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<VersionedProfile> profile = profilesManager.get(uuid, "someversion");
|
||||
|
||||
assertTrue(profile.isPresent());
|
||||
@@ -64,7 +65,7 @@ public class ProfilesManagerTest {
|
||||
when(jedis.hget(eq("profiles::" + uuid.toString()), eq("someversion"))).thenReturn(null);
|
||||
when(profiles.get(eq(uuid), eq("someversion"))).thenReturn(Optional.of(profile));
|
||||
|
||||
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheClient, cacheCluster);
|
||||
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<VersionedProfile> retrieved = profilesManager.get(uuid, "someversion");
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -94,7 +95,7 @@ public class ProfilesManagerTest {
|
||||
when(jedis.hget(eq("profiles::" + uuid.toString()), eq("someversion"))).thenThrow(new JedisException("Connection lost"));
|
||||
when(profiles.get(eq(uuid), eq("someversion"))).thenReturn(Optional.of(profile));
|
||||
|
||||
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheClient, cacheCluster);
|
||||
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<VersionedProfile> retrieved = profilesManager.get(uuid, "someversion");
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.whispersystems.textsecuregcm.tests.storage;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.whispersystems.textsecuregcm.experiment.Experiment;
|
||||
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
||||
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
|
||||
import org.whispersystems.textsecuregcm.storage.ReservedUsernames;
|
||||
@@ -33,7 +34,7 @@ public class UsernamesManagerTest {
|
||||
when(cacheClient.getReadResource()).thenReturn(jedis);
|
||||
when(jedis.get(eq("UsernameByUsername::n00bkiller"))).thenReturn(uuid.toString());
|
||||
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster);
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<UUID> retrieved = usernamesManager.get("n00bkiller");
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -58,7 +59,7 @@ public class UsernamesManagerTest {
|
||||
when(cacheClient.getReadResource()).thenReturn(jedis);
|
||||
when(jedis.get(eq("UsernameByUuid::" + uuid.toString()))).thenReturn("n00bkiller");
|
||||
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster);
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<String> retrieved = usernamesManager.get(uuid);
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -87,7 +88,7 @@ public class UsernamesManagerTest {
|
||||
when(jedis.get(eq("UsernameByUsername::n00bkiller"))).thenReturn(null);
|
||||
when(usernames.get(eq("n00bkiller"))).thenReturn(Optional.of(uuid));
|
||||
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster);
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<UUID> retrieved = usernamesManager.get("n00bkiller");
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -119,7 +120,7 @@ public class UsernamesManagerTest {
|
||||
when(jedis.get(eq("UsernameByUuid::" + uuid.toString()))).thenReturn(null);
|
||||
when(usernames.get(eq(uuid))).thenReturn(Optional.of("n00bkiller"));
|
||||
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster);
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<String> retrieved = usernamesManager.get(uuid);
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -150,7 +151,7 @@ public class UsernamesManagerTest {
|
||||
when(jedis.get(eq("UsernameByUsername::n00bkiller"))).thenThrow(new JedisException("Connection lost!"));
|
||||
when(usernames.get(eq("n00bkiller"))).thenReturn(Optional.of(uuid));
|
||||
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster);
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<UUID> retrieved = usernamesManager.get("n00bkiller");
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
@@ -182,7 +183,7 @@ public class UsernamesManagerTest {
|
||||
when(jedis.get(eq("UsernameByUuid::" + uuid))).thenThrow(new JedisException("Connection lost!"));
|
||||
when(usernames.get(eq(uuid))).thenReturn(Optional.of("n00bkiller"));
|
||||
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster);
|
||||
UsernamesManager usernamesManager = new UsernamesManager(usernames, reserved, cacheClient, cacheCluster, mock(Experiment.class));
|
||||
Optional<String> retrieved = usernamesManager.get(uuid);
|
||||
|
||||
assertTrue(retrieved.isPresent());
|
||||
|
||||
Reference in New Issue
Block a user