Alerting: Enable simplified routing FF by default (#84856)
This commit is contained in:
@@ -145,13 +145,11 @@ func TestIntegrationAMConfigAccess(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("when retrieve alertmanager configuration", func(t *testing.T) {
|
||||
cfgBody := `
|
||||
cfgTemplate := `
|
||||
{
|
||||
"template_files": null,
|
||||
"alertmanager_config": {
|
||||
"route": {
|
||||
"receiver": "grafana-default-email"
|
||||
},
|
||||
"route": %s,
|
||||
"templates": null,
|
||||
"receivers": [{
|
||||
"name": "grafana-default-email",
|
||||
@@ -169,6 +167,22 @@ func TestIntegrationAMConfigAccess(t *testing.T) {
|
||||
}
|
||||
}
|
||||
`
|
||||
cfgWithoutAutogen := fmt.Sprintf(cfgTemplate, `{
|
||||
"receiver": "grafana-default-email"
|
||||
}`)
|
||||
cfgWithAutogen := fmt.Sprintf(cfgTemplate, `{
|
||||
"receiver": "grafana-default-email",
|
||||
"routes": [{
|
||||
"receiver": "grafana-default-email",
|
||||
"object_matchers": [["__grafana_autogenerated__", "=", "true"]],
|
||||
"routes": [{
|
||||
"receiver": "grafana-default-email",
|
||||
"group_by": ["grafana_folder", "alertname"],
|
||||
"object_matchers": [["__grafana_receiver__", "=", "grafana-default-email"]]
|
||||
}]
|
||||
}]
|
||||
}`)
|
||||
|
||||
testCases := []testCase{
|
||||
{
|
||||
desc: "un-authenticated request should fail",
|
||||
@@ -180,19 +194,19 @@ func TestIntegrationAMConfigAccess(t *testing.T) {
|
||||
desc: "viewer request should succeed",
|
||||
url: "http://viewer:viewer@%s/api/alertmanager/grafana/config/api/v1/alerts",
|
||||
expStatus: http.StatusOK,
|
||||
expBody: cfgBody,
|
||||
expBody: cfgWithoutAutogen,
|
||||
},
|
||||
{
|
||||
desc: "editor request should succeed",
|
||||
url: "http://editor:editor@%s/api/alertmanager/grafana/config/api/v1/alerts",
|
||||
expStatus: http.StatusOK,
|
||||
expBody: cfgBody,
|
||||
expBody: cfgWithoutAutogen,
|
||||
},
|
||||
{
|
||||
desc: "admin request should succeed",
|
||||
url: "http://admin:admin@%s/api/alertmanager/grafana/config/api/v1/alerts",
|
||||
expStatus: http.StatusOK,
|
||||
expBody: cfgBody,
|
||||
expBody: cfgWithAutogen,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -2030,17 +2044,14 @@ func TestIntegrationAlertmanagerStatus(t *testing.T) {
|
||||
expBody string
|
||||
}
|
||||
|
||||
cfgBody := `
|
||||
cfgTemplate := `
|
||||
{
|
||||
"cluster": {
|
||||
"peers": [],
|
||||
"status": "disabled"
|
||||
},
|
||||
"config": {
|
||||
"route": {
|
||||
"receiver": "grafana-default-email",
|
||||
"group_by": ["grafana_folder", "alertname"]
|
||||
},
|
||||
"route": %s,
|
||||
"templates": null,
|
||||
"receivers": [{
|
||||
"name": "grafana-default-email",
|
||||
@@ -2067,6 +2078,23 @@ func TestIntegrationAlertmanagerStatus(t *testing.T) {
|
||||
}
|
||||
}
|
||||
`
|
||||
cfgWithoutAutogen := fmt.Sprintf(cfgTemplate, `{
|
||||
"receiver": "grafana-default-email",
|
||||
"group_by": ["grafana_folder", "alertname"]
|
||||
}`)
|
||||
cfgWithAutogen := fmt.Sprintf(cfgTemplate, `{
|
||||
"receiver": "grafana-default-email",
|
||||
"routes": [{
|
||||
"receiver": "grafana-default-email",
|
||||
"object_matchers": [["__grafana_autogenerated__", "=", "true"]],
|
||||
"routes": [{
|
||||
"receiver": "grafana-default-email",
|
||||
"group_by": ["grafana_folder", "alertname"],
|
||||
"object_matchers": [["__grafana_receiver__", "=", "grafana-default-email"]]
|
||||
}]
|
||||
}],
|
||||
"group_by": ["grafana_folder", "alertname"]
|
||||
}`)
|
||||
|
||||
testCases := []testCase{
|
||||
{
|
||||
@@ -2079,19 +2107,19 @@ func TestIntegrationAlertmanagerStatus(t *testing.T) {
|
||||
desc: "viewer request should succeed",
|
||||
url: "http://viewer:viewer@%s/api/alertmanager/grafana/api/v2/status",
|
||||
expStatus: http.StatusOK,
|
||||
expBody: cfgBody,
|
||||
expBody: cfgWithoutAutogen,
|
||||
},
|
||||
{
|
||||
desc: "editor request should succeed",
|
||||
url: "http://editor:editor@%s/api/alertmanager/grafana/api/v2/status",
|
||||
expStatus: http.StatusOK,
|
||||
expBody: cfgBody,
|
||||
expBody: cfgWithoutAutogen,
|
||||
},
|
||||
{
|
||||
desc: "admin request should succeed",
|
||||
url: "http://admin:admin@%s/api/alertmanager/grafana/api/v2/status",
|
||||
expStatus: http.StatusOK,
|
||||
expBody: cfgBody,
|
||||
expBody: cfgWithAutogen,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user