Exemplo n.º 1
0
        public void ConfigurationTests_Configuration_Filters()
        {
            var pipelineId = Guid.NewGuid().ToString();
            var config     = new PipelineConfiguration
            {
                Id             = pipelineId,
                InputHandler   = new HandlerNode(typeof(GenericInputHandler <LogMessage>)),
                OutputHandlers = new List <HandlerNode>
                {
                    new HandlerNode("ConsoleOutput")
                    {
                        Filters = new List <string>
                        {
                            "Message -> msg"
                        }
                    }
                }
            };


            var builder = new PipelineBuilder();

            builder.BuildPipeline(ProcessingServer.Server, config);

            var client = new EventDispatcher();

            client.Process(pipelineId, new LogMessage {
                Message = "ConfigurationTests_NewPipelinePerEvent1"
            });
            client.Process(pipelineId, new LogMessage {
                Message = "ConfigurationTests_NewPipelinePerEvent2"
            });

            ProcessingServer.Server.WaitAll(pipelineId);
        }
        private static async Task <long> ExecutePipelineAsync(Type pipelineType, PipelineConfiguration configuration, CancellationToken cancellationToken)
        {
            IAsyncPipeline asyncPipeline;

            if ((object)pipelineType == null)
            {
                throw new ArgumentNullException(nameof(pipelineType));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            asyncPipeline = (IAsyncPipeline)Activator.CreateInstance(pipelineType);

            if ((object)asyncPipeline == null)
            {
                throw new InvalidOperationException(nameof(asyncPipeline));
            }

            using (AsyncDisposal.Await(asyncPipeline, cancellationToken))
            {
                asyncPipeline.Configuration = configuration;
                await asyncPipeline.CreateAsync(cancellationToken);

                IAsyncContext asyncContext;
                using (AsyncDisposal.Await(asyncContext = asyncPipeline.CreateContextAsync(), cancellationToken))
                {
                    await asyncContext.CreateAsync(cancellationToken);

                    return(await asyncPipeline.ExecuteAsync(asyncContext, cancellationToken));
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PipelineBuilderCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private PipelineBuilderCommand(Package package, DTE2 dte)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            if (dte == null)
            {
                throw new ArgumentNullException("dte");
            }

            this.package = package;
            this.dte     = dte;
            this.config  = new PipelineConfiguration();

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(this.MenuItemCallback, menuCommandID);
                commandService.AddCommand(menuItem);
            }
        }
Exemplo n.º 4
0
        public void ConfigurationTests_Configuration()
        {
            var pipelineId = Guid.NewGuid().ToString();
            var config     = new PipelineConfiguration
            {
                Id             = pipelineId,
                InputHandler   = new HandlerNode("CustomInput"),
                OutputHandlers = new List <HandlerNode>
                {
                    new HandlerNode("ConsoleOutput")
                }
            };


            var builder = new PipelineBuilder();

            builder.BuildPipeline(config);

            var client = new EventDispatcher();

            client.Process(pipelineId, new LogMessage {
                Message = "ConfigurationTests_NewPipelinePerEvent1"
            });
            client.Process(pipelineId, new LogMessage {
                Message = "ConfigurationTests_NewPipelinePerEvent2"
            });
        }
Exemplo n.º 5
0
        public void LoadTesting_MultipleProcessors()
        {
            GlobalConfiguration.Setup(s => s.UseOptions(new Options
            {
                MaxItemsInQueue = 10,
                MinProcessors   = 10,
                MaxProcessors   = 50
            }));

            var pipelineId = Guid.NewGuid().ToString();
            var config     = new PipelineConfiguration
            {
                Id             = pipelineId,
                InputHandler   = new HandlerNode("CustomInput"),
                OutputHandlers = new List <HandlerNode>
                {
                    new HandlerNode("ConsoleOutput")
                    {
                        Filters = new List <string>
                        {
                            "Message -> msg",
                            "Level -> lvl"
                        }
                    },
                    new HandlerNode(typeof(ThreadWaitHandler))
                }
            };

            var builder = new PipelineBuilder();

            builder.BuildPipeline(config);

            var result = ProfilerSession.StartSession()
                         .Task(ctx =>
            {
                var client = new EventDispatcher();
                client.Process(pipelineId, new LogMessage {
                    Level = "Info", Message = $"Loadtesting {ctx.Get<int>(ContextKeys.Iteration)} on Thread {ctx.Get<int>(ContextKeys.ThreadId)}", Title = "Loadtest"
                });
            })
                         .SetIterations(100)
                         .SetThreads(10)
                         .Settings(s => s.RunWarmup = false)
                         .RunSession();

            ProcessingServer.Server.WaitAll(pipelineId);

            // delay to ensure all threads are ended
            System.Threading.Tasks.Task.Delay(3000);

            var storage = GlobalConfiguration.Configuration.Resolve <IStorage>();

            Assert.GreaterOrEqual(100 * 10, storage.Get <long>(new StorageKey(pipelineId, "ProcessedEventsMetric")));

            var stats = new StatisticsApi(pipelineId);

            Assert.AreEqual(10, stats.GetMetricValue(MetricType.ThreadCount));

            result.Trace("### LoadTesting");
        }
Exemplo n.º 6
0
        public TestResultSummaryViewModel(TestResultSummary summary, PipelineConfiguration pipelineConfiguration, bool includeOthersInTotal)
        {
            PassedTests = 0;
            FailedTests = 0;

            if (summary.AggregatedResultsAnalysis.ResultsByOutcome.ContainsKey(TestOutcome.Passed))
            {
                PassedTests = summary.AggregatedResultsAnalysis.ResultsByOutcome[TestOutcome.Passed].Count;
            }
            if (summary.AggregatedResultsAnalysis.ResultsByOutcome.ContainsKey(TestOutcome.Failed))
            {
                FailedTests = summary.AggregatedResultsAnalysis.ResultsByOutcome[TestOutcome.Failed].Count;
            }

            TotalTests = summary.AggregatedResultsAnalysis.TotalTests;
            OtherTests = TotalTests - PassedTests - FailedTests;

            if (!includeOthersInTotal)
            {
                TotalTests -= OtherTests;
            }

            PassingRate = TestResultsHelper.GetTestOutcomePercentageString(PassedTests, TotalTests);
            Duration    = TimeSpanFormatter.FormatDurationWithUnit(summary.AggregatedResultsAnalysis.Duration);
            Url         = pipelineConfiguration.TestTabLink;
        }
Exemplo n.º 7
0
        public ICodeGenerationPipeline Build(JObject configuration)
        {
            this.logger.Write(new StageTopLevelInfoRecord("Building code generation pipeline."));

            try
            {
                var context = new PipelineCreationContext(this.basePath);

                var reader = new PipelineConfiguration(configuration);
                var result = new CodeGenerationPipeline(this.logger);
                result.PipelineEnvironment = this.CreatePipelineEnvironment(result.PipelineExecutionInfo, reader);

                var inputConfig = reader.InputCodeStreamProviderConfiguration;
                if (inputConfig != null)
                {
                    var inputBuilder = new CodeStreamProviderBuilder(result.PipelineEnvironment, this.workspaceManagers.OutputWorkspace, this.fileSystem, this.basePath);
                    result.InputCodeStreamProvider = inputBuilder.Build(inputConfig);
                }

                result.Batches = this.BuildBatches(reader.BatchConfigurations, context);

                return(result);
            }
            catch (Exception ex)
            {
                this.logger.Write(new ErrorLogRecord("Error occurred while building code generation pipeline.", ex));
                throw;
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Build the pipeline based on the configuration
        /// </summary>
        /// <param name="server"></param>
        /// <param name="config"></param>
        public void BuildPipeline(IProcessingServer server, PipelineConfiguration config)
        {
            _logger.Write($"Setup Pipeline:{config}", Category.Log, LogLevel.Debug, "PipelineBuilder");

            server.SetupPipeline(config.Id, s =>
            {
                var rootCtx = GlobalConfiguration.Configuration.Resolve <IActivationContext>();

                s.Register(() =>
                {
                    var pipeline = new EventPipeline();
                    foreach (var node in config.OutputHandlers)
                    {
                        var ctx           = rootCtx.ChildContext();
                        var outputHandler = BuildHandler <IOutputHandler>(ctx, node);

                        var converter = node.BuildDataFilter();
                        if (converter.Filters.Any(f => f.FilterType == Filters.FilterType.Property))
                        {
                            outputHandler = new DataFilterDecorator(converter, outputHandler);
                        }

                        pipeline.AddHandler(outputHandler);
                    }

                    return(pipeline);
                }, config.Options);

                var inputHandler = BuildHandler <IInputHandler>(rootCtx.ChildContext(), config.InputHandler);
                s.Register(inputHandler);
            });
        }
Exemplo n.º 9
0
        /// <summary>
        /// Run the validation of the supplied source document, optionally
        /// writing the validated document to the supplied destination.
        /// </summary>

        public void Run()
        {
            AugmentedSource aug = AugmentedSource.makeAugmentedSource(source);

            aug.setSchemaValidationMode(lax ? Validation.LAX : Validation.STRICT);
            JReceiver receiver;

            if (destination == null)
            {
                receiver = new Sink();
            }
            else if (destination is Serializer)
            {
                receiver = ((Serializer)destination).GetReceiver(config);
            }
            else
            {
                Result result = destination.GetResult();
                if (result is JReceiver)
                {
                    receiver = (JReceiver)result;
                }
                else
                {
                    throw new ArgumentException("Unknown type of destination");
                }
            }
            PipelineConfiguration pipe = config.makePipelineConfiguration();

            if (errorList != null)
            {
                pipe.setErrorListener(new ErrorGatherer(errorList));
            }
            new Sender(pipe).send(aug, receiver, true);
        }
Exemplo n.º 10
0
        public void ProcessingServer_PipelineOptions()
        {
            var factory = new EventBusFactory();
            var server  = new ProcessingServer(factory);


            var config = new PipelineConfiguration
            {
                Id           = "test",
                InputHandler = new HandlerNode
                {
                    Type = typeof(LogInputHandler)
                },
                OutputHandlers = new List <HandlerNode>
                {
                    new HandlerNode
                    {
                        Type = typeof(ConsoleOutputHandler)
                    }
                },
                Options = new PipelineOptions
                {
                    MinProcessors   = 1,
                    MaxItemsInQueue = 100,
                    MaxProcessors   = 1
                }
            };


            server.SetupPipeline("test", config);

            var bus = factory.GetEventBus("test");

            Assert.AreSame(bus.PipelineFactory.Options, config.Options);
        }
Exemplo n.º 11
0
        static async Task Run()
        {
            var configuration = new PipelineConfiguration()
                                .AddGlobalVariable("ID", Guid.NewGuid())
                                .NextStep(new StepOne(), Variables.Empty)
                                .NextStep(new StepGlobalVariable())
                                .NextStepWithCommand(new StepShowMessageFromCommand(), new StepCommand()
            {
                Message = "Hello world"
            })
                                .NextStep(new StepLocalVariable(), new Variables {
                { "MESSAGE", "Hello from variables" }
            })
                                .NextStep(new StepAddObjectScope())
                                .NextStep(new StepReadScope(), Variables.Empty, "MAIN")
                                .AddAlwaysEnd(x =>
            {
                Console.WriteLine("----------- END -----------");
            })
                                .AddBeforeStart(x =>
            {
                Console.WriteLine("----------- START -----------");
            });

            var manager = new PipelineManager();

            await manager.Configure(configuration)
            .Run();
        }
Exemplo n.º 12
0
        public static PipelineConfiguration RegisterCustomerPublications(this PipelineConfiguration configuration)
        {
            configuration.customerPublisher.CustomerFoundHandler += async(s, e) => await configuration.transactionRegistration.OnCustomerCheckEvent(s, e).ConfigureAwait(true);

            configuration.customerPublisher.LogHandler += async(s, e) => await configuration.LogSubscriber.OnLogReceivedEvent(s, e).ConfigureAwait(true);

            return(configuration);
        }
 public ChangeViewModel(ChangeData change, PipelineConfiguration config)
     : this(change.Id,
            StringUtils.CompressNewLines(change.Message),
            change.Author?.DisplayName,
            DateTimeHelper.GetLocalTimeWithTimeZone(change.Timestamp),
            LinkHelper.GetCommitLink(change.Id, change.Location.AbsoluteUri, config))
 {
 }
        public TestSummaryGroupViewModel(TestSummaryGroup testSummaryGroup, PipelineConfiguration config,
                                         bool includeOthersInTotal)
        {
            GroupName = testSummaryGroup.GroupingType.GetDescription();

            InitializeSummaryItems(testSummaryGroup, config, includeOthersInTotal);

            InitializeSupportedPriorityColumns();
        }
Exemplo n.º 15
0
        private static string GetBuildLink(PipelineConfiguration config, string collectionUri,
                                           Dictionary <string, object> parameters)
        {
            var uri = new Uri(GetBaseUri(collectionUri),
                              GetBuildRelativeUrl(config.ProjectName) + GetQueryParameter(parameters))
                      .AbsoluteUri;

            return(uri);
        }
Exemplo n.º 16
0
 public static string GetCreateBugLinkForTest(PipelineConfiguration config,
                                              TestCaseResult testResult)
 {
     return(GetTestResultLink(config, testResult.TestRun?.Id,
                              testResult.Id, new Dictionary <string, string>
     {
         { "create-bug", "true" }
     }));
 }
 private void InitializeSummaryItems(TestSummaryGroup testSummaryGroup, PipelineConfiguration config,
                                     bool includeOthersInTotal)
 {
     SummaryItems = new List <TestSummaryItemViewModel>();
     foreach (var testSummaryItem in testSummaryGroup.Runs)
     {
         SummaryItems.Add(new TestSummaryItemViewModel(testSummaryGroup.GroupingType, testSummaryItem, config, includeOthersInTotal));
     }
 }
Exemplo n.º 18
0
        public static PipelineConfiguration RegisterSiteSubscriptions(this PipelineConfiguration configuration)
        {
            configuration.transactionRegistration.TransactionHandler += async(s, e) => await configuration.siteSubscriber.OnTransactionReceivedEvent(s, e).ConfigureAwait(true);

            configuration.transactionRegistration.LogHandler += async(s, e) => await configuration.LogSubscriber.OnLogReceivedEvent(s, e).ConfigureAwait(true);

            configuration.siteSubscriber.LogHandler += async(s, e) => await configuration.LogSubscriber.OnLogReceivedEvent(s, e).ConfigureAwait(true);

            return(configuration);
        }
        public async override Task <TestResultSummary> QueryTestResultsReportAsync(PipelineConfiguration releaseConfig = null)
        {
            var releaseConfiguration = (releaseConfig != null && releaseConfig is ReleaseConfiguration)
                ? (releaseConfig as ReleaseConfiguration) : _releaseConfig;

            return //TODO - RetryHelper.Retry(()
                   (await _tcmClient.QueryTestResultsReportForReleaseAsync(
                        releaseConfiguration.ProjectName,
                        releaseConfiguration.Id,
                        releaseConfiguration.EnvironmentId));
        }
 private void InitializeAssociatedChanges(AbstractReport emailReportDto, PipelineConfiguration config)
 {
     if (emailReportDto.AssociatedChanges?.Any() == true)
     {
         AssociatedChanges = new List <ChangeViewModel>();
         foreach (var associatedChange in emailReportDto.AssociatedChanges)
         {
             AssociatedChanges.Add(new ChangeViewModel(associatedChange, config));
         }
     }
 }
Exemplo n.º 21
0
        public override ReleaseViewModel GetReleaseViewModel(PipelineConfiguration config)
        {
            var releaseConfig = config.Clone() as ReleaseConfiguration;

            if (releaseConfig == null)
            {
                throw new NotSupportedException();
            }

            return(new ReleaseViewModel(Environment, releaseConfig));
        }
Exemplo n.º 22
0
        private void ButtonExecute_Click(object sender, RoutedEventArgs e)
        {
            if (Configuration is null)
            {
                return;
            }
            var win = new PipelineExecuterWindow(Configuration);

            win.ShowDialog();
            Configuration = win.Configuration;
        }
Exemplo n.º 23
0
            private static async Task Main(string[] args)
            {
                var files = Directory.GetFiles(@"TestData\", "*.cs");

                var configure = new PipelineConfiguration(2, 2, 2);
                var pipeline  = new Pipeline(configure);

                var outputDirectory = Directory.GetCurrentDirectory() + @"\TestResult\";

                await pipeline.Processing(files, outputDirectory);
            }
        public static EmailReportConfiguration CreateConfiguration(IHeaderDictionary headers, string jsonRequest, ILogger logger)
        {
            var data = (JObject)JsonConvert.DeserializeObject(jsonRequest);

            JToken executeConditionObject;

            if (data.TryGetValue("ExecuteCondition", out executeConditionObject) && executeConditionObject != null)
            {
                var executeCondition = JsonConvert.DeserializeObject <ExecuteCondition>(executeConditionObject.ToString());
                // Evaluate condition and if fails, exit
                if (!executeCondition.Evaluate())
                {
                    return(null);
                }
            }

            StringValues authTokenValues;

            headers.TryGetValue("AuthToken", out authTokenValues);
            var accessToken = authTokenValues.FirstOrDefault();

            if (!string.IsNullOrWhiteSpace(accessToken))
            {
                var credentials             = new VssBasicCredential("", accessToken);
                var reportDataConfiguration = JsonConvert.DeserializeObject <ReportDataConfiguration>(data.GetValue("ReportDataConfiguration").ToString());
                var mailConfiguration       = JsonConvert.DeserializeObject <MailConfiguration[]>(data.GetValue("EmailConfiguration").ToString());

                var pipelineInfoObject = (JObject)JsonConvert.DeserializeObject(data.GetValue("PipelineInfo").ToString());
                var pipelineType       = pipelineInfoObject.GetValue("PipelineType").ToObject <PipelineType>();

                PipelineConfiguration pipelineConfiguration = null;
                if (pipelineType == PipelineType.Release)
                {
                    pipelineConfiguration             = JsonConvert.DeserializeObject <ReleaseConfiguration>(data.GetValue("PipelineInfo").ToString());
                    pipelineConfiguration.Credentials = credentials;
                }
                else
                {
                    // TODO
                    return(null);
                }

                return(new EmailReportConfiguration()
                {
                    PipelineType = pipelineType,
                    ReportDataConfiguration = reportDataConfiguration,
                    MailConfigurations = mailConfiguration,
                    PipelineConfiguration = pipelineConfiguration
                });
            }

            return(null);
        }
Exemplo n.º 25
0
        public static string GetBuildSummaryLink(string buildId, PipelineConfiguration config)
        {
            var collectionUri = config.ServerUri;
            var parameters    = new Dictionary <string, object>
            {
                { "buildId", buildId },
                { "_a", "summary" }
            };
            var uri = GetBuildLink(config, collectionUri, parameters);

            return(uri);
        }
Exemplo n.º 26
0
        public static string GetBuildDefinitionLink(string definitionId, PipelineConfiguration config)
        {
            var collectionUri = config.ServerUri;
            var parameters    = new Dictionary <string, object>
            {
                { "definitionId", definitionId },
                { "_a", "completed" }
            };
            var uri = GetBuildLink(config, collectionUri, parameters);

            return(uri);
        }
Exemplo n.º 27
0
        public static string GetWorkItemLink(PipelineConfiguration config, int workItemId)
        {
            var queryParams = new Dictionary <string, object>
            {
                { "id", workItemId }
            };

            return(new Uri(
                       GetBaseUri(config.ServerUri),
                       GetWorkItemRelativeUrl(config.ProjectName) + GetQueryParameter(queryParams))
                   .AbsoluteUri);
        }
Exemplo n.º 28
0
        public ArtifactViewModel(Artifact artifact, PipelineConfiguration config)
        {
            Version = GetArtifactInfo(artifact, ArtifactDefinitionConstants.Version);

            BranchName = GetArtifactInfo(artifact, ArtifactDefinitionConstants.Branch);

            Name = artifact.Alias;

            IsPrimary = artifact.IsPrimary;

            BuildSummaryUrl       = LinkHelper.GetBuildSummaryLink(artifact, config);
            ArtifactDefinitionUrl = LinkHelper.GetBuildDefinitionLink(artifact, config);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Supply the instance document to be validated, in the form of an XmlReader.
        /// </summary>
        /// <remarks>
        /// The XmlReader is responsible for parsing the document; this method validates it.
        /// </remarks>
        /// <param name="reader">The <c>XmlReader</c> used to read and parse the instance
        /// document being validated. This is used as supplied. For conformance, use of a
        /// plain <c>XmlTextReader</c> is discouraged, because it does not expand entity
        /// references. This may cause validation failures.
        /// </param>

        public void SetSource(XmlReader reader)
        {
            PullProvider          pp   = new DotNetPullProvider(reader);
            PipelineConfiguration pipe = config.makePipelineConfiguration();

            pipe.setUseXsiSchemaLocation(useXsiSchemaLocation);
            pp.setPipelineConfiguration(pipe);
            // pp = new PullTracer(pp);  /* diagnostics */
            PullSource psource = new PullSource(pp);

            psource.setSystemId(reader.BaseURI);
            this.source = psource;
        }
Exemplo n.º 30
0
        private static string GetReleaseLinkTab(PipelineConfiguration config, string tab)
        {
            var collectionUri = config.ServerUri;
            var releaseConfig = config as ReleaseConfiguration;
            var parameters    = GetQueryParameter(new Dictionary <string, object> {
                { "_a", ReleaseEnvironmentExtension },
                { "releaseId", releaseConfig.Id },
                { "environmentId", releaseConfig.EnvironmentId },
                { "extensionId", tab }
            });

            return(new Uri(GetBaseUri(collectionUri), config.ProjectName + "/" + ReleaseProgressView + parameters).AbsoluteUri);
        }