-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add workaround for input event problems in MongoInputStatusService #7993
Conversation
public void handleDeleteEvent_DoesNothing() throws Exception { | ||
final String deletedInput = "54e3deadbeefdeadbeef0001"; | ||
final InputDeleted inputDeletedEvent = new InputDeleted() { | ||
@Override | ||
public String id() { | ||
return "54e3deadbeefdeadbeef0001"; | ||
return deletedInput; | ||
} | ||
}); | ||
}; | ||
|
||
cut.handleInputDeleted(inputDeletedEvent); | ||
// The record should not be removed from the DB | ||
Optional<InputStatusRecord> optDbRecord = cut.get("54e3deadbeefdeadbeef0001"); | ||
assertThat(cut.get(deletedInput).isPresent(), is(true)); | ||
|
||
assertThat(optDbRecord, notNullValue()); | ||
assertThat(optDbRecord.isPresent(), is(true)); | ||
// Simulate that the input has actually been deleted | ||
// TODO: This will change once we fix https://github.com/Graylog2/graylog2-server/issues/7812 | ||
when(inputService.find(deletedInput)).thenThrow(new NotFoundException()); | ||
|
||
cut.handleInputDeleted(inputDeletedEvent); | ||
// The record should be removed from the DB | ||
assertThat(cut.get(deletedInput).isPresent(), is(false)); | ||
} |
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 should be split into two separate tests to make it easier to see if a change breaks one but not the other.
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.
Good point! 👍
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
This is a workaround for the problem described in #7812.
When we receive an "InputDeleted" event, check if the input still exists
in the database. If so, the input has only been stopped and we don't
want to delete our state.
Refs #7812