public DFrameApp(ILogger <DFrameApp> logger, IServiceProvider provider, DFrameOptions options, DFrameWorkerCollection workers) { this.provider = provider; this.logger = logger; this.workers = workers; this.options = options; }
/// <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); }
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); } }
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); } }
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); } }
public DFrameWorkerApp(ILogger <DFrameWorkerApp> logger, IServiceProvider provider, DFrameOptions options) { this.provider = provider; this.logger = logger; this.options = options; }
public WorkerContext(Channel masterChannel, DFrameOptions options) { this.masterChannel = masterChannel; this.WorkerId = Guid.NewGuid().ToString(); this.serializerOptions = options.SerializerOptions; }
public static async Task RunDFrameLoadTestingAsync(this IHostBuilder hostBuilder, string[] args, DFrameOptions options) { options.OnExecuteResult = SummaryResult; await hostBuilder.RunDFrameAsync(args, options); }
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; }
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; }