public Task SmallBlobsInRedisAfterCopy() { ConfigureWithOneMasterAndSmallBlobs(); return RunTestAsync( new Context(Logger), 2, async context => { var sessions = context.Sessions; var session0 = context.GetDistributedSession(0); var redisStore0 = context.GetRedisGlobalStore(0); var session1 = context.GetDistributedSession(1); var redisStore1 = context.GetRedisGlobalStore(1); var putResult = await session0.PutRandomAsync(context, HashType.Vso0, false, 10, CancellationToken.None).ShouldBeSuccess(); Assert.Equal(1, redisStore0.Counters[GlobalStoreCounters.PutBlob].Value); // Simulate that the blob has expired. var blobKey = RedisBlobAdapter.GetBlobKey(putResult.ContentHash); var deleted = await PrimaryGlobalStoreDatabase.KeyDeleteAsync($"{redisStore0.Configuration.Keyspace}{blobKey}"); Assert.True(deleted, $"Could not delete {blobKey} because it does not exist."); var openStreamResult = await session1.OpenStreamAsync(context, putResult.ContentHash, CancellationToken.None).ShouldBeSuccess(); Assert.Equal(0, redisStore1.BlobAdapter.Counters[RedisBlobAdapter.RedisBlobAdapterCounters.DownloadedBlobs].Value); Assert.Equal(1, redisStore1.Counters[GlobalStoreCounters.PutBlob].Value); }); }
public Task SmallBlobsInRedisAfterCopy() { return(RunTestAsync( new Context(Logger), 2, async context => { var sessions = context.Sessions; var session0 = context.GetDistributedSession(0); var redisStore0 = (RedisContentLocationStore)session0.ContentLocationStore; var session1 = context.GetDistributedSession(1); var redisStore1 = (RedisContentLocationStore)session1.ContentLocationStore; var putResult = await session0.PutRandomAsync(context, HashType.Vso0, false, 10, CancellationToken.None).ShouldBeSuccess(); var counters0 = redisStore0.GetCounters(context).ToDictionaryIntegral(); Assert.Equal(1, counters0["RedisContentLocationStore.BlobAdapter.PutBlob.Count"]); // Simulate that the blob has expired. var blobKey = RedisBlobAdapter.GetBlobKey(putResult.ContentHash); var deleted = await _localDatabases[context.Context.Id].KeyDeleteAsync($"{RedisContentLocationStoreFactory.DefaultKeySpace}{blobKey}"); Assert.True(deleted, $"Could not delete {blobKey} because it does not exist."); var openStreamResult = await session1.OpenStreamAsync(context, putResult.ContentHash, CancellationToken.None).ShouldBeSuccess(); var counters1 = redisStore1.GetCounters(context).ToDictionaryIntegral(); Assert.Equal(0, counters1["RedisContentLocationStore.BlobAdapter.DownloadedBlobs.Count"]); Assert.Equal(1, counters1["RedisContentLocationStore.BlobAdapter.PutBlob.Count"]); })); }