public void GetIntegrationQueueSnapshotForSingleProjectOnSingleQueue()
        {
            project1Mock.SetupResult("CurrentActivity", ProjectActivity.CheckingModifications);
            queueNotifier1Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier1Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueue1.Enqueue(integrationQueueItem1);

            QueueSetSnapshot queueSetSnapshot = integrationQueues.GetIntegrationQueueSnapshot();

            Assert.IsNotNull(queueSetSnapshot);
            Assert.AreEqual(2, queueSetSnapshot.Queues.Count);

            QueueSnapshot queueSnapshot = queueSetSnapshot.Queues[0];

            Assert.IsNotNull(queueSnapshot);
            Assert.IsFalse(queueSnapshot.IsEmpty);
            Assert.AreEqual(TestQueueName, queueSnapshot.QueueName);
            Assert.AreEqual(1, queueSnapshot.Requests.Count);
            Assert.AreEqual(queueSnapshot, queueSetSnapshot.FindByName(TestQueueName));

            QueuedRequestSnapshot queuedRequestSnapshot = queueSnapshot.Requests[0];

            Assert.AreEqual("ProjectOne", queuedRequestSnapshot.ProjectName);
            Assert.AreEqual(ProjectActivity.CheckingModifications, queuedRequestSnapshot.Activity);

            QueueSnapshot queueSnapshot2 = queueSetSnapshot.Queues[1];

            Assert.IsNotNull(queueSnapshot2);
            Assert.IsTrue(queueSnapshot2.IsEmpty);

            VerifyAll();
        }
        public void GetIntegrationQueueSnapshotForMultipleProjectsOnSingleQueue()
        {
            project1Mock.SetupResult("CurrentActivity", ProjectActivity.CheckingModifications);
            queueNotifier1Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier1Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueue1.Enqueue(integrationQueueItem1);

            // Second item is different project but same queue
            project2Mock.ExpectAndReturn("QueueName", TestQueueName);
            project2Mock.SetupResult("CurrentActivity", ProjectActivity.Pending);
            queueNotifier2Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier2Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueue1.Enqueue(integrationQueueItem2);

            QueueSetSnapshot queueSetSnapshot = integrationQueues.GetIntegrationQueueSnapshot();

            Assert.AreEqual(2, queueSetSnapshot.Queues.Count);

            QueueSnapshot queueSnapshot = queueSetSnapshot.Queues[0];

            Assert.AreEqual(2, queueSnapshot.Requests.Count);

            QueuedRequestSnapshot firstQueuedRequestSnapshot = queueSnapshot.Requests[0];

            Assert.AreEqual("ProjectOne", firstQueuedRequestSnapshot.ProjectName);
            Assert.AreEqual(ProjectActivity.CheckingModifications, firstQueuedRequestSnapshot.Activity);

            QueuedRequestSnapshot secondQueuedRequestSnapshot = queueSnapshot.Requests[1];

            Assert.AreEqual("ProjectTwo", secondQueuedRequestSnapshot.ProjectName);
            Assert.AreEqual(ProjectActivity.Pending, secondQueuedRequestSnapshot.Activity);

            VerifyAll();
        }
Exemplo n.º 3
0
        public void RemoveProjectClearsOnlyItemsThatAreForThisProject()
        {
            queueNotifier1Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier1Mock.Expect("NotifyExitingIntegrationQueue", false);
            integrationQueueUseFirst.Enqueue(integrationQueueItem1);

            // Second item is different project but same queue
            project2Mock.SetupResult("QueueName", TestQueueName);
            queueNotifier2Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier2Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueueUseFirst.Enqueue(integrationQueueItem2);

            // Third item is same project as the first.
            IIntegrationQueueItem thirdQueueItem = new IntegrationQueueItem((IProject)project1Mock.MockInstance,
                                                                            integrationRequestForceBuild, (IIntegrationQueueNotifier)queueNotifier3Mock.MockInstance);

            queueNotifier3Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier3Mock.Expect("NotifyExitingIntegrationQueue", true);
            integrationQueueUseFirst.Enqueue(thirdQueueItem);

            integrationQueueUseFirst.RemoveProject((IProject)project1Mock.MockInstance);

            IIntegrationQueueItem[] itemsOnQueue = integrationQueueUseFirst.GetQueuedIntegrations();
            Assert.AreEqual(1, itemsOnQueue.Length);
            Assert.AreSame(integrationQueueItem2, itemsOnQueue[0]);

            VerifyAll();
        }
        public void CancellingAPendingRequestWhileNotBuildingGoesToSleeping()
        {
            LatchMock otherProjectMock = new LatchMock(typeof(IProject));

            otherProjectMock.Strict = true;
            otherProjectMock.SetupResult("Name", "otherProject");
            otherProjectMock.SetupResult("QueueName", TestQueueName);
            otherProjectMock.SetupResult("QueuePriority", 0);
            otherProjectMock.SetupResult("Triggers", integrationTriggerMock.MockInstance);
            otherProjectMock.SetupResult("WorkingDirectory", tempDir + "tempWorkingDir2");
            otherProjectMock.SetupResult("ArtifactDirectory", tempDir + "tempArtifactDir2");

            IProject otherProject = (IProject)otherProjectMock.MockInstance;
            IProject project      = (IProject)projectMock.MockInstance;

            ProjectIntegrator otherIntegrator = new ProjectIntegrator(otherProject, integrationQueue);
            // Queue up the "otherProject" in the first queue position to build
            IntegrationRequest otherProjectRequest = new IntegrationRequest(BuildCondition.IfModificationExists, "intervalTrigger", null);

            otherProjectMock.Expect("NotifyPendingState");

            // Queue up our test project on the same queue as so it goes to pending
            IntegrationRequest request2 = new IntegrationRequest(BuildCondition.IfModificationExists, "intervalTrigger", null);

            projectMock.Expect("NotifyPendingState");
            // Cancelling the pending request should revert status to sleeping
            projectMock.Expect("NotifySleepingState");
            integrationTriggerMock.Expect("IntegrationCompleted");

            integrationQueue.Enqueue(new IntegrationQueueItem(otherProject, otherProjectRequest, otherIntegrator));
            integrationQueue.Enqueue(new IntegrationQueueItem(project, request2, integrator));
            // Cancel second build project on queue
            integrator.CancelPendingRequest();

            otherProjectMock.Verify();
            VerifyAll();
        }
        public void VerifyStateAfterException()
        {
            string exceptionMessage = "Intentional exception";

            integrationTriggerMock.ExpectAndReturn("Fire", ForceBuildRequest());
            projectMock.Expect("NotifyPendingState");
            projectMock.ExpectAndThrow("Integrate", new CruiseControlException(exceptionMessage), new HasForceBuildCondition());
            projectMock.ExpectAndSignal("NotifySleepingState");
            projectMock.SetupResult("MaxSourceControlRetries", 5);
            projectMock.SetupResult("SourceControlErrorHandling", ThoughtWorks.CruiseControl.Core.Sourcecontrol.Common.SourceControlErrorHandlingPolicy.ReportEveryFailure);
            integrationTriggerMock.Expect("IntegrationCompleted");

            integrator.Start();
            projectMock.WaitForSignal();
            Assert.AreEqual(ProjectIntegratorState.Running, integrator.State);
            integrator.Stop(false);
            integrator.WaitForExit();
            Assert.AreEqual(ProjectIntegratorState.Stopped, integrator.State);
            VerifyAll();
        }
Exemplo n.º 6
0
        public void TwoProjectsWithSameQueueNameShouldShareQueue()
        {
            // Setup the first project request
            queueNotifier1Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier1Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueueUseFirst.Enqueue(integrationQueueItem1);

            // Add a second project request for different project with same queue name
            project2Mock.SetupResult("QueueName", TestQueueName);
            queueNotifier2Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier2Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueueUseFirst.Enqueue(integrationQueueItem2);

            string[] queueNames = integrationQueues.GetQueueNames();
            Assert.AreEqual(4, queueNames.Length);
            Assert.AreEqual(TestQueueName, queueNames[0]);

            IIntegrationQueueItem[] itemsOnQueue = integrationQueueUseFirst.GetQueuedIntegrations();
            Assert.AreEqual(2, itemsOnQueue.Length);
            Assert.AreSame(integrationQueueItem1, itemsOnQueue[0]);
            Assert.AreSame(integrationQueueItem2, itemsOnQueue[1]);

            VerifyAll();
        }
Exemplo n.º 7
0
        public void FirstProjectOnQueueShouldIntegrateImmediately()
        {
            queueNotifier1Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier1Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueueUseFirst.Enqueue(integrationQueueItem1);

            string[] queueNames = integrationQueues.GetQueueNames();
            Assert.AreEqual(4, queueNames.Length);
            Assert.AreEqual(TestQueueName, queueNames[0]);

            IIntegrationQueueItem[] itemsOnQueue = integrationQueueUseFirst.GetQueuedIntegrations();
            Assert.AreEqual(1, itemsOnQueue.Length);
            Assert.AreSame(integrationQueueItem1, itemsOnQueue[0]);

            VerifyAll();
        }