示例#1
0
        public async Task ExecuteAsync()
        {
            _errorNotifier.Clear();

            // update status
            await _executeContext.ExecuteAsync();

            OnUpdateStatus?.Invoke(_executeContext.Status);

            var sw = ValueStopwatch.StartNew();

            // todo: specify IScalingProvider
            // run dframe
            await Host.CreateDefaultBuilder(_executeContext.Argument.Arguments)
            .ConfigureLogging(logging =>
            {
                logging.ClearProviders();
                logging.SetMinimumLevel(_loggingService.ExecuteLogProcessor.LogLevel);
                logging.AddZLoggerLogProcessor(_loggingService.ExecuteLogProcessor);
                logging.AddZLoggerLogProcessor(_errorNotifier);
                // todo: remove console logger?
                logging.AddZLoggerConsole();
            })
            .RunDFrameLoadTestingAsync(_executeContext.Argument.Arguments !, new DFrameOptions(_executeContext.Argument.HostAddress, 12345));

            var duration = sw.Elapsed;

            // update status
            if (_errorNotifier.GetExceptions().Length == 0)
            {
                await _executeContext.StopAsync();
            }
            else
            {
                await _executeContext.ErrorAsync();
            }
            OnUpdateStatus?.Invoke(_executeContext.Status);

            // record
            using (var scope = _serviceProvider.CreateScope())
            {
                // todo: requests and errors will obtain after progress implementation
                var profiler = scope.ServiceProvider.GetService <IDFrameProfiler>();
                await profiler.InsertAsync(_executeContext.ExecuteId, _executeContext.Argument.WorkerName, _executeContext.Argument.Arguments, 0, 0, duration, default);
            }
        }