Skip to content

Allow testing of alertmanager gRPC replication in multitenant_test.go. #3958

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

Merged
merged 1 commit into from
Mar 18, 2021

Conversation

stevesg
Copy link
Contributor

@stevesg stevesg commented Mar 16, 2021

What this PR does:
Allow testing of alertmanager gRPC replication in multitenant_test.go.

Use a fake implementation of the alertmanager ClientPool to connect
together the alertmanager instances in the multitenant_test.go unit
test. This allows testing of the replication logic without relying on
doing do at integration test level, and without having the weight of the
gRPC server running.

Checklist

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

Use a fake implementation of the alertmanager ClientPool to connect
together the alertmanager instances in the multitenant_test.go unit
test. This allows testing of the replication logic without relying on
doing do at integration test level, and without having the weight of the
gRPC server running.

Signed-off-by: Steve Simpson <steve.simpson@grafana.com>
// For RF=3 1 -> 2 -> 4 = Total 6 merges
nFanOut := tt.replicationFactor - 1
nMerges := nFanOut + (nFanOut * nFanOut)
assert.Equal(t, float64(nMerges), metrics.GetSumOfCounters("cortex_alertmanager_partial_state_merges_total"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note I've fixed the names of these metrics by adding the cortex_ - is my assumption correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct 👍

Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Good job, LGTM!

// For RF=3 1 -> 2 -> 4 = Total 6 merges
nFanOut := tt.replicationFactor - 1
nMerges := nFanOut + (nFanOut * nFanOut)
assert.Equal(t, float64(nMerges), metrics.GetSumOfCounters("cortex_alertmanager_partial_state_merges_total"))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct 👍

Copy link
Contributor

@jtlisi jtlisi left a comment

Choose a reason for hiding this comment

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

LGTM, good work!

@pracucci pracucci merged commit ec958eb into cortexproject:master Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants