Skip to content

Commit 7da5c38

Browse files
committed
Better logging
1 parent c6df9d1 commit 7da5c38

6 files changed

Lines changed: 42 additions & 48 deletions

File tree

src/TurboHTTP.IntegrationTests/H10/EdgeCaseSpec.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ private ClientHelper CreateClient()
2121
return ClientHelper.CreateClient(_server.H1Port, new Version(1, 0), system: _systemFixture.System);
2222
}
2323

24-
[Fact(Timeout = 30000)]
24+
[Fact(Timeout = 60000)]
2525
public async Task EdgeCase_should_receive_large_256kb_body_via_connection_close()
2626
{
2727
// HTTP/1.0 uses connection-close to delimit body end (no chunked encoding)
28-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(15));
28+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
2929
await using var helper = CreateClient();
3030

3131
var request = new HttpRequestMessage(HttpMethod.Get, "/large/256");
@@ -37,10 +37,10 @@ public async Task EdgeCase_should_receive_large_256kb_body_via_connection_close(
3737
Assert.All(bytes, b => Assert.Equal((byte)'A', b));
3838
}
3939

40-
[Fact(Timeout = 30000)]
40+
[Fact(Timeout = 60000)]
4141
public async Task EdgeCase_should_echo_post_body_correctly()
4242
{
43-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(15));
43+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
4444
await using var helper = CreateClient();
4545

4646
var payload = "hello from http10";
@@ -62,7 +62,7 @@ public async Task EdgeCase_should_echo_post_body_correctly()
6262
[InlineData(500)]
6363
public async Task EdgeCase_should_return_status_codes_correctly(int statusCode)
6464
{
65-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(15));
65+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
6666
await using var helper = CreateClient();
6767

6868
var request = new HttpRequestMessage(HttpMethod.Get, $"/status/{statusCode}");
@@ -71,10 +71,10 @@ public async Task EdgeCase_should_return_status_codes_correctly(int statusCode)
7171
Assert.Equal((HttpStatusCode)statusCode, response.StatusCode);
7272
}
7373

74-
[Fact(Timeout = 30000)]
74+
[Fact(Timeout = 60000)]
7575
public async Task EdgeCase_should_echo_custom_headers_in_response()
7676
{
77-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(15));
77+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
7878
await using var helper = CreateClient();
7979

8080
var request = new HttpRequestMessage(HttpMethod.Get, "/headers/echo");
@@ -90,10 +90,10 @@ public async Task EdgeCase_should_echo_custom_headers_in_response()
9090
Assert.Equal("second", string.Join("", anotherValues));
9191
}
9292

93-
[Fact(Timeout = 30000)]
93+
[Fact(Timeout = 60000)]
9494
public async Task EdgeCase_should_complete_empty_body_response_without_hanging()
9595
{
96-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(15));
96+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
9797
await using var helper = CreateClient();
9898

9999
var request = new HttpRequestMessage(HttpMethod.Get, "/edge/empty-body");

src/TurboHTTP.IntegrationTests/H11/ConnectionSpec.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ private ClientHelper CreateClient()
2020
return ClientHelper.CreateClient(_server.HttpPort, new Version(1, 1), system: _systemFixture.System);
2121
}
2222

23-
[Fact(Timeout = 20000)]
23+
[Fact(Timeout = 60000)]
2424
public async Task Connection_should_allow_sequential_requests_with_keep_alive()
2525
{
26-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
26+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
2727
await using var helper = CreateClient();
2828

2929
// First request with explicit Connection: Keep-Alive
@@ -41,10 +41,10 @@ public async Task Connection_should_allow_sequential_requests_with_keep_alive()
4141
Assert.Equal("keep-alive", body2);
4242
}
4343

44-
[Fact(Timeout = 20000)]
44+
[Fact(Timeout = 60000)]
4545
public async Task Connection_should_have_close_header_in_response()
4646
{
47-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
47+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
4848
await using var helper = CreateClient();
4949

5050
var request = new HttpRequestMessage(HttpMethod.Get, "/conn/close");
@@ -59,10 +59,10 @@ public async Task Connection_should_have_close_header_in_response()
5959
"Response should contain Connection: close header");
6060
}
6161

62-
[Fact(Timeout = 20000)]
62+
[Fact(Timeout = 60000)]
6363
public async Task Connection_should_default_to_keep_alive_without_connection_header()
6464
{
65-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
65+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
6666
await using var helper = CreateClient();
6767

6868
// First request — no explicit Connection header from server
@@ -80,24 +80,24 @@ public async Task Connection_should_default_to_keep_alive_without_connection_hea
8080
Assert.Equal("default", body2);
8181
}
8282

83-
[Fact(Timeout = 20000)]
83+
[Fact(Timeout = 60000)]
8484
public async Task Connection_101_switching_protocols_must_not_be_reusable_for_http()
8585
{
8686
// 101 Switching Protocols transitions the connection away from HTTP.
8787
// The client cannot complete a normal HTTP exchange over a switched connection,
8888
// so we expect the request to fail (timeout or exception) rather than return 101.
89-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
89+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
9090
await using var helper = CreateClient();
9191

9292
var request = new HttpRequestMessage(HttpMethod.Get, "/conn/upgrade-101");
9393
await Assert.ThrowsAnyAsync<OperationCanceledException>(
9494
async () => await helper.Client.SendAsync(request, cts.Token));
9595
}
9696

97-
[Fact(Timeout = 20000)]
97+
[Fact(Timeout = 60000)]
9898
public async Task Connection_should_prove_reuse_across_different_endpoints()
9999
{
100-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
100+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
101101
await using var helper = CreateClient();
102102

103103
// Send multiple requests to different endpoints on the same client

src/TurboHTTP.IntegrationTests/LoggingBridgeSpec.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -136,31 +136,6 @@ private ITurboHttpClient BuildClientViaUserDI(bool withTurboTrace = false)
136136
return _client;
137137
}
138138

139-
[Fact(Timeout = 20000)]
140-
public async Task Akka_bridge_should_route_stream_creation_message_to_MEL()
141-
{
142-
// Verifies that ClientStreamOwnerActor's Info log for "Creating stream instance"
143-
// flows through the Akka→MEL bridge to the capturing provider.
144-
var client = BuildClientViaUserDI();
145-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
146-
147-
var response = await client.SendAsync(new HttpRequestMessage(HttpMethod.Get, "/hello"), cts.Token);
148-
Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode);
149-
150-
await Task.Delay(TimeSpan.FromMilliseconds(200), cts.Token);
151-
152-
var entries = _capture.Entries.ToList();
153-
var entry = entries.FirstOrDefault(e =>
154-
e.Level == LogLevel.Information &&
155-
e.Message.Contains("Creating stream instance", StringComparison.OrdinalIgnoreCase));
156-
157-
Assert.NotNull(entry);
158-
// LoggerFactoryLogger routes all Akka actor messages under the "Akka.Actor.ActorSystem"
159-
// MEL category; the actor path (containing "stream-owner") is embedded in the message.
160-
Assert.Equal("Akka.Actor.ActorSystem", entry.CategoryName);
161-
Assert.Contains("stream-owner", entry.Message, StringComparison.OrdinalIgnoreCase);
162-
}
163-
164139
[Fact(Timeout = 20000)]
165140
public async Task Akka_bridge_should_route_pipeline_materialized_message_to_MEL()
166141
{

src/TurboHTTP.IntegrationTests/Shared/ActorSystemFixture.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using Akka.Actor;
2+
using Akka.Configuration;
23
using Akka.DependencyInjection;
34
using Microsoft.Extensions.DependencyInjection;
5+
using Microsoft.Extensions.Logging;
6+
using TurboHTTP.Diagnostics;
47

58
namespace TurboHTTP.IntegrationTests.Shared;
69

@@ -11,13 +14,27 @@ namespace TurboHTTP.IntegrationTests.Shared;
1114
/// </summary>
1215
public sealed class ActorSystemFixture : IAsyncLifetime
1316
{
17+
private static readonly Config QuietConfig = ConfigurationFactory.ParseString(
18+
"akka.loglevel = WARNING");
19+
1420
public ActorSystem System { get; private set; } = null!;
1521

1622
public ValueTask InitializeAsync()
1723
{
24+
var loggerFactory = LoggerFactory.Create(b =>
25+
{
26+
b.AddConsole();
27+
b.SetMinimumLevel(LogLevel.Information);
28+
});
29+
30+
TurboTrace.Configure(
31+
new LoggerTraceListener(loggerFactory, TurboTraceCategory.All, TurboTraceLevel.Info),
32+
TurboTraceCategory.All,
33+
TurboTraceLevel.Info);
34+
1835
var services = new ServiceCollection();
1936
var diSetup = DependencyResolverSetup.Create(services.BuildServiceProvider());
20-
var bootstrap = BootstrapSetup.Create();
37+
var bootstrap = BootstrapSetup.Create().WithConfig(QuietConfig);
2138

2239
var setup = bootstrap.And(diSetup);
2340
System = ActorSystem.Create($"turbohttp-shared-{Guid.NewGuid()}", setup);

src/TurboHTTP.IntegrationTests/Shared/ServerFixture.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public async ValueTask InitializeAsync()
4343
var builder = WebApplication.CreateBuilder();
4444
builder.Logging.ClearProviders();
4545
builder.Logging.AddConsole();
46+
builder.Logging.AddFilter("Microsoft.AspNetCore", LogLevel.Warning);
47+
builder.Logging.AddFilter("Microsoft.Hosting", LogLevel.Warning);
4648

4749
builder.WebHost.ConfigureKestrel(options =>
4850
{

src/TurboHTTP/Streams/Lifecycle/ClientStreamOwner.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected override void OnReceive(object message)
9292

9393
private void HandleCreateStreamInstance(OwnerMsg.CreateStreamInstance create)
9494
{
95-
_log.Info("Creating stream instance (options: BaseAddress={0})",
95+
_log.Debug("Creating stream instance (options: BaseAddress={0})",
9696
create.ClientOptions.BaseAddress);
9797

9898
_createRequest = create;
@@ -281,14 +281,14 @@ private void HandleShutdown()
281281

282282
if (_killSwitch is not null)
283283
{
284-
_log.Info("Shutdown requested — firing KillSwitch, pipeline will drain");
284+
_log.Debug("Shutdown requested — firing KillSwitch, pipeline will drain");
285285
_killSwitch.Shutdown();
286286

287287
Timers.StartSingleTimer(ShutdownTimerKey, ShutdownTimeoutExpired.Instance, ShutdownTimeout);
288288
}
289289
else
290290
{
291-
_log.Info("Shutdown requested — no stream materialized, self-terminating");
291+
_log.Debug("Shutdown requested — no stream materialized, self-terminating");
292292
Context.Stop(Self);
293293
}
294294
}

0 commit comments

Comments
 (0)