-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Diagnostic events in tests #1209
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1209 +/- ##
============================================
+ Coverage 91.46% 91.48% +0.02%
- Complexity 4260 4269 +9
============================================
Files 546 547 +1
Lines 13289 13346 +57
Branches 758 759 +1
============================================
+ Hits 12155 12210 +55
Misses 895 895
- Partials 239 241 +2 |
@alexander-yevsyukov, PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the design and impl. in general. But I have some questions and comments. Please have a look. Let's talk if you need more info on why I think some of the changes are questionable.
@@ -30,6 +30,12 @@ | |||
</XML> | |||
<codeStyleSettings language="Dart"> | |||
<option name="RIGHT_MARGIN" value="100" /> | |||
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We keep tossing these settings back and forth by different people. I guess we need to standardize either to have them or not have them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those come from config
. It's strange that they get deleted sometimes. I vote for leaving them.
@@ -33,6 +33,6 @@ | |||
@Override | |||
default void onDuplicate(I target, CommandEnvelope envelope) { | |||
repository().lifecycleOf(target) | |||
.onDuplicateCommand(envelope.id()); | |||
.onDuplicateCommand(envelope.messageId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any other ID we have in relation to an envelope? Why do we need a longer name in this context?
@@ -367,22 +367,26 @@ public final void onDispatchingFailed(MessageId dispatchedSignal, Error error) { | |||
} | |||
} | |||
|
|||
public void onDuplicateEvent(EventId eventId) { | |||
public void onDuplicateEvent(MessageId eventId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks suspicious. I would understand having the method renamed to onDuplicatedMessage()
retaining the parameter type of EventId
, so that we can have onDuplicateMessage(CommandId)
below. But this generalization looks a bit strange. Why do we need it?
CannotDispatchDuplicateEvent event = CannotDispatchDuplicateEvent | ||
.newBuilder() | ||
.setEntity(entityId) | ||
.setEvent(eventId) | ||
.setEvent(eventId.asEventId()) | ||
.setDuplicateEvent(eventId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to speak duplicated
again? We already said that in the name of the rejection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why do we set general type MessageId
while we know the specific type (and say it in the name of the field)?
// | ||
core.CommandId command = 2 [deprecated = true]; | ||
|
||
core.MessageId duplicate_command = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear why do we need a general type while we say command
in the field name. Please explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MessageId
also contains the type URL of the command, while CommandId
does not. We don't lose any information when using MessageId
here.
The same applies to EventId
in CannotDispatchDuplicateEvent
.
// | ||
core.EventId event = 2 [deprecated = true]; | ||
|
||
core.MessageId duplicate_event = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear why do we have a more general type MessageId
while we speak specific type event
in the field name. Please explain.
* | ||
* <p>Logs all the received diagnostic events with a meaningful message. | ||
*/ | ||
final class Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the design, but I'm not sure this is the best name. I would keep such a general (and UI-related term) for a bigger thing. Speaking something about “diagnostics” in the name would look more natural.
String typeUrl = event.getEntity() | ||
.getTypeUrl(); | ||
String idAsString = Identifier.toString(event.getEntity().getId()); | ||
log(event, "Entity state (ID: %s, type: %s) is invalid.", idAsString, typeUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add backticks to code-related things in the messages here and below.
|
||
@Subscribe | ||
void on(HandlerFailedUnexpectedly event) { | ||
log(event, "Signal %s could not be handled by %s:%n%s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we're putting messages on new line (and understandably not having a period in the format) we need to separate this message from the next one on the log.
Options that I see here:
- Have some indentation after
%n
. - Have another
%n
at the end, so that the whole log record on an event looks as a clearly separated block.
Without it the message which starts at the new line could be confused with a start of a new log record. It's easy to miss the colon at the end of the previous line, especially if the log line is long and full of code-related details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Dashboard
When testing a Spine-based system with
BlackBoxBoundedContext
, it is important to be aware of all the failures which happen backstage. For this, we introduce a new system event subscriber —Dashboard
. ADashboard
logs all the diagnostic events which occur in the Bounded Context under test. The only way to turn theDashboard
off is viaMuteLogging
aspect.Duplicate signal events
Previously,
CannotDispatchDuplicateEvent
andCannotDispatchDuplicateCommand
events did not provide any info on the type of the duplicate signal. Now, instead of providing info about the ID, the type info is also included in the events.Fixes #1207.