Files
mesh-controller/internal/inventory/plans_leave_the_store_test.go
T

48 lines
1.8 KiB
Go

//go:build integration
package inventory
import (
"strings"
"testing"
)
// **Migration 0108 drops the tables of the delivery plans' machinery** (novox/hq ADR 0539 §17, design 47 release 6, issue 1945):
// the record of each send, the assignment generation, the gate's verdicts and the measured durations. The store is built as
// the mesh holds it before the migration, with a row in each, and after it the four are gone and what the controller still
// keeps stays: the node and its columns, the module, the bus step, the core box and the refused registrations.
func TestMigration0108DropsTheTablesOfThePlansMachineryAndKeepsWhatTheControllerStillKeeps(t *testing.T) {
inv, migrate := ForTestBefore(t, 108)
tables := func() map[string]bool {
t.Helper()
out := map[string]bool{}
for _, row := range inv.QueryForTest(t, `select table_name::text from information_schema.tables where table_schema = 'public'`) {
out[strings.Trim(row[0], `"`)] = true
}
return out
}
gone := []string{"declaration_send", "assignment_generation", "build_gate", "duration"}
before := tables()
for _, name := range gone {
if !before[name] {
t.Fatalf("the table %s is not in the store before the migration", name)
}
}
migrate()
after := tables()
for _, name := range gone {
if after[name] {
t.Errorf("the table %s is still in the store", name)
}
}
for _, stays := range []string{"node", "module", "bus_step", "core_box", "build_refused", "controller_schema"} {
if !after[stays] {
t.Errorf("the table %s is gone", stays)
}
}
// The functions and triggers the tables carried go with them.
if rows := inv.QueryForTest(t, `select count(*) from pg_proc where proname = 'raise_assignment_generation'`); rows[0][0] != "0" {
t.Errorf("the function raise_assignment_generation is still in the store")
}
}