public void TestConstructor() { BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(0, 0, 0); BuildRequestConfigurationResponse response2 = new BuildRequestConfigurationResponse(0, 1, 0); BuildRequestConfigurationResponse response3 = new BuildRequestConfigurationResponse(0, -1, 0); BuildRequestConfigurationResponse response4 = new BuildRequestConfigurationResponse(1, 0, 0); BuildRequestConfigurationResponse response5 = new BuildRequestConfigurationResponse(1, 1, 0); BuildRequestConfigurationResponse response6 = new BuildRequestConfigurationResponse(1, -1, 0); BuildRequestConfigurationResponse response7 = new BuildRequestConfigurationResponse(-1, 0, 0); BuildRequestConfigurationResponse response8 = new BuildRequestConfigurationResponse(-1, 1, 0); BuildRequestConfigurationResponse response9 = new BuildRequestConfigurationResponse(-1, -1, 0); BuildRequestConfigurationResponse response10 = new BuildRequestConfigurationResponse(0, 0, 1); BuildRequestConfigurationResponse response11 = new BuildRequestConfigurationResponse(0, 1, 0); BuildRequestConfigurationResponse response12 = new BuildRequestConfigurationResponse(0, -1, -1); BuildRequestConfigurationResponse response13 = new BuildRequestConfigurationResponse(1, 0, 1); BuildRequestConfigurationResponse response14 = new BuildRequestConfigurationResponse(1, 1, 0); BuildRequestConfigurationResponse response15 = new BuildRequestConfigurationResponse(1, -1, -1); BuildRequestConfigurationResponse response16 = new BuildRequestConfigurationResponse(-1, 0, 1); BuildRequestConfigurationResponse response17 = new BuildRequestConfigurationResponse(-1, 1, 0); BuildRequestConfigurationResponse response18 = new BuildRequestConfigurationResponse(-1, -1, -1); }
/// <summary> /// Handles the BuildRequestConfigurationResponse packet. /// </summary> private void HandleBuildRequestConfigurationResponse(BuildRequestConfigurationResponse response) { _buildRequestEngine.ReportConfigurationResponse(response); }
/// <summary> /// Reports a configuration response to the request, allowing it to satisfy outstanding requests. /// <seealso cref="BuildRequestConfigurationResponse"/> /// </summary> /// <param name="response">The configuration response.</param> /// <remarks> /// Called by the Node. Non-overlapping with other calls from the Node. /// </remarks> public void ReportConfigurationResponse(BuildRequestConfigurationResponse response) { QueueAction( () => { ErrorUtilities.VerifyThrow(_status != BuildRequestEngineStatus.Shutdown && _status != BuildRequestEngineStatus.Uninitialized, "Engine loop not yet started, status is {0}.", _status); TraceEngine("Received configuration response for node config {0}, now global config {1}.", response.NodeConfigurationId, response.GlobalConfigurationId); ErrorUtilities.VerifyThrow(_componentHost != null, "No host object set"); // Remove the unresolved configuration entry from the unresolved cache. BuildRequestConfiguration config = _unresolvedConfigurations[response.NodeConfigurationId]; _unresolvedConfigurations.RemoveConfiguration(response.NodeConfigurationId); // Add the configuration to the resolved cache unless it already exists there. This will be // the case in single-proc mode as we share the global cache with the Build Manager. IConfigCache globalConfigurations = (IConfigCache)_componentHost.GetComponent(BuildComponentType.ConfigCache); if (!globalConfigurations.HasConfiguration(response.GlobalConfigurationId)) { config.ConfigurationId = response.GlobalConfigurationId; config.ResultsNodeId = response.ResultsNodeId; globalConfigurations.AddConfiguration(config); } // Evaluate the current list of requests and tell any waiting requests about our new configuration update. // If any requests can now issue build requests, do so. IResultsCache resultsCache = (IResultsCache)_componentHost.GetComponent(BuildComponentType.ResultsCache); List<BuildRequestBlocker> blockersToIssue = new List<BuildRequestBlocker>(); foreach (BuildRequestEntry currentEntry in _requests) { List<BuildRequest> requestsToIssue = new List<BuildRequest>(); if (currentEntry.State == BuildRequestEntryState.Waiting) { // Resolve the configuration id and get the list of requests to be issued, if any. bool issueRequests = currentEntry.ResolveConfigurationRequest(response.NodeConfigurationId, response.GlobalConfigurationId); // If we had any requests which are now ready to be issued, do so. if (issueRequests) { IEnumerable<BuildRequest> resolvedRequests = currentEntry.GetRequestsToIssueIfReady(); foreach (BuildRequest request in resolvedRequests) { // If we have results already in the cache for this request, give them to the // entry now. ResultsCacheResponse cacheResponse = resultsCache.SatisfyRequest(request, config.ProjectInitialTargets, config.ProjectDefaultTargets, config.GetAfterTargetsForDefaultTargets(request), skippedResultsAreOK: false); if (cacheResponse.Type == ResultsCacheResponseType.Satisfied) { // We have a result, give it back to this request. currentEntry.ReportResult(cacheResponse.Results); } else { requestsToIssue.Add(request); } } } } if (requestsToIssue.Count != 0) { BuildRequestBlocker blocker = new BuildRequestBlocker(currentEntry.Request.GlobalRequestId, currentEntry.GetActiveTargets(), requestsToIssue.ToArray()); blockersToIssue.Add(blocker); } } // Issue all of the outstanding build requests. foreach (BuildRequestBlocker blocker in blockersToIssue) { // Issue the build request IssueBuildRequest(blocker); } }, isLastTask: false); }
public void TestBuildWithNewConfiguration() { BuildRequestData data = new BuildRequestData(Path.GetFullPath("TestFile"), new Dictionary<string, string>(), "TestToolsVersion", new string[0], null); BuildRequestConfiguration config = new BuildRequestConfiguration(1, data, "2.0"); _cache.AddConfiguration(config); // Configure the builder to spawn build requests MockRequestBuilder builder = (MockRequestBuilder)_host.GetComponent(BuildComponentType.RequestBuilder); BuildRequestData data2 = new BuildRequestData(Path.GetFullPath("OtherFile"), new Dictionary<string, string>(), "TestToolsVersion", new string[0], null); BuildRequestConfiguration unresolvedConfig = new BuildRequestConfiguration(data2, "2.0"); builder.NewRequests.Add(new FullyQualifiedBuildRequest[1] { new FullyQualifiedBuildRequest(unresolvedConfig, new string[1] { "requiredTarget1" }, true) }); // Create the initial build request string[] targets = new string[3] { "target1", "target2", "target3" }; BuildRequest request = CreateNewBuildRequest(1, targets); // Kick it off VerifyEngineStatus(BuildRequestEngineStatus.Uninitialized); _engine.InitializeForBuild(new NodeLoggingContext(_host.LoggingService, 0, false)); _engine.SubmitBuildRequest(request); Thread.Sleep(250); VerifyEngineStatus(BuildRequestEngineStatus.Active); // Wait for the request to generate the child request with the unresolved configuration WaitForEvent(_newConfigurationEvent, "NewConfigurationEvent"); Assert.Equal(Path.GetFullPath("OtherFile"), _newConfiguration_Config.ProjectFullPath); Assert.Equal("TestToolsVersion", _newConfiguration_Config.ToolsVersion); Assert.True(_newConfiguration_Config.WasGeneratedByNode); Thread.Sleep(250); VerifyEngineStatus(BuildRequestEngineStatus.Waiting); // Resolve the configuration BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(_newConfiguration_Config.ConfigurationId, 2, 0); _engine.ReportConfigurationResponse(response); // Now wait for the actual requests to be issued. WaitForEvent(_newRequestEvent, "NewRequestEvent"); Assert.Equal(2, _newRequest_Request.BuildRequests[0].ConfigurationId); Assert.Equal(2, _newRequest_Request.BuildRequests[0].ConfigurationId); Assert.Equal(1, _newRequest_Request.BuildRequests[0].Targets.Count); Assert.Equal("requiredTarget1", _newRequest_Request.BuildRequests[0].Targets[0]); // Report a result to satisfy the build request BuildResult result = new BuildResult(_newRequest_Request.BuildRequests[0]); result.AddResultsForTarget("requiredTarget1", TestUtilities.GetEmptySucceedingTargetResult()); _engine.UnblockBuildRequest(new BuildRequestUnblocker(result)); // Continue the request _engine.UnblockBuildRequest(new BuildRequestUnblocker(request.GlobalRequestId)); // Wait for the original request to complete WaitForEvent(_requestCompleteEvent, "RequestComplete"); Assert.Equal(request, _requestComplete_Request); Assert.Equal(BuildResultCode.Success, _requestComplete_Result.OverallResult); Thread.Sleep(250); VerifyEngineStatus(BuildRequestEngineStatus.Idle); }
public void TestTranslation() { BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(1, 2, 3); Assert.Equal(response.Type, NodePacketType.BuildRequestConfigurationResponse); ((INodePacketTranslatable)response).Translate(TranslationHelpers.GetWriteTranslator()); INodePacket deserializedPacket = BuildRequestConfigurationResponse.FactoryForDeserialization(TranslationHelpers.GetReadTranslator()); BuildRequestConfigurationResponse deserializedResponse = deserializedPacket as BuildRequestConfigurationResponse; Assert.Equal(response.NodeConfigurationId, deserializedResponse.NodeConfigurationId); Assert.Equal(response.GlobalConfigurationId, deserializedResponse.GlobalConfigurationId); Assert.Equal(response.ResultsNodeId, deserializedResponse.ResultsNodeId); }
public void TestResultsNodeId() { BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(0, 1, 2); Assert.Equal(2, response.ResultsNodeId); }
public void TestGlobalConfigurationId() { BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(0, 1, 0); Assert.Equal(1, response.GlobalConfigurationId); }
public void TestNodeConfigurationId() { BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(1, 0, 0); Assert.Equal(1, response.NodeConfigurationId); }