@@ -50,6 +50,18 @@ func object(t *testing.T, objects []map[string]any, kind, name string) map[strin
5050// TestCutoverPreservesOldStorageAndUsesRetainedReplacement fences the storage handoff.
5151func TestCutoverPreservesOldStorageAndUsesRetainedReplacement (t * testing.T ) {
5252 production := render (t , "k8s/providers/hetzner/infrastructure" )
53+ prepared := object (t , production , "PersistentVolumeClaim" , "vault-snapshots-recovery-v2" )
54+ preparedMetadata := prepared ["metadata" ].(map [string ]any )
55+ preparedSpec := prepared ["spec" ].(map [string ]any )
56+ if preparedMetadata ["namespace" ] != "openbao" || preparedMetadata ["annotations" ].(map [string ]any )["kustomize.toolkit.fluxcd.io/prune" ] != "disabled" ||
57+ preparedMetadata ["labels" ].(map [string ]any )["platform.devantler.tech/storage-stage" ] != "prepared" ||
58+ preparedSpec ["storageClassName" ] != "longhorn-v2" || preparedSpec ["volumeName" ] != nil ||
59+ preparedSpec ["volumeMode" ] != "Filesystem" || preparedSpec ["resources" ].(map [string ]any )["requests" ].(map [string ]any )["storage" ] != "10Gi" {
60+ t .Fatal ("the new claim must remain an unbound and retained V2 staging claim with the original capacity" )
61+ }
62+ if modes := preparedSpec ["accessModes" ].([]any ); len (modes ) != 1 || modes [0 ] != "ReadWriteOnce" {
63+ t .Fatal ("the V2 claim must preserve single-writer access" )
64+ }
5365 for _ , name := range []string {"vault-snapshots" , "vault-snapshots-recovery" } {
5466 claim := object (t , production , "PersistentVolumeClaim" , name )
5567 metadata := claim ["metadata" ].(map [string ]any )
@@ -170,13 +182,27 @@ func TestActiveSnapshotStorageRequiresBinding(t *testing.T) {
170182 ready , lost := compile (current ), compile (failed )
171183 for _ , tt := range []struct {
172184 name , phase string
185+ claim string
173186 mutate func (map [string ]any , map [string ]any )
174187 want bool
175188 wantFailed bool
176189 }{
177190 {name : "old prepared marker cannot bypass binding" , phase : "Pending" , mutate : func (m , _ map [string ]any ) {
178191 m ["labels" ] = map [string ]any {"platform.devantler.tech/storage-stage" : "prepared" }
179192 }},
193+ {name : "prepared V2 claim waits without a first consumer" , phase : "Pending" , claim : "vault-snapshots-recovery-v2" , want : true },
194+ {name : "a selected V2 consumer must bind" , phase : "Pending" , claim : "vault-snapshots-recovery-v2" , mutate : func (m , _ map [string ]any ) {
195+ m ["annotations" ].(map [string ]any )["volume.kubernetes.io/selected-node" ] = "worker"
196+ }},
197+ {name : "the V2 claim must bind after serving starts" , phase : "Pending" , claim : "vault-snapshots-recovery-v2" , mutate : func (m , _ map [string ]any ) {
198+ delete (m , "labels" )
199+ }},
200+ {name : "V2 preparation requires the exact namespace" , phase : "Pending" , claim : "vault-snapshots-recovery-v2" , mutate : func (m , _ map [string ]any ) {
201+ m ["namespace" ] = "other"
202+ }},
203+ {name : "V2 preparation requires the exact class" , phase : "Pending" , claim : "vault-snapshots-recovery-v2" , mutate : func (_ , s map [string ]any ) {
204+ s ["storageClassName" ] = "hcloud"
205+ }},
180206 {name : "bound claim" , phase : "Bound" , want : true },
181207 {name : "lost claim" , phase : "Lost" , wantFailed : true },
182208 {name : "unobserved status" },
@@ -195,7 +221,11 @@ func TestActiveSnapshotStorageRequiresBinding(t *testing.T) {
195221 {name : "terminating bound claim" , phase : "Bound" , mutate : func (m , _ map [string ]any ) { m ["deletionTimestamp" ] = "2026-10-26T00:00:00Z" }},
196222 } {
197223 t .Run (tt .name , func (t * testing.T ) {
198- claim := object (t , render (t , "k8s/providers/hetzner/infrastructure/vault-backup-recovery" ), "PersistentVolumeClaim" , "vault-snapshots-recovery" )
224+ name := tt .claim
225+ if name == "" {
226+ name = "vault-snapshots-recovery"
227+ }
228+ claim := object (t , render (t , "k8s/providers/hetzner/infrastructure/vault-backup-recovery" ), "PersistentVolumeClaim" , name )
199229 metadata , spec := claim ["metadata" ].(map [string ]any ), claim ["spec" ].(map [string ]any )
200230 if tt .mutate != nil {
201231 tt .mutate (metadata , spec )
0 commit comments