From dce44f2a20c2cfb15fd472e0ddee282cf516c774 Mon Sep 17 00:00:00 2001 From: Buqian Zheng Date: Mon, 29 Dec 2025 09:51:21 +0800 Subject: [PATCH] test: reduce test time for TestSparsePlaceholderGroupSize (#46637) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit issue: #44452 ## Summary Reduce test combinations in `TestSparsePlaceholderGroupSize` to decrease test execution time: - `nqs`: from `[1, 10, 100, 1000, 10000]` to `[1, 100, 10000]` - `averageNNZs`: from `[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]` to `[1, 4, 16, 64, 256, 1024]` ## TestSparsePlaceholderGroupSize Test Reduction **Core Invariant:** The sparse vector NNZ estimation algorithm (`EstimateSparseVectorNNZFromPlaceholderGroup`) must maintain accuracy within bounded error thresholds—individual cases < 10% error and no more than 2% of cases exceeding 5% error—across representative parameter ranges. **Test Coverage Optimized, Not Removed:** Test combinations reduced from 60 to 18 by pruning redundant parameter points while retaining critical coverage: nqs now tests [1, 100, 10000] (min, mid, max) and averageNNZs tests [1, 4, 16, 64, 256, 1024] (exponential spacing). Variant generation logic (powers of 2 scaling) remains unchanged, ensuring error scenarios are still exercised. **No Behavioral Regression:** The algorithm under test is untouched; only test case frequency decreases. The same assertions validate error bounds are satisfied—individual assertions (`assert.Less(errorRatio, 10.0)`) and statistical assertions (`assert.Less(largeErrorRatio, 2.0)`) remain identical, confirming that estimation quality is still verified. **Why Safe:** Exponential spacing of removed parameters (e.g., nqs: 10, 1000 removed; averageNNZs: 2, 8, 32, 128, 512, 2048 removed) addresses diminishing returns—intermediate values provide no new error scenarios beyond what surrounding powers-of-2 values expose, while keeping test execution time proportional to coverage value gained. Signed-off-by: Buqian Zheng --- pkg/util/typeutil/schema_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/util/typeutil/schema_test.go b/pkg/util/typeutil/schema_test.go index f9de5f2430..628bc91de0 100644 --- a/pkg/util/typeutil/schema_test.go +++ b/pkg/util/typeutil/schema_test.go @@ -2926,8 +2926,8 @@ func TestParseJsonSparseFloatRowBytes(t *testing.T) { // with various nq and averageNNZ, test if the estimated number of non-zero // elements is close to the actual number. func TestSparsePlaceholderGroupSize(t *testing.T) { - nqs := []int{1, 10, 100, 1000, 10000} - averageNNZs := []int{1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048} + nqs := []int{1, 100, 10000} + averageNNZs := []int{1, 4, 16, 64, 256, 1024} numCases := 0 casesWithLargeError := 0 for _, nq := range nqs {