Skip to content
Merged
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 @@ -5,7 +5,8 @@
namespace Internal.Generated.WolverineHandlers
{
// START: CompleteFourHandler1230864511
public class CompleteFourHandler1230864511 : Wolverine.Runtime.Handlers.MessageHandler
[global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
public sealed class CompleteFourHandler1230864511 : Wolverine.Runtime.Handlers.MessageHandler
{
private readonly Raven.Client.Documents.IDocumentStore _documentStore;

Expand Down Expand Up @@ -34,6 +35,7 @@ public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.

else
{
context.SetSagaId(sagaId);

// The actual message execution
stringBasicWorkflow.Handle(completeFour);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace Internal.Generated.WolverineHandlers
{
// START: CompleteOneHandler1612253335
public class CompleteOneHandler1612253335 : Wolverine.Runtime.Handlers.MessageHandler
[global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
public sealed class CompleteOneHandler1612253335 : Wolverine.Runtime.Handlers.MessageHandler
{
private readonly Raven.Client.Documents.IDocumentStore _documentStore;

Expand Down Expand Up @@ -34,6 +35,7 @@ public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.

else
{
context.SetSagaId(sagaId);

// The actual message execution
var outgoing1 = stringBasicWorkflow.Handle(completeOne);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace Internal.Generated.WolverineHandlers
{
// START: CompleteTwoHandler402398939
public class CompleteTwoHandler402398939 : Wolverine.Runtime.Handlers.MessageHandler
[global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
public sealed class CompleteTwoHandler402398939 : Wolverine.Runtime.Handlers.MessageHandler
{
private readonly Raven.Client.Documents.IDocumentStore _documentStore;

Expand Down Expand Up @@ -34,6 +35,7 @@ public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.

else
{
context.SetSagaId(sagaId);

// The actual message execution
stringBasicWorkflow.Handle(completeTwo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace Internal.Generated.WolverineHandlers
{
// START: FinishItAllHandler1534262635
public class FinishItAllHandler1534262635 : Wolverine.Runtime.Handlers.MessageHandler
[global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
public sealed class FinishItAllHandler1534262635 : Wolverine.Runtime.Handlers.MessageHandler
{
private readonly Raven.Client.Documents.IDocumentStore _documentStore;

Expand Down Expand Up @@ -34,6 +35,7 @@ public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.

else
{
context.SetSagaId(sagaId);

// The actual message execution
stringBasicWorkflow.Handle(finishItAll);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace Internal.Generated.WolverineHandlers
{
// START: StringCompleteThreeHandler606415888
public class StringCompleteThreeHandler606415888 : Wolverine.Runtime.Handlers.MessageHandler
[global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
public sealed class StringCompleteThreeHandler606415888 : Wolverine.Runtime.Handlers.MessageHandler
{
private readonly Raven.Client.Documents.IDocumentStore _documentStore;

Expand All @@ -22,6 +23,8 @@ public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.
// The actual message body
var stringCompleteThree = (Wolverine.ComplianceTests.Sagas.StringCompleteThree)context.Envelope.Message;

// Application-specific Open Telemetry auditing
System.Diagnostics.Activity.Current?.SetTag("SagaId", stringCompleteThree.SagaId);
string sagaId = context.Envelope.SagaId ?? stringCompleteThree.SagaId;
if (string.IsNullOrEmpty(sagaId)) throw new Wolverine.Persistence.Sagas.IndeterminateSagaStateIdException(context.Envelope);

Expand All @@ -34,6 +37,7 @@ public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.

else
{
context.SetSagaId(sagaId);

// The actual message execution
stringBasicWorkflow.Handle(stringCompleteThree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace Internal.Generated.WolverineHandlers
{
// START: StringDoThreeHandler1820069266
public class StringDoThreeHandler1820069266 : Wolverine.Runtime.Handlers.MessageHandler
[global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
public sealed class StringDoThreeHandler1820069266 : Wolverine.Runtime.Handlers.MessageHandler
{
private readonly Raven.Client.Documents.IDocumentStore _documentStore;

Expand All @@ -22,6 +23,8 @@ public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.
// The actual message body
var stringDoThree = (Wolverine.ComplianceTests.Sagas.StringDoThree)context.Envelope.Message;

// Application-specific Open Telemetry auditing
System.Diagnostics.Activity.Current?.SetTag("TheSagaId", stringDoThree.TheSagaId);
string sagaId = context.Envelope.SagaId ?? stringDoThree.TheSagaId;
if (string.IsNullOrEmpty(sagaId)) throw new Wolverine.Persistence.Sagas.IndeterminateSagaStateIdException(context.Envelope);

Expand All @@ -34,6 +37,7 @@ public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.

else
{
context.SetSagaId(sagaId);

// The actual message execution
stringBasicWorkflow.Handles(stringDoThree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace Internal.Generated.WolverineHandlers
{
// START: StringStartHandler2085759971
public class StringStartHandler2085759971 : Wolverine.Runtime.Handlers.MessageHandler
[global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
public sealed class StringStartHandler2085759971 : Wolverine.Runtime.Handlers.MessageHandler
{
private readonly Raven.Client.Documents.IDocumentStore _documentStore;

Expand All @@ -22,11 +23,14 @@ public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.
// The actual message body
var stringStart = (Wolverine.ComplianceTests.Sagas.StringStart)context.Envelope.Message;

// Application-specific Open Telemetry auditing
System.Diagnostics.Activity.Current?.SetTag("Id", stringStart.Id);
var stringBasicWorkflow = new Wolverine.ComplianceTests.Sagas.StringBasicWorkflow();

// The actual message execution
stringBasicWorkflow.Start(stringStart);

context.SetSagaId(stringStart.Id);
if (!stringBasicWorkflow.IsCompleted())
{
await asyncDocumentSession.StoreAsync(stringBasicWorkflow, cancellation).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
namespace Internal.Generated.WolverineHandlers
{
// START: WildcardStartHandler784149372
public class WildcardStartHandler784149372 : Wolverine.Runtime.Handlers.MessageHandler
[global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
public sealed class WildcardStartHandler784149372 : Wolverine.Runtime.Handlers.MessageHandler
{
private readonly Raven.Client.Documents.IDocumentStore _documentStore;

Expand All @@ -22,11 +23,14 @@ public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.
// The actual message body
var wildcardStart = (Wolverine.ComplianceTests.Sagas.WildcardStart)context.Envelope.Message;

// Application-specific Open Telemetry auditing
System.Diagnostics.Activity.Current?.SetTag("Id", wildcardStart.Id);
var stringBasicWorkflow = new Wolverine.ComplianceTests.Sagas.StringBasicWorkflow();

// The actual message execution
stringBasicWorkflow.Starts(wildcardStart);

context.SetSagaId(wildcardStart.Id);
if (!stringBasicWorkflow.IsCompleted())
{
await asyncDocumentSession.StoreAsync(stringBasicWorkflow, cancellation).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public IncomingMessage_mapping()
theEnvelope.Id = Guid.NewGuid();
theEnvelope.OwnerId = 3;
theEnvelope.Attempts = 2;
theEnvelope.Status = EnvelopeStatus.Handled;
theEnvelope.Status = EnvelopeStatus.Incoming;

var message = new IncomingMessage(theEnvelope, new RavenDbMessageStore(Substitute.For<IDocumentStore>(), new WolverineOptions()));
theMappedEnvelope = message.Read();
Expand All @@ -35,7 +35,7 @@ public void map_the_id()
[Fact]
public void map_the_status()
{
theMappedEnvelope.Status.ShouldBe(EnvelopeStatus.Handled);
theMappedEnvelope.Status.ShouldBe(EnvelopeStatus.Incoming);
}

[Fact]
Expand Down
38 changes: 34 additions & 4 deletions src/Persistence/RavenDbTests/message_store_compliance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,40 @@ namespace RavenDbTests;

public class DatabaseFixture : RavenTestDriver
{
private static bool _configured;

public IDocumentStore StartRavenStore()
{
EnsureServerConfigured();
return GetDocumentStore();
}

internal static void EnsureServerConfigured()
{
if (_configured) return;
_configured = true;

// Configure the embedded RavenDB server.
// RavenDB.TestDriver 7.0.x requires .NET 8.0.15+ runtime.
// We try to use a brew-installed .NET 8 if available, otherwise fall back to system dotnet.
var options = new TestServerOptions
{
FrameworkVersion = null, // Use available runtime
Licensing = new ServerOptions.LicensingOptions
{
ThrowOnInvalidOrMissingLicense = false // Don't require license for tests
}
};

// Check for brew-installed .NET 8 which has newer runtime
var brewDotNetPath = "/opt/homebrew/opt/dotnet@8/bin/dotnet";
if (File.Exists(brewDotNetPath))
{
options.DotNetPath = brewDotNetPath;
}

ConfigureServer(options);
}
}

[CollectionDefinition("raven")]
Expand Down Expand Up @@ -52,13 +82,13 @@ public override async Task<IHost> BuildCleanHost()
{
// TODO -- TEMP!
opts.Durability.Mode = DurabilityMode.Solo;

opts.UseRavenDbPersistence();
opts.Services.AddSingleton<IDocumentStore>(store);

opts.ListenAtPort(2345).UseDurableInbox();
}).StartAsync();

return host;
}

Expand All @@ -74,11 +104,11 @@ public async Task marks_envelope_as_having_an_expires_on_mark_handled()
var incoming = await session.LoadAsync<IncomingMessage>(envelope.Id.ToString());
var metadata = session.Advanced.GetMetadataFor(incoming);
metadata.TryGetValue("@expires", out var raw).ShouldBeTrue();

var value = metadata["@expires"];
Debug.WriteLine(value);

}


}
}
14 changes: 8 additions & 6 deletions src/Persistence/RavenDbTests/ravendb_durability_end_to_end.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Wolverine.RavenDb.Internals;
using Wolverine.Transports.Tcp;
using Wolverine.Util;
using RavenDbTests;

public class ravendb_durability_end_to_end : RavenTestDriver, IAsyncLifetime
{
Expand All @@ -34,6 +35,7 @@ public async Task InitializeAsync()
{
_listener = new Uri($"tcp://localhost:{PortFinder.GetAvailablePort()}");

DatabaseFixture.EnsureServerConfigured();
_receiverStore = GetDocumentStore();
_senderStore = GetDocumentStore();

Expand All @@ -53,11 +55,11 @@ public async Task InitializeAsync()

// Leave it as a lambda so it doesn't get disposed
opts.Services.AddSingleton<IDocumentStore>(s => _receiverStore);

opts.ListenForMessagesFrom(_listener).UseDurableInbox();

opts.Services.AddResourceSetupOnStartup();

opts.UseTcpForControlEndpoint();
})
.Start();
Expand All @@ -75,10 +77,10 @@ public async Task InitializeAsync()
.UseDurableOutbox());

opts.UseTcpForControlEndpoint();

opts.CodeGeneration.InsertFirstPersistenceStrategy<RavenDbPersistenceFrameProvider>();
opts.Services.AddSingleton<IMessageStore>(s => new RavenDbMessageStore(_senderStore, s.GetRequiredService<WolverineOptions>()));

// Leave it as a lambda so it doesn't get disposed
opts.Services.AddSingleton<IDocumentStore>(s => _senderStore);

Expand Down Expand Up @@ -108,7 +110,7 @@ public async Task DisposeAsync()
}

_senders.Clear();

_receiverStore.Dispose();
_senderStore.Dispose();
}
Expand Down Expand Up @@ -245,4 +247,4 @@ public async Task Handle(TraceMessage message, IAsyncDocumentSession session)
var traceDoc = new TraceDoc { Name = message.Name };
await session.StoreAsync(traceDoc);
}
}
}
11 changes: 6 additions & 5 deletions src/Persistence/RavenDbTests/saga_storage_compliance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,25 @@ namespace RavenDbTests;
public class RavenDbSagaHost : RavenTestDriver, ISagaHost
{
private IDocumentStore _store;

public IHost BuildHost<TSaga>()
{
DatabaseFixture.EnsureServerConfigured();
_store = GetDocumentStore();

return Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
opts.Durability.Mode = DurabilityMode.Solo;

opts.CodeGeneration.GeneratedCodeOutputPath = AppContext.BaseDirectory.ParentDirectory().ParentDirectory().ParentDirectory().AppendPath("Internal", "Generated");
opts.CodeGeneration.TypeLoadMode = TypeLoadMode.Auto;

// Shouldn't be necessary, but apparently is. Type scanning is not working
// for some reason across the compliance tests
opts.Discovery.IncludeType<StringBasicWorkflow>();
opts.Discovery.IncludeAssembly(typeof(StringBasicWorkflow).Assembly);

opts.Services.AddSingleton(_store);
opts.UseRavenDbPersistence();
}).Start();
Expand Down Expand Up @@ -65,4 +66,4 @@ public class saga_storage_compliance : StringIdentifiedSagaComplianceSpecs<Raven
public saga_storage_compliance()
{
}
}
}
9 changes: 6 additions & 3 deletions src/Persistence/RavenDbTests/transactional_middleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ public async Task use_end_to_end()
.UseWolverine(opts =>
{
opts.Durability.Mode = DurabilityMode.Solo;

opts.Services.AddSingleton(store);

opts.ListenAtPort(2345).UseDurableInbox();

opts.UseRavenDbPersistence();
opts.Policies.AutoApplyTransactions();

// Include handlers from this test assembly
opts.Discovery.IncludeAssembly(typeof(transactional_middleware).Assembly);
}).StartAsync();

await host.InvokeAsync(new RecordTeam("Chiefs", 1960));
Expand Down
Loading
Loading