未验证 提交 08ca16c6 编写于 作者: K Keima 提交者: GitHub

新增配置项用于控制是否允许测试数据库版本小于线上数据库 (#297)

新增配置项用于控制是否允许测试数据库版本小于线上数据库

Log: 新增配置项用于控制是否允许测试数据库版本小于线上数据库
上级 80439cfa
......@@ -54,6 +54,7 @@ type Configuration struct {
OnlineDSN *Dsn `yaml:"online-dsn"` // 线上环境数据库配置
TestDSN *Dsn `yaml:"test-dsn"` // 测试环境数据库配置
AllowOnlineAsTest bool `yaml:"allow-online-as-test"` // 允许 Online 环境也可以当作 Test 环境
DisableVersionCheck bool `yaml:"disable-version-check"` // 是否禁用环境检测,开启后表示允许测试环境版本低于线上环境 不建议开启,可能会导致语句执行异常
DropTestTemporary bool `yaml:"drop-test-temporary"` // 是否清理Test环境产生的临时库表
CleanupTestDatabase bool `yaml:"cleanup-test-database"` // 清理残余的测试数据库(程序异常退出或未开启drop-test-temporary) issue #48
OnlySyntaxCheck bool `yaml:"only-syntax-check"` // 只做语法检查不输出优化建议
......
......@@ -23,6 +23,8 @@ test-dsn:
disable: false
# 是否允许测试环境与线上环境配置相同
allow-online-as-test: true
# 是否禁用环境检测,开启后表示允许测试环境版本低于线上环境 不建议开启,可能会导致语句执行异常
disable-version-check: false
# 是否清理测试时产生的临时文件
drop-test-temporary: true
# 语法检查小工具
......
......@@ -99,10 +99,13 @@ func BuildEnv() (*VirtualEnv, *database.Connector) {
common.Config.OnlineDSN.Disable = true
}
// 判断测试环境与线上环境版本是否一致,要求测试环境版本不低于线上环境
if vEnvVersion < rEnvVersion {
common.Log.Warning("TestDSN MySQL version older than OnlineDSN(%d), TestDSN(%d) will not be used", rEnvVersion, vEnvVersion)
common.Config.TestDSN.Disable = true
// 是否禁用版本检测,禁用后,不再对比测试环境和线上环境的版本大小
if !common.Config.DisableVersionCheck {
// 判断测试环境与线上环境版本是否一致,要求测试环境版本不低于线上环境
if vEnvVersion < rEnvVersion {
common.Log.Warning("TestDSN MySQL version older than OnlineDSN(%d), TestDSN(%d) will not be used", rEnvVersion, vEnvVersion)
common.Config.TestDSN.Disable = true
}
}
return vEnv, connOnline
......
......@@ -15,6 +15,7 @@ test-dsn:
# 高危,仅测试时使用,线上环境禁止配置为 true
allow-online-as-test: true
disable-version-check: false
column-not-allow-type:
- json
- text
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册