Repository navigation
feat(sqle): support GaussDB TopSQL scan task and normalize db_type alias (#2877) - #3319
Closed
actiontech-bot wants to merge 4 commits into
Closed
actiontech-bot wants to merge 4 commits into
actiontech-bot wants to merge 4 commits into
Conversation
DMS 后端枚举 DBTypeGaussDB = "GaussDB / openGauss"(dms / dms-ee 双仓库同步), SQLE 后端 InstanceTypeGaussDB / DriverTypeGaussDB = "GaussDB",且 sqle-gaussdb-plugin 注册的 driver name 也是 "GaussDB"。三处契约要求 byte-by-byte 相等,但 DMS 透传 到 SQLE 的 inst.DbType 字面值带有空格和斜杠,导致 sqle pluginManager.OpenPlugin 按 inst.DbType 找不到 plugin,sqled.log 报 "plugin not found",UI 上 GaussDB 实例的连通性测试卡死。 实现:在 sqle/dms/instance.go 写入 model.Instance.DbType 之前增加单点规范化映射 parseInstanceDBType,把 "GaussDB / openGauss" 映射为 driverV2.DriverTypeGaussDB; 其它 DBType 字面值原样透传,行为无回归。映射条目集中放在 dmsDBTypeAliasMap, 后续新增规范化条目只需在此一个 map 添加,便于回滚和审计。 新增单测 sqle/dms/instance_test.go::Test_parseInstanceDBType 覆盖 5 条契约: - GaussDB / openGauss 别名命中 - MySQL / PostgreSQL / TiDB 原样透传 - 空串 no-panic 返回空 不动 vendor / go.mod / go.sum / CE 仓库,build tag 维持 dummyhead,enterprise。
补完上一次 commit 遗漏的入口:之前只在 sqle/dms/instance.go::convertInstance
(DMS 列表导入到 SQLE Instance 的路径)做了规范化,但 HTTP 直入口
POST /v1/projects/.../instances/connection_check / DMS 转发的连通性测试
直接构造 model.Instance{DbType: req.DBType} 走 common.NewDriverManagerWithoutAudit,
未经过任何规范化,依旧把 "GaussDB / openGauss" 透传到 OpenPlugin,命中
ErrPluginNotFound,sqled.log 仍报 "check instance is connectable failed:
open plugin: plugin not found",UI 上"测试数据源连通性"按钮报错。
实现:
- 把 sqle/dms/instance.go::parseInstanceDBType 改名为导出函数 ParseInstanceDBType,
让 common 包可以引用同一份规范化逻辑。
- sqle/common/driver.go 的 NewDriverManagerWithoutAudit / NewDriverManagerWithoutCfg
在调用 driver.GetPluginManager().OpenPlugin 之前显式调用 dms.ParseInstanceDBType
做一次兜底规范化;未命中映射条目的 DBType 原样透传,行为无回归。
- sqle/dms/instance_test.go 一同把测试函数名从 Test_parseInstanceDBType
改为 Test_ParseInstanceDBType,覆盖契约不变。
完成后 UI 上 opengauss_baseline 数据源的"测试数据源连通性"按钮返回
"数据源连通性测试成功",sqled.log 不再产生新的 plugin not found 警告。
不动 vendor / go.mod / go.sum / CE 仓库 / DMS / dms-ui-ee。
修复 sqle-ee #2877 Batch 1 复测发现的 bug-B: DMS 创建数据源时 SQLEConfig.RuleTemplateID 默认空字符串(未配规则模板), sqle-ee/sqle/dms/instance.go::convertInstance 直接调用 strconv.ParseInt("", 0, 64) 会抛错,使 getInstance / GetInstance 把这台 数据源整体当作 not exist;上层 controller 对外返回 4011 instance is not exist。 修复:在 ParseInt 之前判空字符串,空字符串映射为 0;非空值保留原 ParseInt 行为,非法数字字符串仍报错。新增 3 个单测覆盖三类输入: - TestConvertInstance_EmptyRuleTemplateID → 期望成功,RuleTemplateId=0,DbType 走 ParseInstanceDBType - TestConvertInstance_NonEmptyRuleTemplateID → 期望成功,按数字解析 - TestConvertInstance_InvalidRuleTemplateID → 期望 ParseInt 报错 Refs #2877
新增 ApMetaGaussDBTopSQL i18n 文案,用于 EE 的 GaussDB TopSQL 扫描任务 meta description。 key:value 三处保持一致: - sqle/locale/active.en.toml: ApMetaGaussDBTopSQL = "GaussDB TOP SQL" - sqle/locale/active.zh.toml: ApMetaGaussDBTopSQL = "GaussDB TOP SQL" - sqle/locale/message_zh.go: ApMetaGaussDBTopSQL i18n.Message 文案排版与 ApMetaGaussDBProcesslist / ApMetaGaussDBSlowLog 邻位 保持一致,避免 EE 注册 GaussDBTopSQLTaskV2 时引用未定义 key。 Refs #2877
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GaussDB 数据源支持 TopSQL 扫描任务(CE 部分):
ApMetaGaussDBTopSQL(en/zh/Go),供 EE 注册GaussDBTopSQLTaskV2时使用sqle/dms/instance.go:新增ParseInstanceDBType导出函数 +dmsDBTypeAliasMap,把 DMS 透传的"GaussDB / openGauss"归一为 SQLE 内部主形态"GaussDB"sqle/common/driver.go:在NewDriverManagerWithoutAudit/NewDriverManagerWithoutCfg入口显式调用dms.ParseInstanceDBType,覆盖 connection_check 等 HTTP 直入口sqle/dms/instance.go::convertInstance:兜底空RuleTemplateID(DMS 默认空串),避免strconv.ParseInt("")把整台数据源识别为 4011 not exist关联 issue: actiontech/sqle-ee#2877
Test plan
go vet ./sqle/dms/... ./sqle/common/... ./sqle/locale/...全包通过go test ./sqle/dms/...全包通过,覆盖:Test_ParseInstanceDBType(5 条契约:GaussDB / openGauss alias 命中、MySQL / PostgreSQL / TiDB 透传、空串无 panic)TestConvertInstance_EmptyRuleTemplateID/_NonEmpty/_Invalid_ee后缀文件,符合 CE/EE 拆分规范