MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestAMConfigListUserConfig

Function TestAMConfigListUserConfig

pkg/alertmanager/api_test.go:1183–1268  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1181}
1182
1183func TestAMConfigListUserConfig(t *testing.T) {
1184 testCases := map[string]*UserConfig{
1185 "user1": {
1186 AlertmanagerConfig: `
1187global:
1188 resolve_timeout: 5m
1189route:
1190 receiver: route1
1191 group_by:
1192 - '...'
1193 continue: false
1194receivers:
1195- name: route1
1196 webhook_configs:
1197 - send_resolved: true
1198 http_config: {}
1199 url: http://alertmanager/api/notifications?orgId=1&rrid=7
1200 max_alerts: 0
1201`,
1202 },
1203 "user2": {
1204 AlertmanagerConfig: `
1205global:
1206 resolve_timeout: 5m
1207route:
1208 receiver: route1
1209 group_by:
1210 - '...'
1211 continue: false
1212receivers:
1213- name: route1
1214 webhook_configs:
1215 - send_resolved: true
1216 http_config: {}
1217 url: http://alertmanager/api/notifications?orgId=2&rrid=7
1218 max_alerts: 0
1219`,
1220 },
1221 }
1222
1223 storage := objstore.NewInMemBucket()
1224 bkt := &alertstore.MockBucket{Bucket: storage}
1225
1226 usersScannerConfig := users.UsersScannerConfig{Strategy: users.UserScanStrategyList}
1227 reg := prometheus.NewPedanticRegistry()
1228 alertStore, err := bucketclient.NewBucketAlertStore(bkt, usersScannerConfig, nil, log.NewNopLogger(), reg)
1229 require.NoError(t, err)
1230
1231 for u, cfg := range testCases {
1232 err := alertStore.SetAlertConfig(context.Background(), alertspb.AlertConfigDesc{
1233 User: u,
1234 RawConfig: cfg.AlertmanagerConfig,
1235 })
1236 require.NoError(t, err)
1237 }
1238
1239 externalURL := flagext.URLValue{}
1240 err = externalURL.Set("http://localhost:8080/alertmanager")

Callers

nothing calls this directly

Calls 13

SetAlertConfigMethod · 0.95
SetMethod · 0.95
NewBucketAlertStoreFunction · 0.92
StartAndAwaitRunningFunction · 0.92
StopAndAwaitTerminatedFunction · 0.92
mockAlertmanagerConfigFunction · 0.85
loadAndSyncConfigsMethod · 0.80
EqualMethod · 0.65
GetMethod · 0.65
LenMethod · 0.45
ServeHTTPMethod · 0.45

Tested by

no test coverage detected