-
Notifications
You must be signed in to change notification settings - Fork 833
Add Alertmanager Integration Tests and Static File Backend #2125
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cortexproject/cortex/integration/e2e" | ||
"github.com/cortexproject/cortex/integration/e2ecortex" | ||
) | ||
|
||
func TestAlertmanager(t *testing.T) { | ||
s, err := e2e.NewScenario(networkName) | ||
require.NoError(t, err) | ||
defer s.Close() | ||
|
||
alertmanagerDir := filepath.Join(s.SharedDir(), "alertmanager_configs") | ||
require.NoError(t, os.Mkdir(alertmanagerDir, os.ModePerm)) | ||
|
||
require.NoError(t, ioutil.WriteFile( | ||
filepath.Join(alertmanagerDir, "user-1.yaml"), | ||
[]byte(cortexAlertmanagerUserConfigYaml), | ||
os.ModePerm), | ||
) | ||
|
||
alertmanager := e2ecortex.NewAlertmanager("alertmanager", AlertmanagerConfigs, "") | ||
require.NoError(t, s.StartAndWaitReady(alertmanager)) | ||
require.NoError(t, alertmanager.WaitSumMetric("cortex_alertmanager_configs", 1)) | ||
|
||
c, err := e2ecortex.NewClient("", "", alertmanager.Endpoint(80), "user-1") | ||
require.NoError(t, err) | ||
|
||
cfg, err := c.GetAlertmanagerConfig(context.Background()) | ||
require.NoError(t, err) | ||
|
||
// Ensure the returned status config matches alertmanager_test_fixtures/user-1.yaml | ||
require.NotNil(t, cfg) | ||
require.Equal(t, "example_receiver", cfg.Route.Receiver) | ||
require.Len(t, cfg.Route.GroupByStr, 1) | ||
require.Equal(t, "example_groupby", cfg.Route.GroupByStr[0]) | ||
require.Len(t, cfg.Receivers, 1) | ||
require.Equal(t, "example_receiver", cfg.Receivers[0].Name) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,22 @@ const ( | |
prefix: cortex_chunks_ | ||
period: 168h0m0s | ||
` | ||
|
||
cortexAlertmanagerUserConfigYaml = `route: | ||
receiver: "example_receiver" | ||
group_by: ["example_groupby"] | ||
receivers: | ||
- name: "example_receiver" | ||
` | ||
) | ||
|
||
var ( | ||
AlertmanagerConfigs = map[string]string{ | ||
"-alertmanager.storage.local.path": filepath.Join(e2e.ContainerSharedDir, "alertmanager_configs"), | ||
|
||
"-alertmanager.storage.type": "local", | ||
"-alertmanager.web.external-url": "http://localhost/api/prom", | ||
} | ||
|
||
BlocksStorage = map[string]string{ | ||
"-store.engine": "tsdb", | ||
"-experimental.tsdb.backend": "s3", | ||
|
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.
I just realized we didn't mention the introduction of the
local
storage in the changelog. I think it's worth to mention it.