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

Unit tests for event forwarding #145

Merged
merged 5 commits into from
Feb 23, 2021
Merged

Unit tests for event forwarding #145

merged 5 commits into from
Feb 23, 2021

Conversation

squaremo
Copy link
Member

This adds some tests to check that events are forwarded as specified by alerts.

The controllers themselves aren't needed; but since the internal/server package refer directly to Kubernetes resources, the tests share prerequisites with controller tests. For that reason I have started by putting these tests in controllers/.

I have tried not to touch the server code itself, but it was necessary to change it to use a fresh http.ServerMux rather than the (global) default, so that the tests can create an event server each.

I've taken the opportunity to include a very minor tidy of bits of internal/server/.

This adds some scaffolding for testing that events are forwarded as
specified by alerts.

The controllers themselves aren't needed; but since the
internal/server package refer directly to Kubernetes resources, the
tests share prerequisites with controller tests. For that reason I
have started by putting these tests in controllers/.

I have tried not to touch the server code itself, but it was necessary
to change it to use a fresh http.ServerMux rather than the (global)
default, so that the tests can create an event server each.

Signed-off-by: Michael Bridgen <[email protected]>
This rearranges the tests a little to make it easier to test for
events being filtered (not forwarded).

Signed-off-by: Michael Bridgen <[email protected]>
This adds tests that the filtering by alert.Spec.ExclusionList works.

Signed-off-by: Michael Bridgen <[email protected]>
`continue` with a label is for exactly this situation.

Signed-off-by: Michael Bridgen <[email protected]>
Signed-off-by: Michael Bridgen <[email protected]>
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @squaremo

@squaremo squaremo merged commit 22c6082 into main Feb 23, 2021
@squaremo squaremo deleted the continue-outer branch February 23, 2021 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants