test: add an OBC update helper to util/obc

Add obc.Update, a get/mutate/update helper for live ObjectBucketClaims,
generalized from the notification suite's label updater, which becomes a
thin wrapper over it. The bucket quota conversion needs the same shape for
additionalConfig updates.

Signed-off-by: Joshua Hoblitt <josh@hoblitt.com>
This commit is contained in:
Joshua Hoblitt committed 2026-07-06 10:35:37 -07:00
1 parent eba12411a9
commit 8dfc5d408d
2 files changed
+21 -12

No files matched your search

@@ -312,18 +312,12 @@ func TestBucketNotification(t *testing.T, k8sh *utils.K8sHelper, store *sharedst
func updateOBCLabels(ctx context.Context, t *testing.T, k8sh *utils.K8sHelper, namespace, name string, mutate func(map[string]string)) {
t.Helper()
obcClient := k8sh.BucketClientset.ObjectbucketV1alpha1().ObjectBucketClaims(namespace)
liveOBC, err := obcClient.Get(ctx, name, metav1.GetOptions{})
require.NoError(t, err)
if liveOBC.Labels == nil {
liveOBC.Labels = map[string]string{}
}
mutate(liveOBC.Labels)
_, err = obcClient.Update(ctx, liveOBC, metav1.UpdateOptions{})
require.NoError(t, err)
obc.Update(ctx, t, k8sh, namespace, name, func(live *bktv1alpha1.ObjectBucketClaim) {
if live.Labels == nil {
live.Labels = map[string]string{}
}
mutate(live.Labels)
})
}
// requireHTTPSink deploys a sample HTTP server that records the bucket
+15
View File
@@ -87,6 +87,21 @@ func NewS3Agent(ctx context.Context, t *testing.T, k8sh *utils.K8sHelper, store
return agent
}
// Update applies mutate to the live OBC and updates it.
func Update(ctx context.Context, t *testing.T, k8sh *utils.K8sHelper, namespace, name string, mutate func(*bktv1alpha1.ObjectBucketClaim)) {
t.Helper()
obcClient := k8sh.BucketClientset.ObjectbucketV1alpha1().ObjectBucketClaims(namespace)
live, err := obcClient.Get(ctx, name, metav1.GetOptions{})
require.NoError(t, err)
mutate(live)
_, err = obcClient.Update(ctx, live, metav1.UpdateOptions{})
require.NoError(t, err)
}
// DeleteAndWait deletes the OBC and waits for its backing ObjectBucket (and thus
// the rgw bucket) to be garbage-collected by the provisioner.
func DeleteAndWait(ctx context.Context, t *testing.T, k8sh *utils.K8sHelper, namespace, name string) {