public void SetUp() { _nodeRequestId = 1; _host = new MockHost(); _mockLogger = new MockLogger(); _host.OnLoggingThreadException += this.LoggingException; }
public void SetUp() { LoggingServiceFactory loggingFactory = new LoggingServiceFactory(LoggerMode.Synchronous, 1); _loggingService = loggingFactory.CreateInstance(BuildComponentType.LoggingService) as LoggingService; _customLogger = new MyCustomLogger(); _mockHost = new MockHost(); _mockHost.LoggingService = _loggingService; _loggingService.RegisterLogger(_customLogger); _elementLocation = ElementLocation.Create("MockFile", 5, 5); BuildRequest buildRequest = new BuildRequest(1 /* submissionId */, 1, 1, new List<string>(), null, BuildEventContext.Invalid, null); BuildRequestConfiguration configuration = new BuildRequestConfiguration(1, new BuildRequestData("Nothing", new Dictionary<string, string>(), "4.0", new string[0], null), "2.0"); configuration.Project = new ProjectInstance(ProjectRootElement.Create()); BuildRequestEntry entry = new BuildRequestEntry(buildRequest, configuration); BuildResult buildResult = new BuildResult(buildRequest, false); buildResult.AddResultsForTarget("Build", new TargetResult(new TaskItem[] { new TaskItem("IamSuper", configuration.ProjectFullPath) }, TestUtilities.GetSkippedResult())); _mockRequestCallback = new MockIRequestBuilderCallback(new BuildResult[] { buildResult }); entry.Builder = (IRequestBuilder)_mockRequestCallback; _taskHost = new TaskHost(_mockHost, entry, _elementLocation, null /*Dont care about the callback either unless doing a build*/); _taskHost.LoggingContext = new TaskLoggingContext(_loggingService, BuildEventContext.Invalid); }
/// <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(); }
/// <summary> /// Sets up to run tests. Creates the host object. /// </summary> public TargetBuilder_Tests() { _nodeRequestId = 1; _host = new MockHost(); _mockLogger = new MockLogger(); _host.OnLoggingThreadException += this.LoggingException; }
/// <summary> /// Set up and initialize before each test is run /// </summary> public TaskHost_Tests() { LoggingServiceFactory loggingFactory = new LoggingServiceFactory(LoggerMode.Synchronous, 1); _loggingService = loggingFactory.CreateInstance(BuildComponentType.LoggingService) as LoggingService; _customLogger = new MyCustomLogger(); _mockHost = new MockHost(); _mockHost.LoggingService = _loggingService; _loggingService.RegisterLogger(_customLogger); _elementLocation = ElementLocation.Create("MockFile", 5, 5); BuildRequest buildRequest = new BuildRequest(1 /* submissionId */, 1, 1, new List <string>(), null, BuildEventContext.Invalid, null); BuildRequestConfiguration configuration = new BuildRequestConfiguration(1, new BuildRequestData("Nothing", new Dictionary <string, string>(), "4.0", new string[0], null), "2.0"); configuration.Project = new ProjectInstance(ProjectRootElement.Create()); BuildRequestEntry entry = new BuildRequestEntry(buildRequest, configuration); BuildResult buildResult = new BuildResult(buildRequest, false); buildResult.AddResultsForTarget("Build", new TargetResult(new TaskItem[] { new TaskItem("IamSuper", configuration.ProjectFullPath) }, TestUtilities.GetSkippedResult())); _mockRequestCallback = new MockIRequestBuilderCallback(new BuildResult[] { buildResult }); entry.Builder = (IRequestBuilder)_mockRequestCallback; _taskHost = new TaskHost(_mockHost, entry, _elementLocation, null /*Don't care about the callback either unless doing a build*/); _taskHost.LoggingContext = new TaskLoggingContext(_loggingService, BuildEventContext.Invalid); }
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 RequestBuilder_Tests() { _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 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); }
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); }
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 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 }
/// <summary> /// Prepares the environment for the test. /// </summary> public TaskBuilder_Tests(ITestOutputHelper output) { _host = new MockHost(); _testOutput = output; _testProject = CreateTestProject(); }
/// <summary> /// Prepares the environment for the test. /// </summary> public TaskBuilder_Tests() { _host = new MockHost(); _testProject = CreateTestProject(); }
public void SetUp() { _linkStatusTable = new Dictionary <INodeEndpoint, LinkStatusContext>(); _host = new MockHost(); }
public void SetUp() { _host = new MockHost(); _testProject = CreateTestProject(); }
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 }
/// <summary> /// Instantiate and Initialize a new loggingService. /// This is used by the test setup method to create /// a new logging service before each test. /// </summary> private void InitializeLoggingService() { BuildParameters parameters = new BuildParameters(); parameters.MaxNodeCount = 2; MockHost mockHost = new MockHost(parameters); IBuildComponent logServiceComponent = (IBuildComponent)LoggingService.CreateLoggingService(LoggerMode.Synchronous, 1); logServiceComponent.InitializeComponent(mockHost); _initializedService = logServiceComponent as LoggingService; }
public void TearDown() { ((IBuildComponent)_requestBuilder).ShutdownComponent(); _host = null; }
public void TearDown() { _linkStatusTable = null; _host = null; }
/// <summary> /// Called prior to each test. /// </summary> public TargetEntry_Tests() { _nodeRequestId = 1; _host = new MockHost(); _host.OnLoggingThreadException += this.LoggingException; }
public void Dispose() { ((IBuildComponent)_requestBuilder).ShutdownComponent(); _host = null; }
public NodeEndpointInProc_Tests() { _linkStatusTable = new Dictionary<INodeEndpoint, LinkStatusContext>(); _host = new MockHost(); }
public TargetUpToDateChecker_Tests(ITestOutputHelper testOutputHelper) { _mockHost = new MockHost(); _testOutputHelper = testOutputHelper; }
/// <summary> /// Executed after all tests are run. /// </summary> public void Dispose() { File.Delete("testProject.proj"); _mockLogger = null; _host = null; }
public void Dispose() { if (_engine.Status != BuildRequestEngineStatus.Uninitialized) { _engine.CleanupForBuild(); } ((IBuildComponent)_engine).ShutdownComponent(); _engineStatusChangedEvent.Close(); _requestCompleteEvent.Close(); _requestResumedEvent.Close(); _newRequestEvent.Close(); _newConfigurationEvent.Close(); _engineExceptionEvent.Close(); _host = null; }
public void SetUp() { _linkStatusTable = new Dictionary<INodeEndpoint, LinkStatusContext>(); _host = new MockHost(); }
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); }
public void SetUp() { _mockHost = new MockHost(); }
public void TearDown() { _customLogger = null; _mockHost = null; _elementLocation = null; _taskHost = null; }
public void InitializeComponent() { IBuildComponent logServiceComponent = (IBuildComponent)LoggingService.CreateLoggingService(LoggerMode.Synchronous, 1); BuildParameters parameters = new BuildParameters(); parameters.MaxNodeCount = 4; parameters.OnlyLogCriticalEvents = true; IBuildComponentHost loggingHost = new MockHost(parameters); // Make sure we are in the Instantiated state before initializing Assert.Equal(((LoggingService)logServiceComponent).ServiceState, LoggingServiceState.Instantiated); logServiceComponent.InitializeComponent(loggingHost); // Makesure that the parameters in the host are set in the logging service LoggingService service = (LoggingService)logServiceComponent; Assert.Equal(service.ServiceState, LoggingServiceState.Initialized); Assert.Equal(4, service.MaxCPUCount); Assert.True(service.OnlyLogCriticalEvents); }
public TargetUpToDateChecker_Tests() { _mockHost = new MockHost(); }
public void TearDown() { _testProject = null; _host = null; }
public void TearDown() { File.Delete("testProject.proj"); _host = null; }
public NodeEndpointInProc_Tests() { _linkStatusTable = new Dictionary <INodeEndpoint, LinkStatusContext>(); _host = new MockHost(); }