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) {