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

Add workaround for input event problems in MongoInputStatusService #7993

Merged
merged 2 commits into from
Apr 29, 2020

Conversation

bernd
Copy link
Member

@bernd bernd commented Apr 28, 2020

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

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
@bernd bernd added this to the 3.3.0 milestone Apr 28, 2020
@bernd bernd requested a review from waab76 April 28, 2020 16:32
Comment on lines 191 to 211
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));
}
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point! 👍

@bernd bernd requested a review from waab76 April 29, 2020 07:19
Copy link
Contributor

@waab76 waab76 left a comment

Choose a reason for hiding this comment

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

LGTM

@waab76 waab76 merged commit 993554b into master Apr 29, 2020
@waab76 waab76 deleted the issue-7812 branch April 29, 2020 13:13
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.

2 participants