Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ await Define<ScenarioContext>()
return false;
}

var items = await first.Content.ReadFromJsonAsync<List<EventLogItem>>(SerializerOptions);
var items = await first.Content.ReadFromJsonAsync<List<EventLogItemView>>(SerializerOptions);

// Keep polling until the endpoint's startup event has landed. An empty event
// log has a stable ETag of its own and would make the assertions meaningless.
Expand Down Expand Up @@ -65,7 +65,7 @@ await Define<ScenarioContext>()
var unknown = await Poll("\"not-an-etag-this-instance-ever-issued\"");
unknownEtagStatus = unknown.StatusCode;

var unknownBody = await unknown.Content.ReadFromJsonAsync<List<EventLogItem>>(SerializerOptions);
var unknownBody = await unknown.Content.ReadFromJsonAsync<List<EventLogItemView>>(SerializerOptions);
unknownEtagReturnedItems = unknownBody is { Count: > 0 };

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using NUnit.Framework;
using ServiceControl.Contracts;
using ServiceControl.MessageFailures;
using ServiceControl.MessageFailures.Api;

class When_a_group_is_archived : ExternalIntegrationAcceptanceTest
{
Expand Down Expand Up @@ -39,7 +40,7 @@ public async Task Should_publish_notification()
.Do("WaitUntilGroupsContainsFailedMessages", async ctx =>
{
// Don't retry until the message has been added to a group
var groups = await this.TryGetMany<FailedMessage.FailureGroup>("/api/recoverability/groups/");
var groups = await this.TryGetMany<GroupOperation>("/api/recoverability/groups/");
if (!groups)
{
return false;
Expand All @@ -52,7 +53,7 @@ public async Task Should_publish_notification()
ctx => Task.FromResult(ctx.ExternalProcessorSubscribed))
.Do("WaitUntilGroupContainsBothMessages", async ctx =>
{
var failedMessages = await this.TryGetMany<FailedMessage>($"/api/recoverability/groups/{ctx.GroupId}/errors");
var failedMessages = await this.TryGetMany<FailedMessageView>($"/api/recoverability/groups/{ctx.GroupId}/errors");
return failedMessages && failedMessages.Items.Count == 1;
})
.Do("Archive", async ctx => { await this.Post<object>($"/api/recoverability/groups/{ctx.GroupId}/errors/archive"); })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using NServiceBus.Settings;
using NUnit.Framework;
using ServiceControl.MessageFailures;
using ServiceControl.MessageFailures.Api;
using TestSupport;

class When_a_group_is_archived : AcceptanceTest
Expand All @@ -32,7 +33,7 @@ await Define<MyContext>()
}

// Don't retry until the message has been added to a group
var groups = await this.TryGetMany<FailedMessage.FailureGroup>("/api/recoverability/groups/");
var groups = await this.TryGetMany<GroupOperation>("/api/recoverability/groups/");
if (!groups)
{
return false;
Expand All @@ -43,7 +44,7 @@ await Define<MyContext>()
})
.Do("WaitUntilGroupContainsBothMessages", async ctx =>
{
var failedMessages = await this.TryGetMany<FailedMessage>($"/api/recoverability/groups/{ctx.GroupId}/errors");
var failedMessages = await this.TryGetMany<FailedMessageView>($"/api/recoverability/groups/{ctx.GroupId}/errors");
return failedMessages && failedMessages.Items.Count == 2;
})
.Do("Archive", async ctx => { await this.Post<object>($"/api/recoverability/groups/{ctx.GroupId}/errors/archive"); })
Expand Down Expand Up @@ -78,7 +79,7 @@ await Define<MyContext>()
}

// Don't retry until the message has been added to a group
var groups = await this.TryGetMany<FailedMessage.FailureGroup>("/api/recoverability/groups/");
var groups = await this.TryGetMany<GroupOperation>("/api/recoverability/groups/");
if (!groups)
{
return false;
Expand All @@ -89,7 +90,7 @@ await Define<MyContext>()
})
.Do("WaitUntilGroupContainsBothMessages", async ctx =>
{
var failedMessages = await this.TryGetMany<FailedMessage>($"/api/recoverability/groups/{ctx.GroupId}/errors");
var failedMessages = await this.TryGetMany<FailedMessageView>($"/api/recoverability/groups/{ctx.GroupId}/errors");
return failedMessages && failedMessages.Items.Count == 2;
})
.Do("Archive", async ctx => { await this.Post<object>($"/api/recoverability/groups/{ctx.GroupId}/errors/archive"); })
Expand Down Expand Up @@ -129,7 +130,7 @@ await Define<MyContext>()
}

// Don't retry until the message has been added to a group
var groups = await this.TryGetMany<FailedMessage.FailureGroup>("/api/recoverability/groups/");
var groups = await this.TryGetMany<GroupOperation>("/api/recoverability/groups/");
if (!groups)
{
return false;
Expand All @@ -140,7 +141,7 @@ await Define<MyContext>()
})
.Do("WaitUntilGroupContainsBothMessages", async ctx =>
{
var failedMessages = await this.TryGetMany<FailedMessage>($"/api/recoverability/groups/{ctx.GroupId}/errors");
var failedMessages = await this.TryGetMany<FailedMessageView>($"/api/recoverability/groups/{ctx.GroupId}/errors");
return failedMessages && failedMessages.Items.Count == 2;
})
.Do("Archive", async ctx => { await this.Post<object>($"/api/recoverability/groups/{ctx.GroupId}/errors/archive"); })
Expand Down Expand Up @@ -181,7 +182,7 @@ await Define<MyContext>()
}

// Don't retry until the message has been added to a group
var groups = await this.TryGetMany<FailedMessage.FailureGroup>("/api/recoverability/groups/");
var groups = await this.TryGetMany<GroupOperation>("/api/recoverability/groups/");
if (!groups)
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ await Define<MyContext>()
.WithEndpoint<Receiver>()
.Done(async c =>
{
var result = await this.TryGetMany<FailedMessage.FailureGroup>("/api/recoverability/groups");
List<FailedMessage.FailureGroup> groups = result;
var result = await this.TryGetMany<GroupOperation>("/api/recoverability/groups");
List<GroupOperation> groups = result;
if (!result)
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class When_messages_have_failed : AcceptanceTest
[Test]
public async Task Should_be_grouped()
{
List<FailureGroupView> defaultGroups = null;
List<FailureGroupView> exceptionTypeAndStackTraceGroups = null;
List<FailureGroupView> messageTypeGroups = null;
List<GroupOperation> defaultGroups = null;
List<GroupOperation> exceptionTypeAndStackTraceGroups = null;
List<GroupOperation> messageTypeGroups = null;

FailedMessage failedMessageA = null;
FailedMessage failedMessageB = null;
Expand All @@ -40,7 +40,7 @@ public async Task Should_be_grouped()
return false;
}

var defaultGroupsResult = await this.TryGetMany<FailureGroupView>("/api/recoverability/groups/");
var defaultGroupsResult = await this.TryGetMany<GroupOperation>("/api/recoverability/groups/");
defaultGroups = defaultGroupsResult;
if (!defaultGroupsResult)
{
Expand All @@ -52,8 +52,8 @@ public async Task Should_be_grouped()
return false;
}

messageTypeGroups = await this.TryGetMany<FailureGroupView>("/api/recoverability/groups/Message%20Type");
exceptionTypeAndStackTraceGroups = await this.TryGetMany<FailureGroupView>("/api/recoverability/groups/Exception%20Type%20and%20Stack%20Trace");
messageTypeGroups = await this.TryGetMany<GroupOperation>("/api/recoverability/groups/Message%20Type");
exceptionTypeAndStackTraceGroups = await this.TryGetMany<GroupOperation>("/api/recoverability/groups/Exception%20Type%20and%20Stack%20Trace");

var failedMessageAResult = await this.TryGet<FailedMessage>($"/api/errors/{c.UniqueMessageIdA}", msg => msg.FailureGroups.Any());
failedMessageA = failedMessageAResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class When_two_similar_messages_have_failed : AcceptanceTest
[Test]
public async Task They_should_be_grouped_together()
{
List<FailureGroupView> exceptionTypeAndStackTraceGroups = null;
List<FailureGroupView> messageTypeGroups = null;
List<GroupOperation> exceptionTypeAndStackTraceGroups = null;
List<GroupOperation> messageTypeGroups = null;
FailedMessage firstFailure = null;
FailedMessage secondFailure = null;

Expand All @@ -38,7 +38,7 @@ await Define<MyContext>()
return false;
}

var result = await this.TryGetMany<FailureGroupView>("/api/recoverability/groups/");
var result = await this.TryGetMany<GroupOperation>("/api/recoverability/groups/");
exceptionTypeAndStackTraceGroups = result;
if (!result)
{
Expand All @@ -50,7 +50,7 @@ await Define<MyContext>()
return false;
}

messageTypeGroups = await this.TryGetMany<FailureGroupView>("/api/recoverability/groups/Message%20Type");
messageTypeGroups = await this.TryGetMany<GroupOperation>("/api/recoverability/groups/Message%20Type");

var firstFailureResult = await this.TryGet<FailedMessage>($"/api/errors/{c.FirstMessageId}");
firstFailure = firstFailureResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using NServiceBus.Settings;
using NUnit.Framework;
using ServiceControl.MessageFailures;
using ServiceControl.MessageFailures.Api;

class When_a_pending_retry_is_resolved_by_queue_and_timeframe : AcceptanceTest
{
Expand All @@ -36,7 +37,7 @@ await Define<Context>()
})
.Do("WaitForStaleIndex", async ctx =>
{
return await this.TryGet<FailedMessage[]>("/api/errors",
return await this.TryGet<FailedMessageView[]>("/api/errors",
allErrors => allErrors.Any(fm => fm.Id == ctx.UniqueMessageId));
})
.Do("ResolvePending", async ctx =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using NServiceBus.Settings;
using NUnit.Framework;
using ServiceControl.MessageFailures;
using ServiceControl.MessageFailures.Api;

class When_a_pending_retry_is_retried_by_queue_and_timeframe : AcceptanceTest
{
Expand All @@ -32,7 +33,7 @@ await Define<Context>()
})
.Do("WaitForIndex", async ctx =>
{
return await this.TryGet<FailedMessage[]>("/api/errors",
return await this.TryGet<FailedMessageView[]>("/api/errors",
allErrors => allErrors.Any(fm => fm.Id == ctx.UniqueMessageId));
})
.Do("RetryPending", async ctx =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class When_a_retry_fails_to_be_sent : AcceptanceTest
[CancelAfter(180_000)]
public async Task SubsequentBatchesShouldBeProcessed(CancellationToken cancellationToken = default)
{
FailedMessage decomissionedFailure = null, successfullyRetried = null;
FailedMessageView decomissionedFailure = null, successfullyRetried = null;

CustomizeHostBuilder = hostBuilder =>
{
Expand Down Expand Up @@ -56,9 +56,9 @@ await Define<MyContext>()
return false;
}

var decomissionedFailureResult = await this.TryGetSingle<FailedMessage>("/api/errors/", m => m.Id == ctx.DecommissionedEndpointUniqueMessageId && m.Status == FailedMessageStatus.Unresolved);
var decomissionedFailureResult = await this.TryGetSingle<FailedMessageView>("/api/errors/", m => m.Id == ctx.DecommissionedEndpointUniqueMessageId && m.Status == FailedMessageStatus.Unresolved);
decomissionedFailure = decomissionedFailureResult;
var successfullyRetriedResult = await this.TryGetSingle<FailedMessage>("/api/errors/", m => m.Id == ctx.MessageThatWillFailUniqueMessageId && m.Status == FailedMessageStatus.Resolved);
var successfullyRetriedResult = await this.TryGetSingle<FailedMessageView>("/api/errors/", m => m.Id == ctx.MessageThatWillFailUniqueMessageId && m.Status == FailedMessageStatus.Resolved);
successfullyRetried = successfullyRetriedResult;
return decomissionedFailureResult && successfullyRetriedResult;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class When_a_retry_for_a_failed_message_is_successful : AcceptanceTest
public async Task Should_show_up_as_resolved_in_the_eventlog(CancellationToken cancellationToken = default)
{
FailedMessage failure = null;
List<EventLogItem> eventLogItems = null;
List<EventLogItemView> eventLogItems = null;

await Define<MyContext>()
.WithEndpoint<FailureEndpoint>(b => b.When(bus => bus.SendLocal(new MyMessage())).DoNotFailOnErrorMessages())
Expand All @@ -38,7 +38,7 @@ await Define<MyContext>()

if (failure.Status == FailedMessageStatus.Resolved)
{
var eventLogItemsResult = await this.TryGetMany<EventLogItem>("/api/eventlogitems", item => item.Description.StartsWith("Failed message resolved by retry"));
var eventLogItemsResult = await this.TryGetMany<EventLogItemView>("/api/eventlogitems", item => item.Description.StartsWith("Failed message resolved by retry"));
eventLogItems = eventLogItemsResult;
return eventLogItemsResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task<MessageBodyResult> TryFetch(string bodyId, CancellationToken c

return MessageBodyResult.Available(new MessageBodyStreamContent(
new MemoryStream(bytes, writable: false),
row.BodyContentType,
row.BodyContentType ?? "text/plain",
Comment thread
rbev marked this conversation as resolved.
bytes.Length,
uniqueMessageId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public Task Add(EventLogItem logItem, CancellationToken cancellationToken = defa
{
dbContext.EventLogItems.Add(new EventLogItemEntity
{
Description = logItem.Description,
Description = logItem.Description ?? string.Empty,
Severity = logItem.Severity,
RaisedAt = logItem.RaisedAt,
RelatedTo = logItem.RelatedTo ?? [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Task<bool> QueryContainsFailedImports(CancellationToken cancellationToken
public Task StoreFailedErrorImport(FailedErrorImport failure, CancellationToken cancellationToken = default) =>
ExecuteWithDbContext(async (dbContext, token) =>
{
var uniqueMessageId = FailedErrorImport.DeriveKey(failure.Message.Headers, failure.Message.Id);
var uniqueMessageId = FailedErrorImport.DeriveKey(failure.Message!.Headers, failure.Message.Id);
var body = failure.Message.Body ?? [];
var storeExternally = body.Length > bodyStorageSettings.MaxBodySizeToStore;

Expand All @@ -54,15 +54,15 @@ public Task StoreFailedErrorImport(FailedErrorImport failure, CancellationToken
HeadersJson = headersJson,
Body = storedBody,
BodyStoredExternally = storeExternally,
ExceptionInfo = failure.ExceptionInfo
ExceptionInfo = failure.ExceptionInfo ?? string.Empty
}, (entity) =>
{
entity.FailedAt = failedAt;
entity.MessageId = failure.Message.Id;
entity.HeadersJson = headersJson;
entity.Body = storedBody;
entity.BodyStoredExternally = storeExternally;
entity.ExceptionInfo = failure.ExceptionInfo;
entity.ExceptionInfo = failure.ExceptionInfo ?? string.Empty;
}, token);
}, cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static ExceptionDetails ToExceptionDetails(this FailedMessageEntity entity, Dict
: new EndpointDetails
{
Name = entity.SendingEndpointName,
Host = entity.SendingEndpointHost,
Host = entity.SendingEndpointHost ?? string.Empty,
HostId = entity.SendingEndpointHostId ?? Guid.Empty
};

Expand All @@ -142,7 +142,7 @@ static ExceptionDetails ToExceptionDetails(this FailedMessageEntity entity, Dict
: new EndpointDetails
{
Name = entity.ReceivingEndpointName,
Host = entity.ReceivingEndpointHost,
Host = entity.ReceivingEndpointHost ?? string.Empty,
HostId = entity.ReceivingEndpointHostId ?? Guid.Empty
};

Expand Down
Loading