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

Function TestConfigAPIEndpoint

integration/api_endpoints_test.go:54–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestConfigAPIEndpoint(t *testing.T) {
55 s, err := e2e.NewScenario(networkName)
56 require.NoError(t, err)
57 defer s.Close()
58
59 configOverrides := map[string]string{
60 // alert manager
61 "-alertmanager.web.external-url": "http://localhost/alertmanager",
62 "-alertmanager-storage.backend": "local",
63 "-alertmanager-storage.local.path": filepath.Join(e2e.ContainerSharedDir, "alertmanager_configs"),
64 }
65 // make alert manager config dir
66 require.NoError(t, writeFileToSharedDir(s, "alertmanager_configs", []byte{}))
67
68 // Start Cortex in single binary mode, reading the config from file.
69 require.NoError(t, copyFileToSharedDir(s, "docs/configuration/single-process-config-blocks-local.yaml", cortexConfigFile))
70
71 cortex1 := e2ecortex.NewSingleBinaryWithConfigFile("cortex-1", cortexConfigFile, configOverrides, "", 9009, 9095)
72 require.NoError(t, s.StartAndWaitReady(cortex1))
73
74 // Get config from /config API endpoint.
75 res, err := e2e.GetRequest(fmt.Sprintf("http://%s/config", cortex1.Endpoint(9009)))
76 require.NoError(t, err)
77
78 defer runutil.ExhaustCloseWithErrCapture(&err, res.Body, "config API response")
79 body, err := io.ReadAll(res.Body)
80 require.NoError(t, err)
81 require.Equal(t, http.StatusOK, res.StatusCode)
82
83 // Start again Cortex in single binary with the exported config
84 // and ensure it starts (pass the readiness probe).
85 require.NoError(t, writeFileToSharedDir(s, cortexConfigFile, body))
86 configOverrides["-alertmanager.cluster.peers"] = cortex1.HTTPEndpoint()
87 cortex2 := e2ecortex.NewSingleBinaryWithConfigFile("cortex-2", cortexConfigFile, configOverrides, "", 9009, 9095)
88 require.NoError(t, s.StartAndWaitReady(cortex2))
89}
90
91func Test_AllUserStats_WhenIngesterRollingUpdate(t *testing.T) {
92 s, err := e2e.NewScenario(networkName)

Callers

nothing calls this directly

Calls 11

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
NewScenarioFunction · 0.92
GetRequestFunction · 0.92
writeFileToSharedDirFunction · 0.85
copyFileToSharedDirFunction · 0.85
JoinMethod · 0.80
HTTPEndpointMethod · 0.80
EqualMethod · 0.65
EndpointMethod · 0.45

Tested by

no test coverage detected