Skip to content

Commit

Permalink
Test: make query a constant to make linter happy
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Baungard Hansen <[email protected]>
  • Loading branch information
jacobbaungard committed Oct 5, 2023
1 parent 5ab1868 commit 7c7cb4d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/e2e/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import (
"github.com/thanos-io/thanos/test/e2e/e2ethanos"
)

const testQueryA = "{a=\"1\"}"

func defaultWebConfig() string {
// username: test, secret: test(bcrypt hash)
return `
Expand Down Expand Up @@ -2416,7 +2418,7 @@ func TestQueryTenancyEnforcement(t *testing.T) {
)

// tenant-01 should only see part of the results
queryAndAssertSeries(t, ctx, querierEnforce.Endpoint("http"), func() string { return "{a=\"1\"}" },
queryAndAssertSeries(t, ctx, querierEnforce.Endpoint("http"), func() string { return testQueryA },
time.Now, promclient.QueryOptions{
Deduplicate: false,
HTTPHeaders: tenant1Header,
Expand All @@ -2430,7 +2432,7 @@ func TestQueryTenancyEnforcement(t *testing.T) {
)

// With no enforcement enabled, default tenant can see everything
queryAndAssertSeries(t, ctx, querierNoEnforce.Endpoint("http"), func() string { return "{a=\"1\"}" },
queryAndAssertSeries(t, ctx, querierNoEnforce.Endpoint("http"), func() string { return testQueryA },
time.Now, promclient.QueryOptions{
Deduplicate: false,
},
Expand All @@ -2443,15 +2445,15 @@ func TestQueryTenancyEnforcement(t *testing.T) {
)

// Default tenant don't see "a" when tenancy is enforced
queryAndAssertSeries(t, ctx, querierEnforce.Endpoint("http"), func() string { return "{a=\"1\"}" },
queryAndAssertSeries(t, ctx, querierEnforce.Endpoint("http"), func() string { return testQueryA },
time.Now, promclient.QueryOptions{
Deduplicate: false,
},
nil,
)

// tenant-2 don't see "a" when tenancy is enforced
queryAndAssertSeries(t, ctx, querierEnforce.Endpoint("http"), func() string { return "{a=\"1\"}" },
queryAndAssertSeries(t, ctx, querierEnforce.Endpoint("http"), func() string { return testQueryA },
time.Now, promclient.QueryOptions{
Deduplicate: false,
HTTPHeaders: tenant2Header,
Expand All @@ -2467,7 +2469,7 @@ func TestQueryTenancyEnforcement(t *testing.T) {
nil,
)

rangeQuery(t, ctx, querierEnforce.Endpoint("http"), func() string { return "{a=\"1\"}" }, timestamp.FromTime(now.Add(-time.Hour)), timestamp.FromTime(now.Add(time.Hour)), 3600,
rangeQuery(t, ctx, querierEnforce.Endpoint("http"), func() string { return testQueryA }, timestamp.FromTime(now.Add(-time.Hour)), timestamp.FromTime(now.Add(time.Hour)), 3600,
promclient.QueryOptions{
Deduplicate: true,
}, func(res model.Matrix) error {
Expand All @@ -2478,7 +2480,7 @@ func TestQueryTenancyEnforcement(t *testing.T) {
}
})

rangeQuery(t, ctx, querierNoEnforce.Endpoint("http"), func() string { return "{a=\"1\"}" }, timestamp.FromTime(now.Add(-time.Hour)), timestamp.FromTime(now.Add(time.Hour)), 3600,
rangeQuery(t, ctx, querierNoEnforce.Endpoint("http"), func() string { return testQueryA }, timestamp.FromTime(now.Add(-time.Hour)), timestamp.FromTime(now.Add(time.Hour)), 3600,
promclient.QueryOptions{
Deduplicate: true,
}, func(res model.Matrix) error {
Expand Down

0 comments on commit 7c7cb4d

Please sign in to comment.