90a2530689
gates / gates (push) Successful in 48s
Found live on 9202: every MariaDB 11+ import timed out (mysqladmin/mysql absent). Red-proved.
48 lines
2.5 KiB
Go
48 lines
2.5 KiB
Go
package appexport
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"log"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/appbackup"
|
|
)
|
|
|
|
// R-1187, found live on 9202 2026-10-26 night: the `.fab` import waited with `mysqladmin` and loaded with `mysql` — names
|
|
// the MariaDB 11+ images do not ship (only mariadb-admin / mariadb; measured in mariadb:11.4) — and read the password
|
|
// from the app's env under two fixed names (grimmory's is DB_ROOT_PASSWORD). Every import of a MariaDB 11+ app timed
|
|
// out and left the app down. The import now uses the BACKUP side's discovery (the live container's own credentials)
|
|
// and appbackup.ImportDump (mariadb / mariadb-admin, psql ON_ERROR_STOP + --single-transaction). The seams keep this
|
|
// test off the real Docker (R-650). RED-PROOF: the old body (its own waitForDB + importDBDump) never reaches the seams.
|
|
func TestR1187_TheImportLoadsTheDumpThroughTheBackupSide(t *testing.T) {
|
|
oldD, oldI := discoverDBsFn, importDumpFn
|
|
defer func() { discoverDBsFn, importDumpFn = oldD, oldI }()
|
|
discoverDBsFn = func(ctx context.Context, l *log.Logger, debug bool, known []string) ([]appbackup.DiscoveredDB, error) {
|
|
return []appbackup.DiscoveredDB{
|
|
{ContainerName: "paperless-postgres", ContainerID: "1b47ee5f58d2", DBType: appbackup.DBTypePostgres, StackName: "paperless-ngx"},
|
|
{ContainerName: "grimmory-db", ContainerID: "2310c379bd74", DBType: appbackup.DBTypeMariaDB, DBName: "grimmory", StackName: "grimmory"},
|
|
}, nil
|
|
}
|
|
var got appbackup.DiscoveredDB
|
|
var gotPath string
|
|
importDumpFn = func(ctx context.Context, db appbackup.DiscoveredDB, dumpPath string, l *log.Logger, debug bool) error {
|
|
got, gotPath = db, dumpPath
|
|
return nil
|
|
}
|
|
e := NewExporter(&rtProvider{}, log.New(io.Discard, "", 0), "test")
|
|
err := e.importIntoContainer("grimmory", "2310c379bd742a9bbb3a78ceb60d1872edb2dfe0ddc15b134edb9142b048e558", "mariadb", "/tmp/x/grimmory-mariadb.sql.gz", nil)
|
|
if err != nil {
|
|
t.Fatalf("import: %v", err)
|
|
}
|
|
if got.ContainerName != "grimmory-db" || gotPath != "/tmp/x/grimmory-mariadb.sql.gz" {
|
|
t.Fatalf("the dump did not go through the backup side's ImportDump for the started container: %+v %q", got, gotPath)
|
|
}
|
|
// A container the backup side cannot see is a clear refusal, never a guess.
|
|
err = e.importIntoContainer("grimmory", "ffffffffffff", "mariadb", "/tmp/x/d.sql.gz", nil)
|
|
if err == nil || !strings.Contains(err.Error(), "ffffffffffff") {
|
|
t.Fatalf("an undiscovered container must be refused naming it, got %v", err)
|
|
}
|
|
}
|