Ported Cluster and Archive client unit tests from Java#148
Conversation
fb5f03a to
24a1484
Compare
| var actualException = Assert.Throws<InvalidOperationException>(() => AeronArchive.ConnectAsync(ctx)); | ||
| Assert.AreSame(error, actualException); | ||
|
|
||
| A.CallTo(() => ctx.Conclude()).MustHaveHappened().Then( |
There was a problem hiding this comment.
Formatting. We should break the link on the ., e.g:
A.CallTo(() => ctx.Conclude()).MustHaveHappened()
.Then(A.CallTo(() => ctx.AeronClient()).MustHaveHappened())
.Then(A.CallTo(() => ctx.ControlResponseChannel()).MustHaveHappened())
.Then(A.CallTo(() => ctx.ControlResponseStreamId()).MustHaveHappened())
.Then(A.CallTo(() => aeron.AsyncAddSubscription(
responseChannel, responseStreamId, A<AvailableImageHandler>._, A<UnavailableImageHandler>._))
.MustHaveHappened())
.Then(A.CallTo(() => ctx.Dispose()).MustHaveHappened());
There's are a few other instance similar to this.
| var actualException = Assert.Throws<IndexOutOfRangeException>(() => AeronArchive.ConnectAsync(ctx)); | ||
| Assert.AreSame(error, actualException); | ||
|
|
||
| A.CallTo(() => ctx.Conclude()).MustHaveHappened().Then( |
| private long controlSessionId = Aeron.Aeron.NULL_VALUE; | ||
| private byte[] encodedCredentialsFromChallenge = null; | ||
| private AsyncConnectState state = AsyncConnectState.ADD_PUBLICATION; | ||
| private AsyncConnectState state = AsyncConnectState.AWAIT_SUBSCRIPTION; |
There was a problem hiding this comment.
The Java code moves this code into the constructor, while functionally equivalent (on the happy path). I think it is clearer if this gets moved to a similar location to the Java version.
| @@ -3548,8 +3602,11 @@ public void Dispose() | |||
| { | |||
| if (null != controlResponsePoller) | |||
There was a problem hiding this comment.
The Java implementation is doing a check for ownsAeronClient, is that required here?
There was a problem hiding this comment.
Probably... added.
| CheckDeadline(); | ||
| ctx.RunInvokers(); | ||
|
|
||
| if (AsyncConnectState.AWAIT_SUBSCRIPTION == state) |
There was a problem hiding this comment.
The Java implementation uses a switch statement here instead a lot of ifs. It may be out of scope for this PR, but we should look at aligning the implementation.
There was a problem hiding this comment.
Changed to switch.
| object publication = null != archiveProxy ? (object)archiveProxy.Pub() : ctx.ControlRequestChannel(); | ||
| object subscription = null != controlResponsePoller | ||
| ? (object)controlResponsePoller.Subscription() | ||
| : ctx.ControlResponseChannel(); |
There was a problem hiding this comment.
Formatting, should be:
throw new TimeoutException(
"Archive connect timeout: step=" + state +
" publication=" + publication +
" subscription=" + subscription);
| { | ||
| public int DisposeCount { get; private set; } | ||
|
|
||
| public override void Dispose() |
There was a problem hiding this comment.
This requires that AeronCluster.Context.Dispose to be declared virtual. If there is an alternative to this implementation, then that would be better than a derived class. This looks like it is a replacement for a spy, which the .Net mocking library doesn't seem to support. If making the method virtual is the only solution, then I guess we need to go with that.
There was a problem hiding this comment.
Turns out there was an alternative using Fody... so used that instead, Dispose is back to non-virtual.
|
|
||
| asyncConnect.Dispose(); | ||
|
|
||
| A.CallTo(() => _aeron.Ctx).MustHaveHappened().Then( |
|
|
||
| asyncConnect.Dispose(); | ||
|
|
||
| A.CallTo(() => _aeron.Ctx).MustHaveHappened().Then( |
|
|
||
| [SetUp] | ||
| public void SetUp() | ||
| { |
There was a problem hiding this comment.
A lot of this logic could move to field initialisation to better follow the Java implemementation.
There was a problem hiding this comment.
Mostly fixed... some couldn't be moved due to .NET rules.
24a1484 to
90dbec7
Compare
Added a new "Unsealer.Fody" Fody addin to allow tests to subclass sealed classes (Debug builds only). Changed EgressPoller.OnFragment to skip over unknown schemaIds and continue to match Java behavior Added ArchiveException.ErrorCodeAsString, made AeronArchive.QuietClose public, and added MessageRetryAttempts config option for parity with Java Changed serialization of booleans in URIs to be lowercase "true/false" rather than .NET's default "True/False" Changed AeronArchive.AsyncConnect to match Java's version and state machine Fixed wrong decoder used in EgressAdapter.OnFragment's new leader event case
90dbec7 to
1752af2
Compare
| private EgressPoller _egressPoller; | ||
|
|
||
| [SetUp] | ||
| public void SetUp() |
There was a problem hiding this comment.
Initialisation can happen on the field and this setup method can be removed.
Added a new "Unsealer.Fody" Fody addin to allow tests to subclass sealed classes (Debug builds only).
Changed EgressPoller.OnFragment to skip over unknown schemaIds and continue to match Java behavior
Added ArchiveException.ErrorCodeAsString, made AeronArchive.QuietClose public, and added MessageRetryAttempts config option for parity with Java
Changed serialization of booleans in URIs to be lowercase "true/false" rather than .NET's default "True/False"
Changed AeronArchive.AsyncConnect to match Java's version and state machine
Fixed wrong decoder used in EgressAdapter.OnFragment's new leader event case