diff --git a/pkg/testhelper/kube/deployment.go b/pkg/testhelper/kube/deployment.go index fc8f94b..411d785 100644 --- a/pkg/testhelper/kube/deployment.go +++ b/pkg/testhelper/kube/deployment.go @@ -12,13 +12,11 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/1Password/onepassword-operator/pkg/testhelper/defaults" ) type Deployment struct { client client.Client - config *ClusterConfig + config *Config name string } @@ -128,5 +126,5 @@ func (d *Deployment) WaitDeploymentRolledOut(ctx context.Context) { g.Expect(newDeployment.Status.Replicas).To(Equal(desired)) return nil - }, defaults.E2ETimeout, defaults.E2EInterval).Should(Succeed()) + }, d.config.TestConfig.Timeout, d.config.TestConfig.Interval).Should(Succeed()) } diff --git a/pkg/testhelper/kube/kube.go b/pkg/testhelper/kube/kube.go index 4d5f9f5..6c613b9 100644 --- a/pkg/testhelper/kube/kube.go +++ b/pkg/testhelper/kube/kube.go @@ -23,17 +23,23 @@ import ( apiv1 "github.com/1Password/onepassword-operator/api/v1" ) -type ClusterConfig struct { +type TestConfig struct { + Timeout time.Duration + Interval time.Duration +} + +type Config struct { Namespace string ManifestsDir string + TestConfig *TestConfig } type Kube struct { - Config *ClusterConfig + Config *Config Client client.Client } -func NewKubeClient(clusterConfig *ClusterConfig) *Kube { +func NewKubeClient(config *Config) *Kube { By("Creating a kubernetes client") kubeconfig := os.Getenv("KUBECONFIG") if kubeconfig == "" { @@ -62,12 +68,12 @@ func NewKubeClient(clusterConfig *ClusterConfig) *Kube { ctx, ok := cfg.Contexts[currentContext] Expect(ok).To(BeTrue(), fmt.Sprintf("current context %q not found in kubeconfig", currentContext)) - ctx.Namespace = clusterConfig.Namespace + ctx.Namespace = config.Namespace err = clientcmd.ModifyConfig(pathOpts, *cfg, true) Expect(err).NotTo(HaveOccurred()) return &Kube{ - Config: clusterConfig, + Config: config, Client: kubernetesClient, } } diff --git a/pkg/testhelper/kube/pod.go b/pkg/testhelper/kube/pod.go index 8b7f2d3..b26dd98 100644 --- a/pkg/testhelper/kube/pod.go +++ b/pkg/testhelper/kube/pod.go @@ -11,13 +11,11 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/1Password/onepassword-operator/pkg/testhelper/defaults" ) type Pod struct { client client.Client - config *ClusterConfig + config *Config selector map[string]string } @@ -45,5 +43,5 @@ func (p *Pod) WaitingForRunningPod(ctx context.Context) { } } g.Expect(foundRunning).To(BeTrue(), "pod not Running yet") - }, defaults.E2ETimeout, defaults.E2EInterval).Should(Succeed()) + }, p.config.TestConfig.Timeout, p.config.TestConfig.Interval).Should(Succeed()) } diff --git a/pkg/testhelper/kube/secret.go b/pkg/testhelper/kube/secret.go index 5770611..bbed2f4 100644 --- a/pkg/testhelper/kube/secret.go +++ b/pkg/testhelper/kube/secret.go @@ -15,13 +15,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/1Password/onepassword-operator/pkg/testhelper/defaults" "github.com/1Password/onepassword-operator/pkg/testhelper/system" ) type Secret struct { client client.Client - config *ClusterConfig + config *Config name string } @@ -138,5 +137,5 @@ func (s *Secret) CheckIfExists(ctx context.Context) { secret := &corev1.Secret{} err := s.client.Get(attemptCtx, client.ObjectKey{Name: s.name, Namespace: s.config.Namespace}, secret) g.Expect(err).NotTo(HaveOccurred()) - }, defaults.E2ETimeout, defaults.E2EInterval).Should(Succeed()) + }, s.config.TestConfig.Timeout, s.config.TestConfig.Interval).Should(Succeed()) } diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 7712970..dbe4a5a 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -30,9 +30,13 @@ var _ = Describe("Onepassword Operator e2e", Ordered, func() { ctx := context.Background() BeforeAll(func() { - kubeClient = kube.NewKubeClient(&kube.ClusterConfig{ + kubeClient = kube.NewKubeClient(&kube.Config{ Namespace: "default", ManifestsDir: filepath.Join("manifests"), + TestConfig: &kube.TestConfig{ + Timeout: defaults.E2ETimeout, + Interval: defaults.E2EInterval, + }, }) operator.BuildOperatorImage()