Skip to content

Commit

Permalink
RavenDB-21956 Add test for big message
Browse files Browse the repository at this point in the history
  • Loading branch information
djordjedjukic committed Apr 10, 2024
1 parent 734821a commit b376de7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Azure.Storage.Queues;
using Azure.Storage.Queues.Models;
using Raven.Client.Documents;
Expand Down Expand Up @@ -93,4 +94,17 @@ protected static QueueMessage[] ReceiveAndDeleteMessages(QueueClient queueClient
messages.Value.ToList().ForEach(message => queueClient.DeleteMessage(message.MessageId, message.PopReceipt));
return messages.Value.ToArray();
}

protected string GenerateLargeString()
{
StringBuilder builder = new StringBuilder();

// Append characters to the StringBuilder until it's larger than 64KB
while (builder.Length <= 64 * 1024)
{
builder.Append("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
}

return builder.ToString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,38 @@ public void SimpleScript()
Assert.Equal(order.TotalCost, 10);
}
}

[Fact]
public async Task Simple_script_large_message_error_expected()
{
using (var store = GetDocumentStore())
{
var config = SetupQueueEtlToAzureQueueStorageOnline(store,
@$"loadToUsers(this)", new[] { "users" },
new[] { new EtlQueue { Name = $"users" } });

using (var session = store.OpenSession())
{
session.Store(new User()
{
Id = "users/1-A",
Name = GenerateLargeString()
});
session.SaveChanges();
}

var alert = await AssertWaitForNotNullAsync(() =>
{
Etl.TryGetLoadError(store.Database, config, out var error);
return Task.FromResult(error);
}, timeout: (int)TimeSpan.FromMinutes(1).TotalMilliseconds);

Assert.StartsWith(
"Raven.Server.Exceptions.ETL.QueueEtl.QueueLoadException: Failed to deliver message, Azure error code: 'RequestBodyTooLarge'",
alert.Error);
}
}

[Fact]
public void Error_if_script_does_not_contain_any_loadTo_method()
Expand Down Expand Up @@ -362,7 +394,7 @@ public async Task ShouldImportTask()
}

[RavenFact(RavenTestCategory.BackupExportImport | RavenTestCategory.Sharding | RavenTestCategory.Etl)]
public async Task ShouldSkipUnsupportedFeaturesInShardingOnImport_RabbitMqEtl()
public async Task ShouldSkipUnsupportedFeaturesInShardingOnImport_AzureQueueStorageEtl()
{
using (var srcStore = GetDocumentStore())
using (var dstStore = Sharding.GetDocumentStore())
Expand Down

0 comments on commit b376de7

Please sign in to comment.