Skip to content

Commit 4b2feaf

Browse files
morningmanclaude
andcommitted
[fix](test) make test_temp_table replica detection robust (build #198126)
test_temp_table asserted `3 * replicaNum == show_tablets_result.size()`, deriving replicaNum by regex-parsing force_olap_table_replication_allocation with `/:(\d+)/`. That detection is wrong on clusters that force replication=3: the canonical allocation string `tag.location.default: 3` has a space after the colon so the regex never matches (replicaNum stuck at 1), and the separate force_olap_table_replication_num config is never consulted. On the 3-replica TeamCity cluster SHOW TABLETS returned 9 rows (3 tablets x 3 replicas) while the test expected 3. Keep verifying the real replica count (so a wrong/missing replica is still caught) but fix the detection: - assert there are exactly 3 distinct tablets (3 partitions x 1 bucket), and - assert total rows == 3 * replicaNum, where replicaNum is derived robustly and mirrors FE precedence (PropertyAnalyzer.analyzeReplicaAllocation): the force_olap_table_replication_allocation per-tag counts are summed first with a whitespace-tolerant regex `/:\s*(\d+)/`, falling back to force_olap_table_replication_num. Same defect exists on apache/master; forward-port there too. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent 45fb438 commit 4b2feaf

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

‎regression-test/suites/temp_table_p0/test_temp_table.groovy‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,31 @@ suite('test_temp_table', 'p0') {
274274

275275
def show_tablets_result = sql "show tablets from t_test_temp_table1"
276276
// t_test_temp_table1 has 3 partitions x 1 bucket = 3 tablets. SHOW TABLETS returns one row
277-
// per replica, so the row count depends on the cluster's force_olap_table_replication_allocation.
278-
def forceReplicaAlloc = getFeConfig('force_olap_table_replication_allocation')
277+
// per replica, so the total row count = 3 tablets x the cluster's effective replica count.
278+
// Assert both: there are exactly 3 tablets, AND the per-tablet replica count matches the
279+
// cluster's forced replication (so a wrong/missing replica is still caught).
280+
assertEquals(3, show_tablets_result.collect { it[0] }.unique().size())
281+
// Derive the expected replica count robustly. Mirror FE precedence
282+
// (PropertyAnalyzer.analyzeReplicaAllocation): force_olap_table_replication_allocation is the
283+
// primary force path, so check it first (summing the per-tag counts), then fall back to
284+
// force_olap_table_replication_num. The allocation regex is whitespace-tolerant because the
285+
// canonical value is "tag.location.default: 3" (a space after the colon), which the old
286+
// /:(\d+)/ silently missed -> replicaNum stuck at 1.
279287
def replicaNum = 1
288+
def forceReplicaAlloc = getFeConfig('force_olap_table_replication_allocation')
280289
if (forceReplicaAlloc != null && !forceReplicaAlloc.isEmpty()) {
281-
def m = (forceReplicaAlloc =~ /:(\d+)/)
282-
if (m.find()) {
283-
replicaNum = m.group(1).toInteger()
290+
def total = 0
291+
def m = (forceReplicaAlloc =~ /:\s*(\d+)/)
292+
while (m.find()) {
293+
total += m.group(1).toInteger()
294+
}
295+
if (total > 0) {
296+
replicaNum = total
297+
}
298+
} else {
299+
def forceReplicaNum = getFeConfig('force_olap_table_replication_num')
300+
if (forceReplicaNum != null && forceReplicaNum.isInteger() && (forceReplicaNum as int) > 0) {
301+
replicaNum = forceReplicaNum as int
284302
}
285303
}
286304
assertEquals(3 * replicaNum, show_tablets_result.size())

0 commit comments

Comments
 (0)