Example #1
0
 private void OnNewRequest(BuildRequestBlocker blocker)
 {
     if (_nodeEndpoint.LinkStatus == LinkStatus.Active)
     {
         _nodeEndpoint.SendData(blocker);
     }
 }
Example #2
0
        public void TestChildRequest()
        {
            CreateConfiguration(1, "foo.proj");
            BuildRequest request = CreateBuildRequest(1, 1, new string[] { "foo" });

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(-1, new string[] { }, new BuildRequest[] { request });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            CreateConfiguration(2, "bar.proj");
            BuildRequest childRequest = CreateBuildRequest(2, 2, new string[] { "foo" }, request);
            BuildResult  childResult  = CacheBuildResult(childRequest, "foo", TestUtilities.GetSuccessResult());

            blocker  = new BuildRequestBlocker(0, new string[] { "foo" }, new BuildRequest[] { childRequest });
            response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            Assert.Equal(2, response.Count);

            // The first response will be to report the results back to the node.
            Assert.Equal(ScheduleActionType.ReportResults, response[0].Action);
            Assert.True(ResultsCache_Tests.AreResultsIdentical(childResult, response[0].Unblocker.Result));

            // The second response will be to continue building the original request.
            Assert.Equal(ScheduleActionType.ResumeExecution, response[1].Action);
            Assert.Null(response[1].Unblocker.Result);
        }
Example #3
0
        public void TestMultipleRequestsWithAllResults()
        {
            CreateConfiguration(1, "foo.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" });
            BuildResult  result1  = CacheBuildResult(request1, "foo", TestUtilities.GetSuccessResult());

            CreateConfiguration(2, "bar.proj");
            BuildRequest request2 = CreateBuildRequest(2, 2, new string[] { "bar" });
            BuildResult  result2  = CacheBuildResult(request2, "bar", TestUtilities.GetSuccessResult());

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request1, request2 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            Assert.Equal(3, response.Count);

            // First two are the results which were cached.
            Assert.Equal(ScheduleActionType.ReportResults, response[0].Action);
            Assert.True(ResultsCache_Tests.AreResultsIdentical(result1, response[0].Unblocker.Result));
            Assert.Equal(ScheduleActionType.ReportResults, response[1].Action);
            Assert.True(ResultsCache_Tests.AreResultsIdentical(result2, response[1].Unblocker.Result));

            // Last response is to continue the parent.
            Assert.Equal(ScheduleActionType.ResumeExecution, response[2].Action);
            Assert.Equal(request1.ParentGlobalRequestId, response[2].Unblocker.BlockedRequestId);
            Assert.Null(response[2].Unblocker.Result);
        }
Example #4
0
 /// <summary>
 /// Gets called by the build request engine when there is a new build request (engine callback)
 /// </summary>
 /// <param name="request"></param>
 private void RequestEngine_OnNewRequest(BuildRequestBlocker blocker)
 {
     if (this.testDataProvider != null)
     {
         foreach (BuildRequest request in blocker.BuildRequests)
         {
             this.testDataProvider.NewRequest = request;
         }
     }
 }
Example #5
0
        public void TestSimpleRequest()
        {
            CreateConfiguration(1, "foo.proj");
            BuildRequest            request  = CreateBuildRequest(1, 1);
            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            Assert.Equal(1, response.Count);
            Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, response[0].Action);
            Assert.Equal(request, response[0].BuildRequest);
        }
Example #6
0
        public void TestMultipleRequests()
        {
            CreateConfiguration(1, "foo.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" });
            BuildRequest request2 = CreateBuildRequest(2, 1, new string[] { "bar" });

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request1, request2 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            Assert.AreEqual(1, response.Count);
            Assert.AreEqual(ScheduleActionType.ScheduleWithConfiguration, response[0].Action);
            Assert.AreEqual(request1, response[0].BuildRequest);
        }
Example #7
0
        public void TestTwoRequestsWithSecondFailure()
        {
            CreateConfiguration(1, "foo.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" });
            BuildRequest request2 = CreateBuildRequest(2, 1, new string[] { "bar" });
            BuildResult  result2  = CacheBuildResult(request2, "bar", TestUtilities.GetStopWithErrorResult());

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request1, request2 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            Assert.Equal(2, response.Count);
            Assert.True(ResultsCache_Tests.AreResultsIdentical(result2, response[0].Unblocker.Result));
            Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, response[1].Action);
        }
Example #8
0
        public void TestOutOfProcNodeCreatedWhenAffinityIsOutOfProc()
        {
            CreateConfiguration(1, "foo.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" }, NodeAffinity.OutOfProc, _defaultParentRequest);
            BuildRequest request2 = CreateBuildRequest(2, 1, new string[] { "bar" }, NodeAffinity.OutOfProc, _defaultParentRequest);

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request1, request2 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            // Parent request is blocked by the fact that both child requests require the out-of-proc node that doesn't
            // exist yet.
            Assert.Equal(1, response.Count);
            Assert.Equal(ScheduleActionType.CreateNode, response[0].Action);
            Assert.Equal(NodeAffinity.OutOfProc, response[0].RequiredNodeType);
            Assert.Equal(1, response[0].NumberOfNodesToCreate);
        }
Example #9
0
        public void TestNoNewNodesCreatedForMultipleRequestsWithSameConfiguration()
        {
            _host.BuildParameters.MaxNodeCount = 3;

            CreateConfiguration(1, "foo.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" });
            BuildRequest request2 = CreateBuildRequest(2, 1, new string[] { "bar" });
            BuildRequest request3 = CreateBuildRequest(3, 1, new string[] { "baz" });
            BuildRequest request4 = CreateBuildRequest(4, 1, new string[] { "qux" });

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request1, request2, request3, request4 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            Assert.Equal(1, response.Count);
            Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, response[0].Action);
            Assert.Equal(request1, response[0].BuildRequest);
        }
Example #10
0
        public void TestTraversalAffinityIsInProc()
        {
            _host.BuildParameters.MaxNodeCount = 3;

            CreateConfiguration(1, "dirs.proj");
            CreateConfiguration(2, "abc.metaproj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" }, _defaultParentRequest);
            BuildRequest request2 = CreateBuildRequest(2, 2, new string[] { "bar" }, _defaultParentRequest);

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request1, request2 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            // There will be no request to create a new node, because both of the above requests are traversals,
            // which have an affinity of "inproc", and the inproc node already exists.
            Assert.Equal(1, response.Count);
            Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, response[0].Action);
            Assert.Equal(request1, response[0].BuildRequest);
        }
Example #11
0
        public void TestMultipleRequestsWithSomeResults()
        {
            CreateConfiguration(1, "foo.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" });

            CreateConfiguration(2, "bar.proj");
            BuildRequest request2 = CreateBuildRequest(2, 2, new string[] { "bar" });
            BuildResult  result2  = CacheBuildResult(request2, "bar", BuildResultUtilities.GetSuccessResult());

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, Array.Empty <string>(), new BuildRequest[] { request1, request2 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            Assert.Equal(2, response.Count);
            Assert.Equal(ScheduleActionType.ReportResults, response[0].Action);
            Assert.True(ResultsCache_Tests.AreResultsIdentical(result2, response[0].Unblocker.Result));
            Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, response[1].Action);
            Assert.Equal(request1, response[1].BuildRequest);
        }
Example #12
0
        public void TestSimpleRequestWithCachedResultsFail()
        {
            CreateConfiguration(1, "foo.proj");
            BuildRequest request = CreateBuildRequest(1, 1, new string[] { "foo" });
            BuildResult  result  = CacheBuildResult(request, "foo", TestUtilities.GetStopWithErrorResult());

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            Assert.Equal(2, response.Count);

            // First response tells the parent of the results.
            Assert.Equal(ScheduleActionType.ReportResults, response[0].Action);
            Assert.True(ResultsCache_Tests.AreResultsIdentical(result, response[0].Unblocker.Result));

            // Second response tells the parent to continue.
            Assert.Equal(ScheduleActionType.ResumeExecution, response[1].Action);
            Assert.Null(response[1].Unblocker.Result);
        }
Example #13
0
        public void TestResult()
        {
            CreateConfiguration(1, "foo.proj");
            BuildRequest            request  = CreateBuildRequest(1, 1);
            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            BuildResult result = CreateBuildResult(request, "foo", TestUtilities.GetSuccessResult());

            response = new List <ScheduleResponse>(_scheduler.ReportResult(1, result));

            Assert.Equal(2, response.Count);

            // First response is reporting the results for this request to the parent
            Assert.Equal(ScheduleActionType.ReportResults, response[0].Action);

            // Second response is continuing execution of the parent
            Assert.Equal(ScheduleActionType.ResumeExecution, response[1].Action);
            Assert.Equal(request.ParentGlobalRequestId, response[1].Unblocker.BlockedRequestId);
        }
Example #14
0
        public void TestProxyAffinityIsInProc()
        {
            _host.BuildParameters.MaxNodeCount = 4;
            ReportDefaultParentRequestIsFinished();

            CreateConfiguration(1, "foo.csproj");

            BuildRequest request1 = CreateProxyBuildRequest(1, 1, new ProxyTargets(new Dictionary <string, string> {
                { "foo", "bar" }
            }), null);

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(-1, Array.Empty <string>(), new[] { request1 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            // There will be no request to create a new node, because both of the above requests are proxy build requests,
            // which have an affinity of "inproc", and the inproc node already exists.
            Assert.Single(response);
            Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, response[0].Action);
            Assert.Equal(request1, response[0].BuildRequest);
            Assert.Equal(Scheduler.InProcNodeId, response[0].NodeId);
        }
Example #15
0
        public void TestMaxNodeCountNodesNotExceededWithSomeOOPRequests2()
        {
            _host.BuildParameters.MaxNodeCount = 3;

            CreateConfiguration(1, "foo.proj");
            CreateConfiguration(2, "bar.proj");
            CreateConfiguration(3, "baz.proj");
            CreateConfiguration(4, "quz.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" }, NodeAffinity.OutOfProc, _defaultParentRequest);
            BuildRequest request2 = CreateBuildRequest(2, 2, new string[] { "bar" }, NodeAffinity.OutOfProc, _defaultParentRequest);
            BuildRequest request3 = CreateBuildRequest(3, 3, new string[] { "baz" });
            BuildRequest request4 = CreateBuildRequest(4, 4, new string[] { "qux" });

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request1, request2, request3, request4 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            Assert.Equal(2, response.Count);
            Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, response[0].Action);
            Assert.Equal(request3, response[0].BuildRequest);
            Assert.Equal(ScheduleActionType.CreateNode, response[1].Action);
            Assert.Equal(NodeAffinity.OutOfProc, response[1].RequiredNodeType);
            Assert.Equal(2, response[1].NumberOfNodesToCreate);
        }
Example #16
0
        public void TestMaxNodeCountOOPNodesCreatedForOOPAffinitizedRequests()
        {
            _host.BuildParameters.MaxNodeCount = 3;

            CreateConfiguration(1, "foo.proj");
            CreateConfiguration(2, "bar.proj");
            CreateConfiguration(3, "baz.proj");
            CreateConfiguration(4, "quz.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" }, NodeAffinity.OutOfProc, _defaultParentRequest);
            BuildRequest request2 = CreateBuildRequest(2, 2, new string[] { "bar" }, NodeAffinity.OutOfProc, _defaultParentRequest);
            BuildRequest request3 = CreateBuildRequest(3, 3, new string[] { "baz" }, NodeAffinity.OutOfProc, _defaultParentRequest);
            BuildRequest request4 = CreateBuildRequest(4, 4, new string[] { "qux" }, NodeAffinity.OutOfProc, _defaultParentRequest);

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request1, request2, request3, request4 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            // Parent request is blocked by the fact that both child requests require the out-of-proc node that doesn't
            // exist yet.
            Assert.Equal(1, response.Count);
            Assert.Equal(ScheduleActionType.CreateNode, response[0].Action);
            Assert.Equal(NodeAffinity.OutOfProc, response[0].RequiredNodeType);
            Assert.Equal(3, response[0].NumberOfNodesToCreate);
        }
Example #17
0
 /// <summary>
 /// Callback for event raised when a new build request is generated by an MSBuild callback
 /// </summary>
 /// <param name="request">The new build request</param>
 private void Engine_NewRequest(BuildRequestBlocker blocker)
 {
     _newRequest_Request = blocker;
     _newRequestEvent.Set();
 }