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

Fix silence tests #8283

Merged
merged 2 commits into from
Jun 6, 2024
Merged

Fix silence tests #8283

merged 2 commits into from
Jun 6, 2024

Conversation

grobinson-grafana
Copy link
Contributor

@grobinson-grafana grobinson-grafana commented Jun 5, 2024

What this PR does

This commit fixes the silence tests, using the exact same tests in prometheus/alertmanager to avoid regressions due to modules, but using the New function in pkg/alertmanager/alertmanager.go to ensure the correct limits are set.

It bumps go.mod to commit db27a98 which is a no-op as Mimir does not vendor tests, but its meant to indicate we are using the fix from prometheus/alertmanager#3866.

The changes to go.mod are no longer needed as prometheus/alertmanager#3866 is included in #8200.

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@grobinson-grafana grobinson-grafana requested review from grafanabot and a team as code owners June 5, 2024 14:37
@grobinson-grafana grobinson-grafana marked this pull request as draft June 5, 2024 14:59
@grobinson-grafana grobinson-grafana force-pushed the grobinson/fix-silence-tests branch 5 times, most recently from 271b117 to 27ecae9 Compare June 5, 2024 18:59
@grobinson-grafana grobinson-grafana marked this pull request as ready for review June 5, 2024 18:59
// Set the interval to 1s as this test can trigger multiple broadcasts
// creating and expiring silences.
PersisterConfig: PersisterConfig{Interval: time.Second},
// We have set this 1 minute, but we don't use it in this
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't use the interval, why do we have to change the current value? Or even better, why do we have to set it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. Most tests use 1 hour for the interval, and this test used to use 1 hour before I changed it to 1 second, thinking the interval was the issue. However, I found that the interval is not the issue, so I increased it from 1 second to 1 minute. I can also change it back to 1 hour which will be a no-op – but at least consistent with the other tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible not to specify the interval length at all, since it is not used? If it is not possible, then I would set it to 1h in order to be consistent with other tests, and I would write a comment stating that we set it to 1h for consistency, but that actually it will be overridden by a call to Setxxx. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not possible I'm afraid, otherwise it panics with panic: non-positive interval for NewTicker. I've set it to 1h 👍

There is an existing comment:

// We have set this to 1 hour, but we don't use it in this test as we override the broadcast function with SetBroadcast.

Is that sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you

@@ -373,8 +374,13 @@ func TestSilenceLimits(t *testing.T) {
require.EqualError(t, err, "exceeded maximum number of silences: 1 (limit: 1)")
require.Equal(t, "", id2)

// Expire sil1. This should allow sil2 to be inserted.
// Expire sil1 and run the GC. This should allow sil2 to be
Copy link
Contributor

Choose a reason for hiding this comment

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

From the comment it looks like you run the GC on sil1 only, but you actually run it on both sil1 and sil2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sil2 hasn't been set at this time, so the GC just affects sil1. sil2 is no inserted until Line 384.

This commit fixes the silence tests, using the exact same tests
in prometheus/alertmanager to avoid regressions due to modules,
but using the New function in pkg/alertmanager/alertmanager.go
to ensure the correct limits are set.
@grobinson-grafana grobinson-grafana force-pushed the grobinson/fix-silence-tests branch from 27ecae9 to c83cb28 Compare June 6, 2024 08:47
Copy link
Contributor

@duricanikolic duricanikolic left a comment

Choose a reason for hiding this comment

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

LGTM

@grobinson-grafana grobinson-grafana merged commit 5988b23 into main Jun 6, 2024
29 checks passed
@grobinson-grafana grobinson-grafana deleted the grobinson/fix-silence-tests branch June 6, 2024 14:01
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