Esempio n. 1
0
 public DFrameApp(ILogger <DFrameApp> logger, IServiceProvider provider, DFrameOptions options, DFrameWorkerCollection workers)
 {
     this.provider = provider;
     this.logger   = logger;
     this.workers  = workers;
     this.options  = options;
 }
Esempio n. 2
0
        /// <summary>
        /// ApacheBench like reports
        /// </summary>
        /// <param name="results"></param>
        /// <param name="options"></param>
        static async Task OutputReportAb(ExecuteResult[] results, DFrameOptions options, ExecuteScenario executeScenario)
        {
            var scalingType = options.ScalingProvider.GetType().Name;
            var abReport    = new AbReport(results, executeScenario, scalingType);

            Console.WriteLine(abReport.ToString());
            await ReportNotifier.OnReportOutput.PublishAsync(abReport).ConfigureAwait(false);
        }
Esempio n. 3
0
        public async Task StartWorkerAsync(DFrameOptions options, int processCount, IServiceProvider provider, IFailSignal failSignal, CancellationToken cancellationToken)
        {
            this.failSignal = failSignal;

            var location = Assembly.GetEntryAssembly().Location;

            var cmd = $"dotnet \"{location}\" --worker-flag";

            for (int i = 0; i < processCount; i++)
            {
                var startProcessTask = ProcessX.StartAsync(cmd);
                WriteAll(startProcessTask);
            }
        }
Esempio n. 4
0
        static void SummaryResult(ExecuteResult[] results, DFrameOptions options, ExecuteScenario executeScenario)
        {
            // TODO: Logger
            if (!results.Any())
            {
                // canceled
                Console.WriteLine("No execution result found, quit result report.");
                return;
            }

            // Output req/sec and other calcutlation report.
            Console.WriteLine("Show Load Testing result report.");
            OutputReportAb(results, options, executeScenario).GetAwaiter().GetResult();
        }
        public Task StartWorkerAsync(DFrameOptions options, int processCount, IServiceProvider provider, IFailSignal failSignal, CancellationToken cancellationToken)
        {
            this.failSignal         = failSignal;
            cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);

            var tasks = new Task[processCount];

            for (int i = 0; i < processCount; i++)
            {
                tasks[i] = Core(provider, options, cancellationTokenSource.Token);
            }

            this.tasks = Task.WhenAll(tasks);
            return(Task.CompletedTask);
        }
        async Task Core(IServiceProvider provider, DFrameOptions options, CancellationToken cancellationToken)
        {
            // create shim of ConsoleApp
            try
            {
                var logger  = provider.GetService(typeof(ILogger <DFrameWorkerApp>));
                var logger2 = provider.GetService(typeof(ILogger <ConsoleAppFramework.ConsoleAppEngine>));
                var app     = new DFrameWorkerApp((ILogger <DFrameWorkerApp>)logger, provider, options);
                app.Context = new ConsoleAppFramework.ConsoleAppContext(new string[0], DateTime.UtcNow, cancellationToken, (ILogger <ConsoleAppFramework.ConsoleAppEngine>)logger2);

                await app.Main();
            }
            catch (Exception ex)
            {
                failSignal.TrySetException(ex);
            }
        }
Esempio n. 7
0
        public static async Task RunDFrameAsync(this IHostBuilder hostBuilder, string[] args, DFrameOptions options)
        {
            var workerCollection = DFrameWorkerCollection.FromCurrentAssemblies();

            if (args.Length == 0)
            {
                ShowDFrameAppList(workerCollection);
                return;
            }

            hostBuilder = hostBuilder
                          .ConfigureServices(x =>
            {
                x.AddSingleton(options);
                x.AddSingleton(workerCollection);

                foreach (var item in workerCollection.All)
                {
                    x.AddTransient(item.WorkerType);
                }
            });

            if (args.Length != 0 && args.Contains("--worker-flag"))
            {
                await hostBuilder.RunConsoleAppFrameworkAsync <DFrameWorkerApp>(args);
            }
            else
            {
                await hostBuilder.RunConsoleAppFrameworkAsync <DFrameApp>(args);
            }
        }
Esempio n. 8
0
 public DFrameWorkerApp(ILogger <DFrameWorkerApp> logger, IServiceProvider provider, DFrameOptions options)
 {
     this.provider = provider;
     this.logger   = logger;
     this.options  = options;
 }
Esempio n. 9
0
 public WorkerContext(Channel masterChannel, DFrameOptions options)
 {
     this.masterChannel     = masterChannel;
     this.WorkerId          = Guid.NewGuid().ToString();
     this.serializerOptions = options.SerializerOptions;
 }
Esempio n. 10
0
        public static async Task RunDFrameLoadTestingAsync(this IHostBuilder hostBuilder, string[] args, DFrameOptions options)
        {
            options.OnExecuteResult = SummaryResult;

            await hostBuilder.RunDFrameAsync(args, options);
        }
Esempio n. 11
0
        public DFrameRamupRunner(ILogger <DFrameApp> logger, IServiceProvider provider, DFrameOptions options, DFrameWorkerCollection workers, int maxWorkerPerProcess, int workerSpawnCount, int workerSpawnSecond)

            : base(logger, provider, options, workers)
        {
            this.maxWorkerPerProcess = maxWorkerPerProcess;
            this.workerSpawnCount    = workerSpawnCount;
            this.workerSpawnSecond   = workerSpawnSecond;
        }
Esempio n. 12
0
 public DFrameConcurrentRequestRunner(ILogger <DFrameApp> logger, IServiceProvider provider, DFrameOptions options, DFrameWorkerCollection workers, int workerPerProcess, int executePerWorker)
     : base(logger, provider, options, workers)
 {
     this.workerPerProcess = workerPerProcess;
     this.executePerWorker = executePerWorker;
 }