-
Notifications
You must be signed in to change notification settings - Fork 692
Tempo Serverless: Queriers Prefer Self #1307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c97a595
5795aee
f52232e
27bfbc3
f1cd602
de1fbd1
6980c41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package querier | ||
|
|
||
| import ( | ||
| "context" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/grafana/tempo/modules/ingester/client" | ||
| "github.com/grafana/tempo/pkg/tempopb" | ||
| "github.com/stretchr/testify/require" | ||
| "github.com/uber-go/atomic" | ||
| "github.com/weaveworks/common/user" | ||
| ) | ||
|
|
||
| func TestQuerierUsesSearchExternalEndpoint(t *testing.T) { | ||
| numExternalRequests := atomic.NewInt32(0) | ||
|
|
||
| srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| time.Sleep(100 * time.Millisecond) | ||
| numExternalRequests.Inc() | ||
| })) | ||
| defer srv.Close() | ||
|
|
||
| tests := []struct { | ||
| cfg Config | ||
| queriesToExecute int | ||
| externalExpected int32 | ||
| }{ | ||
| // SearchExternalEndpoints is respected | ||
| { | ||
| cfg: Config{ | ||
| SearchExternalEndpoints: []string{srv.URL}, | ||
| }, | ||
| queriesToExecute: 3, | ||
| externalExpected: 3, | ||
| }, | ||
| // No SearchExternalEndpoints causes the querier to service everything internally | ||
| { | ||
| cfg: Config{}, | ||
| queriesToExecute: 3, | ||
| externalExpected: 0, | ||
| }, | ||
| // SearchPreferSelf is respected. this test won't pass b/c SearchBlock fails instantly and so | ||
| // all 3 queries are executed locally and nothing is proxied to the external endpoint. | ||
| // we'd have to mock the storage.Store interface to get this to pass. it's a big interface. | ||
| // { | ||
| // cfg: Config{ | ||
| // SearchExternalEndpoints: []string{srv.URL}, | ||
| // SearchPreferSelf: 2, | ||
| // }, | ||
| // queriesToExecute: 3, | ||
| // externalExpected: 1, | ||
| // }, | ||
| } | ||
|
|
||
| ctx := user.InjectOrgID(context.Background(), "blerg") | ||
|
|
||
| for _, tc := range tests { | ||
| numExternalRequests.Store(0) | ||
|
|
||
| q, err := New(tc.cfg, client.Config{}, nil, nil, nil) | ||
| require.NoError(t, err) | ||
|
|
||
| for i := 0; i < tc.queriesToExecute; i++ { | ||
| // ignore error purposefully here. all queries will error, but we don't care | ||
| // numExternalRequests will tell us what we need to know | ||
| _, _ = q.SearchBlock(ctx, &tempopb.SearchBlockRequest{}) | ||
| } | ||
|
|
||
| require.Equal(t, tc.externalExpected, numExternalRequests.Load()) | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.