/// <summary> /// Set up /// </summary> public Scheduler_Tests() { // Since we're creating our own BuildManager, we need to make sure that the default // one has properly relinquished the inproc node NodeProviderInProc nodeProviderInProc = ((IBuildComponentHost)BuildManager.DefaultBuildManager).GetComponent(BuildComponentType.InProcNodeProvider) as NodeProviderInProc; if (nodeProviderInProc != null) { nodeProviderInProc.Dispose(); } _host = new MockHost(); _scheduler = new Scheduler(); _scheduler.InitializeComponent(_host); CreateConfiguration(99, "parent.proj"); _defaultParentRequest = CreateBuildRequest(99, 99, new string[] { }, null); // Set up the scheduler with one node to start with. _scheduler.ReportNodesCreated(new NodeInfo[] { new NodeInfo(1, NodeProviderType.InProc) }); _scheduler.ReportRequestBlocked(1, new BuildRequestBlocker(-1, new string[] { }, new BuildRequest[] { _defaultParentRequest })); _logger = new MockLogger(); _parameters = new BuildParameters(); _parameters.Loggers = new ILogger[] { _logger }; _parameters.ShutdownInProcNodeOnBuildFinish = true; _buildManager = new BuildManager(); }
public void VerifyNoOverCreationOfNodesWithBuildLoop() { // Since we're creating our own BuildManager, we need to make sure that the default // one has properly relinquished the inproc node NodeProviderInProc nodeProviderInProc = ((IBuildComponentHost)BuildManager.DefaultBuildManager).GetComponent(BuildComponentType.InProcNodeProvider) as NodeProviderInProc; if (nodeProviderInProc != null) { nodeProviderInProc.Dispose(); } _host = new MockHost(); _host.BuildParameters.MaxNodeCount = 3; _scheduler = new Scheduler(); _scheduler.InitializeComponent(_host); _parameters = new BuildParameters(); _parameters.ShutdownInProcNodeOnBuildFinish = true; _buildManager = new BuildManager(); CreateConfiguration(99, "parent.proj"); _defaultParentRequest = CreateBuildRequest(99, 99, new string[] { }, null); CreateConfiguration(1, "foo.proj"); BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" }, NodeAffinity.OutOfProc, _defaultParentRequest); CreateConfiguration(2, "foo2.proj"); BuildRequest request2 = CreateBuildRequest(2, 2, new string[] { "bar" }, NodeAffinity.OutOfProc, _defaultParentRequest); CreateConfiguration(3, "foo3.proj"); BuildRequest request3 = CreateBuildRequest(3, 3, new string[] { "bar" }, NodeAffinity.InProc, _defaultParentRequest); List<ScheduleResponse> responses = new List<ScheduleResponse>(_scheduler.ReportRequestBlocked(1, new BuildRequestBlocker(-1, new string[] { }, new BuildRequest[] { _defaultParentRequest, request1, request2, request3 }))); int nextNodeId = 1; bool inProcNodeExists = false; MockPerformSchedulingActions(responses, ref nextNodeId, ref inProcNodeExists); Assert.Equal(4, nextNodeId); // 3 nodes }
public void VerifyRequestOrderingDoesNotAffectNodeCreationCountWithInProcAndAnyRequests() { // Since we're creating our own BuildManager, we need to make sure that the default // one has properly relinquished the inproc node NodeProviderInProc nodeProviderInProc = ((IBuildComponentHost)BuildManager.DefaultBuildManager).GetComponent(BuildComponentType.InProcNodeProvider) as NodeProviderInProc; if (nodeProviderInProc != null) { nodeProviderInProc.Dispose(); } _host = new MockHost(); _host.BuildParameters.MaxNodeCount = 3; _scheduler = new Scheduler(); _scheduler.InitializeComponent(_host); _logger = new MockLogger(); _parameters = new BuildParameters(); _parameters.Loggers = new ILogger[] { _logger }; _parameters.ShutdownInProcNodeOnBuildFinish = true; _buildManager = new BuildManager(); CreateConfiguration(99, "parent.proj"); _defaultParentRequest = CreateBuildRequest(99, 99, new string[] { }, null); CreateConfiguration(1, "foo.proj"); BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" }, NodeAffinity.Any, _defaultParentRequest); BuildRequest request2 = CreateBuildRequest(2, 1, new string[] { "bar" }, NodeAffinity.InProc, _defaultParentRequest); BuildRequest request3 = CreateBuildRequest(3, 1, new string[] { "bar" }, NodeAffinity.InProc, _defaultParentRequest); List<ScheduleResponse> response = new List<ScheduleResponse>(_scheduler.ReportRequestBlocked(1, new BuildRequestBlocker(-1, new string[] { }, new BuildRequest[] { _defaultParentRequest, request1, request2, request3 }))); Assert.Equal(1, response.Count); Assert.Equal(ScheduleActionType.CreateNode, response[0].Action); Assert.Equal(NodeAffinity.InProc, response[0].RequiredNodeType); Assert.Equal(1, response[0].NumberOfNodesToCreate); List<NodeInfo> nodeInfos = new List<NodeInfo>(new NodeInfo[] { new NodeInfo(1, NodeProviderType.InProc) }); List<ScheduleResponse> moreResponses = new List<ScheduleResponse>(_scheduler.ReportNodesCreated(nodeInfos)); Assert.Equal(2, moreResponses.Count); Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, moreResponses[0].Action); Assert.Equal(ScheduleActionType.CreateNode, moreResponses[1].Action); Assert.Equal(NodeAffinity.OutOfProc, moreResponses[1].RequiredNodeType); Assert.Equal(1, moreResponses[1].NumberOfNodesToCreate); }