From 8dfc5d408d466b54038d7d6ff7cc5b4522d8e441 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 2 Jul 2026 09:39:44 -0700 Subject: [PATCH] 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 --- .../object/notification/notification.go | 18 ++++++------------ tests/integration/object/util/obc/obc.go | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/integration/object/notification/notification.go b/tests/integration/object/notification/notification.go index bf99d7e99..4579b5845 100644 --- a/tests/integration/object/notification/notification.go +++ b/tests/integration/object/notification/notification.go @@ -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 diff --git a/tests/integration/object/util/obc/obc.go b/tests/integration/object/util/obc/obc.go index 04ed3d6ba..82cff68c8 100644 --- a/tests/integration/object/util/obc/obc.go +++ b/tests/integration/object/util/obc/obc.go @@ -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) {