/// <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 Dispose() { ((IBuildComponent)_requestBuilder).ShutdownComponent(); _host = null; // Normally, RequestBuilder ensures that this gets reset before completing // requests, but we call it in odd ways here so restore it manually // to keep the overall test invariant happy. Directory.SetCurrentDirectory(_originalWorkingDirectory); }
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.Single(response); 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); }
public void Dispose() { if (_engine.Status != BuildRequestEngineStatus.Uninitialized) { _engine.CleanupForBuild(); } ((IBuildComponent)_engine).ShutdownComponent(); _engineStatusChangedEvent.Dispose(); _requestCompleteEvent.Dispose(); _requestResumedEvent.Dispose(); _newRequestEvent.Dispose(); _newConfigurationEvent.Dispose(); _engineExceptionEvent.Dispose(); _host = null; }
public BuildRequestEngine_Tests() { _host = new MockHost(); _nodeRequestId = 1; _globalRequestId = 1; _engineStatusChangedEvent = new AutoResetEvent(false); _requestCompleteEvent = new AutoResetEvent(false); _requestResumedEvent = new AutoResetEvent(false); _newRequestEvent = new AutoResetEvent(false); _newConfigurationEvent = new AutoResetEvent(false); _engineExceptionEvent = new AutoResetEvent(false); _engine = (IBuildRequestEngine)_host.GetComponent(BuildComponentType.RequestEngine); _cache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache); ConfigureEngine(_engine); }
#pragma warning restore xUnit1013 public RequestBuilder_Tests() { _originalWorkingDirectory = Directory.GetCurrentDirectory(); _nodeRequestId = 1; _host = new MockHost(); _host.RequestBuilder = new RequestBuilder(); ((IBuildComponent)_host.RequestBuilder).InitializeComponent(_host); _host.OnLoggingThreadException += this.LoggingException; _newBuildRequestsEvent = new AutoResetEvent(false); _buildRequestCompletedEvent = new AutoResetEvent(false); _requestBuilder = (IRequestBuilder)_host.GetComponent(BuildComponentType.RequestBuilder); _requestBuilder.OnBuildRequestCompleted += this.BuildRequestCompletedCallback; _requestBuilder.OnNewBuildRequests += this.NewBuildRequestsCallback; }
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 NodeEndpointInProc_Tests() { _linkStatusTable = new Dictionary <INodeEndpoint, LinkStatusContext>(); _host = new MockHost(); }
/// <summary> /// Prepares the environment for the test. /// </summary> public TaskBuilder_Tests(ITestOutputHelper output) { _host = new MockHost(); _testOutput = output; _testProject = CreateTestProject(); }
public TargetUpToDateChecker_Tests(ITestOutputHelper testOutputHelper) { _mockHost = new MockHost(); _testOutputHelper = testOutputHelper; }