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

Function TestOverridesAPI_PATCH

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

Source from the content-addressed store, hash-verified

334}
335
336func TestOverridesAPI_PATCH(t *testing.T) {
337 util.RunIntegrationTests(t, util.TestHarnessConfig{
338 ConfigOverlay: configOverrides,
339 DeploymentMode: util.DeploymentModeSingleBinary,
340 Backends: util.BackendObjectStorageS3, // this test fails on other backends b/c it's testing specific etag related code
341 }, func(h *util.TempoHarness) {
342 t.Run("with no existing config creates new config", func(t *testing.T) {
343 apiClient := h.APIClientHTTP("tenant-patch-1")
344
345 patch := &client.Limits{
346 MetricsGenerator: client.LimitsMetricsGenerator{
347 DisableCollection: boolPtr(true),
348 },
349 }
350 returnedLimits, etag, err := apiClient.PatchOverrides(patch)
351 require.NoError(t, err)
352 require.NotEmpty(t, etag)
353
354 // verify returned limits match patch
355 disableCollection, ok := returnedLimits.GetMetricsGenerator().GetDisableCollection()
356 require.True(t, ok)
357 require.True(t, disableCollection)
358
359 // verify config was created via GET
360 getLimits, getEtag, err := apiClient.GetOverrides()
361 require.NoError(t, err)
362 require.Equal(t, etag, getEtag)
363 require.Equal(t, returnedLimits, getLimits)
364 })
365
366 t.Run("preserves existing config sections", func(t *testing.T) {
367 apiClient := h.APIClientHTTP("tenant-patch-2")
368
369 // create initial config with processors
370 initialLimits := &client.Limits{
371 MetricsGenerator: client.LimitsMetricsGenerator{
372 DisableCollection: boolPtr(true),
373 Processors: &listtomap.ListToMap{"span-metrics": {}},
374 },
375 }
376 _, _, err := apiClient.PatchOverrides(initialLimits)
377 require.NoError(t, err)
378
379 // PATCH with additional processor config
380 patch := &client.Limits{
381 MetricsGenerator: client.LimitsMetricsGenerator{
382 Processor: client.LimitsMetricsGeneratorProcessor{
383 SpanMetrics: client.LimitsMetricsGeneratorProcessorSpanMetrics{
384 EnableInstanceLabel: boolPtr(false),
385 },
386 },
387 },
388 }
389 returnedLimits, _, err := apiClient.PatchOverrides(patch)
390 require.NoError(t, err)
391
392 // verify original fields are preserved and not wiped out
393 disableCollection, ok := returnedLimits.GetMetricsGenerator().GetDisableCollection()

Callers

nothing calls this directly

Calls 15

RunIntegrationTestsFunction · 0.92
keysFunction · 0.85
APIClientHTTPMethod · 0.80
GetDisableCollectionMethod · 0.80
GetMetricsGeneratorMethod · 0.80
GetProcessorsMethod · 0.80
GetMapMethod · 0.80
GetSpanMetricsMethod · 0.80
GetProcessorMethod · 0.80
GetServiceGraphsMethod · 0.80
GetCostAttributionMethod · 0.80

Tested by

no test coverage detected