Compare results of reads from old and new Redis caches.

This commit is contained in:
Jon Chambers 2020-06-07 14:52:44 -04:00 committed by Jon Chambers
parent c2a4a2778e
commit 52310b5dd9
14 changed files with 121 additions and 59 deletions

View File

@ -75,6 +75,7 @@ import org.whispersystems.textsecuregcm.controllers.SecureBackupController;
import org.whispersystems.textsecuregcm.controllers.SecureStorageController;
import org.whispersystems.textsecuregcm.controllers.StickerController;
import org.whispersystems.textsecuregcm.controllers.VoiceVerificationController;
import org.whispersystems.textsecuregcm.experiment.Experiment;
import org.whispersystems.textsecuregcm.filters.TimestampResponseFilter;
import org.whispersystems.textsecuregcm.limits.RateLimiters;
import org.whispersystems.textsecuregcm.liquibase.NameableMigrationsBundle;
@ -251,9 +252,9 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
DirectoryQueue directoryQueue = new DirectoryQueue(config.getDirectoryConfiguration().getSqsConfiguration());
PendingAccountsManager pendingAccountsManager = new PendingAccountsManager(pendingAccounts, cacheClient, cacheCluster);
PendingDevicesManager pendingDevicesManager = new PendingDevicesManager(pendingDevices, cacheClient, cacheCluster);
AccountsManager accountsManager = new AccountsManager(accounts, directory, cacheClient, cacheCluster);
UsernamesManager usernamesManager = new UsernamesManager(usernames, reservedUsernames, cacheClient, cacheCluster);
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheClient, cacheCluster);
AccountsManager accountsManager = new AccountsManager(accounts, directory, cacheClient, cacheCluster, new Experiment("RedisCluster", "AccountsManager"));
UsernamesManager usernamesManager = new UsernamesManager(usernames, reservedUsernames, cacheClient, cacheCluster, new Experiment("RedisCluster", "UsernamesManager"));
ProfilesManager profilesManager = new ProfilesManager(profiles, cacheClient, cacheCluster, new Experiment("RedisCluster", "ProfilesManager"));
MessagesCache messagesCache = new MessagesCache(messagesClient, messages, accountsManager, config.getMessageCacheConfiguration().getPersistDelayMinutes());
MessagesManager messagesManager = new MessagesManager(messages, messagesCache);
RemoteConfigsManager remoteConfigsManager = new RemoteConfigsManager(remoteConfigs);
@ -286,7 +287,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
DirectoryReconciliationClient directoryReconciliationClient = new DirectoryReconciliationClient(config.getDirectoryConfiguration().getDirectoryServerConfiguration());
ActiveUserCounter activeUserCounter = new ActiveUserCounter(config.getMetricsFactory(), cacheClient, cacheCluster);
ActiveUserCounter activeUserCounter = new ActiveUserCounter(config.getMetricsFactory(), cacheClient, cacheCluster, new Experiment("RedisCluster", "ActiveUserCounter"));
DirectoryReconciler directoryReconciler = new DirectoryReconciler(directoryReconciliationClient, directory);
AccountCleaner accountCleaner = new AccountCleaner(accountsManager, directoryQueue);
PushFeedbackProcessor pushFeedbackProcessor = new PushFeedbackProcessor(accountsManager, directoryQueue);

View File

@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.controllers.RateLimitExceededException;
import org.whispersystems.textsecuregcm.experiment.Experiment;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
import org.whispersystems.textsecuregcm.util.Constants;
@ -46,6 +47,7 @@ public class RateLimiter {
private final int bucketSize;
private final double leakRatePerMillis;
private final boolean reportLimits;
private final Experiment redisClusterExperiment;
public RateLimiter(ReplicatedJedisPool cacheClient, FaultTolerantRedisCluster cacheCluster, String name,
int bucketSize, double leakRatePerMinute)
@ -59,13 +61,14 @@ public class RateLimiter {
{
MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate(Constants.METRICS_NAME);
this.meter = metricRegistry.meter(name(getClass(), name, "exceeded"));
this.cacheClient = cacheClient;
this.cacheCluster = cacheCluster;
this.name = name;
this.bucketSize = bucketSize;
this.leakRatePerMillis = leakRatePerMinute / (60.0 * 1000.0);
this.reportLimits = reportLimits;
this.meter = metricRegistry.meter(name(getClass(), name, "exceeded"));
this.cacheClient = cacheClient;
this.cacheCluster = cacheCluster;
this.name = name;
this.bucketSize = bucketSize;
this.leakRatePerMillis = leakRatePerMinute / (60.0 * 1000.0);
this.reportLimits = reportLimits;
this.redisClusterExperiment = new Experiment("RedisCluster", "RateLimiter", name);
}
public void validate(String key, int amount) throws RateLimitExceededException {
@ -107,7 +110,10 @@ public class RateLimiter {
private LeakyBucket getBucket(String key) {
try (Jedis jedis = cacheClient.getReadResource()) {
String serialized = jedis.get(getBucketName(key));
final String bucketName = getBucketName(key);
String serialized = jedis.get(bucketName);
redisClusterExperiment.compareResult(serialized, cacheCluster.withReadCluster(connection -> connection.async().get(bucketName)));
if (serialized != null) {
return LeakyBucket.fromSerialized(mapper, serialized);

View File

@ -17,6 +17,7 @@
package org.whispersystems.textsecuregcm.storage;
import io.lettuce.core.SetArgs;
import org.whispersystems.textsecuregcm.experiment.Experiment;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
import org.whispersystems.textsecuregcm.redis.LuaScript;
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
@ -41,6 +42,7 @@ public class AccountDatabaseCrawlerCache {
private final ReplicatedJedisPool jedisPool;
private final FaultTolerantRedisCluster cacheCluster;
private final LuaScript luaScript;
private final Experiment redisClusterExperiment = new Experiment("RedisCluster", "AccountDatabaseCrawlerCache");
public AccountDatabaseCrawlerCache(ReplicatedJedisPool jedisPool, FaultTolerantRedisCluster cacheCluster) throws IOException {
this.jedisPool = jedisPool;
@ -57,7 +59,10 @@ public class AccountDatabaseCrawlerCache {
public boolean isAccelerated() {
try (Jedis jedis = jedisPool.getWriteResource()) {
return "1".equals(jedis.get(ACCELERATE_KEY));
final String accelerated = jedis.get(ACCELERATE_KEY);
redisClusterExperiment.compareResult(accelerated, cacheCluster.withReadCluster(connection -> connection.async().get(ACCELERATE_KEY)));
return "1".equals(accelerated);
}
}
@ -83,6 +88,7 @@ public class AccountDatabaseCrawlerCache {
public Optional<UUID> getLastUuid() {
try (Jedis jedis = jedisPool.getWriteResource()) {
String lastUuidString = jedis.get(LAST_UUID_KEY);
redisClusterExperiment.compareResult(lastUuidString, cacheCluster.withWriteCluster(connection -> connection.async().get(LAST_UUID_KEY)));
if (lastUuidString == null) return Optional.empty();
else return Optional.of(UUID.fromString(lastUuidString));

View File

@ -27,6 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.auth.AmbiguousIdentifier;
import org.whispersystems.textsecuregcm.entities.ClientContact;
import org.whispersystems.textsecuregcm.experiment.Experiment;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
import org.whispersystems.textsecuregcm.util.Constants;
@ -61,13 +62,15 @@ public class AccountsManager {
private final FaultTolerantRedisCluster cacheCluster;
private final DirectoryManager directory;
private final ObjectMapper mapper;
private final Experiment redisClusterExperiment;
public AccountsManager(Accounts accounts, DirectoryManager directory, ReplicatedJedisPool cacheClient, FaultTolerantRedisCluster cacheCluster) {
this.accounts = accounts;
this.directory = directory;
this.cacheClient = cacheClient;
this.cacheCluster = cacheCluster;
this.mapper = SystemMapper.getMapper();
public AccountsManager(Accounts accounts, DirectoryManager directory, ReplicatedJedisPool cacheClient, FaultTolerantRedisCluster cacheCluster, Experiment redisClusterExperiment) {
this.accounts = accounts;
this.directory = directory;
this.cacheClient = cacheClient;
this.cacheCluster = cacheCluster;
this.mapper = SystemMapper.getMapper();
this.redisClusterExperiment = redisClusterExperiment;
}
public boolean create(Account account) {
@ -173,7 +176,10 @@ public class AccountsManager {
try (Jedis jedis = cacheClient.getReadResource();
Timer.Context ignored = redisNumberGetTimer.time())
{
String uuid = jedis.get(getAccountMapKey(number));
final String key = getAccountMapKey(number);
String uuid = jedis.get(key);
redisClusterExperiment.compareResult(uuid, cacheCluster.withReadCluster(connection -> connection.async().get(key)));
if (uuid != null) return redisGet(jedis, UUID.fromString(uuid));
else return Optional.empty();
@ -194,7 +200,10 @@ public class AccountsManager {
private Optional<Account> redisGet(Jedis jedis, UUID uuid) {
try (Timer.Context ignored = redisUuidGetTimer.time()) {
String json = jedis.get(getAccountEntityKey(uuid));
final String key = getAccountEntityKey(uuid);
String json = jedis.get(key);
redisClusterExperiment.compareResult(json, cacheCluster.withReadCluster(connection -> connection.async().get(key)));
if (json != null) {
Account account = mapper.readValue(json, Account.class);

View File

@ -21,6 +21,7 @@ import com.codahale.metrics.MetricRegistry;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.whispersystems.textsecuregcm.entities.ActiveUserTally;
import org.whispersystems.textsecuregcm.experiment.Experiment;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
import org.whispersystems.textsecuregcm.util.SystemMapper;
@ -51,12 +52,14 @@ public class ActiveUserCounter extends AccountDatabaseCrawlerListener {
private final ReplicatedJedisPool jedisPool;
private final FaultTolerantRedisCluster cacheCluster;
private final ObjectMapper mapper;
private final Experiment redisClusterExperiment;
public ActiveUserCounter(MetricsFactory metricsFactory, ReplicatedJedisPool jedisPool, FaultTolerantRedisCluster cacheCluster) {
this.metricsFactory = metricsFactory;
this.jedisPool = jedisPool;
this.cacheCluster = cacheCluster;
this.mapper = SystemMapper.getMapper();
public ActiveUserCounter(MetricsFactory metricsFactory, ReplicatedJedisPool jedisPool, FaultTolerantRedisCluster cacheCluster, Experiment redisClusterExperiment) {
this.metricsFactory = metricsFactory;
this.jedisPool = jedisPool;
this.cacheCluster = cacheCluster;
this.mapper = SystemMapper.getMapper();
this.redisClusterExperiment = redisClusterExperiment;
}
@Override
@ -162,6 +165,8 @@ public class ActiveUserCounter extends AccountDatabaseCrawlerListener {
private void incrementTallies(UUID fromUuid, Map<String, long[]> platformIncrements, Map<String, long[]> countryIncrements) {
try (Jedis jedis = jedisPool.getWriteResource()) {
String tallyValue = jedis.get(TALLY_KEY);
redisClusterExperiment.compareResult(tallyValue, cacheCluster.withReadCluster(connection -> connection.async().get(TALLY_KEY)));
ActiveUserTally activeUserTally;
if (tallyValue == null) {
@ -204,7 +209,10 @@ public class ActiveUserCounter extends AccountDatabaseCrawlerListener {
private ActiveUserTally getFinalTallies() {
try (Jedis jedis = jedisPool.getReadResource()) {
return mapper.readValue(jedis.get(TALLY_KEY), ActiveUserTally.class);
final String tallyJson = jedis.get(TALLY_KEY);
redisClusterExperiment.compareResult(tallyJson, cacheCluster.withReadCluster(connection -> connection.async().get(TALLY_KEY)));
return mapper.readValue(tallyJson, ActiveUserTally.class);
} catch (IOException e) {
throw new RuntimeException(e);
}

View File

@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.auth.StoredVerificationCode;
import org.whispersystems.textsecuregcm.experiment.Experiment;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
import org.whispersystems.textsecuregcm.util.SystemMapper;
@ -40,6 +41,7 @@ public class PendingAccountsManager {
private final ReplicatedJedisPool cacheClient;
private final FaultTolerantRedisCluster cacheCluster;
private final ObjectMapper mapper;
private final Experiment redisClusterExperiment = new Experiment("RedisCluster", "PendingAccountsManager");
public PendingAccountsManager(PendingAccounts pendingAccounts, ReplicatedJedisPool cacheClient, FaultTolerantRedisCluster cacheCluster)
{
@ -84,7 +86,10 @@ public class PendingAccountsManager {
private Optional<StoredVerificationCode> memcacheGet(String number) {
try (Jedis jedis = cacheClient.getReadResource()) {
String json = jedis.get(CACHE_PREFIX + number);
final String key = CACHE_PREFIX + number;
String json = jedis.get(key);
redisClusterExperiment.compareResult(json, cacheCluster.withReadCluster(connection -> connection.async().get(key)));
if (json == null) return Optional.empty();
else return Optional.of(mapper.readValue(json, StoredVerificationCode.class));

View File

@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.auth.StoredVerificationCode;
import org.whispersystems.textsecuregcm.experiment.Experiment;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
import org.whispersystems.textsecuregcm.util.SystemMapper;
@ -40,6 +41,7 @@ public class PendingDevicesManager {
private final ReplicatedJedisPool cacheClient;
private final FaultTolerantRedisCluster cacheCluster;
private final ObjectMapper mapper;
private final Experiment redisClusterExperiment = new Experiment("RedisCluster", "PendingDevicesManager");
public PendingDevicesManager(PendingDevices pendingDevices, ReplicatedJedisPool cacheClient, FaultTolerantRedisCluster cacheCluster) {
this.pendingDevices = pendingDevices;
@ -83,7 +85,10 @@ public class PendingDevicesManager {
private Optional<StoredVerificationCode> memcacheGet(String number) {
try (Jedis jedis = cacheClient.getReadResource()) {
String json = jedis.get(CACHE_PREFIX + number);
final String key = CACHE_PREFIX + number;
String json = jedis.get(key);
redisClusterExperiment.compareResult(json, cacheCluster.withReadCluster(connection -> connection.async().get(key)));
if (json == null) return Optional.empty();
else return Optional.of(mapper.readValue(json, StoredVerificationCode.class));

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.experiment.Experiment;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
import org.whispersystems.textsecuregcm.util.SystemMapper;
@ -25,12 +26,14 @@ public class ProfilesManager {
private final ReplicatedJedisPool cacheClient;
private final FaultTolerantRedisCluster cacheCluster;
private final ObjectMapper mapper;
private final Experiment redisClusterExperiment;
public ProfilesManager(Profiles profiles, ReplicatedJedisPool cacheClient, FaultTolerantRedisCluster cacheCluster) {
this.profiles = profiles;
this.cacheClient = cacheClient;
this.cacheCluster = cacheCluster;
this.mapper = SystemMapper.getMapper();
public ProfilesManager(Profiles profiles, ReplicatedJedisPool cacheClient, FaultTolerantRedisCluster cacheCluster, Experiment redisClusterExperiment) {
this.profiles = profiles;
this.cacheClient = cacheClient;
this.cacheCluster = cacheCluster;
this.mapper = SystemMapper.getMapper();
this.redisClusterExperiment = redisClusterExperiment;
}
public void set(UUID uuid, VersionedProfile versionedProfile) {
@ -68,7 +71,10 @@ public class ProfilesManager {
private Optional<VersionedProfile> memcacheGet(UUID uuid, String version) {
try (Jedis jedis = cacheClient.getReadResource()) {
String json = jedis.hget(CACHE_PREFIX + uuid.toString(), version);
final String key = CACHE_PREFIX + uuid.toString();
String json = jedis.hget(key, version);
redisClusterExperiment.compareResult(json, cacheCluster.withReadCluster(connection -> connection.async().hget(key, version)));
if (json == null) return Optional.empty();
else return Optional.of(mapper.readValue(json, VersionedProfile.class));

View File

@ -6,6 +6,7 @@ import com.codahale.metrics.Timer;
import io.lettuce.core.cluster.api.async.RedisAdvancedClusterAsyncCommands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.experiment.Experiment;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
import org.whispersystems.textsecuregcm.util.Constants;
@ -35,12 +36,14 @@ public class UsernamesManager {
private final ReservedUsernames reservedUsernames;
private final ReplicatedJedisPool cacheClient;
private final FaultTolerantRedisCluster cacheCluster;
private final Experiment redisClusterExperiment;
public UsernamesManager(Usernames usernames, ReservedUsernames reservedUsernames, ReplicatedJedisPool cacheClient, FaultTolerantRedisCluster cacheCluster) {
this.usernames = usernames;
this.reservedUsernames = reservedUsernames;
this.cacheClient = cacheClient;
this.cacheCluster = cacheCluster;
public UsernamesManager(Usernames usernames, ReservedUsernames reservedUsernames, ReplicatedJedisPool cacheClient, FaultTolerantRedisCluster cacheCluster, Experiment redisClusterExperiment) {
this.usernames = usernames;
this.reservedUsernames = reservedUsernames;
this.cacheClient = cacheClient;
this.cacheCluster = cacheCluster;
this.redisClusterExperiment = redisClusterExperiment;
}
public boolean put(UUID uuid, String username) {
@ -142,7 +145,10 @@ public class UsernamesManager {
try (Jedis jedis = cacheClient.getReadResource();
Timer.Context ignored = redisUsernameGetTimer.time())
{
String result = jedis.get(getUsernameMapKey(username));
final String key = getUsernameMapKey(username);
String result = jedis.get(key);
redisClusterExperiment.compareResult(result, cacheCluster.withReadCluster(connection -> connection.async().get(key)));
if (result == null) return Optional.empty();
else return Optional.of(UUID.fromString(result));
@ -156,7 +162,12 @@ public class UsernamesManager {
try (Jedis jedis = cacheClient.getReadResource();
Timer.Context ignored = redisUuidGetTimer.time())
{
return Optional.ofNullable(jedis.get(getUuidMapKey(uuid)));
final String key = getUuidMapKey(uuid);
final String result = jedis.get(key);
redisClusterExperiment.compareResult(result, cacheCluster.withReadCluster(connection -> connection.async().get(key)));
return Optional.ofNullable(result);
} catch (JedisException e) {
logger.warn("Redis get failure", e);
return Optional.empty();

View File

@ -10,6 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
import org.whispersystems.textsecuregcm.auth.AuthenticationCredentials;
import org.whispersystems.textsecuregcm.experiment.Experiment;
import org.whispersystems.textsecuregcm.providers.RedisClientFactory;
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool;
@ -78,7 +79,7 @@ public class DeleteUserCommand extends EnvironmentCommand<WhisperServerConfigura
ReplicatedJedisPool redisClient = new RedisClientFactory("directory_cache_delete_command", configuration.getDirectoryConfiguration().getRedisConfiguration().getUrl(), configuration.getDirectoryConfiguration().getRedisConfiguration().getReplicaUrls(), configuration.getDirectoryConfiguration().getRedisConfiguration().getCircuitBreakerConfiguration()).getRedisClientPool();
DirectoryQueue directoryQueue = new DirectoryQueue (configuration.getDirectoryConfiguration().getSqsConfiguration());
DirectoryManager directory = new DirectoryManager(redisClient );
AccountsManager accountsManager = new AccountsManager(accounts, directory, cacheClient, cacheCluster);
AccountsManager accountsManager = new AccountsManager(accounts, directory, cacheClient, cacheCluster, new Experiment("RedisCluster", "AccountsManager"));
for (String user: users) {
Optional<Account> account = accountsManager.get(user);

View File

@ -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());

View File

@ -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() {

View File

@ -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());

View File

@ -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());