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

Function TestIndexAPIEndpoint

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

Source from the content-addressed store, hash-verified

21)
22
23func TestIndexAPIEndpoint(t *testing.T) {
24 s, err := e2e.NewScenario(networkName)
25 require.NoError(t, err)
26 defer s.Close()
27
28 configOverrides := map[string]string{
29 // alert manager
30 "-alertmanager.web.external-url": "http://localhost/alertmanager",
31 "-alertmanager-storage.backend": "local",
32 "-alertmanager-storage.local.path": filepath.Join(e2e.ContainerSharedDir, "alertmanager_configs"),
33 }
34 // make alert manager config dir
35 require.NoError(t, writeFileToSharedDir(s, "alertmanager_configs", []byte{}))
36
37 // Start Cortex in single binary mode, reading the config from file.
38 require.NoError(t, copyFileToSharedDir(s, "docs/configuration/single-process-config-blocks-local.yaml", cortexConfigFile))
39
40 cortex1 := e2ecortex.NewSingleBinaryWithConfigFile("cortex-1", cortexConfigFile, configOverrides, "", 9009, 9095)
41 require.NoError(t, s.StartAndWaitReady(cortex1))
42
43 // GET / should succeed
44 res, err := e2e.GetRequest(fmt.Sprintf("http://%s", cortex1.Endpoint(9009)))
45 require.NoError(t, err)
46 assert.Equal(t, 200, res.StatusCode)
47
48 // POST / should fail
49 res, err = e2e.PostRequest(fmt.Sprintf("http://%s", cortex1.Endpoint(9009)))
50 require.NoError(t, err)
51 assert.Equal(t, 405, res.StatusCode)
52}
53
54func TestConfigAPIEndpoint(t *testing.T) {
55 s, err := e2e.NewScenario(networkName)

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected