/// <summary> /// Constructor /// </summary> public MockHost(BuildParameters buildParameters) { _buildParameters = buildParameters; _buildParameters.ProjectRootElementCache = new ProjectRootElementCache(false); _configCache = new ConfigCache(); ((IBuildComponent)_configCache).InitializeComponent(this); // We are a logging service _loggingService = this; _legacyThreadingData = new LegacyThreadingData(); _requestEngine = new BuildRequestEngine(); ((IBuildComponent)_requestEngine).InitializeComponent(this); _resultsCache = new ResultsCache(); ((IBuildComponent)_resultsCache).InitializeComponent(this); _requestBuilder = new Microsoft.Build.UnitTests.BackEnd.BuildRequestEngine_Tests.MockRequestBuilder(); ((IBuildComponent)_requestBuilder).InitializeComponent(this); _targetBuilder = new TestTargetBuilder(); ((IBuildComponent)_targetBuilder).InitializeComponent(this); }
public void TestSimpleBuildRequest() { BuildRequestConfiguration configuration = CreateTestProject(1); try { TestTargetBuilder targetBuilder = (TestTargetBuilder)_host.GetComponent(BuildComponentType.TargetBuilder); IConfigCache configCache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache); configCache.AddConfiguration(configuration); BuildRequest request = CreateNewBuildRequest(1, new string[1] { "target1" }); BuildRequestEntry entry = new BuildRequestEntry(request, configuration); BuildResult result = new BuildResult(request); result.AddResultsForTarget("target1", GetEmptySuccessfulTargetResult()); targetBuilder.SetResultsToReturn(result); _requestBuilder.BuildRequest(GetNodeLoggingContext(), entry); WaitForEvent(_buildRequestCompletedEvent, "Build Request Completed"); Assert.Equal(BuildRequestEntryState.Complete, entry.State); Assert.Equal(entry, _buildRequestCompleted_Entry); Assert.Equal(BuildResultCode.Success, _buildRequestCompleted_Entry.Result.OverallResult); } finally { DeleteTestProject(configuration); } }
/// <summary> /// Cleanup /// </summary> public void ShutdownComponent() { // If the processor thread is still there then signal it to go away // Wait for QAMockHost.globalTimeOut seconds for the thread to go away or complete. If not then abort it. if (!this.processorThreadExited) { this.processorThreadExit.Set(); if (!this.processorThread.Join(QAMockHost.globalTimeOut)) { this.processorThread.Abort(); } this.processorThread = null; } // dispose all the definition object here. foreach (RequestDefinition definition in this.definitions.Values) { definition.Dispose(); } this.definitions.Clear(); this.newResults.Clear(); this.newRequests.Clear(); this.newConfigurations.Clear(); this.newRequests = null; this.newResults = null; this.newConfigurations = null; this.configurationCache = null; this.resultsCache = null; }
public void IfCacheSpecified_WillUseCachedValueIfPresent() { IConfigCache configCache = MockRepository.GenerateStub <IConfigCache>(); configCache.Stub(x => x.GetCachedValue("MyCachedConfigKey")).Return("MyCachedConfigValue"); CacheableConfigController sut = new CacheableConfigController(); sut.Cache = configCache; Queue <string> priority = new Queue <string>(); priority.Enqueue("FirstPlane"); sut.Priority = priority; sut.UpsertDefaultConfigValue("FirstPlane", "ConfigKey", "ConfigValue"); Dictionary <string, string> context = new Dictionary <string, string>(); context.Add("FirstPlane", "MyConfigContext"); sut.SearchContext = context; sut.GetConfigValue("ConfigKey"); string result = sut.GetConfigValue("MyCachedConfigKey"); Assert.That(result.Equals("MyCachedConfigValue", StringComparison.InvariantCulture)); }
public void GetCache_ReturnCurrentCache() { IConfigCache configCache = MockRepository.GenerateStub <IConfigCache>(); configCache.Stub(x => x.GetCachedValue("MyCachedConfigKey")).Return("MyCachedConfigValue"); CacheableConfigController sut = new CacheableConfigController(); sut.Cache = configCache; Queue <string> priority = new Queue <string>(); priority.Enqueue("FirstPlane"); sut.Priority = priority; sut.UpsertDefaultConfigValue("FirstPlane", "ConfigKey", "ConfigValue"); Dictionary <string, string> context = new Dictionary <string, string>(); context.Add("FirstPlane", "MyConfigContext"); sut.SearchContext = context; sut.GetConfigValue("ConfigKey"); string result = sut.GetConfigValue("MyCachedConfigKey"); IConfigCache cache = sut.Cache; Assert.IsNotNull(cache); }
/// <summary> /// The component is being initialized /// </summary> public void InitializeComponent(IBuildComponentHost host) { _host = host; _resultsCache = (IResultsCache)(_host.GetComponent(BuildComponentType.ResultsCache)); _configCache = (IConfigCache)(_host.GetComponent(BuildComponentType.ConfigCache)); _testDataProvider = (ITestDataProvider)(_host.GetComponent(BuildComponentType.TestDataProvider)); }
public CacheConfigManager( IConfigManager innerManager, IConfigCache cache) { this.configManager = innerManager ?? throw new ArgumentNullException(nameof(innerManager)); this.cache = cache; }
private void CleanupCaches() { IConfigCache configCache = _componentFactories.GetComponent(BuildComponentType.ConfigCache) as IConfigCache; if (null != configCache) { configCache.ClearConfigurations(); } IResultsCache resultsCache = _componentFactories.GetComponent(BuildComponentType.ResultsCache) as IResultsCache; if (null != resultsCache) { resultsCache.ClearResults(); } if (Environment.GetEnvironmentVariable("MSBUILDCLEARXMLCACHEONCHILDNODES") == "1") { // Optionally clear out the cache. This has the advantage of releasing memory, // but the disadvantage of causing the next build to repeat the load and parse. // We'll experiment here and ship with the best default. s_projectRootElementCache = null; } // Since we aren't going to be doing any more work, lets clean up all our memory usage. GC.Collect(); }
/// <summary> /// Constructor /// </summary> public MockHost(BuildParameters buildParameters) { _buildParameters = buildParameters; _buildParameters.ProjectRootElementCache = new ProjectRootElementCache(false); _configCache = new ConfigCache(); ((IBuildComponent)_configCache).InitializeComponent(this); // We are a logging service _loggingService = this; _legacyThreadingData = new LegacyThreadingData(); _requestEngine = new BuildRequestEngine(); ((IBuildComponent)_requestEngine).InitializeComponent(this); _resultsCache = new ResultsCache(); ((IBuildComponent)_resultsCache).InitializeComponent(this); _requestBuilder = new Microsoft.Build.UnitTests.BackEnd.BuildRequestEngine_Tests.MockRequestBuilder(); ((IBuildComponent)_requestBuilder).InitializeComponent(this); _targetBuilder = new TestTargetBuilder(); ((IBuildComponent)_targetBuilder).InitializeComponent(this); }
/// <summary> /// The component is being initialized /// </summary> public void InitializeComponent(IBuildComponentHost host) { this.host = host; this.resultsCache = (IResultsCache)(this.host.GetComponent(BuildComponentType.ResultsCache)); this.configCache = (IConfigCache)(this.host.GetComponent(BuildComponentType.ConfigCache)); this.testDataProvider = (ITestDataProvider)(this.host.GetComponent(BuildComponentType.TestDataProvider)); }
/// <summary> /// Constructor. /// </summary> public OutOfProcNode( #if !FEATURE_NAMED_PIPES_FULL_DUPLEX string clientToServerPipeHandle, string serverToClientPipeHandle #endif ) { s_isOutOfProcNode = true; #if FEATURE_APPDOMAIN_UNHANDLED_EXCEPTION AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler); #endif #if !FEATURE_NAMED_PIPES_FULL_DUPLEX _clientToServerPipeHandle = clientToServerPipeHandle; _serverToClientPipeHandle = serverToClientPipeHandle; #endif _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1"); _receivedPackets = new ConcurrentQueue <INodePacket>(); _packetReceivedEvent = new AutoResetEvent(false); _shutdownEvent = new ManualResetEvent(false); _legacyThreadingData = new LegacyThreadingData(); _componentFactories = new BuildComponentFactoryCollection(this); _componentFactories.RegisterDefaultFactories(); _packetFactory = new NodePacketFactory(); _buildRequestEngine = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine; _globalConfigCache = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache; _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager; // Create a factory for the out-of-proc SDK resolver service which can pass our SendPacket delegate to be used for sending packets to the main node OutOfProcNodeSdkResolverServiceFactory sdkResolverServiceFactory = new OutOfProcNodeSdkResolverServiceFactory(SendPacket); ((IBuildComponentHost)this).RegisterFactory(BuildComponentType.SdkResolverService, sdkResolverServiceFactory.CreateInstance); _sdkResolverService = (this as IBuildComponentHost).GetComponent(BuildComponentType.SdkResolverService) as ISdkResolverService; if (s_projectRootElementCache == null) { s_projectRootElementCache = new ProjectRootElementCache(true /* automatically reload any changes from disk */); } _buildRequestEngine.OnEngineException += new EngineExceptionDelegate(OnEngineException); _buildRequestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(OnNewConfigurationRequest); _buildRequestEngine.OnRequestBlocked += new RequestBlockedDelegate(OnNewRequest); _buildRequestEngine.OnRequestComplete += new RequestCompleteDelegate(OnRequestComplete); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResolveSdkResponse, SdkResolverResponse.FactoryForDeserialization, _sdkResolverService as INodePacketHandler); }
protected ConfigServiceBase(IConfigFetcher configFetcher, IConfigCache configCache, ILogger log) { this.configFetcher = configFetcher; this.configCache = configCache; this.log = log; }
internal AutoPollConfigService( IConfigFetcher configFetcher, IConfigCache configCache, TimeSpan pollingInterval, TimeSpan maxInitWaitTime, ILoggerFactory loggerFactory) : this(configFetcher, configCache, pollingInterval, maxInitWaitTime, loggerFactory, true) { }
protected ConfigServiceBase(IConfigFetcher configFetcher, CacheParameters cacheParameters, ILogger log) { this.configFetcher = configFetcher; this.configCache = cacheParameters.ConfigCache; this.cacheKey = cacheParameters.CacheKey; this.log = log; }
internal AutoPollConfigService( IConfigFetcher configFetcher, IConfigCache configCache, TimeSpan pollingInterval, TimeSpan maxInitWaitTime, ILoggerFactory loggerFactory) : base(configFetcher, configCache, loggerFactory.GetLogger(nameof(AutoPollConfigService))) { this.timer = new Timer(RefreshLogic, "auto", TimeSpan.Zero, pollingInterval); this.maxInitWaitExpire = DateTime.UtcNow.Add(maxInitWaitTime); }
/// <summary> /// Constructor that takes in nothing. /// </summary> public QARequestBuilder() { _host = null; _configCache = null; _resultsCache = null; _builderThread = null; _requestedEntry = null; _cancelEvent = new AutoResetEvent(false); _continueEvent = new AutoResetEvent(false); _threadStarted = new ManualResetEvent(false); _currentProjectDefinition = null; }
/// <summary> /// Constructor that takes in nothing. /// </summary> public QARequestBuilder() { this.host = null; this.configCache = null; this.resultsCache = null; this.builderThread = null; this.requestedEntry = null; this.cancelEvent = new AutoResetEvent(false); this.continueEvent = new AutoResetEvent(false); this.threadStarted = new ManualResetEvent(false); this.currentProjectDefinition = null; }
/// <summary> /// Creates a new BuildRequestDefinition cache. /// </summary> public TestDataProvider() { this.definitions = new Dictionary <int, RequestDefinition>(); this.configurationCache = null; this.key = 2; this.newConfigurations = new Queue <BuildRequestConfiguration>(); this.newRequests = new Queue <BuildRequest>(); this.newResults = new Queue <ResultFromEngine>(); this.engineException = null; this.processorThreadResume = new AutoResetEvent(false); this.processorThreadExit = new AutoResetEvent(false); this.processorThreadExited = false; this.processorThread = new Thread(ProcessorThreadProc); this.processorThread.Name = "Test Data provider processor thread"; this.processorThread.Start(); }
public void TestRequestWithReferenceCancelled() { BuildRequestConfiguration configuration = CreateTestProject(1); try { TestTargetBuilder targetBuilder = (TestTargetBuilder)_host.GetComponent(BuildComponentType.TargetBuilder); IConfigCache configCache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache); FullyQualifiedBuildRequest[] newRequest = new FullyQualifiedBuildRequest[1] { new FullyQualifiedBuildRequest(configuration, new string[1] { "testTarget2" }, true) }; targetBuilder.SetNewBuildRequests(newRequest); configCache.AddConfiguration(configuration); BuildRequest request = CreateNewBuildRequest(1, new string[1] { "target1" }); BuildRequestEntry entry = new BuildRequestEntry(request, configuration); BuildResult result = new BuildResult(request); result.AddResultsForTarget("target1", GetEmptySuccessfulTargetResult()); targetBuilder.SetResultsToReturn(result); _requestBuilder.BuildRequest(GetNodeLoggingContext(), entry); WaitForEvent(_newBuildRequestsEvent, "New Build Requests"); Assert.Equal(_newBuildRequests_Entry, entry); ObjectModelHelpers.AssertArrayContentsMatch(_newBuildRequests_FQRequests, newRequest); BuildResult newResult = new BuildResult(_newBuildRequests_BuildRequests[0]); newResult.AddResultsForTarget("testTarget2", GetEmptySuccessfulTargetResult()); entry.ReportResult(newResult); _requestBuilder.ContinueRequest(); Thread.Sleep(500); _requestBuilder.CancelRequest(); WaitForEvent(_buildRequestCompletedEvent, "Build Request Completed"); Assert.Equal(BuildRequestEntryState.Complete, entry.State); Assert.Equal(entry, _buildRequestCompleted_Entry); Assert.Equal(BuildResultCode.Failure, _buildRequestCompleted_Entry.Result.OverallResult); } finally { DeleteTestProject(configuration); } }
public void IfCacheSpecified_ChangingContextClearsCache() { IConfigCache configCache = MockRepository.GenerateStub <IConfigCache>(); CacheableConfigController sut = new CacheableConfigController(); sut.Cache = configCache; Queue <string> priority = new Queue <string>(); priority.Enqueue("FirstPlane"); configCache.AssertWasNotCalled(x => x.ClearCache()); sut.SetContext(new Dictionary <string, string>()); configCache.AssertWasCalled(x => x.ClearCache()); }
public void IfCacheSpecified_UpsertingConfigValueClearsCache() { IConfigCache configCache = MockRepository.GenerateStub <IConfigCache>(); CacheableConfigController sut = new CacheableConfigController(); sut.Cache = configCache; Queue <string> priority = new Queue <string>(); priority.Enqueue("FirstPlane"); configCache.AssertWasNotCalled(x => x.ClearCache()); sut.UpsertDefaultConfigValue("FirstPlane", "ConfigKey", "ConfigValue"); configCache.AssertWasCalled(x => x.ClearCache()); }
public BuildRequestEngine_Tests() { _host = new MockHost(); _nodeRequestId = 1; _globalRequestId = 1; _engineStatusChangedEvent = new AutoResetEvent(false); _requestCompleteEvent = new AutoResetEvent(false); _requestResumedEvent = new AutoResetEvent(false); _newRequestEvent = new AutoResetEvent(false); _newConfigurationEvent = new AutoResetEvent(false); _engineExceptionEvent = new AutoResetEvent(false); _engine = (IBuildRequestEngine)_host.GetComponent(BuildComponentType.RequestEngine); _cache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache); ConfigureEngine(_engine); }
/// <summary> /// Constructor. /// </summary> public OutOfProcNode() { s_isOutOfProcNode = true; _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1"); _receivedPackets = new ConcurrentQueue <INodePacket>(); _packetReceivedEvent = new AutoResetEvent(false); _shutdownEvent = new ManualResetEvent(false); _legacyThreadingData = new LegacyThreadingData(); _componentFactories = new BuildComponentFactoryCollection(this); _componentFactories.RegisterDefaultFactories(); _packetFactory = new NodePacketFactory(); _buildRequestEngine = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine; _globalConfigCache = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache; _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager; // Create a factory for the out-of-proc SDK resolver service which can pass our SendPacket delegate to be used for sending packets to the main node OutOfProcNodeSdkResolverServiceFactory sdkResolverServiceFactory = new OutOfProcNodeSdkResolverServiceFactory(SendPacket); ((IBuildComponentHost)this).RegisterFactory(BuildComponentType.SdkResolverService, sdkResolverServiceFactory.CreateInstance); _sdkResolverService = (this as IBuildComponentHost).GetComponent(BuildComponentType.SdkResolverService) as ISdkResolverService; if (s_projectRootElementCacheBase == null) { s_projectRootElementCacheBase = new ProjectRootElementCache(true /* automatically reload any changes from disk */); } _buildRequestEngine.OnEngineException += OnEngineException; _buildRequestEngine.OnNewConfigurationRequest += OnNewConfigurationRequest; _buildRequestEngine.OnRequestBlocked += OnNewRequest; _buildRequestEngine.OnRequestComplete += OnRequestComplete; _buildRequestEngine.OnResourceRequest += OnResourceRequest; (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResourceResponse, ResourceResponse.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResolveSdkResponse, SdkResult.FactoryForDeserialization, _sdkResolverService as INodePacketHandler); }
private void NewBuildRequestsCallback(BuildRequestEntry entry, FullyQualifiedBuildRequest[] requests) { _newBuildRequests_FQRequests = requests; _newBuildRequests_BuildRequests = new BuildRequest[requests.Length]; _newBuildRequests_Entry = entry; int index = 0; foreach (FullyQualifiedBuildRequest request in requests) { IConfigCache configCache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache); BuildRequestConfiguration matchingConfig = configCache.GetMatchingConfiguration(request.Config); BuildRequest newRequest = CreateNewBuildRequest(matchingConfig.ConfigurationId, request.Targets); entry.WaitForResult(newRequest); _newBuildRequests_BuildRequests[index++] = newRequest; } _newBuildRequestsEvent.Set(); }
public void TestMissingProjectFile() { TestTargetBuilder targetBuilder = (TestTargetBuilder)_host.GetComponent(BuildComponentType.TargetBuilder); IConfigCache configCache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache); BuildRequestConfiguration configuration = new BuildRequestConfiguration(1, new BuildRequestData("testName", new Dictionary <string, string>(), "3.5", Array.Empty <string>(), null), "2.0"); configCache.AddConfiguration(configuration); BuildRequest request = CreateNewBuildRequest(1, new string[1] { "target1" }); BuildRequestEntry entry = new BuildRequestEntry(request, configuration); _requestBuilder.BuildRequest(GetNodeLoggingContext(), entry); WaitForEvent(_buildRequestCompletedEvent, "Build Request Completed"); Assert.Equal(BuildRequestEntryState.Complete, entry.State); Assert.Equal(entry, _buildRequestCompleted_Entry); Assert.Equal(BuildResultCode.Failure, _buildRequestCompleted_Entry.Result.OverallResult); Assert.Equal(typeof(InvalidProjectFileException), _buildRequestCompleted_Entry.Result.Exception.GetType()); }
/// <summary> /// Constructor /// /// UNDONE: Refactor this, and the other MockHosts, to use a common base implementation. The duplication of the /// logging implementation alone is unfortunate. /// </summary> public MockHost() { _buildParameters = new BuildParameters(); _legacyThreadingData = new LegacyThreadingData(); _configCache = new ConfigCache(); ((IBuildComponent)_configCache).InitializeComponent(this); _loggingService = this; _resultsCache = new ResultsCache(); ((IBuildComponent)_resultsCache).InitializeComponent(this); _requestBuilder = new RequestBuilder(); ((IBuildComponent)_requestBuilder).InitializeComponent(this); _targetBuilder = new TargetBuilder(); ((IBuildComponent)_targetBuilder).InitializeComponent(this); _sdkResolverService = new MockSdkResolverService(); ((IBuildComponent)_sdkResolverService).InitializeComponent(this); }
/// <summary> /// Constructor. /// </summary> public OutOfProcNode() { s_isOutOfProcNode = true; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler); _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1"); _receivedPackets = new Queue <INodePacket>(); _packetReceivedEvent = new AutoResetEvent(false); _shutdownEvent = new ManualResetEvent(false); _legacyThreadingData = new LegacyThreadingData(); _componentFactories = new BuildComponentFactoryCollection(this); _componentFactories.RegisterDefaultFactories(); _packetFactory = new NodePacketFactory(); _buildRequestEngine = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine; _globalConfigCache = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache; _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager; if (s_projectRootElementCache == null) { s_projectRootElementCache = new ProjectRootElementCache(true /* automatically reload any changes from disk */); } _buildRequestEngine.OnEngineException += new EngineExceptionDelegate(OnEngineException); _buildRequestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(OnNewConfigurationRequest); _buildRequestEngine.OnRequestBlocked += new RequestBlockedDelegate(OnNewRequest); _buildRequestEngine.OnRequestComplete += new RequestCompleteDelegate(OnRequestComplete); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this); }
/// <summary> /// Returns the number of configurations assigned to the specified node. /// </summary> public int GetConfigurationsCountByNode(int nodeId, bool excludeTraversals, IConfigCache configCache) { HashSet <int> configurationsAssignedToNode; if (!_configurationsByNode.TryGetValue(nodeId, out configurationsAssignedToNode)) { return(0); } int excludeCount = 0; if (excludeTraversals && (configCache != null)) { foreach (int config in configurationsAssignedToNode) { if (configCache[config].IsTraversal) { excludeCount++; } } } return(configurationsAssignedToNode.Count - excludeCount); }
public void IfCacheSpecified_AReadResultsInKeyValueWrittenToCache() { IConfigCache configCache = MockRepository.GenerateStub <IConfigCache>(); CacheableConfigController sut = new CacheableConfigController(); sut.Cache = configCache; Queue <string> priority = new Queue <string>(); priority.Enqueue("FirstPlane"); sut.Priority = priority; sut.UpsertDefaultConfigValue("FirstPlane", "ConfigKey", "ConfigValue"); Dictionary <string, string> context = new Dictionary <string, string>(); context.Add("FirstPlane", "MyConfigContext"); sut.SearchContext = context; sut.GetConfigValue("ConfigKey"); configCache.AssertWasCalled(x => x.CacheInsert(Arg <string> .Is.Equal("ConfigKey"), Arg <string> .Is.Equal("ConfigValue"))); }
/// <summary> /// Initializes the component with the specified component host. /// </summary> /// <param name="host">The component host.</param> public void InitializeComponent(IBuildComponentHost host) { _componentHost = host; _resultsCache = (IResultsCache)_componentHost.GetComponent(BuildComponentType.ResultsCache); _configCache = (IConfigCache)_componentHost.GetComponent(BuildComponentType.ConfigCache); }
/// <summary> /// Constructor /// /// UNDONE: Refactor this, and the other MockHosts, to use a common base implementation. The duplication of the /// logging implementation alone is unfortunate. /// </summary> public MockHost() { _buildParameters = new BuildParameters(); _legacyThreadingData = new LegacyThreadingData(); _configCache = new ConfigCache(); ((IBuildComponent)_configCache).InitializeComponent(this); _loggingService = this; _resultsCache = new ResultsCache(); ((IBuildComponent)_resultsCache).InitializeComponent(this); _requestBuilder = new RequestBuilder(); ((IBuildComponent)_requestBuilder).InitializeComponent(this); _targetBuilder = new TargetBuilder(); ((IBuildComponent)_targetBuilder).InitializeComponent(this); }
internal ManualPollConfigService(IConfigFetcher configFetcher, IConfigCache configCache, ILoggerFactory loggerFactory) : base(configFetcher, configCache, loggerFactory.GetLogger(nameof(ManualPollConfigService))) { }
/// <summary> /// Constructor. /// </summary> public SchedulingPlan(IConfigCache configCache, SchedulingData schedulingData) { _configCache = configCache; _schedulingData = schedulingData; this.MaximumConfigurationId = BuildRequestConfiguration.InvalidConfigurationId; }
/// <summary> /// Constructor. /// </summary> public OutOfProcNode() { s_isOutOfProcNode = true; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler); _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1"); _receivedPackets = new Queue<INodePacket>(); _packetReceivedEvent = new AutoResetEvent(false); _shutdownEvent = new ManualResetEvent(false); _legacyThreadingData = new LegacyThreadingData(); _componentFactories = new BuildComponentFactoryCollection(this); _componentFactories.RegisterDefaultFactories(); _packetFactory = new NodePacketFactory(); _buildRequestEngine = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine; _globalConfigCache = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache; _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager; if (s_projectRootElementCache == null) { s_projectRootElementCache = new ProjectRootElementCache(true /* automatically reload any changes from disk */); } _buildRequestEngine.OnEngineException += new EngineExceptionDelegate(OnEngineException); _buildRequestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(OnNewConfigurationRequest); _buildRequestEngine.OnRequestBlocked += new RequestBlockedDelegate(OnNewRequest); _buildRequestEngine.OnRequestComplete += new RequestCompleteDelegate(OnRequestComplete); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this); }
/// <summary> /// Returns the number of configurations assigned to the specified node. /// </summary> public int GetConfigurationsCountByNode(int nodeId, bool excludeTraversals, IConfigCache configCache) { HashSet<int> configurationsAssignedToNode; if (!_configurationsByNode.TryGetValue(nodeId, out configurationsAssignedToNode)) { return 0; } int excludeCount = 0; if (excludeTraversals && (configCache != null)) { foreach (int config in configurationsAssignedToNode) { if (configCache[config].IsTraversal) { excludeCount++; } } } return configurationsAssignedToNode.Count - excludeCount; }
public ConfigCacheWithOverride(IConfigCache @override) { _override = @override; CurrentCache = new ConfigCache(); }
/// <summary> /// The component is being initialized /// </summary> public void InitializeComponent(IBuildComponentHost host) { this.host = host; this.resultsCache = (IResultsCache)(this.host.GetComponent(BuildComponentType.ResultsCache)); this.configCache = (IConfigCache)(this.host.GetComponent(BuildComponentType.ConfigCache)); this.testDataProvider = (ITestDataProvider)(this.host.GetComponent(BuildComponentType.TestDataProvider)); }
/// <summary> /// Sets the build component host for this object. /// </summary> /// <param name="host">The host.</param> public void InitializeComponent(IBuildComponentHost host) { ErrorUtilities.VerifyThrowArgumentNull(host, "host"); ErrorUtilities.VerifyThrow(_componentHost == null, "BuildRequestEngine already initialized!"); _componentHost = host; _configCache = (IConfigCache)host.GetComponent(BuildComponentType.ConfigCache); // Create a local configuration cache which is used to temporarily hold configurations which don't have // proper IDs yet. We don't get this from the global config cache because that singleton shouldn't be polluted // with our temporaries. // NOTE: Because we don't get this from the component host, we cannot override it. ConfigCache unresolvedConfigCache = new ConfigCache(); unresolvedConfigCache.InitializeComponent(host); _unresolvedConfigurations = unresolvedConfigCache; }
/// <summary> /// The component is being initialized /// </summary> public void InitializeComponent(IBuildComponentHost host) { _host = host; _resultsCache = (IResultsCache)(_host.GetComponent(BuildComponentType.ResultsCache)); _configCache = (IConfigCache)(_host.GetComponent(BuildComponentType.ConfigCache)); _testDataProvider = (ITestDataProvider)(_host.GetComponent(BuildComponentType.TestDataProvider)); }
/// <summary> /// Creates a new BuildRequestDefinition cache. /// </summary> public TestDataProvider() { this.definitions = new Dictionary<int, RequestDefinition>(); this.configurationCache = null; this.key = 2; this.newConfigurations = new Queue<BuildRequestConfiguration>(); this.newRequests = new Queue<BuildRequest>(); this.newResults = new Queue<ResultFromEngine>(); this.engineException = null; this.processorThreadResume = new AutoResetEvent(false); this.processorThreadExit = new AutoResetEvent(false); this.processorThreadExited = false; this.processorThread = new Thread(ProcessorThreadProc); this.processorThread.Name = "Test Data provider processor thread"; this.processorThread.Start(); }
/// <summary> /// Cleanup /// </summary> public void ShutdownComponent() { // If the processor thread is still there then signal it to go away // Wait for QAMockHost.globalTimeOut seconds for the thread to go away or complete. If not then abort it. if (!this.processorThreadExited) { this.processorThreadExit.Set(); if(!this.processorThread.Join(QAMockHost.globalTimeOut)) { this.processorThread.Abort(); } this.processorThread = null; } // dispose all the definition object here. foreach (RequestDefinition definition in this.definitions.Values) { definition.Dispose(); } this.definitions.Clear(); this.newResults.Clear(); this.newRequests.Clear(); this.newConfigurations.Clear(); this.newRequests = null; this.newResults = null; this.newConfigurations = null; this.configurationCache = null; this.resultsCache = null; }
/// <summary> /// Save the configuration cache information from the host /// </summary> public void InitializeComponent(IBuildComponentHost host) { this.configurationCache = (IConfigCache)host.GetComponent(BuildComponentType.ConfigCache); this.resultsCache = (IResultsCache)host.GetComponent(BuildComponentType.ResultsCache); }
/// <summary> /// Constructor. /// </summary> public SchedulingPlan(IConfigCache configCache, SchedulingData schedulingData) { _configCache = configCache; _schedulingData = schedulingData; this.MaximumConfigurationId = BuildRequestConfiguration.InvalidConfigurationId; }
public BuildRequestEngine_Tests() { _host = new MockHost(); _nodeRequestId = 1; _globalRequestId = 1; _engineStatusChangedEvent = new AutoResetEvent(false); _requestCompleteEvent = new AutoResetEvent(false); _requestResumedEvent = new AutoResetEvent(false); _newRequestEvent = new AutoResetEvent(false); _newConfigurationEvent = new AutoResetEvent(false); _engineExceptionEvent = new AutoResetEvent(false); _engine = (IBuildRequestEngine)_host.GetComponent(BuildComponentType.RequestEngine); _cache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache); ConfigureEngine(_engine); }