Files
traces/integration/api/multi_tenant_test.go
Joe ElliottandGitHub 5ee93d3cf8 Tempo 3.0: Integration Tests Rewrite (#6088)
* First pass test harness

Signed-off-by: Joe Elliott <[email protected]>

* limits - passed

Signed-off-by: Joe Elliott <[email protected]>

* metrics generator - passed

Signed-off-by: Joe Elliott <[email protected]>

* harness cleanup/fix target info test

Signed-off-by: Joe Elliott <[email protected]>

* deployments - passed

Signed-off-by: Joe Elliott <[email protected]>

* receivers - passed

Signed-off-by: Joe Elliott <[email protected]>

* harness cleanup

Signed-off-by: Joe Elliott <[email protected]>

* storage - passed

Signed-off-by: Joe Elliott <[email protected]>

* api - passing

Signed-off-by: Joe Elliott <[email protected]>

* cleanup and CI

Signed-off-by: Joe Elliott <[email protected]>

* Additional tests

Signed-off-by: Joe Elliott <[email protected]>

* it's me and you linter. how many times are you going to do this to me?

Signed-off-by: Joe Elliott <[email protected]>

* lint and tests

Signed-off-by: Joe Elliott <[email protected]>

* restored live store partition tests

Signed-off-by: Joe Elliott <[email protected]>

* massive lint

Signed-off-by: Joe Elliott <[email protected]>

* cleanup

Signed-off-by: Joe Elliott <[email protected]>

* lint >.<

Signed-off-by: Joe Elliott <[email protected]>

* wups

Signed-off-by: Joe Elliott <[email protected]>

* cleanup and stabilizing

Signed-off-by: Joe Elliott <[email protected]>

* cleanup

Signed-off-by: Joe Elliott <[email protected]>

* omg

Signed-off-by: Joe Elliott <[email protected]>

* added config file. removed empty file. deleted some debug code

Signed-off-by: Joe Elliott <[email protected]>

* even more fixes

Signed-off-by: Joe Elliott <[email protected]>

* maybe this works? maybe it was all local networking issues

Signed-off-by: Joe Elliott <[email protected]>

* review

Signed-off-by: Joe Elliott <[email protected]>

* backed off huge write timeout. added missing config file

Signed-off-by: Joe Elliott <[email protected]>

* restore disable parallelism setting. restore beefy write timeout

Signed-off-by: Joe Elliott <[email protected]>

* apparently another test relied on the http receiver

Signed-off-by: Joe Elliott <[email protected]>

* livestore avail zone!

Signed-off-by: Joe Elliott <[email protected]>

* add support for v1 traces and tags endpoints

Signed-off-by: Joe Elliott <[email protected]>

* review

Signed-off-by: Joe Elliott <[email protected]>

* changed the location of the changelog entry to avoid conflicts

Signed-off-by: Joe Elliott <[email protected]>

---------

Signed-off-by: Joe Elliott <[email protected]>
2026-01-07 08:31:11 -05:00

72 lines
1.9 KiB
Go

package api
import (
"strings"
"testing"
"time"
"github.com/grafana/tempo/integration/util"
tempoUtil "github.com/grafana/tempo/pkg/util"
"github.com/stretchr/testify/require"
)
func TestSingleTenantSearch(t *testing.T) {
testSearch(t, "test")
}
func TestWildCardTenantSearch(t *testing.T) {
testSearch(t, "*")
}
func TestTwoTenantsSearch(t *testing.T) {
testSearch(t, "test|test2")
}
func TestThreeTenantsSearch(t *testing.T) {
testSearch(t, "test|test2|test3")
}
func testSearch(t *testing.T, tenant string) {
util.RunIntegrationTests(t, util.TestHarnessConfig{
ConfigOverlay: "config-multi-tenant.yaml",
}, func(h *util.TempoHarness) {
h.WaitTracesWritable(t)
var info *tempoUtil.TraceInfo
tenants := strings.Split(tenant, "|")
tenantSize := len(tenants)
// write traces for all tenants
for _, tenant := range tenants {
info = tempoUtil.NewTraceInfo(time.Now(), tenant)
require.NoError(t, h.WriteTraceInfo(info, tenant))
}
// assert that we have one trace for each tenant and correct number of spans received
h.WaitTracesQueryable(t, tenantSize)
// check trace by id
apiClient := h.APIClientHTTP(tenant)
util.SearchTraceQLAndAssertTrace(t, apiClient, info)
// call search tags endpoints, ensure no errors and results are not empty
tagsV2Resp, err := apiClient.SearchTagsV2()
require.NoError(t, err)
require.Equal(t, 4, len(tagsV2Resp.GetScopes())) // resource, span, event, link, instrumentation intrinsics
for _, s := range tagsV2Resp.Scopes {
require.NotEmpty(t, s.Tags)
}
tagsValuesV2Resp, err := apiClient.SearchTagValuesV2("span.vulture-0", "{}")
require.NoError(t, err)
require.NotEmpty(t, tagsValuesV2Resp.TagValues)
grpcClient, ctx, err := h.APIClientGRPC(tenant)
require.NoError(t, err)
now := time.Now()
util.SearchStreamAndAssertTrace(t, ctx, grpcClient, info, now.Add(-time.Hour).Unix(), now.Add(time.Hour).Unix())
})
}