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

Function TestAlertmanagerShardingScaling

integration/alertmanager_test.go:541–731  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

539}
540
541func TestAlertmanagerShardingScaling(t *testing.T) {
542 // Note that we run the test with the persister interval reduced in
543 // order to speed up the testing. However, this could mask issues with
544 // the syncing state from replicas. Therefore, we also run the tests
545 // with the sync interval increased (with the caveat that we cannot
546 // test the all-replica shutdown/restart).
547 tests := map[string]struct {
548 replicationFactor int
549 withPersister bool
550 }{
551 "RF = 2 with persister": {replicationFactor: 2, withPersister: true},
552 "RF = 3 with persister": {replicationFactor: 3, withPersister: true},
553 "RF = 2 without persister": {replicationFactor: 2, withPersister: false},
554 "RF = 3 without persister": {replicationFactor: 3, withPersister: false},
555 }
556
557 for testName, testCfg := range tests {
558 t.Run(testName, func(t *testing.T) {
559 s, err := e2e.NewScenario(networkName)
560 require.NoError(t, err)
561 defer s.Close()
562
563 // Start dependencies.
564 consul := e2edb.NewConsul()
565 minio := e2edb.NewMinio(9000, alertsBucketName)
566 require.NoError(t, s.StartAndWaitReady(consul, minio))
567
568 client, err := s3.NewBucketWithConfig(nil, s3.Config{
569 Endpoint: minio.HTTPEndpoint(),
570 Insecure: true,
571 Bucket: alertsBucketName,
572 AccessKey: e2edb.MinioAccessKey,
573 SecretKey: e2edb.MinioSecretKey,
574 }, "alertmanager-test", nil)
575 require.NoError(t, err)
576
577 // Create and upload Alertmanager configurations.
578 numUsers := 20
579 for i := 1; i <= numUsers; i++ {
580 user := fmt.Sprintf("user-%d", i)
581 desc := alertspb.AlertConfigDesc{
582 RawConfig: simpleAlertmanagerConfig,
583 User: user,
584 Templates: []*alertspb.TemplateDesc{},
585 }
586
587 d, err := desc.Marshal()
588 require.NoError(t, err)
589 err = client.Upload(context.Background(), fmt.Sprintf("/alerts/%s", user), bytes.NewReader(d))
590 require.NoError(t, err)
591 }
592
593 persistInterval := "5h"
594 if testCfg.withPersister {
595 persistInterval = "5s"
596 }
597
598 flags := mergeFlags(AlertmanagerFlags(),

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
MarshalMethod · 0.95
StopMethod · 0.95
CreateSilenceMethod · 0.95
NewScenarioFunction · 0.92
NewAlertmanagerFunction · 0.92
EqualsFunction · 0.92
NewClientFunction · 0.92
GreaterFunction · 0.92
HTTPEndpointMethod · 0.80

Tested by

no test coverage detected