Skip to content

Commit 1327bea

Browse files
committed
Thanks who ever wrote a test with dependency on log output message without making this dependency visible :yakshaving:
1 parent 4ecfcc6 commit 1327bea

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/ServiceControl.Audit.AcceptanceTests.RavenDB/Auditing/When_critical_storage_threshold_reached.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using System.Threading.Tasks;
66
using AcceptanceTesting.EndpointTemplates;
7+
using Audit.Auditing;
78
using Microsoft.Extensions.DependencyInjection;
89
using NServiceBus;
910
using NServiceBus.AcceptanceTesting;
@@ -35,8 +36,7 @@ await Define<ScenarioContext>()
3536
.When(context =>
3637
{
3738
return context.Logs.ToArray().Any(i =>
38-
i.Message.StartsWith(
39-
"Ensure started. Infrastructure started"));
39+
i.Message.StartsWith(AuditIngestion.LogMessages.StartedInfrastructure));
4040
}, (_, __) =>
4141
{
4242
var databaseConfiguration = ServiceProvider.GetRequiredService<DatabaseConfiguration>();
@@ -47,8 +47,7 @@ await Define<ScenarioContext>()
4747
.When(context =>
4848
{
4949
return context.Logs.ToArray().Any(i =>
50-
i.Message.StartsWith(
51-
"Shutting down due to failed persistence health check. Infrastructure shut down completed"));
50+
i.Message.StartsWith(AuditIngestion.LogMessages.StoppedInfrastructure));
5251
}, (bus, c) => bus.SendLocal(new MyMessage()))
5352
)
5453
.Done(async c => await this.TryGetSingle<MessagesView>(
@@ -72,7 +71,7 @@ await Define<ScenarioContext>()
7271
{
7372
return context.Logs.ToArray().Any(i =>
7473
i.Message.StartsWith(
75-
"Ensure started. Infrastructure started"));
74+
AuditIngestion.LogMessages.StartedInfrastructure));
7675
}, (session, context) =>
7776
{
7877
var databaseConfiguration = ServiceProvider.GetRequiredService<DatabaseConfiguration>();
@@ -83,8 +82,7 @@ await Define<ScenarioContext>()
8382
.When(context =>
8483
{
8584
ingestionShutdown = context.Logs.ToArray().Any(i =>
86-
i.Message.StartsWith(
87-
"Shutting down due to failed persistence health check. Infrastructure shut down completed"));
85+
i.Message.StartsWith(AuditIngestion.LogMessages.StoppedInfrastructure));
8886

8987
return ingestionShutdown;
9088
},

src/ServiceControl.Audit/Auditing/AuditIngestion.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async Task SetUpAndStartInfrastructure(CancellationToken cancellationToken)
130130
await auditIngestor.VerifyCanReachForwardingAddress();
131131
await queueIngestor.StartReceive(cancellationToken);
132132

133-
logger.Info("Started infrastructure");
133+
logger.Info(LogMessages.StartedInfrastructure);
134134
}
135135
catch (Exception e)
136136
{
@@ -163,7 +163,7 @@ async Task StopAndTeardownInfrastructure(CancellationToken cancellationToken)
163163
}
164164

165165
queueIngestor = null;
166-
logger.Info("Stopped infrastructure");
166+
logger.Info(LogMessages.StoppedInfrastructure);
167167
}
168168
catch (Exception e)
169169
{
@@ -335,5 +335,11 @@ public override async Task StopAsync(CancellationToken cancellationToken)
335335
readonly IHostApplicationLifetime applicationLifetime;
336336

337337
static readonly ILog logger = LogManager.GetLogger<AuditIngestion>();
338+
339+
internal static class LogMessages
340+
{
341+
internal const string StartedInfrastructure = "Started infrastructure";
342+
internal const string StoppedInfrastructure = "Stopped infrastructure";
343+
}
338344
}
339345
}

0 commit comments

Comments
 (0)