Skip to content

Commit b6b5d28

Browse files
craig[bot]yuzefovich
andcommitted
106769: tenantcostclient: tighten query RU estimate test r=yuzefovich a=yuzefovich The query RU estimate test involves two runs of test queries: - via EXPLAIN ANALYZE to get the RU estimate - "vanilla" way and getting the precise RU usage. One of the test queries is a large INSERT, and previously we didn't delete the data after the first run. As a result, the second run would operate on 2x size of the data set. This commit fixes that oversight by including a DELETE query into the test query set which allows us to tighten the delta margin from 0.75 to 0.05 (got no failures in over 1k runs with 0.05 now). Epic: None Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
2 parents ff5f220 + 73f2374 commit b6b5d28

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pkg/ccl/multitenantccl/tenantcostclient/query_ru_estimate_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ func TestEstimateQueryRUConsumption(t *testing.T) {
130130
sql: "SELECT 'deadbeef' FROM generate_series(1, 50000)",
131131
count: 10,
132132
},
133+
{ // Delete (this also ensures that two runs work with the same dataset)
134+
sql: "DELETE FROM abcd WHERE true",
135+
count: 1,
136+
},
133137
}
134138

135139
var err error
@@ -191,12 +195,7 @@ func TestEstimateQueryRUConsumption(t *testing.T) {
191195
// Check the estimated RU aggregate for all the queries against the actual
192196
// measured RU consumption for the tenant.
193197
tenantMeasuredRUs = getTenantRUs() - tenantStartRUs
194-
// Usually, the difference is within 0.25 delta, but in rare cases it can be
195-
// outside of that delta (when ran on the gceworker, it was outside the 0.5
196-
// delta within 6 minutes of stressing), so we allow for generous 0.75
197-
// delta. This still provides a good enough sanity check for the RU
198-
// estimation.
199-
const deltaFraction = 0.75
198+
const deltaFraction = 0.05
200199
allowedDelta := tenantMeasuredRUs * deltaFraction
201200
require.InDeltaf(t, tenantMeasuredRUs, tenantEstimatedRUs, allowedDelta,
202201
"estimated RUs (%d) were not within %f RUs of the expected value (%f)",

0 commit comments

Comments
 (0)