carlos / platform Public

test: align departure proof fixture scope before startup

Construct the backend, identity and proof-store expectation with the same bucket. Wait for consumer startup in the successor fixture so initialization checks run deterministically instead of depending on shutdown timing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 48f8a230bbdaa265fac98b4c01c94ce4030bc7f6 parent 61f1a4c
2 files changed, +13 −4
  • internal/host/hadepartures_fix_test.go +7 −2
  • internal/host/hadepartures_wiring_test.go +6 −2
diff --git a/internal/host/hadepartures_fix_test.go b/internal/host/hadepartures_fix_test.go
index 5e2de87a8..dd7d92ada 100644
--- a/internal/host/hadepartures_fix_test.go
+++ b/internal/host/hadepartures_fix_test.go
@@ -395,11 +395,10 @@ func TestDepartureAckDoesNotBlockRecord(t *testing.T) {
func installScanSuccessorValidator(t *testing.T, x *scanRig, boxes ...hadeparture.Box) {
t.Helper()
- a, _, _ := departureArmFixture(t)
+ a, _, _ := departureArmFixtureBucket(t, x.d.Box.Scope.DataBucket)
signer := boxidtest.NewSigner(t)
a.Registry = x.r
a.Self = x.c.cfg.Self
- a.Backend.Cfg.Bucket = x.d.Box.Scope.DataBucket
a.Verifier = boxid.Verifier{Account: x.d.Box.Account, Certs: signer.Certs()}
a.OpenStore = x.c.cfg.OpenStore
fixed := map[string]string{}
@@ -422,6 +421,12 @@ func installScanSuccessorValidator(t *testing.T, x *scanRig, boxes ...hadepartur
if e != nil {
t.Fatal(e)
}
+ select {
+ case <-life.Started():
+ case <-time.After(5 * time.Second):
+ _ = life.Stop(context.Background())
+ t.Fatal("successor fixture did not start")
+ }
if e = life.Stop(context.Background()); e != nil {
t.Fatal(e)
}
diff --git a/internal/host/hadepartures_wiring_test.go b/internal/host/hadepartures_wiring_test.go
index 2ed9e2ce2..6216a6080 100644
--- a/internal/host/hadepartures_wiring_test.go
+++ b/internal/host/hadepartures_wiring_test.go
@@ -62,6 +62,10 @@ func (p *departureProofStore) PutObject(_ context.Context, in *s3.PutObjectInput
return &s3.PutObjectOutput{}, nil
}
func departureArmFixture(t *testing.T) (departureArm, *departureProofStore, *int) {
+ t.Helper()
+ return departureArmFixtureBucket(t, "regional-data")
+}
+func departureArmFixtureBucket(t *testing.T, bucket string) (departureArm, *departureProofStore, *int) {
t.Helper()
reg, err := registry.Open(filepath.Join(t.TempDir(), "registry.db"))
if err != nil {
@@ -76,7 +80,7 @@ func departureArmFixture(t *testing.T) (departureArm, *departureProofStore, *int
}
proof := &departureProofStore{}
describes := 0
- self := hadeparture.Box{Ref: "self", InstanceID: "i-0123456789abcdef0", Account: "111122223333", Scope: hadeparture.Scope{CloudRegion: "eu-west-1", DataBucket: "regional-data", SecretsKeyFP: "fp"}}
+ self := hadeparture.Box{Ref: "self", InstanceID: "i-0123456789abcdef0", Account: "111122223333", Scope: hadeparture.Scope{CloudRegion: "eu-west-1", DataBucket: bucket, SecretsKeyFP: "fp"}}
confirmer := &termfence.Confirmer{Self: func() boxid.Cloud { return departureCloud(self) }, Logf: func(string, ...any) {}, API: func(context.Context, string) (termfence.EC2, error) {
return describeInstances(func(_ context.Context, in *ec2.DescribeInstancesInput, _ ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) {
describes++
@@ -84,7 +88,7 @@ func departureArmFixture(t *testing.T) (departureArm, *departureProofStore, *int
}), nil
}}
env := map[string]string{"CARLOS_REGION_HA": "true", "CARLOS_DEPLOYMENT_BUCKET": "deployment-in-us-east-1", departureBindingsEnv: `{"dead":"i-1123456789abcdef0"}`}
- cfg := activator.Config{Bucket: "regional-data", Region: "eu-west-1", Prefix: "instances"}
+ cfg := activator.Config{Bucket: bucket, Region: "eu-west-1", Prefix: "instances"}
return departureArm{Getenv: func(k string) string { return env[k] }, Registry: reg, Service: &activator.Service{}, Backend: &activator.ExecBackend{Cfg: cfg}, Confirmer: confirmer, Inventory: &provision.DepartureInventory{}, OpenStore: func(context.Context) (release.Store, error) { return store, nil }, MakeQueue: func(context.Context) (hadeparture.Queue, error) { return &departureEmptyQueue{}, nil }, ProofStore: func(_ context.Context, b, r string) (termfence.ProofStore, error) {
if b != cfg.Bucket || r != cfg.Region {
t.Errorf("proof scope %s %s", b, r)