From 1fec903bbc521367e2b5299954642cea9807923b Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 8 Jul 2024 14:18:18 +1000 Subject: [PATCH 1/2] Only include detailed HTTP diagnostics in `node health` output when `--verbose` is set --- src/SeqCli/Cli/Commands/Node/HealthCommand.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/SeqCli/Cli/Commands/Node/HealthCommand.cs b/src/SeqCli/Cli/Commands/Node/HealthCommand.cs index 24dad8f1..0bf497f0 100644 --- a/src/SeqCli/Cli/Commands/Node/HealthCommand.cs +++ b/src/SeqCli/Cli/Commands/Node/HealthCommand.cs @@ -54,13 +54,16 @@ protected override async Task Run() try { var response = await connection.Client.HttpClient.GetAsync("health"); - Console.WriteLine($"HTTP {response.Version} {((int)response.StatusCode).ToString(CultureInfo.InvariantCulture)} {response.ReasonPhrase}"); + Log.Information("HTTP {HttpVersion} {StatusCode} {ReasonPhrase}", response.Version, (int)response.StatusCode, response.ReasonPhrase); + foreach (var (key, values) in response.Headers.Concat(response.Content.Headers)) foreach (var value in values) { - Console.WriteLine($"{key}: {value}"); + Log.Information("{HeaderName}: {HeaderValue}", key, value); } + Console.WriteLine(await response.Content.ReadAsStringAsync()); + return response.IsSuccessStatusCode ? 0 : 1; } catch (Exception ex) From dc131b41f6b3c53b68099125db824fc35602306d Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 9 Jul 2024 15:22:19 +1000 Subject: [PATCH 2/2] Fix test --- test/SeqCli.EndToEnd/Node/NodeDemoteTestCase.cs | 2 +- test/SeqCli.EndToEnd/Node/NodeHealthTestCase.cs | 4 ++-- test/SeqCli.EndToEnd/Node/NodeListTestCase.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/SeqCli.EndToEnd/Node/NodeDemoteTestCase.cs b/test/SeqCli.EndToEnd/Node/NodeDemoteTestCase.cs index 1cc7efce..bd460648 100644 --- a/test/SeqCli.EndToEnd/Node/NodeDemoteTestCase.cs +++ b/test/SeqCli.EndToEnd/Node/NodeDemoteTestCase.cs @@ -6,7 +6,7 @@ namespace SeqCli.EndToEnd.Node; -[CliTestCase(MinimumApiVersion = "2021.3.6410")] +[CliTestCase] public class NodeDemoteTestCase: ICliTestCase { public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) diff --git a/test/SeqCli.EndToEnd/Node/NodeHealthTestCase.cs b/test/SeqCli.EndToEnd/Node/NodeHealthTestCase.cs index d13e07cd..5cd54934 100644 --- a/test/SeqCli.EndToEnd/Node/NodeHealthTestCase.cs +++ b/test/SeqCli.EndToEnd/Node/NodeHealthTestCase.cs @@ -6,14 +6,14 @@ namespace SeqCli.EndToEnd.Node; -[CliTestCase(MinimumApiVersion = "2021.3.6410")] +[CliTestCase] public class NodeHealthTestCase: ICliTestCase { public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) { var exit = runner.Exec("node health"); Assert.Equal(0, exit); - Assert.StartsWith("HTTP 1.1 200 OK", runner.LastRunProcess!.Output); + Assert.StartsWith("{\"status\":", runner.LastRunProcess!.Output); return Task.CompletedTask; } } \ No newline at end of file diff --git a/test/SeqCli.EndToEnd/Node/NodeListTestCase.cs b/test/SeqCli.EndToEnd/Node/NodeListTestCase.cs index 46b734df..7c8dfec8 100644 --- a/test/SeqCli.EndToEnd/Node/NodeListTestCase.cs +++ b/test/SeqCli.EndToEnd/Node/NodeListTestCase.cs @@ -6,7 +6,7 @@ namespace SeqCli.EndToEnd.Node; -[CliTestCase(MinimumApiVersion = "2021.3.6410")] +[CliTestCase] public class NodeListTestCase: ICliTestCase { public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner)