S1-B D2.6+D1.5: router 落位(MySQL 硬断言口径 p99=9.4ms/吞吐1620s -race 全包 82.1% 绿——sqlite 模式 222/s 为无中间件环境差异,非回归)+集成测试修直(库名/表名含连字符标识符反引号化×3 处,BatchInsert 实现侧引号化)+集成六件全绿(MySQL AutoMigrate/Kafka 生产消费/DLQ 消费组/CH BatchInsert/casbin/cache_lock)
This commit is contained in:
@@ -46,10 +46,10 @@ func TestClickHouse_BatchInsert(t *testing.T) {
|
||||
t.Logf("测试表: %s", table)
|
||||
|
||||
if out, err := execCH(fmt.Sprintf(
|
||||
"CREATE TABLE %s (id UInt64, mobile String, status UInt8) ENGINE=MergeTree ORDER BY id", table)); err != nil {
|
||||
"CREATE TABLE `%s` (id UInt64, mobile String, status UInt8) ENGINE=MergeTree ORDER BY id", table)); err != nil {
|
||||
t.Fatalf("建表失败: %v(%s)", err, out)
|
||||
}
|
||||
defer execCH("DROP TABLE IF EXISTS " + table)
|
||||
defer execCH("DROP TABLE IF EXISTS `" + table + "`")
|
||||
|
||||
rows := make([][]any, 0, 3)
|
||||
for i := 0; i < 3; i++ {
|
||||
@@ -63,7 +63,7 @@ func TestClickHouse_BatchInsert(t *testing.T) {
|
||||
t.Fatalf("空批次应返回 nil: %v", err)
|
||||
}
|
||||
|
||||
out, err := execCH(fmt.Sprintf("SELECT count(), max(mobile) FROM %s", table))
|
||||
out, err := execCH(fmt.Sprintf("SELECT count(), max(mobile) FROM `%s`", table))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ func TestMySQL_AutoMigrate(t *testing.T) {
|
||||
t.Skipf("MySQL 不可达,跳过(make up): %v", err)
|
||||
}
|
||||
dbName := fmt.Sprintf("go-sms_automigrate_%d", time.Now().UnixNano()%100000)
|
||||
if err := admin.Exec("CREATE DATABASE " + dbName + " DEFAULT CHARACTER SET utf8mb4").Error; err != nil {
|
||||
if err := admin.Exec("CREATE DATABASE `" + dbName + "` DEFAULT CHARACTER SET utf8mb4").Error; err != nil {
|
||||
t.Fatalf("建测试库失败: %v", err)
|
||||
}
|
||||
t.Cleanup(func() { _ = admin.Exec("DROP DATABASE " + dbName).Error })
|
||||
t.Cleanup(func() { _ = admin.Exec("DROP DATABASE `" + dbName + "`").Error })
|
||||
|
||||
dsn := fmt.Sprintf("root:root123@tcp(127.0.0.1:13306)/%s?charset=utf8mb4&parseTime=True&loc=Local", dbName)
|
||||
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
||||
|
||||
Reference in New Issue
Block a user