MCPcopy
hub / github.com/grafana/tempo / TestOverridesAPI_GET

Function TestOverridesAPI_GET

integration/api/overrides_api_test.go:159–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

157}
158
159func TestOverridesAPI_GET(t *testing.T) {
160 util.RunIntegrationTests(t, util.TestHarnessConfig{
161 ConfigOverlay: configOverrides,
162 DeploymentMode: util.DeploymentModeSingleBinary,
163 Backends: util.BackendObjectStorageS3, // this test fails on other backends b/c it's testing specific etag related code
164 }, func(h *util.TempoHarness) {
165 t.Run("returns 404 when config not found", func(t *testing.T) {
166 apiClient := h.APIClientHTTP("tenant-get-1")
167
168 limits, etag, err := apiClient.GetOverrides()
169 require.Nil(t, limits) // no limits because it doesn't exist for this tenant
170 require.Empty(t, etag) // etag will be ""
171 require.ErrorIs(t, err, httpclient.ErrNotFound)
172 })
173
174 t.Run("returns config with etag", func(t *testing.T) {
175 apiClient := h.APIClientHTTP("tenant-get-2")
176
177 // create initial config with POST
178 initialLimits := &client.Limits{
179 CostAttribution: client.CostAttribution{
180 Dimensions: &map[string]string{"host.name": "host_name"},
181 },
182 MetricsGenerator: client.LimitsMetricsGenerator{
183 DisableCollection: boolPtr(false),
184 },
185 }
186 setEtag, err := apiClient.SetOverrides(initialLimits, "0")
187 require.NoError(t, err)
188 require.NotEmpty(t, setEtag)
189
190 // get should return the config and etag
191 returnedLimits, etag, err := apiClient.GetOverrides()
192 require.NoError(t, err)
193 require.Equal(t, setEtag, etag)
194 require.Equal(t, initialLimits, returnedLimits)
195 })
196 })
197}
198
199func TestOverridesAPI_POST(t *testing.T) {
200 util.RunIntegrationTests(t, util.TestHarnessConfig{

Callers

nothing calls this directly

Calls 7

RunIntegrationTestsFunction · 0.92
APIClientHTTPMethod · 0.80
boolPtrFunction · 0.70
GetOverridesMethod · 0.65
SetOverridesMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected