コード例 #1
0
        public async Task <int> OnExecuteAsync(IConsole console)
        {
            try
            {
                var podraceContext =
                    await PodraceContext.LoadAsync(string.IsNullOrEmpty(BasePath)
                                                   ?Directory.GetCurrentDirectory()
                                                       : BasePath);

                // Create a Race session
                var race = new PodraceSession(podraceContext, _loggerFactory, outputDirectory: null);

                _logger.LogInformation("Removing all Kubernetes resources for {RaceName}", podraceContext.Name);
                await race.RemoveAsync();

                _logger.LogInformation("Removed all Kubernetes resources for {RaceName}", podraceContext.Name);

                return(0);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An unexpected error occurred.");
                return(1);
            }
        }
コード例 #2
0
ファイル: RunCommand.cs プロジェクト: anurse/podrace
        public async Task <int> OnExecuteAsync(IConsole console)
        {
            try
            {
                var podraceContext =
                    await PodraceContext.LoadAsync(string.IsNullOrEmpty(BasePath)
                                                   ?Directory.GetCurrentDirectory()
                                                       : BasePath);

                // Create a Race session
                var outDir = string.IsNullOrEmpty(OutputDirectory) ? Directory.GetCurrentDirectory() : OutputDirectory;
                var race   = new PodraceSession(podraceContext, _loggerFactory, outDir);

                try
                {
                    // Deploy the race
                    await race.DeployAsync();

                    // Run the warmup
                    await race.WarmupAsync();

                    // Run the benchmark!
                    await race.RunAsync();

                    // Collect outputs
                    await race.CollectAsync();
                }
                finally
                {
                    if (!NoClean)
                    {
                        _logger.LogInformation("Cleaning up race resources...");
                        await race.RemoveAsync();
                    }
                    else
                    {
                        _logger.LogWarning("Skipping clean-up because --no-clean was set.");
                    }
                }

                return(0);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An unexpected error occurred.");
                return(1);
            }
        }
コード例 #3
0
        public async Task OnExecuteAsync(IConsole console)
        {
            var context =
                await PodraceContext.LoadAsync(string.IsNullOrEmpty(BasePath)
                                               ?Directory.GetCurrentDirectory()
                                                   : BasePath);

            console.WriteLine($"Root Path: {context.RootPath}");
            console.WriteLine();
            console.WriteLine("Kubernetes Config Files:");
            foreach (var config in context.Racefile.Configs)
            {
                var configPath = Path.Combine(context.RootPath, config);
                if (!File.Exists(configPath))
                {
                    console.WriteLine($"* {configPath} (MISSING)");
                }
                else
                {
                    console.WriteLine($"* {configPath}");
                }
            }

            console.WriteLine("Warmup Laps:");
            foreach (var lap in context.Racefile.Warmup)
            {
                console.WriteLine($"* {lap}");
            }

            console.WriteLine("Benchmark Laps:");
            foreach (var lap in context.Racefile.Benchmark)
            {
                console.WriteLine($"* {lap}");
            }

            console.WriteLine("Collectors:");
            foreach (var collector in context.Racefile.Collectors)
            {
                console.WriteLine($"* {collector}");
            }
        }