public void Running_multi_stage_multi_activity_pipeline_that_waits_for_external_dependency_does_nothing()
        {
            var          startTime   = DateTime.UtcNow;
            UniqueStepId firstStepId = null;

            var pipeline = new PipelineBuilder()
                           .AddStage(StageTriggerMode.Automatic)
                           .AddActivity()
                           .AddStepWithoutDependencies()
                           .AddStage(StageTriggerMode.Automatic)
                           .AddActivity()
                           .AddStepWithoutDependencies()
                           .AddStepWithDependencies(x => firstStepId = x)
                           .AddStepWithoutDependencies()
                           .AddActivity()
                           .AddStepWithoutDependencies()
                           .Build();


            var result = pipeline.Run(EventSink, null, startTime);

            Assert.AreEqual(StageState.WaitingForDependency, result);
            EventSink.Events.Clear();

            pipeline.Run(EventSink, null, DateTime.UtcNow);

            Expect(new StepWaitingForExternalDependencyEvent(firstStepId, startTime));
        }
        public void Multiple_activities_are_executed_concurrently()
        {
            UniqueStepId firstStepId  = null;
            UniqueStepId secondStepId = null;
            UniqueStepId firstStepWithDependencyId  = null;
            UniqueStepId secondStepWithDependencyId = null;

            var startTime = DateTime.UtcNow;

            var pipeline = new PipelineBuilder()
                           .AddStage(StageTriggerMode.Automatic)
                           .AddActivity()
                           .AddStepWithoutDependencies(x => firstStepId            = x)
                           .AddStepWithDependencies(x => firstStepWithDependencyId = x)
                           .AddActivity()
                           .AddStepWithoutDependencies(x => secondStepId            = x)
                           .AddStepWithDependencies(x => secondStepWithDependencyId = x)
                           .Build();

            var result = pipeline.Run(EventSink, null, startTime);

            Assert.AreEqual(StageState.WaitingForDependency, result);

            Expect(new StepExecutedEvent(firstStepId))
            .ThenExpect(new StepWaitingForExternalDependencyEvent(firstStepWithDependencyId, startTime))
            .ThenExpect(new StepExecutedEvent(secondStepId))
            .ThenExpect(new StepWaitingForExternalDependencyEvent(secondStepWithDependencyId, startTime))
            .AndNothingElse();
        }
        public void Step_should_retry_after_30_seconds()
        {
            UniqueStepId firstRetryStepId = null;

            var pipeline = new PipelineBuilder()
                           .AddStage(StageTriggerMode.Automatic)
                           .AddActivity()
                           .AddStep <RetryWaitingForExternalDependencyStep>(id => firstRetryStepId = id)
                           .Build(new NoRetryFailureHandlingStrategy());

            var startTime   = DateTime.UtcNow;
            var retryTime   = startTime + TimeSpan.FromSeconds(30);
            var timeoutTime = startTime + TimeSpan.FromSeconds(501);

            pipeline.Run(EventSink, null, startTime);
            pipeline.Run(EventSink, null, retryTime);
            pipeline.Run(EventSink, null, timeoutTime);

            Expect((new StepWaitingForExternalDependencyEvent(firstRetryStepId, startTime)))
            .ThenExpect(new StepWaitingForExternalDependencyEvent(firstRetryStepId, retryTime))
            .ThenExpect(new StepAttemptFailedEvent(firstRetryStepId))
            .ThenExpect(new StepFailedEvent(firstRetryStepId))
            .ThenExpectAny <StageFailedEvent>()
            .AndNothingElse();
        }
        private IEnumerable <Parameter> AllParameters(UniqueStepId stepId)
        {
            yield return(new TypedParameter(typeof(UniqueStepId), stepId));

            foreach (var configParameter in _configParameters)
            {
                yield return(configParameter);
            }
        }
 public StepWaitingForExternalDependencyEvent(UniqueStepId stepId, DateTime resumeTimeUtc)
 {
     if (stepId == null)
     {
         throw new ArgumentNullException("stepId");
     }
     _stepId        = stepId;
     _resumeTimeUtc = resumeTimeUtc;
 }
示例#6
0
        public void It_passes_step_id()
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterType <ParameterlessStep>();
            var factory = new AutofacStepFactory(containerBuilder.Build());
            var stepId  = new UniqueStepId("1", "1", "1", "1", "1");

            var instance = factory.CreateInstance(typeof(ParameterlessStep), stepId);

            Assert.AreSame(instance.StepId, stepId);
        }
示例#7
0
        public void It_passes_dependencies_via_constructor()
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterType <DependencyImplementation>().AsImplementedInterfaces();
            containerBuilder.RegisterType <ParameterlessStepWithDependency>();
            var factory = new AutofacStepFactory(containerBuilder.Build());
            var stepId  = new UniqueStepId("1", "1", "1", "1", "1");

            var instance = (ParameterlessStepWithDependency)factory.CreateInstance(typeof(ParameterlessStepWithDependency), stepId);

            Assert.IsNotNull(instance.Dependency);
        }
示例#8
0
        public IStepBuilder AddStep <T>(Action <UniqueStepId> callback)
        {
            _counter++;
            var uniqueId   = new UniqueStepId(_counter.ToString(), Id, _parent.Id, _parent.Parent.SchemaName, _parent.Parent.SchemaName);
            var stepSchema = new StepSchema()
            {
                Name           = _counter.ToString(),
                Implementation = typeof(T).AssemblyQualifiedName
            };

            Steps.Add(stepSchema);
            callback(uniqueId);
            return(new StepBuilder(this, stepSchema));
        }
        public void Execution_stops_before_stage_with_throttled_trigger()
        {
            UniqueStepId firstStepId = null;
            var          pipeline    = new PipelineBuilder()
                                       .AddStage(StageTriggerMode.Automatic)
                                       .AddActivity()
                                       .AddStepWithoutDependencies(x => firstStepId = x)
                                       .AddStage(StageTriggerMode.Throttled)
                                       .AddActivity()
                                       .AddStepWithoutDependencies()
                                       .Build();

            var result = pipeline.Run(EventSink, null, DateTime.UtcNow);

            Assert.AreEqual(StageState.OnHold, result);

            Expect(new StepExecutedEvent(firstStepId))
            .ThenExpectAny <StageFinishedEvent>()
            .AndNothingElse();
        }
示例#10
0
        public void Pipeline_requests_retry_when_allowed()
        {
            UniqueStepId firstStepId  = null;
            UniqueStepId failedStepId = null;

            var pipeline = new PipelineBuilder()
                           .AddStage(StageTriggerMode.Automatic)
                           .AddActivity()
                           .AddStepWithoutDependencies(id => firstStepId = id)
                           .AddStep <FailingStep>(id => failedStepId     = id)
                           .AddStepWithoutDependencies()
                           .Build(new RetryOnceFailureHandlingStrategy());

            var result = pipeline.Run(EventSink, null, DateTime.UtcNow);

            Assert.AreEqual(StageState.RequestsRetry, result);

            Expect(new StepExecutedEvent(firstStepId))
            .ThenExpect(new StepAttemptFailedEvent(failedStepId))
            .AndNothingElse();
        }
示例#11
0
        public void Pipeline_without_external_dependencies_runs_all_steps_till_completion()
        {
            UniqueStepId firstStepId  = null;
            UniqueStepId secondStepId = null;

            var pipeline = new PipelineBuilder()
                           .AddStage(StageTriggerMode.Automatic)
                           .AddActivity()
                           .AddStepWithoutDependencies(x => firstStepId  = x)
                           .AddStepWithoutDependencies(x => secondStepId = x)
                           .Build();

            var result = pipeline.Run(EventSink, null, DateTime.UtcNow);

            Assert.AreEqual(StageState.Finished, result);

            Expect(new StepExecutedEvent(firstStepId))
            .ThenExpect(new StepExecutedEvent(secondStepId))
            .ThenExpectAny <StageFinishedEvent>()
            .AndNothingElse();
        }
示例#12
0
        public void Pipeline_execution_stops_on_first_failed_step()
        {
            UniqueStepId firstStepId  = null;
            UniqueStepId failedStepId = null;

            var pipeline = new PipelineBuilder()
                           .AddStage(StageTriggerMode.Automatic)
                           .AddActivity()
                           .AddStepWithoutDependencies(id => firstStepId = id)
                           .AddStep <FailingStep>(id => failedStepId     = id)
                           .AddStepWithoutDependencies()
                           .Build();

            var result = pipeline.Run(EventSink, null, DateTime.UtcNow);

            Assert.AreEqual(StageState.Failed, result);

            Expect(new StepExecutedEvent(firstStepId))
            .ThenExpect(new StepAttemptFailedEvent(failedStepId))
            .ThenExpect(new StepFailedEvent(failedStepId))
            .ThenExpectAny <StageFailedEvent>()
            .AndNothingElse();
        }
示例#13
0
        public void Two_steps_should_execute_correctly_after_failing_once_each()
        {
            UniqueStepId firstRetryStepId  = null;
            UniqueStepId secondRetryStepId = null;

            var pipeline = new PipelineBuilder()
                           .AddStage(StageTriggerMode.Automatic)
                           .AddActivity()
                           .AddStep <SuccessAfterRetryStep>(id => firstRetryStepId  = id)
                           .AddStep <SuccessAfterRetryStep>(id => secondRetryStepId = id)
                           .Build(new RetryOnceFailureHandlingStrategy());

            pipeline.Run(EventSink, null, DateTime.UtcNow);
            pipeline.Run(EventSink, null, DateTime.UtcNow);
            pipeline.Run(EventSink, null, DateTime.UtcNow);

            Expect((new StepAttemptFailedEvent(firstRetryStepId)))
            .ThenExpect(new StepExecutedEvent(firstRetryStepId))
            .ThenExpect(new StepAttemptFailedEvent(secondRetryStepId))
            .ThenExpect(new StepExecutedEvent(secondRetryStepId))
            .ThenExpectAny <StageFinishedEvent>()
            .AndNothingElse();
        }
示例#14
0
        public void Manual_trigger_resumes_execution_of_pipeline()
        {
            UniqueStepId manualStepId = null;
            var          pipeline     = new PipelineBuilder()
                                        .AddStage(StageTriggerMode.Automatic)
                                        .AddActivity()
                                        .AddStepWithoutDependencies()
                                        .AddStage(StageTriggerMode.Manual)
                                        .AddActivity()
                                        .AddStepWithoutDependencies(x => manualStepId = x)
                                        .Build();

            var result = pipeline.Run(EventSink, null, DateTime.UtcNow);

            Assert.AreEqual(StageState.OnHold, result);
            EventSink.Events.Clear();

            pipeline.Trigger();
            pipeline.Run(EventSink, null, DateTime.UtcNow);

            Expect(new StepExecutedEvent(manualStepId))
            .ThenExpectAny <StageFinishedEvent>()
            .AndNothingElse();
        }
示例#15
0
 public ParameterlessStepWithDependency(UniqueStepId stepId, IDependency dependency) : base(stepId)
 {
     _dependency = dependency;
 }
示例#16
0
 public WaitForDeploymentFinish(UniqueStepId stepId, IOctopusFacade octopusFacade)
     : base(stepId)
 {
     _octopusFacade = octopusFacade;
 }
 public BaseStep CreateInstance(Type stepType, UniqueStepId stepId)
 {
     return((BaseStep)_container.Resolve(stepType, AllParameters(stepId)));
 }
示例#18
0
 public FailingStep(UniqueStepId stepId)
     : base(stepId)
 {
 }
 public TestStep(UniqueStepId stepId) : base(stepId)
 {
 }
示例#20
0
 public override int GetHashCode()
 {
     return(UniqueStepId.GetHashCode());
 }
示例#21
0
 public Deploy(UniqueStepId stepId, IOctopusFacade octopusFacade)
     : base(stepId)
 {
     _octopusFacade = octopusFacade;
 }
示例#22
0
 public TeamCityBuildFinishedListener(UniqueStepId stepId)
     : base(stepId)
 {
 }
示例#23
0
 public StepWithDependencies(UniqueStepId stepId)
     : base(stepId)
 {
 }
示例#24
0
 public ParametrizedStep(UniqueStepId stepId) : base(stepId)
 {
 }
 public SuccessAfterRetryStep(UniqueStepId stepId)
     : base(stepId)
 {
     Retried = false;
 }
 public TeamCityTestResultsDownloader(UniqueStepId stepId, ITeamCityClient teamCityClient)
     : base(stepId)
 {
     _teamCityClient = teamCityClient;
 }
示例#27
0
 public WaitingForExternalDependencyStep(UniqueStepId stepId)
     : base(stepId)
 {
 }
示例#28
0
 public ParameterlessStep(UniqueStepId stepId) : base(stepId)
 {
 }
示例#29
0
 public CreateRelease(UniqueStepId stepId, IOctopusFacade octopusFacade)
     : base(stepId)
 {
     _octopusFacade = octopusFacade;
 }
示例#30
0
 public LoadTestResults(UniqueStepId stepId) : base(stepId)
 {
 }