liquidprojections / LiquidProjections

Liquid Projections supports building and maintaining autonomous .NET projection code in an Event Sourcing architecture.
https://www.liquidprojections.net
MIT License
169 stars 25 forks source link

Issues with tests using Mac and Linux containers #124

Closed malclear closed 2 years ago

malclear commented 3 years ago

Using Rider, my project's tests will run fine: all tests are green. But when I run the tests from the command line, using "dotnet test myProject.csproj", then certain tests will get the exception listed below. I'm wondering if there is a known fix for this. Notably, I can often get the tests to pass if I shorten either the test class name, or the test function name. However, it is not limited to this because, often, tests with longer names will pass even though the shorter named tests fail.

(The project itself is "LiquidProjections.Couchbase". More on that later perhaps.) The error is:

LiquidProjections.Couchbase.Tests.CouchbaseProjectorSpecs.When_event_requires_update_to_a_projector.Then_it_should_be_updated [FAIL] Failed LiquidProjections.Couchbase.Tests.CouchbaseProjectorSpecs.When_event_requires_update_to_a_projector.Then_it_should_be_updated [1 ms] Error Message: System.AggregateException : One or more errors occurred. (Projector failed to project an event.) ---- LiquidProjections.ProjectionException : Projector failed to project an event. -------- System.ArgumentException : The output byte buffer is too small to contain the encoded data, encoding 'Unicode (UTF-8)' fallback 'System.Text.EncoderReplacementFallback'. (Parameter 'bytes') Stack Trace: at LiquidProjections.Testing.MemorySubscription.WaitUntilCheckpoint(Int64 checkpoint) at LiquidProjections.Testing.MemoryEventSource.WaitForAllSubscriptions() at LiquidProjections.Testing.MemoryEventSource.Write(Object[] events) at Chill.GivenSubject1.<>c__DisplayClass6_0.<When>b__0() at Chill.Common.TaskExtensions.ExecuteInDefaultSynchronizationContext(Action action) at Chill.TestBase.TriggerTest(Action testAction, Boolean expectExceptions) at Chill.GivenSubject1.TriggerTest(Boolean expectExceptions) at Chill.TestBase.EnsureTestTriggered(Boolean expectExceptions) at Chill.GivenSubject1.When(Action whenAction, Nullable1 deferredExecution) at Chill.GivenSubject1.When(Func1 whenActionAsync, Nullable1 deferredExecution) at LiquidProjections.Couchbase.Tests.CouchbaseProjectorSpecs.When_event_requires_update_to_a_projector..ctor(CouchbaseFixture databaseFixture, ITestOutputHelper helper) in /Users/mlearner/work/repos/RCM/LiquidProjections.Couchbase/src/LiquidProjections.Couchbase.Tests/CouchbaseProjectorSpecs.cs:line 530 ----- Inner Stack Trace ----- at LiquidProjections.Couchbase.CouchbaseProjector1.ProjectTransactionStoreCheckpoint(Transaction transaction, IBucket bucket) in /Users/mlearner/work/repos/RCM/LiquidProjections.Couchbase/src/LiquidProjections.Couchbase/CouchbaseProjector.cs:line 155 at LiquidProjections.Couchbase.CouchbaseProjector1.<>c__DisplayClass11_0.<<Handle>b__0>d.MoveNext() in /Users/mlearner/work/repos/RCM/LiquidProjections.Couchbase/src/LiquidProjections.Couchbase/CouchbaseProjector.cs:line 112 --- End of stack trace from previous location where exception was thrown --- at LiquidProjections.Couchbase.CouchbaseProjector1.ExecuteWithRetry(Func1 action) in /Users/mlearner/work/repos/RCM/LiquidProjections.Couchbase/src/LiquidProjections.Couchbase/CouchbaseProjector.cs:line 165 at LiquidProjections.Couchbase.CouchbaseProjector1.ExecuteWithRetry(Func1 action) in /Users/mlearner/work/repos/RCM/LiquidProjections.Couchbase/src/LiquidProjections.Couchbase/CouchbaseProjector.cs:line 172 at LiquidProjections.Couchbase.CouchbaseProjector1.Handle(IEnumerable1 transactions, SubscriptionInfo info) in /Users/mlearner/work/repos/RCM/LiquidProjections.Couchbase/src/LiquidProjections.Couchbase/CouchbaseProjector.cs:line 112 at LiquidProjections.Testing.MemorySubscription.RunAsync(SubscriptionInfo info) at LiquidProjections.Testing.MemorySubscription.<>c__DisplayClass12_0.<<Start>b__0>d.MoveNext() ----- Inner Stack Trace ----- at System.Text.Encoding.ThrowBytesOverflow() at System.Text.Encoding.ThrowBytesOverflow(EncoderNLS encoder, Boolean nothingEncoded) at System.Text.Encoding.GetBytesWithFallback(ReadOnlySpan1 chars, Int32 originalCharsLength, Span1 bytes, Int32 originalBytesLength, EncoderNLS encoder) at System.Text.Encoding.GetBytesWithFallback(Char* pOriginalChars, Int32 originalCharCount, Byte* pOriginalBytes, Int32 originalByteCount, Int32 charsConsumedSoFar, Int32 bytesWrittenSoFar) at System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount) at Couchbase.Core.IO.Converters.ByteConverter.FromString(String value, Span1 buffer) at Couchbase.Core.IO.Operations.OperationBase.WriteKey(Span1 buffer) at Couchbase.Core.IO.Operations.OperationBase.WriteKey(OperationBuilder builder) at Couchbase.Core.IO.Operations.OperationBase.SendAsync(IConnection connection, CancellationToken cancellationToken) at Couchbase.Core.IO.Connections.DataFlow.DataFlowConnectionPool.<>c__DisplayClass29_0.<<BuildHandler>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Couchbase.Core.ClusterNode.ExecuteOp(Func4 sender, IOperation op, Object state, CancellationToken token) at Couchbase.Core.ClusterNode.SendAsync(IOperation op, CancellationToken token) at Couchbase.CouchbaseBucket.SendAsync(IOperation op, CancellationToken token) at Couchbase.CouchbaseBucket.SendAsync(IOperation op, CancellationToken token) at Couchbase.Core.Retry.RetryOrchestrator.RetryAsync(BucketBase bucket, IOperation operation, CancellationToken token) at Couchbase.Core.BucketBase.RetryAsync(IOperation operation, CancellationToken token) at Couchbase.KeyValue.CouchbaseCollection.RetryUntilTimeoutOrSuccessAsync(Nullable1 token, Nullable1 timeout, IOperation op) at Couchbase.KeyValue.CouchbaseCollection.ExecuteGet(String id, GetOptions options, IInternalSpan span) at Couchbase.KeyValue.CouchbaseCollection.GetAsync(String id, GetOptions options) at LiquidProjections.Couchbase.CouchbaseEventMapConfigurator1.OnUpdate(String key, CouchbaseProjectionContext context, Func2 projector, Func1 createIfMissing) in /Users/mlearner/work/repos/RCM/LiquidProjections.Couchbase/src/LiquidProjections.Couchbase/CouchbaseEventMapConfigurator.cs:line 88 at LiquidProjections.EventMapBuilder3.CrudAction1.UpdateAction.OnUpdate(Func4 projector, TEvent anEvent, TContext context) at LiquidProjections.EventMapBuilder1.Action1.<>cDisplayClass5_1.<b1>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at LiquidProjections.EventMapBuilder1.Action1.<>cDisplayClass6_0.<b0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at LiquidProjections.EventMap1.Handle(Object anEvent, TContext context) at LiquidProjections.Couchbase.CouchbaseEventMapConfigurator1.ProjectEvent(Object anEvent, CouchbaseProjectionContext context) in /Users/mlearner/work/repos/RCM/LiquidProjections.Couchbase/src/LiquidProjections.Couchbase/CouchbaseEventMapConfigurator.cs:line 33 at LiquidProjections.Couchbase.CouchbaseProjector`1.ProjectTransaction(Transaction transaction, IBucket bucket) in /Users/mlearner/work/repos/RCM/LiquidProjections.Couchbase/src/LiquidProjections.Couchbase/CouchbaseProjector.cs:line 215

dennisdoomen commented 3 years ago

That's a really weird exception, in particular because that specific line is not doing anything with strings or arrays. Is there a difference between the .NET Core SDK between Rider (under Toolset and Build) and the CLI version?

malclear commented 3 years ago

Looks the same to me. I even changed both projects to build with Net5. Because of the way the problem comes and goes depending on the length of the test class name, I wonder if it's related to the Chill library.

image image

dennisdoomen commented 3 years ago

The only way to verify that is to rewrite that specific without Chill. Just to rule out that option.

dennisdoomen commented 2 years ago

Did you resolve this issue?

malclear commented 2 years ago

I'm not dealing with this problem any more, though I don't remember finding any resolution to it. And we're using LP successfully!