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

Function TestRulerAlertmanagerTLS

integration/ruler_test.go:1028–1104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1026}
1027
1028func TestRulerAlertmanagerTLS(t *testing.T) {
1029 var namespaceOne = "test_/encoded_+namespace/?"
1030 ruleGroup := createTestRuleGroup(t)
1031
1032 s, err := e2e.NewScenario(networkName)
1033 require.NoError(t, err)
1034 defer s.Close()
1035
1036 // Start dependencies.
1037 consul := e2edb.NewConsul()
1038 minio := e2edb.NewMinio(9000, rulestoreBucketName, bucketName)
1039 require.NoError(t, s.StartAndWaitReady(consul, minio))
1040
1041 // set the ca
1042 cert := ca.New("Ruler/Alertmanager Test")
1043
1044 // Ensure the entire path of directories exist.
1045 require.NoError(t, os.MkdirAll(filepath.Join(s.SharedDir(), "certs"), os.ModePerm))
1046
1047 require.NoError(t, cert.WriteCACertificate(filepath.Join(s.SharedDir(), caCertFile)))
1048
1049 // server certificate
1050 require.NoError(t, cert.WriteCertificate(
1051 &x509.Certificate{
1052 Subject: pkix.Name{CommonName: "client"},
1053 ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
1054 },
1055 filepath.Join(s.SharedDir(), clientCertFile),
1056 filepath.Join(s.SharedDir(), clientKeyFile),
1057 ))
1058 require.NoError(t, cert.WriteCertificate(
1059 &x509.Certificate{
1060 Subject: pkix.Name{CommonName: "server"},
1061 DNSNames: []string{"ruler.alertmanager-client"},
1062 ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
1063 },
1064 filepath.Join(s.SharedDir(), serverCertFile),
1065 filepath.Join(s.SharedDir(), serverKeyFile),
1066 ))
1067
1068 // Have at least one alertmanager configuration.
1069 require.NoError(t, writeFileToSharedDir(s, "alertmanager_configs/user-1.yaml", []byte(cortexAlertmanagerUserConfigYaml)))
1070
1071 // Start Alertmanagers.
1072 amFlags := mergeFlags(
1073 AlertmanagerFlags(),
1074 AlertmanagerLocalFlags(),
1075 getServerHTTPTLSFlags(),
1076 )
1077 am1 := e2ecortex.NewAlertmanagerWithTLS("alertmanager1", amFlags, "")
1078 require.NoError(t, s.StartAndWaitReady(am1))
1079
1080 // Connect the ruler to the Alertmanager
1081 configOverrides := mergeFlags(
1082 map[string]string{
1083 "-ruler.alertmanager-url": "https://" + am1.HTTPEndpoint(),
1084 },
1085 getTLSFlagsWithPrefix("ruler.alertmanager-client", "alertmanager", true),

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
SharedDirMethod · 0.95
SetRuleGroupMethod · 0.95
NewScenarioFunction · 0.92
NewFunction · 0.92
NewAlertmanagerWithTLSFunction · 0.92
NewRulerFunction · 0.92
NewClientFunction · 0.92
EqualsFunction · 0.92
createTestRuleGroupFunction · 0.85
writeFileToSharedDirFunction · 0.85

Tested by

no test coverage detected