Skip to content

Commit bd9317e

Browse files
committed
tenantcostclient: speed up query RU estimate test
This commit speeds up the query RU estimate test in two ways: - it forces the production values for some of the metamorphic constants (this brought down the runtime from 93s to 37s for a particular seed) - it reduces the number of rows inserted from 50k to 20k which should be (further bringing down the runtime to 13s). Release note: None
1 parent c403d35 commit bd9317e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pkg/ccl/multitenantccl/tenantcostclient/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ go_test(
7777
"//pkg/sql/catalog/systemschema",
7878
"//pkg/sql/distsql",
7979
"//pkg/sql/execinfra",
80+
"//pkg/sql/sem/eval",
8081
"//pkg/sql/sqlliveness",
8182
"//pkg/sql/sqlliveness/slinstance",
8283
"//pkg/sql/stats",

pkg/ccl/multitenantccl/tenantcostclient/query_ru_estimate_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
_ "github.com/cockroachdb/cockroach/pkg/ccl/multitenantccl/tenantcostserver"
2424
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
2525
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
26+
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
2627
"github.com/cockroachdb/cockroach/pkg/sql/stats"
2728
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
2829
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
@@ -74,6 +75,13 @@ func TestEstimateQueryRUConsumption(t *testing.T) {
7475
tenant1, tenantDB1 := serverutils.StartTenant(t, s, base.TestTenantArgs{
7576
TenantID: tenantID,
7677
Settings: st,
78+
TestingKnobs: base.TestingKnobs{
79+
SQLEvalContext: &eval.TestingKnobs{
80+
// We disable the randomization of some batch sizes because with
81+
// some low values the test takes much longer.
82+
ForceProductionValues: true,
83+
},
84+
},
7785
})
7886
defer tenant1.Stopper().Stop(ctx)
7987
defer tenantDB1.Close()
@@ -87,7 +95,7 @@ func TestEstimateQueryRUConsumption(t *testing.T) {
8795
}
8896
testCases := []testCase{
8997
{ // Insert statement
90-
sql: "INSERT INTO abcd (SELECT t%2, t%3, t, -t FROM generate_series(1,50000) g(t))",
98+
sql: "INSERT INTO abcd (SELECT t%2, t%3, t, -t FROM generate_series(1,20000) g(t))",
9199
count: 1,
92100
},
93101
{ // Point query

0 commit comments

Comments
 (0)