test: align acceptance contracts with current initialization and service clients

This commit is contained in:
2026-09-29 15:06:42 +08:00
parent 60f61d7e0a
commit 41d8387cd5
6 changed files with 32 additions and 25 deletions
+16 -18
View File
@@ -152,16 +152,17 @@ test('domestic Auth receives the overseas JWT signing configuration', async () =
]) assert.match(compose, new RegExp(`${key}: \\$\\{${key}`))
})
test('domestic event bridge SQL converges legacy tenant columns to the customer entity contract', async () => {
test('domestic event bridge initialization defines customer columns without legacy migration', async () => {
const baseline = await read('event-bridge-service/src/main/resources/db/event-bridge.sql')
const incremental = await read('deploy/sql/头程数据库统一增量-MySQL8.sql')
assert.equal((baseline.match(/customer_id VARCHAR\(128\) NOT NULL/g) || []).length, 2)
assert.equal((incremental.slice(0, incremental.indexOf('CREATE TABLE IF NOT EXISTS bridge_delivery_attempt'))
.match(/customer_id VARCHAR\(128\) NOT NULL/g) || []).length, 2)
assert.match(incremental, /ALTER TABLE bridge_inbox RENAME COLUMN tenant_id TO customer_id/)
assert.match(incremental, /ALTER TABLE bridge_outbox RENAME COLUMN tenant_id TO customer_id/)
assert.match(incremental, /bridge_inbox_customer_column = 0 AND @bridge_inbox_tenant_column = 1/)
assert.match(incremental, /bridge_outbox_customer_column = 0 AND @bridge_outbox_tenant_column = 1/)
for (const table of ['bridge_inbox', 'bridge_outbox']) {
const definition = incremental.match(new RegExp(`CREATE TABLE ${table} \\(([\\s\\S]*?)\\) ENGINE`))?.[1]
assert.ok(definition, `${table} must be defined by the empty-database baseline`)
assert.match(definition, /customer_id varchar\(128\)[^\n]*NOT NULL/i)
assert.doesNotMatch(definition, /\btenant_id\b/)
}
assert.doesNotMatch(incremental, /RENAME COLUMN tenant_id TO customer_id/)
})
test('both overseas PDF consumers explicitly connect to the existing CN Print service', async () => {
@@ -176,15 +177,12 @@ test('both overseas PDF consumers explicitly connect to the existing CN Print se
}
})
test('domestic unified SQL creates the overseas hold version before queuing its comment', async () => {
test('domestic initialization defines the overseas hold version and comment in the table', async () => {
const incremental = await read('deploy/sql/头程数据库统一增量-MySQL8.sql')
const addColumn = incremental.indexOf('CALL add_inbound_overseas_hold_version();')
const queueComment = incremental.indexOf("CALL queue_column_comment('baiyue_firstleg', 'fl_inbound_order', 'last_overseas_hold_version'")
assert.notEqual(addColumn, -1)
assert.notEqual(queueComment, -1)
assert.ok(addColumn < queueComment,
'existing databases must add last_overseas_hold_version before the strict comment queue reads it')
const definition = incremental.match(/CREATE TABLE fl_inbound_order \(([\s\S]*?)\) ENGINE/)?.[1]
assert.ok(definition)
assert.match(definition, /last_overseas_hold_version bigint unsigned DEFAULT NULL COMMENT '[^']+'/i)
assert.doesNotMatch(incremental, /CALL (?:add_inbound_overseas_hold_version|queue_column_comment)\(/)
})
test('overseas unified SQL initializes the isolated Event Bridge database before services start', async () => {
@@ -192,15 +190,15 @@ test('overseas unified SQL initializes the isolated Event Bridge database before
assert.match(overseas, /CREATE DATABASE IF NOT EXISTS baiyue_event_bridge_overseas/)
assert.match(overseas, /USE baiyue_event_bridge_overseas;/)
for (const table of ['bridge_outbox', 'bridge_inbox', 'bridge_delivery_attempt']) {
assert.match(overseas, new RegExp(`CREATE TABLE IF NOT EXISTS ${table}`))
assert.match(overseas, new RegExp(`CREATE TABLE ${table} \\(`))
}
for (const index of [
'uk_bridge_outbox_idempotency', 'idx_bridge_outbox_schedule',
'uk_bridge_inbox_idempotency', 'idx_bridge_inbox_consume',
'uk_bridge_attempt', 'idx_bridge_attempt_event'
]) assert.match(overseas, new RegExp(index))
assert.match(overseas, /COUNT\(DISTINCT CONCAT\(table_name, ':', index_name\)\)/)
assert.match(overseas, /CALL assert_overseas_event_bridge_schema\(\);/)
assert.doesNotMatch(overseas, /CREATE TABLE IF NOT EXISTS/)
assert.match(overseas, /initialization_status/)
assert.ok(overseas.indexOf('USE baiyue_event_bridge_overseas;') < overseas.indexOf('USE baiyue_lastleg;'),
'overseas Event Bridge schema must be initialized before Lastleg tables')
})