修正执行租约迁移故障注入并记录三库复审证据
This commit is contained in:
1 parent
eab5ba9a84
commit
37765ff2f0
7 files changed
+40
-3
No files matched your search
@@ -4,7 +4,7 @@ import "testing"
|
||||
|
||||
func TestMySQLDNSExecutionInterruptedMigration(t *testing.T) {
|
||||
f := startRealMySQL(t)
|
||||
for _, boundary := range []string{"before-create", "after-create", "with-record", "bad-column", "bad-index", "bad-collation"} {
|
||||
for _, boundary := range []string{"before-create", "after-create", "with-record", "bad-column", "bad-index", "bad-collation", "bad-column-collation"} {
|
||||
t.Run(boundary, func(t *testing.T) {
|
||||
db := f.database(t)
|
||||
mysqlPrepareVersion(t, db.DB, 28)
|
||||
@@ -18,8 +18,26 @@ func TestMySQLDNSExecutionInterruptedMigration(t *testing.T) {
|
||||
mysqlDeploymentExec(t, db.DB, "ALTER TABLE dns_execution_leases MODIFY COLUMN account_revision INT NULL")
|
||||
case "bad-index":
|
||||
mysqlDeploymentExec(t, db.DB, "ALTER TABLE dns_execution_leases DROP INDEX uq_dns_leases_attempt")
|
||||
case "bad-collation":
|
||||
mysqlDeploymentExec(t, db.DB, "ALTER TABLE dns_execution_leases CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci")
|
||||
case "bad-collation", "bad-column-collation":
|
||||
var before, after string
|
||||
query := `SELECT table_collation FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'dns_execution_leases'`
|
||||
if err := db.DB.QueryRowContext(t.Context(), query).Scan(&before); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// 必须真正改变排序规则,不能把测试库默认值当作故障注入。
|
||||
collation := "utf8mb4_bin"
|
||||
if before == collation {
|
||||
collation = "utf8mb4_unicode_ci"
|
||||
}
|
||||
statement := "ALTER TABLE dns_execution_leases CONVERT TO CHARACTER SET utf8mb4 COLLATE " + collation
|
||||
if boundary == "bad-column-collation" {
|
||||
statement = "ALTER TABLE dns_execution_leases MODIFY COLUMN task_id VARCHAR(64) CHARACTER SET utf8mb4 COLLATE " + collation + " NOT NULL"
|
||||
query = `SELECT collation_name FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dns_execution_leases' AND column_name = 'task_id'`
|
||||
}
|
||||
mysqlDeploymentExec(t, db.DB, statement)
|
||||
if err := db.DB.QueryRowContext(t.Context(), query).Scan(&after); err != nil || before == after {
|
||||
t.Fatal("排序规则故障注入未实际生效", err)
|
||||
}
|
||||
default:
|
||||
conflict = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user