mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-21 11:46:37 +00:00
09d23ae7dd
mariadbd has no time_zone startup option — the name only exists for SET — so the resolved parameter group aborted the server while it parsed defaults, before it opened the datadir. No pidfile was ever written and the reconciler failed every instance at the 20-minute engine-health deadline. ParameterSpec gains an option-file spelling, used only when rendering the include. time_zone is the one setting that needs it, as default_time_zone, which resolves @@global.time_zone to the same value. The customer-facing name is unchanged: the API still reports time_zone and a live apply still issues SET GLOBAL time_zone. Names read back out of a generated file return to the catalog's namespace first, so a startup spelling cannot read as an unknown name and report a pending restart nothing could clear. setup.sh now feeds the catalog's resolved defaults to the image's own mariadbd at build time, so a name the server refuses fails the build rather than every instance built from it.
70 lines
2.4 KiB
Go
70 lines
2.4 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
handlers_rds "github.com/mulgadc/spinifex/spinifex/handlers/rds"
|
|
)
|
|
|
|
// The include the image build validates against a real mariadbd. It is checked
|
|
// in rather than generated during the build because the build runs inside the
|
|
// libguestfs appliance, where there is no Go toolchain to resolve the catalog.
|
|
const mariadbDefaultParametersFixture = "../../scripts/images/rds-mariadb/default-parameters.cnf"
|
|
|
|
// Byte-for-byte what rds-init installs on a smallest-class instance that
|
|
// overrides nothing. Regenerate with RDS_UPDATE_FIXTURES=1 go test ./cmd/rds-agent/.
|
|
//
|
|
// Keeping it in step matters because setup.sh feeds exactly this file to
|
|
// mariadbd: a catalog that grew a name the server refuses at startup would
|
|
// otherwise reach a customer as an instance that never boots.
|
|
func TestMariaDBDefaultParametersFixture_MatchesTheCatalog(t *testing.T) {
|
|
engine, err := handlers_rds.LookupEngine("mariadb")
|
|
if err != nil {
|
|
t.Fatalf("LookupEngine: %v", err)
|
|
}
|
|
class := handlers_rds.SmallestInstanceClass()
|
|
params, err := engine.ResolveEffectiveParameters(class, nil)
|
|
if err != nil {
|
|
t.Fatalf("ResolveEffectiveParameters(%s): %v", class, err)
|
|
}
|
|
body, err := renderParameters("mariadb", params)
|
|
if err != nil {
|
|
t.Fatalf("renderParameters: %v", err)
|
|
}
|
|
want := mariadbParametersHeader + body
|
|
|
|
path := filepath.FromSlash(mariadbDefaultParametersFixture)
|
|
if os.Getenv("RDS_UPDATE_FIXTURES") == "1" {
|
|
if err := os.WriteFile(path, []byte(want), 0o644); err != nil {
|
|
t.Fatalf("update %s: %v", path, err)
|
|
}
|
|
return
|
|
}
|
|
|
|
got, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Fatalf("read %s: %v", path, err)
|
|
}
|
|
if string(got) != want {
|
|
t.Errorf("%s is stale for class %s.\nRegenerate with RDS_UPDATE_FIXTURES=1 go test ./cmd/rds-agent/\n\ngot:\n%s\nwant:\n%s",
|
|
path, class, got, want)
|
|
}
|
|
}
|
|
|
|
// The one thing the fixture exists to prove cannot regress without the image
|
|
// build catching it, asserted here too so a plain preflight names it.
|
|
func TestMariaDBDefaultParametersFixture_CarriesNoSetOnlyName(t *testing.T) {
|
|
got, err := os.ReadFile(filepath.FromSlash(mariadbDefaultParametersFixture))
|
|
if err != nil {
|
|
t.Fatalf("read the fixture: %v", err)
|
|
}
|
|
for _, name := range []string{"\ntime_zone ", "\ntx_isolation ", "\ninnodb_buffer_pool_instances "} {
|
|
if strings.Contains(string(got), name) {
|
|
t.Errorf("the default include carries %q, which mariadbd refuses at startup", name)
|
|
}
|
|
}
|
|
}
|