public void CacheServiceWrapperConstructor_Test() { ICacheService cacheService = new Mock <ICacheService>().Object; const string @namespace = "Test"; var target = new CacheServiceWrapper(cacheService, @namespace); Assert.IsNotNull(target); }
/// <summary> /// Creates a cache server. /// </summary> /// <remarks> /// Currently it can be one of the following: /// * Launcher that will download configured bits and start them. /// * Out-of-proc launcher that will start the current bits in a separate process. /// * In-proc distributed cache service. /// * In-proc local cache service. /// </remarks> public async Task <StartupShutdownBase> CreateAsync(OperationContext operationContext) { var cacheConfig = _arguments.Configuration; if (IsLauncherEnabled(cacheConfig)) { _tracer.Debug(operationContext, $"Creating a launcher."); return(await CreateLauncherAsync(cacheConfig)); } var distributedSettings = cacheConfig.DistributedContentSettings; if (IsOutOfProcCacheEnabled(cacheConfig)) { _tracer.Debug(operationContext, $"Creating an out-of-proc cache service."); var outOfProcCache = await CacheServiceWrapper.CreateAsync(_arguments); if (outOfProcCache.Succeeded) { return(outOfProcCache.Value); } // Tracing and falling back to the in-proc cache _tracer.Error(operationContext, $"Failed to create out of proc cache: {outOfProcCache}. Using in-proc cache instead."); } _tracer.Debug(operationContext, "Creating an in-proc cache service."); cacheConfig.LocalCasSettings = cacheConfig.LocalCasSettings.FilterUnsupportedNamedCaches(_arguments.HostInfo.Capabilities, _logger); var isLocal = distributedSettings == null || !distributedSettings.IsDistributedContentEnabled; if (distributedSettings is not null) { LogManager.Update(distributedSettings.LogManager); } var serviceConfiguration = CreateServiceConfiguration( _logger, _fileSystem, cacheConfig.LocalCasSettings, distributedSettings, new AbsolutePath(_arguments.DataRootPath), isDistributed: !isLocal); var localServerConfiguration = CreateLocalServerConfiguration(cacheConfig.LocalCasSettings.ServiceSettings, serviceConfiguration, distributedSettings); // Initialization of the GrpcEnvironment is nasty business: we have a wrapper class around the internal // state. The internal state has a flag inside that marks whether it's been initialized or not. If we do // any Grpc activity, the internal state will be initialized, and all further attempts to change things // will throw. Since we may need to initialize a Grpc client before we do a Grpc server, this means we // need to call this early, even if it doesn't have anything to do with what's going on here. GrpcEnvironment.Initialize(_logger, localServerConfiguration.GrpcEnvironmentOptions, overwriteSafeOptions: true); if (isLocal) { // In practice, we don't really pass in a null distributedSettings. Hence, we'll enable the metadata // store whenever its set to true. This can only happen in the Application verb, because the Service // verb doesn't change the defaults. return(CreateLocalServer(localServerConfiguration, distributedSettings)); } else { return(CreateDistributedServer(localServerConfiguration, distributedSettings)); } }
public void CacheServiceWrapperConstructor_ExpectedExceptionTest1() { var c = new CacheServiceWrapper(new Mock <ICacheService>().Object, string.Empty); }
public void CacheServiceWrapperConstructor_ExpectedExceptionTest() { var c = new CacheServiceWrapper(null, string.Empty); }