feat(storage): add native MySQL namespace and identity pilots
Add resumable checked migrations and explicit schema administration commands. Port ML budgets, namespaces, identity and group persistence with three-backend contracts. Keep MySQL unavailable as the full application backend.
This commit is contained in:
1 parent
0c7897d695
commit
6a67fd9afe
40 files changed
+3087
-94
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package db
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestMySQLMigrationPlanValidation(t *testing.T) {
|
||||
valid := func() MySQLMigration {
|
||||
return MySQLMigration{Version: 1, Name: "initial", Operations: []MySQLOperation{{SQL: "CREATE TABLE example(id BIGINT)", Check: "SELECT 0", ReplaySafe: true}}, Assertions: []string{"SELECT 1"}}
|
||||
}
|
||||
if e := validateMySQLPlan("machine-learning", []MySQLMigration{valid()}); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
for _, component := range []string{"", "../schema", "has space", "MixedCase"} {
|
||||
if e := validateMySQLPlan(component, []MySQLMigration{valid()}); e == nil {
|
||||
t.Fatal("invalid component accepted", component)
|
||||
}
|
||||
}
|
||||
for _, mutate := range []func(*MySQLMigration){
|
||||
func(m *MySQLMigration) { m.Version = 2 },
|
||||
func(m *MySQLMigration) { m.Name = "" },
|
||||
func(m *MySQLMigration) { m.Operations = nil },
|
||||
func(m *MySQLMigration) { m.Operations[0].SQL = " " },
|
||||
func(m *MySQLMigration) { m.Operations[0].Check = " " },
|
||||
func(m *MySQLMigration) { m.Assertions = nil },
|
||||
func(m *MySQLMigration) { m.Assertions[0] = " " },
|
||||
} {
|
||||
m := valid()
|
||||
mutate(&m)
|
||||
if e := validateMySQLPlan("test", []MySQLMigration{m}); e == nil {
|
||||
t.Fatal("invalid plan accepted", m)
|
||||
}
|
||||
}
|
||||
before := valid()
|
||||
after := valid()
|
||||
after.Operations[0].ReplaySafe = false
|
||||
if mysqlMigrationHash(before) == mysqlMigrationHash(after) {
|
||||
t.Fatal("replay policy not covered by checksum")
|
||||
}
|
||||
if mysqlMigrationHash(before) != mysqlMigrationHash(valid()) {
|
||||
t.Fatal("unstable checksum")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user