Retain strict three-host native qualification, discover fresh representative inventory automatically, and recheck deployed media before promotion. Document offline-only verification and outstanding field gates. Co-authored-by: GPT-6 <gpt-6@openai.com>
53 lines
1.8 KiB
Go
53 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"errors"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestManagedRecoveryProductionTransactionHooks(t *testing.T) {
|
|
d, front, _ := recoveryFixture(t, false)
|
|
if path := os.Getenv("RC_PRIVATE_DB"); path != "" {
|
|
db, err := sql.Open("sqlite", "file:"+path+"?mode=ro")
|
|
if err != nil {
|
|
t.Fatal("private snapshot open failed")
|
|
}
|
|
defer db.Close()
|
|
ids, err := qualifiedCandidateIDs(db, "frontend")
|
|
if err != nil || len(ids) != 1 {
|
|
t.Fatal("private qualification unavailable")
|
|
}
|
|
if err := d.transaction.Apply(db, ids); err != nil {
|
|
t.Fatal("private offline apply failed")
|
|
}
|
|
d.db, front = db, ids[0]
|
|
} else {
|
|
front = managedCandidateFixture(t, d.db, "frontend", "youtube.com", "--lua-desync=fake", true)
|
|
if err := d.transaction.Apply(d.db, []int64{front}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
// Production adapters supply only the target path; recovery binds hooks.
|
|
d.transaction = &managedTransaction{Dir: d.transaction.Dir, Name: "config"}
|
|
d.service, d.adaptive = true, true
|
|
d.frontHealth = d.health
|
|
samples := 0
|
|
d.mediaSamples = func(context.Context) ([]mediaResource, error) {
|
|
samples++
|
|
return nil, &InsufficientAdaptiveSamples{}
|
|
}
|
|
d.verifyGooglevideo = func(context.Context, storedCandidate, []mediaResource) (GooglevideoQualificationProof, error) {
|
|
t.Fatal("unexpected verification")
|
|
return GooglevideoQualificationProof{}, nil
|
|
}
|
|
result, err := recoverManagedTarget(context.Background(), d)
|
|
var failure *InsufficientAdaptiveSamples
|
|
if err != nil || result.FrontendID != front || samples != 1 || !errors.As(result.GGCError, &failure) {
|
|
// Never expose private DB contents or error causes.
|
|
t.Fatalf("frontend_preserved=%t recovery_error_type=%T ggc_error_type=%T", result.FrontendID == front, err, result.GGCError)
|
|
}
|
|
}
|