diff --git a/e2e/suite_client_test.go b/e2e/suite_client_test.go new file mode 100644 index 000000000..6a4a95909 --- /dev/null +++ b/e2e/suite_client_test.go @@ -0,0 +1,59 @@ +//go:build e2e + +// Copyright 2020-2023 Project Capsule Authors. +// SPDX-License-Identifier: Apache-2.0 + +package e2e + +import ( + "context" + "time" + + "sigs.k8s.io/controller-runtime/pkg/client" +) + +type e2eClient struct { + client.Client +} + +func (e *e2eClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error { + time.Sleep(time.Second) + + return e.Client.Get(ctx, key, obj, opts...) +} + +func (e *e2eClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error { + time.Sleep(time.Second) + + return e.Client.List(ctx, list, opts...) +} + +func (e *e2eClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error { + time.Sleep(time.Second) + + return e.Client.Create(ctx, obj, opts...) +} + +func (e *e2eClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error { + time.Sleep(time.Second) + + return e.Client.Delete(ctx, obj, opts...) +} + +func (e *e2eClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error { + time.Sleep(time.Second) + + return e.Client.Update(ctx, obj, opts...) +} + +func (e *e2eClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error { + time.Sleep(time.Second) + + return e.Client.Patch(ctx, obj, patch, opts...) +} + +func (e *e2eClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error { + time.Sleep(time.Second) + + return e.Client.DeleteAllOf(ctx, obj, opts...) +} diff --git a/e2e/suite_test.go b/e2e/suite_test.go index 8897a9034..886d8bd41 100644 --- a/e2e/suite_test.go +++ b/e2e/suite_test.go @@ -53,9 +53,11 @@ var _ = BeforeSuite(func() { Expect(capsulev1beta2.AddToScheme(scheme.Scheme)).NotTo(HaveOccurred()) - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + ctrlClient, err := client.New(cfg, client.Options{Scheme: scheme.Scheme}) Expect(err).ToNot(HaveOccurred()) - Expect(k8sClient).ToNot(BeNil()) + Expect(ctrlClient).ToNot(BeNil()) + + k8sClient = e2eClient{Client: ctrlClient} }) var _ = AfterSuite(func() { @@ -70,5 +72,6 @@ func ownerClient(owner capsulev1beta2.OwnerSpec) (cs kubernetes.Interface) { c.Impersonate.UserName = owner.Name cs, err = kubernetes.NewForConfig(c) Expect(err).ToNot(HaveOccurred()) - return + + return cs }