public async Task DisconnectMostRemoteCacheAddNewReconnect() { string cacheId = "MutlipleCacheRemote"; ICache testCache = await InitializeCacheAsync(NewCache(cacheId, true, false, true)).SuccessAsync(); VerticalCacheAggregator lowerVert = testCache as VerticalCacheAggregator; XAssert.IsNotNull(lowerVert); CallbackCacheWrapper callbackCache = lowerVert.RemoteCache as CallbackCacheWrapper; XAssert.IsNotNull(callbackCache); VerticalCacheAggregator upperVert = callbackCache.WrappedCache as VerticalCacheAggregator; XAssert.IsNotNull(upperVert); ICacheSession session = await testCache.CreateSessionAsync().SuccessAsync(); VerticalAggregatorDisconnectTests.DisconnectCache(upperVert.RemoteCache); FullCacheRecord cacheRecord = await FakeBuild.DoPipAsync(session, "Test Pip"); VerticalAggregatorDisconnectTests.ConnectCache(upperVert.RemoteCache); // Now query each cache, and verify only the remote content is in each. var aggregatorStats = new Dictionary <string, double>(); var remoteDeterminism = CacheDeterminism.ViaCache(upperVert.RemoteCache.CacheGuid, CacheDeterminism.NeverExpires); foreach (var currentCache in new Tuple <ICache, CacheDeterminism, string, int, Dictionary <string, double> >[] { new Tuple <ICache, CacheDeterminism, string, int, Dictionary <string, double> >(testCache, remoteDeterminism, lowerVert.LocalCache.CacheId, 3, aggregatorStats), new Tuple <ICache, CacheDeterminism, string, int, Dictionary <string, double> >(lowerVert.LocalCache, remoteDeterminism, lowerVert.LocalCache.CacheId, 1, null), new Tuple <ICache, CacheDeterminism, string, int, Dictionary <string, double> >(upperVert.LocalCache, remoteDeterminism, upperVert.LocalCache.CacheId, 1, null), new Tuple <ICache, CacheDeterminism, string, int, Dictionary <string, double> >(upperVert.RemoteCache, remoteDeterminism, upperVert.RemoteCache.CacheId, 1, null) }) { await ValidateItemsInCacheAsync( currentCache.Item1, cacheRecord.StrongFingerprint.WeakFingerprint, new List <CasHash>(cacheRecord.CasEntries), currentCache.Item2, cacheRecord.StrongFingerprint.CasElement, currentCache.Item3, currentCache.Item4); } await testCache.ShutdownAsync().SuccessAsync(); }
internal static void PoisonAllRemoteSessions(ICache cache) { Contract.Requires(cache is VerticalCacheAggregator); VerticalCacheAggregator vertCache = cache as VerticalCacheAggregator; CallbackCacheWrapper remoteCache = vertCache.RemoteCache as CallbackCacheWrapper; XAssert.IsNotNull(remoteCache); remoteCache.CreateNamedSessionAsyncCallback = async(string sessionId, ICache cacheInstance) => { ICacheSession session = await cacheInstance.CreateSessionAsync(sessionId).SuccessAsync(); CallbackCacheSessionWrapper wrappedSession = new CallbackCacheSessionWrapper(session); PoisonSession(wrappedSession); return(new BuildXL.Utilities.Possible <ICacheSession, BuildXL.Utilities.Failure>(session)); }; remoteCache.CreateSessionAsyncCallback = async(ICache cacheInstance) => { ICacheSession session = await cacheInstance.CreateSessionAsync().SuccessAsync(); CallbackCacheSessionWrapper wrappedSession = new CallbackCacheSessionWrapper(session); PoisonSession(wrappedSession); return(new BuildXL.Utilities.Possible <ICacheSession, BuildXL.Utilities.Failure>(session)); }; remoteCache.CreateReadOnlySessionAsyncCallback = async(ICache cacheInstance) => { ICacheReadOnlySession session = await cacheInstance.CreateReadOnlySessionAsync().SuccessAsync(); CallbackCacheReadOnlySessionWrapper wrappedSession = new CallbackCacheReadOnlySessionWrapper(session); PoisonROSession(wrappedSession); return(new BuildXL.Utilities.Possible <ICacheReadOnlySession, BuildXL.Utilities.Failure>(session)); }; remoteCache.CacheGuidGetCallback = (ICache wrappedcache) => { XAssert.Fail("Remote Cache was called when disconnected (CacheGuid)"); return(Guid.Empty); }; }