Ejemplo n.º 1
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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }