Skip to content
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

Merged
merged 18 commits into from
Dec 3, 2019
Merged

Diagnostic events in tests #1209

merged 18 commits into from
Dec 3, 2019

Conversation

dmdashenkov
Copy link
Contributor

@dmdashenkov dmdashenkov commented Dec 2, 2019

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. A Dashboard logs all the diagnostic events which occur in the Bounded Context under test. The only way to turn the Dashboard off is via MuteLogging aspect.

Duplicate signal events

Previously, CannotDispatchDuplicateEvent and CannotDispatchDuplicateCommand 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.

@codecov
Copy link

codecov bot commented Dec 2, 2019

Codecov Report

Merging #1209 into master will increase coverage by 0.02%.
The diff coverage is 100%.

@@             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

@dmdashenkov dmdashenkov marked this pull request as ready for review December 2, 2019 14:12
@dmdashenkov
Copy link
Contributor Author

@alexander-yevsyukov, PTAL.

Copy link
Contributor

@alexander-yevsyukov alexander-yevsyukov left a 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" />
Copy link
Contributor

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.

Copy link
Contributor Author

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());
Copy link
Contributor

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) {
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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
Copy link
Contributor

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);
Copy link
Contributor

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",
Copy link
Contributor

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:

  1. Have some indentation after %n.
  2. 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.

Copy link
Contributor

@alexander-yevsyukov alexander-yevsyukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dmdashenkov dmdashenkov merged commit a063012 into master Dec 3, 2019
@dmdashenkov dmdashenkov deleted the visible-diagnostic-events branch December 3, 2019 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make ConstraintViolated visible in tests
2 participants