/// <summary>
        /// New configuration request. New BuildRequestConfiguration is created and added to the configuration cache.
        /// This call is in the ProcessorThread of the TestDataProvider
        /// </summary>
        public void RaiseOnNewConfigurationRequest(BuildRequestConfiguration config)
        {
            if (_configuration != null)
            {
                string message = String.Format("Configuration for request {0}:{1} has already been created", _configuration.ConfigurationId, _configuration.ProjectFullPath);
                throw new InvalidOperationException(message);
            }

            _configuration = _testDataProvider.CreateConfiguration(this);
            _requestEngine.ReportConfigurationResponse(new BuildRequestConfigurationResponse(config.ConfigurationId, _configuration.ConfigurationId, _configuration.ResultsNodeId));
        }
Beispiel #2
0
        /// <summary>
        /// Cache the configuration for this build definition and then submit the build request to the request engine. If the request being submitted does not have
        /// a GlobalRequestId than assign one.
        /// Since we want to make all requests rooted - it the passed in request is null then we will use the dummy root request and make that the parent. This is usually
        /// the case when tests submit build requets. When a request is submitted by the RequestBuilder the request is always populated and likely rooted.
        /// </summary>
        public void Build(BuildRequest request)
        {
            if (request == null)
            {
                this.configuration = testDataProvider.CreateConfiguration(this);
                this.buildRequest  = new BuildRequest(1 /* submissionId */, 1, this.configuration.ConfigurationId, this.targetsToBuild, null, BuildEventContext.Invalid, null);
                this.buildRequest.GlobalRequestId = RequestDefinition.globalRequestId++;
            }
            else
            {
                this.buildRequest = request;
                // Assign a new Global Request id if one is not already there
                bool assignNewId = false;
                if (this.buildRequest.GlobalRequestId == BuildRequest.InvalidGlobalRequestId)
                {
                    foreach (KeyValuePair <int, RequestDefinition> idRequestPair in this.testDataProvider.RequestDefinitions)
                    {
                        if (
                            idRequestPair.Value.buildRequest != null &&
                            idRequestPair.Value.buildRequest.ConfigurationId == this.buildRequest.ConfigurationId &&
                            idRequestPair.Value.buildRequest.Targets.Count == this.buildRequest.Targets.Count
                            )
                        {
                            List <string> leftTargets  = new List <string>(idRequestPair.Value.buildRequest.Targets);
                            List <string> rightTargets = new List <string>(this.buildRequest.Targets);
                            leftTargets.Sort(StringComparer.OrdinalIgnoreCase);
                            rightTargets.Sort(StringComparer.OrdinalIgnoreCase);
                            for (int i = 0; i < leftTargets.Count; i++)
                            {
                                if (!leftTargets[i].Equals(rightTargets[i], StringComparison.OrdinalIgnoreCase))
                                {
                                    assignNewId = true;
                                    break;
                                }
                            }

                            if (!assignNewId)
                            {
                                this.buildRequest.GlobalRequestId = idRequestPair.Value.buildRequest.GlobalRequestId;
                                break;
                            }
                        }
                    }
                }

                if (assignNewId)
                {
                    this.buildRequest.GlobalRequestId = RequestDefinition.globalRequestId++;
                }
            }

            this.requestEngine.SubmitBuildRequest(this.buildRequest);
        }