Example #1
0
        public async Task FailToCreateL2CacheWorks()
        {
            const string TestName    = "FailToCreateL2CacheWorks";
            string       testCacheId = MakeCacheId(TestName);

            string localConfig  = new TestInMemory().NewCache(testCacheId + VerticalAggregatorBaseTests.LocalMarker, false);
            string remoteConfig = new TestInMemory().NewCacheFailure(testCacheId + VerticalAggregatorBaseTests.RemoteMarker, true, authoritative: true);

            string cacheConfigData = VerticalAggregatorBaseTests.NewCacheString(testCacheId, localConfig, remoteConfig, false, false, false, false);

            ICache cache = await InitializeCacheAsync(cacheConfigData).SuccessAsync();

            bool   warningSent     = false;
            string warningMessage  = string.Empty;
            string expectedWarning = string.Format(System.Globalization.CultureInfo.InvariantCulture, VerticalCacheAggregatorFactory.RemoteConstructionFailureWarning, testCacheId + VerticalAggregatorBaseTests.LocalMarker);

            cache.SuscribeForCacheStateDegredationFailures((failure) => { warningSent    = true;
                                                                          warningMessage = failure.Describe(); });

            XAssert.IsTrue(warningSent);

            XAssert.IsNull(cache as VerticalCacheAggregator, "We should have eliminated the VerticalCacheAggregator as there is only 1 operating cache");

            XAssert.AreEqual(expectedWarning, warningMessage);

            await cache.ShutdownAsync().SuccessAsync();
        }
Example #2
0
        public override string NewCache(string cacheId, bool strictMetadataCasCoupling, bool authoritative = false)
        {
            TestInMemory memoryCache = new TestInMemory();

            string memoryString = memoryCache.NewCache(cacheId, strictMetadataCasCoupling);

            return(FormatNewCacheConfig(memoryString));
        }
Example #3
0
        public override string NewCache(string cacheId, bool strictMetadataCasCoupling, bool authoritative = false)
        {
            string localConfig  = new TestInMemory().NewCache(cacheId + VerticalAggregatorBaseTests.LocalMarker, false);
            string remoteConfig = new TestInMemory().NewCache(cacheId + VerticalAggregatorBaseTests.RemoteMarker, true, authoritative: true);

            string configString = VerticalAggregatorBaseTests.NewCacheString(cacheId, localConfig, remoteConfig, false, false, false);

            return(configString);
        }
Example #4
0
        /// <summary>
        /// Returns the config string for a VerticalCacheAggregator that has a local cache wrapped by the CallbackCacheWrapper using the InMemoryCache as the local and remote
        /// backing stores
        /// </summary>
        /// <param name="cacheId">Id of the cache.</param>
        /// <param name="strictMetadataCasCoupling">If the cache should require a strick metadata CAS coupling.</param>
        /// <param name="writeThroughCasData">If the VerticalAggregator should force write through of CAS data.</param>
        /// <returns>A VerticalCacheAggregator </returns>
        internal static string NewWrappedLocalCache(string cacheId, bool strictMetadataCasCoupling, bool writeThroughCasData)
        {
            TestInMemory memTests          = new TestInMemory();
            string       localCacheString  = memTests.NewCache(cacheId + VerticalAggregatorBaseTests.LocalMarker, strictMetadataCasCoupling);
            string       remoteCacheString = memTests.NewCache(cacheId + VerticalAggregatorBaseTests.RemoteMarker, strictMetadataCasCoupling, authoritative: true);

            localCacheString = TestCallbackCache.FormatNewCacheConfig(localCacheString);

            string vertCacheConfig = VerticalAggregatorBaseTests.NewCacheString(cacheId, localCacheString, remoteCacheString, false, false, writeThroughCasData);

            return(vertCacheConfig);
        }
Example #5
0
        public async Task FailToCreateL2CacheFails()
        {
            const string TestName    = "FailToCreateL2CacheFails";
            string       testCacheId = MakeCacheId(TestName);

            string localConfig  = new TestInMemory().NewCache(testCacheId + VerticalAggregatorBaseTests.LocalMarker, false);
            string remoteConfig = new TestInMemory().NewCacheFailure(testCacheId + VerticalAggregatorBaseTests.RemoteMarker, true, authoritative: true);

            string cacheConfigData = VerticalAggregatorBaseTests.NewCacheString(testCacheId, localConfig, remoteConfig, false, false, false, true);

            Possible <ICache, Failure> cachePossible = await InitializeCacheAsync(cacheConfigData);

            XAssert.IsFalse(cachePossible.Succeeded, "This should have failed cache construction");
        }
Example #6
0
        public override string NewCache(string cacheId, bool strictMetadataCasCoupling, bool authoritative = false)
        {
            TestInMemory memory = new TestInMemory();

            return(string.Format(compositingCacheConfigJSONData, cacheId, strictMetadataCasCoupling.ToString().ToLower(), memory.NewCache(cacheId + "Metadata", false), memory.NewCache(cacheId + "CAS", false)));
        }